Skip to content

Commit

Permalink
Sync with polkadot-v1.0.0 branch (#195)
Browse files Browse the repository at this point in the history
- [x] Needs update of
https://github.com/727-Ventures/pallet-assets-chain-extension to
`polkadot-v1.0.0`
- [x] Diff and apply commits between `0.9.43` and `1.0.0`
  • Loading branch information
ascjones authored Jul 25, 2023
1 parent a16421f commit ab620d4
Show file tree
Hide file tree
Showing 9 changed files with 753 additions and 756 deletions.
1,325 changes: 656 additions & 669 deletions Cargo.lock

Large diffs are not rendered by default.

52 changes: 27 additions & 25 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contracts-node"
version = "0.27.0"
version = "0.28.0"
authors = ["Parity Technologies <[email protected]>"]
description = "Substrate node configured for smart contracts via `pallet-contracts`."
edition = "2021"
Expand All @@ -19,32 +19,34 @@ path = "src/main.rs"

[dependencies]
clap = { version = "4.2.7", features = ["derive"] }

sc-cli = { git = "https://github.com/paritytech/substrate", package = "sc-cli", default-features = false, branch = "polkadot-v0.9.43" }
sp-core = { git = "https://github.com/paritytech/substrate", package = "sp-core", branch = "polkadot-v0.9.43" }
sc-executor = { git = "https://github.com/paritytech/substrate", package = "sc-executor", branch = "polkadot-v0.9.43" }
sc-network = { git = "https://github.com/paritytech/substrate", package = "sc-network", branch = "polkadot-v0.9.43" }
sc-service = { git = "https://github.com/paritytech/substrate", package = "sc-service", default-features = false, branch = "polkadot-v0.9.43" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", package = "sc-telemetry", branch = "polkadot-v0.9.43" }
sc-keystore = { git = "https://github.com/paritytech/substrate", package = "sc-keystore", branch = "polkadot-v0.9.43" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", package = "sc-transaction-pool", branch = "polkadot-v0.9.43" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", package = "sc-transaction-pool-api", branch = "polkadot-v0.9.43" }
sc-consensus = { git = "https://github.com/paritytech/substrate", package = "sc-consensus", branch = "polkadot-v0.9.43" }
sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", package = "sc-consensus-manual-seal", branch = "polkadot-v0.9.43" }
sc-client-api = { git = "https://github.com/paritytech/substrate", package = "sc-client-api", branch = "polkadot-v0.9.43" }
sp-runtime = { git = "https://github.com/paritytech/substrate", package = "sp-runtime", branch = "polkadot-v0.9.43" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", package = "sp-timestamp", branch = "polkadot-v0.9.43" }
futures = { version = "0.3.21", features = ["thread-pool"]}

sc-cli = { git = "https://github.com/paritytech/substrate", package = "sc-cli", default-features = false, branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", package = "sp-core", branch = "polkadot-v1.0.0" }
sc-executor = { git = "https://github.com/paritytech/substrate", package = "sc-executor", branch = "polkadot-v1.0.0" }
sc-network = { git = "https://github.com/paritytech/substrate", package = "sc-network", branch = "polkadot-v1.0.0" }
sc-service = { git = "https://github.com/paritytech/substrate", package = "sc-service", default-features = false, branch = "polkadot-v1.0.0" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", package = "sc-telemetry", branch = "polkadot-v1.0.0" }
sc-keystore = { git = "https://github.com/paritytech/substrate", package = "sc-keystore", branch = "polkadot-v1.0.0" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", package = "sc-transaction-pool", branch = "polkadot-v1.0.0" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", package = "sc-transaction-pool-api", branch = "polkadot-v1.0.0" }
sc-offchain = { git = "https://github.com/paritytech/substrate", package = "sc-offchain", branch = "polkadot-v1.0.0" }
sc-consensus = { git = "https://github.com/paritytech/substrate", package = "sc-consensus", branch = "polkadot-v1.0.0" }
sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", package = "sc-consensus-manual-seal", branch = "polkadot-v1.0.0" }
sc-client-api = { git = "https://github.com/paritytech/substrate", package = "sc-client-api", branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", package = "sp-runtime", branch = "polkadot-v1.0.0" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", package = "sp-timestamp", branch = "polkadot-v1.0.0" }

# These dependencies are used for the node's RPCs
jsonrpsee = { version = "0.16.2", features = ["server"] }
sc-rpc = { git = "https://github.com/paritytech/substrate", package = "sc-rpc", branch = "polkadot-v0.9.43" }
sp-api = { git = "https://github.com/paritytech/substrate", package = "sp-api", branch = "polkadot-v0.9.43" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", package = "sc-rpc-api", branch = "polkadot-v0.9.43" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", package = "sp-blockchain", branch = "polkadot-v0.9.43" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", package = "sp-block-builder", branch = "polkadot-v0.9.43" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", package = "sc-basic-authorship", branch = "polkadot-v0.9.43" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", package = "substrate-frame-rpc-system", branch = "polkadot-v0.9.43" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", package = "pallet-transaction-payment-rpc", branch = "polkadot-v0.9.43" }
sp-api = { git = "https://github.com/paritytech/substrate", package = "sp-api", branch = "polkadot-v1.0.0" }
sc-rpc = { git = "https://github.com/paritytech/substrate", package = "sc-rpc", branch = "polkadot-v1.0.0" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", package = "sc-rpc-api", branch = "polkadot-v1.0.0" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", package = "sp-blockchain", branch = "polkadot-v1.0.0" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", package = "sp-block-builder", branch = "polkadot-v1.0.0" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", package = "sc-basic-authorship", branch = "polkadot-v1.0.0" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", package = "substrate-frame-rpc-system", branch = "polkadot-v1.0.0" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", package = "pallet-transaction-payment-rpc", branch = "polkadot-v1.0.0" }

# Local Dependencies
contracts-node-runtime = { path = "../runtime" }
Expand All @@ -55,7 +57,7 @@ contracts-node-runtime = { path = "../runtime" }
enum-as-inner = "=0.5.1"

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", package = "substrate-build-script-utils", branch = "polkadot-v0.9.43" }
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", package = "substrate-build-script-utils", branch = "polkadot-v1.0.0" }

[features]
default = []
10 changes: 6 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use contracts_node_runtime::{
AccountId, BalancesConfig, GenesisConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY,
AccountId, BalancesConfig, RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig,
WASM_BINARY,
};
use sc_service::ChainType;
use sp_core::{sr25519, Pair, Public};
Expand All @@ -9,7 +10,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;

/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -128,11 +129,12 @@ fn testnet_genesis(
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
) -> GenesisConfig {
GenesisConfig {
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
..Default::default()
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
Expand Down
1 change: 1 addition & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Cli {
}

#[derive(Debug, clap::Subcommand)]
#[allow(clippy::large_enum_variant)]
pub enum Subcommand {
/// Key management cli utilities
#[clap(subcommand)]
Expand Down
6 changes: 1 addition & 5 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
service,
};
use contracts_node_runtime::Block;
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;

impl SubstrateCli for Cli {
Expand Down Expand Up @@ -40,10 +40,6 @@ impl SubstrateCli for Cli {
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
&contracts_node_runtime::VERSION
}
}

/// Parse and run command line arguments
Expand Down
4 changes: 2 additions & 2 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use std::sync::Arc;

use contracts_node_runtime::{opaque::Block, AccountId, Balance, Index};
use contracts_node_runtime::{opaque::Block, AccountId, Balance, Nonce};
use jsonrpsee::RpcModule;
use sc_client_api::BlockBackend;
use sc_rpc::dev::{Dev, DevApiServer};
Expand Down Expand Up @@ -37,7 +37,7 @@ where
C: BlockBackend<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
C: Send + Sync + 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
Expand Down
27 changes: 21 additions & 6 deletions node/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.

use contracts_node_runtime::{self, opaque::Block, RuntimeApi};
use futures::FutureExt;
use sc_client_api::Backend;
pub use sc_executor::NativeElseWasmExecutor;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use std::sync::Arc;

// Our native executor instance.
Expand Down Expand Up @@ -52,7 +55,7 @@ pub fn new_partial(
})
.transpose()?;

let executor = sc_service::new_native_or_wasm_executor(&config);
let executor = sc_service::new_native_or_wasm_executor(config);

let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
Expand Down Expand Up @@ -123,11 +126,23 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
})?;

if config.offchain_worker.enabled {
sc_service::build_offchain_workers(
&config,
task_manager.spawn_handle(),
client.clone(),
network.clone(),
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-worker",
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
is_validator: config.role.is_authority(),
keystore: Some(keystore_container.keystore()),
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: network.clone(),
enable_http_requests: true,
custom_extensions: |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
);
}

Expand Down
Loading

0 comments on commit ab620d4

Please sign in to comment.