From eb25725d5e695428ba99c643b76c12ab14e00b1f Mon Sep 17 00:00:00 2001 From: renauter Date: Fri, 24 Nov 2023 13:47:02 -0300 Subject: [PATCH 01/31] upgrade to polkadot 0.9.43 --- substrate-node/Cargo.toml | 132 +++++++++++++++--------------- substrate-node/runtime/Cargo.toml | 2 +- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/substrate-node/Cargo.toml b/substrate-node/Cargo.toml index ca0599f98..45247f26d 100644 --- a/substrate-node/Cargo.toml +++ b/substrate-node/Cargo.toml @@ -60,73 +60,73 @@ tfchain-support = { path = "support", default-features = false } tfchain-runtime = { path = "runtime", default-features = false } # Benchmarking (with default disabled) -frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} # Substrate (with default disabled) -frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-session-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-transaction-payment-rpc = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-storage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-keystore = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} -sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} +frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-session-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-transaction-payment-rpc = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-storage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-keystore = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} # Client-only (with default enabled) -polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42"} -polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42"} -polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42"} -sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-chain-spec = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-rpc = { git = "https://github.com/paritytech/substrate.git", "branch" = "polkadot-v0.9.42" } -sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -sp-timestamp = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -substrate-frame-rpc-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} -substrate-prometheus-endpoint = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} +polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.43"} +polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.43"} +polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.43"} +sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-chain-spec = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-rpc = { git = "https://github.com/paritytech/substrate.git", "branch" = "polkadot-v0.9.43" } +sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +sp-timestamp = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +substrate-frame-rpc-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +substrate-prometheus-endpoint = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} diff --git a/substrate-node/runtime/Cargo.toml b/substrate-node/runtime/Cargo.toml index 095b6318e..05206d0ea 100644 --- a/substrate-node/runtime/Cargo.toml +++ b/substrate-node/runtime/Cargo.toml @@ -14,7 +14,7 @@ version.workspace = true targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } [dependencies] smallvec.workspace = true From fb8a23ebc37b4182a2974efc6bd1c93f785b8bf3 Mon Sep 17 00:00:00 2001 From: renauter Date: Fri, 24 Nov 2023 13:48:24 -0300 Subject: [PATCH 02/31] update rust-toolchain to 1.70.0 --- substrate-node/rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate-node/rust-toolchain.toml b/substrate-node/rust-toolchain.toml index aa33e4ae2..1405ae81a 100644 --- a/substrate-node/rust-toolchain.toml +++ b/substrate-node/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.69.0" +channel = "1.70.0" components = [ "cargo", "clippy", From aeac5f8fa24ae80afc7fc2e48da673be17a2c501 Mon Sep 17 00:00:00 2001 From: renauter Date: Fri, 24 Nov 2023 13:49:12 -0300 Subject: [PATCH 03/31] update node sevices.rs --- substrate-node/node/Cargo.toml | 1 + substrate-node/node/src/service.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/substrate-node/node/Cargo.toml b/substrate-node/node/Cargo.toml index 45d2af21e..4fb2d5fd9 100644 --- a/substrate-node/node/Cargo.toml +++ b/substrate-node/node/Cargo.toml @@ -28,6 +28,7 @@ serde_json.workspace = true sc-cli.workspace = true sp-core.workspace = true sc-executor.workspace = true +sc-network.workspace = true sc-service.workspace = true sc-telemetry.workspace = true sc-keystore.workspace = true diff --git a/substrate-node/node/src/service.rs b/substrate-node/node/src/service.rs index b6320aaa0..05117164a 100644 --- a/substrate-node/node/src/service.rs +++ b/substrate-node/node/src/service.rs @@ -156,7 +156,7 @@ pub fn new_partial( } /// Builds a new service for a full client. -pub fn new_full(mut config: Configuration) -> Result { +pub fn new_full(config: Configuration) -> Result { let sc_service::PartialComponents { client, backend, @@ -168,6 +168,8 @@ pub fn new_full(mut config: Configuration) -> Result other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; + let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); + let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name( &client .block_hash(0) @@ -176,13 +178,10 @@ pub fn new_full(mut config: Configuration) -> Result .expect("Genesis block exists; qed"), &config.chain_spec, ); + net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config( + grandpa_protocol_name.clone(), + )); - config - .network - .extra_sets - .push(sc_consensus_grandpa::grandpa_peers_set_config( - grandpa_protocol_name.clone(), - )); let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( backend.clone(), grandpa_link.shared_authority_set().clone(), @@ -192,6 +191,7 @@ pub fn new_full(mut config: Configuration) -> Result let (network, system_rpc_tx, tx_handler_controller, network_starter, sync) = sc_service::build_network(sc_service::BuildNetworkParams { config: &config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), spawn_handle: task_manager.spawn_handle(), From 8ad030261f46f0bd7977930a88a078b8f66525f2 Mon Sep 17 00:00:00 2001 From: renauter Date: Fri, 24 Nov 2023 18:04:46 -0300 Subject: [PATCH 04/31] update try-runtime feature --- .../src/migrations/v10.rs | 2 +- .../src/migrations/v11.rs | 4 +- .../src/migrations/v6.rs | 4 +- .../src/migrations/v8.rs | 4 +- .../src/migrations/v9.rs | 2 +- .../pallet-tfgrid/src/migrations/v10.rs | 4 +- .../pallet-tfgrid/src/migrations/v11.rs | 4 +- .../pallet-tfgrid/src/migrations/v12.rs | 4 +- .../pallet-tfgrid/src/migrations/v13.rs | 4 +- .../pallet-tfgrid/src/migrations/v14.rs | 4 +- .../pallet-tfgrid/src/migrations/v15.rs | 4 +- .../pallet-tfgrid/src/migrations/v17.rs | 4 +- .../pallet-tft-bridge/src/migrations/v2.rs | 66 ++++++++++--------- .../tfgrid_v15_smart_contract_v8.rs | 4 +- 14 files changed, 60 insertions(+), 54 deletions(-) diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs index ca180d44d..c130c03e2 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs @@ -16,7 +16,7 @@ impl OnRuntimeUpgrade for ReworkBillingLoopInsertion { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), &'static str> { + fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V10); diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs index 4ea467536..52a5840e3 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs @@ -23,7 +23,7 @@ pub type ContractLock = StorageMap< pub struct ExtendContractLock(PhantomData); impl OnRuntimeUpgrade for ExtendContractLock { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V10); @@ -41,7 +41,7 @@ impl OnRuntimeUpgrade for ExtendContractLock { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), &'static str> { + fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V11); diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs index 7d6df417f..70e3702a6 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs @@ -11,7 +11,7 @@ pub struct ContractMigrationV5(PhantomData); impl OnRuntimeUpgrade for ContractMigrationV5 { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V5); @@ -30,7 +30,7 @@ impl OnRuntimeUpgrade for ContractMigrationV5 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_contracts_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_contracts_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V6); diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs index 9c2214474..ccdcf8912 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs @@ -15,7 +15,7 @@ pub struct FixTwinLockedBalances(PhantomData); impl OnRuntimeUpgrade for FixTwinLockedBalances { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V6); @@ -33,7 +33,7 @@ impl OnRuntimeUpgrade for FixTwinLockedBalances { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), &'static str> { + fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V8); diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs index d420af067..c7314a930 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs @@ -24,7 +24,7 @@ impl OnRuntimeUpgrade for CleanStorageState { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() == types::StorageVersion::V8 || PalletVersion::::get() == types::StorageVersion::V9); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs index 7863413e3..f6953ca7d 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs @@ -11,7 +11,7 @@ pub struct FixFarmNodeIndexMap(PhantomData); impl OnRuntimeUpgrade for FixFarmNodeIndexMap { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V9Struct); @@ -35,7 +35,7 @@ impl OnRuntimeUpgrade for FixFarmNodeIndexMap { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_nodes_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_nodes_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V10Struct); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs index 2d0848e7c..b86ad25ac 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs @@ -12,7 +12,7 @@ pub struct FixFarmingPolicy(PhantomData); impl OnRuntimeUpgrade for FixFarmingPolicy { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V10Struct); @@ -36,7 +36,7 @@ impl OnRuntimeUpgrade for FixFarmingPolicy { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_farms_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_farms_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V11Struct); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs index cbf9abd29..29bbcff13 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs @@ -35,7 +35,7 @@ pub struct InputValidation(PhantomData); impl OnRuntimeUpgrade for InputValidation { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V11Struct); @@ -59,7 +59,7 @@ impl OnRuntimeUpgrade for InputValidation { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_nodes_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_nodes_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V12Struct); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs index fe35d1fe9..a7c790b88 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs @@ -18,7 +18,7 @@ pub struct FixPublicIP(PhantomData); impl OnRuntimeUpgrade for FixPublicIP { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() <= types::StorageVersion::V12Struct); @@ -42,7 +42,7 @@ impl OnRuntimeUpgrade for FixPublicIP { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_nodes_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_nodes_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V13Struct); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs index 3ab9d9a53..79bec6c75 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs @@ -12,7 +12,7 @@ pub struct FixFarmingPoliciesMap(PhantomData); impl OnRuntimeUpgrade for FixFarmingPoliciesMap { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V13Struct); @@ -36,7 +36,7 @@ impl OnRuntimeUpgrade for FixFarmingPoliciesMap { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_policies_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_policies_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V14Struct); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs index 341523adf..e4417f31f 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs @@ -12,7 +12,7 @@ pub struct MigrateTwinsV15(PhantomData); impl OnRuntimeUpgrade for MigrateTwinsV15 { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V14Struct); @@ -36,7 +36,7 @@ impl OnRuntimeUpgrade for MigrateTwinsV15 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_twins_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_twins_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V15Struct); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs index 7b21c5e62..55543aeb3 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs @@ -14,7 +14,7 @@ pub struct FixFarmPublicIps(PhantomData); impl OnRuntimeUpgrade for FixFarmPublicIps { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V16Struct); @@ -38,7 +38,7 @@ impl OnRuntimeUpgrade for FixFarmPublicIps { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_farms_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_farms_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); assert!(PalletVersion::::get() >= types::StorageVersion::V17Struct); diff --git a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs index bceb91343..74e87d3b4 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs @@ -10,7 +10,7 @@ pub struct MigrateBurnTransactionsV2(PhantomData); impl OnRuntimeUpgrade for MigrateBurnTransactionsV2 { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); if PalletVersion::::get() != types::StorageVersion::V1 { return Ok(Vec::::new()); @@ -44,12 +44,15 @@ impl OnRuntimeUpgrade for MigrateBurnTransactionsV2 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_pre_burn_transactions_count: Vec) -> Result<(), &'static str> { + fn post_upgrade( + _pre_burn_transactions_count: Vec, + ) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); if PalletVersion::::get() != types::StorageVersion::V2 { return Ok(()); } - let burn_transactions_count: u64 = migrations::types::v2::BurnTransactions::::iter().count() as u64; + let burn_transactions_count: u64 = + migrations::types::v2::BurnTransactions::::iter().count() as u64; info!( "🔎 MigrateBurnTransactionsV2 post migration: Number of existing burn transactions {:?}", burn_transactions_count @@ -71,11 +74,14 @@ pub fn migrate_burn_transactions() -> frame_support::weights::Weight let mut read_writes = 0; - migrations::types::v2::BurnTransactions::::translate::, _>( - |k, burn_transaction| { - debug!("migrated burn transaction: {:?}", k); + migrations::types::v2::BurnTransactions::::translate::< + super::types::v1::BurnTransaction, + _, + >(|k, burn_transaction| { + debug!("migrated burn transaction: {:?}", k); - let new_burn_transaction = migrations::types::v2::BurnTransaction:: { + let new_burn_transaction = + migrations::types::v2::BurnTransaction:: { block: burn_transaction.block, amount: burn_transaction.amount, source: None, @@ -84,29 +90,29 @@ pub fn migrate_burn_transactions() -> frame_support::weights::Weight sequence_number: burn_transaction.sequence_number, }; - read_writes += 1; - Some(new_burn_transaction) - }, - ); - - migrations::types::v2::ExecutedBurnTransactions::::translate::, _>( - |k, executed_burn_transaction| { - debug!("migrated executed burn transaction: {:?}", k); - - let new_executed_burn_transaction = - migrations::types::v2::BurnTransaction:: { - block: executed_burn_transaction.block, - amount: executed_burn_transaction.amount, - source: None, - target: executed_burn_transaction.target, - signatures: executed_burn_transaction.signatures, - sequence_number: executed_burn_transaction.sequence_number, - }; - - read_writes += 1; - Some(new_executed_burn_transaction) - }, - ); + read_writes += 1; + Some(new_burn_transaction) + }); + + migrations::types::v2::ExecutedBurnTransactions::::translate::< + super::types::v1::BurnTransaction, + _, + >(|k, executed_burn_transaction| { + debug!("migrated executed burn transaction: {:?}", k); + + let new_executed_burn_transaction = + migrations::types::v2::BurnTransaction:: { + block: executed_burn_transaction.block, + amount: executed_burn_transaction.amount, + source: None, + target: executed_burn_transaction.target, + signatures: executed_burn_transaction.signatures, + sequence_number: executed_burn_transaction.sequence_number, + }; + + read_writes += 1; + Some(new_executed_burn_transaction) + }); // Update pallet storage version PalletVersion::::set(types::StorageVersion::V2); diff --git a/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs b/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs index aa208cdcf..61098abf8 100644 --- a/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs +++ b/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs @@ -34,7 +34,7 @@ pub struct Migrate(PhantomData); impl OnRuntimeUpgrade for Migrate { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!( "current pallet version: {:?}", pallet_tfgrid::PalletVersion::::get() @@ -92,7 +92,7 @@ impl OnRuntimeUpgrade for Migrate { } #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_twins_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(pre_twins_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!( "current pallet version: {:?}", pallet_tfgrid::PalletVersion::::get() From e238adb48aba111698c844afe7415af52b57a05a Mon Sep 17 00:00:00 2001 From: renauter Date: Sat, 25 Nov 2023 14:09:33 -0300 Subject: [PATCH 05/31] update integration tests --- substrate-node/tests/TfChainClient.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate-node/tests/TfChainClient.py b/substrate-node/tests/TfChainClient.py index 1b205ae2c..4b918c047 100644 --- a/substrate-node/tests/TfChainClient.py +++ b/substrate-node/tests/TfChainClient.py @@ -116,8 +116,8 @@ def propose_council_motion(self, substrate, who, call): for event in response.triggered_events: if event.value["event_id"] == "Proposed": - proposal_hash = event.value["event"]["attributes"]["proposal_hash"] - proposal_index = event.value["event"]["attributes"]["proposal_index"] + proposal_hash = event.value["event"]["attributes"][2] + proposal_index = event.value["event"]["attributes"][1] return proposal_hash, proposal_index From da6757516a237265a9a0c89041b0a674df702917 Mon Sep 17 00:00:00 2001 From: renauter Date: Sat, 25 Nov 2023 16:51:52 -0300 Subject: [PATCH 06/31] prefer returning TryRuntimeError in pre_upgrade() post_upgrade() --- .../src/migrations/v10.rs | 7 +++- .../src/migrations/v11.rs | 34 +++++++++++++------ .../src/migrations/v6.rs | 19 +++++++---- .../src/migrations/v8.rs | 12 +++++-- .../src/migrations/v9.rs | 8 ++++- .../pallet-tfgrid/src/migrations/v10.rs | 19 +++++++---- .../pallet-tfgrid/src/migrations/v11.rs | 19 +++++++---- .../pallet-tfgrid/src/migrations/v12.rs | 19 +++++++---- .../pallet-tfgrid/src/migrations/v13.rs | 19 +++++++---- .../pallet-tfgrid/src/migrations/v14.rs | 19 +++++++---- .../pallet-tfgrid/src/migrations/v15.rs | 19 +++++++---- .../pallet-tfgrid/src/migrations/v17.rs | 19 +++++++---- .../pallet-tft-bridge/src/migrations/v2.rs | 17 ++++++---- .../tfgrid_v15_smart_contract_v8.rs | 19 ++++++----- 14 files changed, 172 insertions(+), 77 deletions(-) diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs index c130c03e2..fa255505b 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs @@ -5,6 +5,8 @@ use sp_core::Get; use sp_runtime::Saturating; use sp_std::{marker::PhantomData, vec}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; @@ -18,7 +20,10 @@ impl OnRuntimeUpgrade for ReworkBillingLoopInsertion { #[cfg(feature = "try-runtime")] fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V10); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V10, + DispatchError::Other("Unexpected pallet version") + ); super::v9::check_contracts_to_bill_at::(); diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs index 52a5840e3..3346a4e9d 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs @@ -8,6 +8,8 @@ use sp_core::Get; use sp_runtime::traits::Zero; use sp_std::marker::PhantomData; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use sp_std::{vec, vec::Vec}; @@ -25,7 +27,10 @@ impl OnRuntimeUpgrade for ExtendContractLock { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V10); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V10, + DispatchError::Other("Unexpected pallet version") + ); debug!("👥 Smart Contract pallet to V11 passes PRE migrate checks ✅",); Ok(vec![]) @@ -43,16 +48,12 @@ impl OnRuntimeUpgrade for ExtendContractLock { #[cfg(feature = "try-runtime")] fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V11); - - check_contract_lock_v11::(); - - debug!( - "👥 Smart Contract pallet to {:?} passes POST migrate checks ✅", - PalletVersion::::get() + ensure!( + PalletVersion::::get() >= types::StorageVersion::V11, + DispatchError::Other("Unexpected pallet version") ); - Ok(()) + check_contract_lock_v11::() } } @@ -86,7 +87,8 @@ pub fn migrate_to_version_11() -> frame_support::weights::Weight { T::DbWeight::get().reads_writes(r, w) } -pub fn check_contract_lock_v11() { +#[cfg(feature = "try-runtime")] +pub fn check_contract_lock_v11() -> Result<(), sp_runtime::TryRuntimeError> { debug!( "🔎 Smart Contract pallet {:?} checking ContractLock storage map START", PalletVersion::::get() @@ -112,7 +114,10 @@ pub fn check_contract_lock_v11() { ); } else { // Ensure new field is set to zero - assert_eq!(contract_lock.extra_amount_locked, BalanceOf::::zero()); + ensure!( + contract_lock.extra_amount_locked == BalanceOf::::zero(), + DispatchError::Other("Unexpected lock amount") + ); } } @@ -120,4 +125,11 @@ pub fn check_contract_lock_v11() { "🏁 Smart Contract pallet {:?} checking ContractLock storage map END", PalletVersion::::get() ); + + debug!( + "👥 Smart Contract pallet to {:?} passes POST migrate checks ✅", + PalletVersion::::get() + ); + + Ok(()) } diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs index 70e3702a6..34010b446 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs @@ -4,6 +4,8 @@ use log::{debug, info}; use sp_core::Get; use sp_std::{marker::PhantomData, vec::Vec}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; @@ -13,7 +15,10 @@ impl OnRuntimeUpgrade for ContractMigrationV5 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V5); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V5, + DispatchError::Other("Unexpected pallet version") + ); let contracts_count: u64 = ContractsToBillAt::::iter().count() as u64; log::info!( @@ -32,15 +37,17 @@ impl OnRuntimeUpgrade for ContractMigrationV5 { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_contracts_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V6); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V6, + DispatchError::Other("Unexpected pallet version") + ); // Check number of Contracts against pre-check result let pre_contracts_count: u64 = Decode::decode(&mut pre_contracts_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - ContractsToBillAt::::iter().count() as u64, - pre_contracts_count, - "Number of Contracts migrated does not match" + ensure!( + ContractsToBillAt::::iter().count() as u64 == pre_contracts_count, + DispatchError::Other("Number of Contracts migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs index ccdcf8912..4fcb53bf3 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs @@ -8,6 +8,8 @@ use sp_core::Get; use sp_runtime::traits::{CheckedSub, SaturatedConversion}; use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use sp_std::{vec, vec::Vec}; @@ -17,7 +19,10 @@ impl OnRuntimeUpgrade for FixTwinLockedBalances { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V6); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V6, + DispatchError::Other("Unexpected pallet version") + ); debug!("👥 Smart Contract pallet to V8 passes PRE migrate checks ✅",); Ok(vec![]) @@ -35,7 +40,10 @@ impl OnRuntimeUpgrade for FixTwinLockedBalances { #[cfg(feature = "try-runtime")] fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { debug!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V8); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V8, + DispatchError::Other("Unexpected pallet version") + ); debug!( "👥 Smart Contract pallet to {:?} passes POST migrate checks ✅", diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs index c7314a930..abc3ca0eb 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs @@ -6,6 +6,9 @@ use scale_info::prelude::string::String; use sp_core::Get; use sp_std::{marker::PhantomData, vec, vec::Vec}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; + pub struct CleanStorageState(PhantomData); impl OnRuntimeUpgrade for CleanStorageState { @@ -26,7 +29,10 @@ impl OnRuntimeUpgrade for CleanStorageState { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() == types::StorageVersion::V8 || PalletVersion::::get() == types::StorageVersion::V9); + ensure!( + PalletVersion::::get() == types::StorageVersion::V8 || PalletVersion::::get() == types::StorageVersion::V9, + DispatchError::Other("Unexpected pallet version") + ); check_pallet_smart_contract::(); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs index f6953ca7d..8e772f748 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs @@ -4,6 +4,8 @@ use log::{debug, info}; use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData}; use sp_std::{vec, vec::Vec}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; @@ -13,7 +15,10 @@ impl OnRuntimeUpgrade for FixFarmNodeIndexMap { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V9Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V9Struct, + DispatchError::Other("Unexpected pallet version") + ); let nodes_count: u64 = Nodes::::iter().count() as u64; log::info!( @@ -37,15 +42,17 @@ impl OnRuntimeUpgrade for FixFarmNodeIndexMap { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_nodes_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V10Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V10Struct, + DispatchError::Other("Unexpected pallet version") + ); // Check number of nodes against pre-check result let pre_nodes_count: u64 = Decode::decode(&mut pre_nodes_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - Nodes::::iter().count() as u64, - pre_nodes_count, - "Number of nodes migrated does not match" + ensure!( + Nodes::::iter().count() as u64 == pre_nodes_count, + DispatchError::Other("Number of nodes migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs index b86ad25ac..a6bb51408 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs @@ -3,6 +3,8 @@ use frame_support::{traits::Get, traits::OnRuntimeUpgrade, weights::Weight}; use log::{debug, info}; use sp_std::marker::PhantomData; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] @@ -14,7 +16,10 @@ impl OnRuntimeUpgrade for FixFarmingPolicy { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V10Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V10Struct, + DispatchError::Other("Unexpected pallet version") + ); let farms_count: u64 = Farms::::iter().count() as u64; log::info!( @@ -38,15 +43,17 @@ impl OnRuntimeUpgrade for FixFarmingPolicy { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_farms_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V11Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V11Struct, + DispatchError::Other("Unexpected pallet version") + ); // Check number of farms against pre-check result let pre_farms_count: u64 = Decode::decode(&mut pre_farms_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - Farms::::iter().count() as u64, - pre_farms_count, - "Number of farms migrated does not match" + ensure!( + Farms::::iter().count() as u64 == pre_farms_count, + DispatchError::Other("Number of farms migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs index 29bbcff13..be66a58ae 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs @@ -6,6 +6,8 @@ use frame_support::{ use log::{debug, info}; use sp_std::marker::PhantomData; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] @@ -37,7 +39,10 @@ impl OnRuntimeUpgrade for InputValidation { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V11Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V11Struct, + DispatchError::Other("Unexpected pallet version") + ); let nodes_count: u64 = Nodes::::iter().count() as u64; log::info!( @@ -61,15 +66,17 @@ impl OnRuntimeUpgrade for InputValidation { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_nodes_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V12Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V12Struct, + DispatchError::Other("Unexpected pallet version") + ); // Check number of nodes against pre-check result let pre_nodes_count: u64 = Decode::decode(&mut pre_nodes_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - Nodes::::iter().count() as u64, - pre_nodes_count, - "Number of nodes migrated does not match" + ensure!( + Nodes::::iter().count() as u64 == pre_nodes_count, + DispatchError::Other("Number of nodes migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs index a7c790b88..8b70e9588 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs @@ -9,6 +9,8 @@ use tfchain_support::{ types::{Farm, Node, PublicIP, IP4}, }; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] @@ -20,7 +22,10 @@ impl OnRuntimeUpgrade for FixPublicIP { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() <= types::StorageVersion::V12Struct); + ensure!( + PalletVersion::::get() <= types::StorageVersion::V12Struct, + DispatchError::Other("Unexpected pallet version") + ); let nodes_count: u64 = Nodes::::iter().count() as u64; log::info!( @@ -44,15 +49,17 @@ impl OnRuntimeUpgrade for FixPublicIP { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_nodes_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V13Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V13Struct, + DispatchError::Other("Unexpected pallet version") + ); // Check number of nodes against pre-check result let pre_nodes_count: u64 = Decode::decode(&mut pre_nodes_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - Nodes::::iter().count() as u64, - pre_nodes_count, - "Number of nodes migrated does not match" + ensure!( + Nodes::::iter().count() as u64 == pre_nodes_count, + DispatchError::Other("Number of nodes migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs index 79bec6c75..967c9ce73 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs @@ -3,6 +3,8 @@ use frame_support::{traits::Get, traits::OnRuntimeUpgrade, weights::Weight}; use log::{debug, info}; use sp_std::marker::PhantomData; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] @@ -14,7 +16,10 @@ impl OnRuntimeUpgrade for FixFarmingPoliciesMap { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V13Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V13Struct, + DispatchError::Other("Unexpected pallet version") + ); let policies_count: u64 = FarmingPoliciesMap::::iter().count() as u64; info!( @@ -38,15 +43,17 @@ impl OnRuntimeUpgrade for FixFarmingPoliciesMap { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_policies_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V14Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V14Struct, + DispatchError::Other("Unexpected pallet version") + ); // Check number of farming policies against pre-check result let pre_policies_count: u64 = Decode::decode(&mut pre_policies_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - FarmingPoliciesMap::::iter().count() as u64, - pre_policies_count, - "Number of farming policies migrated does not match" + ensure!( + FarmingPoliciesMap::::iter().count() as u64 == pre_policies_count, + DispatchError::Other("Number of farming policies migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs index e4417f31f..637160796 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs @@ -3,6 +3,8 @@ use frame_support::{traits::Get, traits::OnRuntimeUpgrade, weights::Weight}; use log::{debug, info}; use sp_std::marker::PhantomData; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::Decode; #[cfg(feature = "try-runtime")] @@ -14,7 +16,10 @@ impl OnRuntimeUpgrade for MigrateTwinsV15 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V14Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V14Struct, + DispatchError::Other("Unexpected pallet version") + ); let twins_count: u64 = Twins::::iter().count() as u64; log::info!( @@ -38,15 +43,17 @@ impl OnRuntimeUpgrade for MigrateTwinsV15 { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_twins_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V15Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V15Struct, + DispatchError::Other("Unexpected pallet version") + ); // Check number of twins against pre-check result let pre_twins_count: u64 = Decode::decode(&mut pre_twins_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - Twins::::iter().count() as u64, - pre_twins_count, - "Number of twins migrated does not match" + ensure!( + Twins::::iter().count() as u64 == pre_twins_count, + DispatchError::Other("Number of twins migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs index 55543aeb3..3e95841c8 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs @@ -7,6 +7,8 @@ use sp_runtime::{BoundedVec, Saturating}; use sp_std::{marker::PhantomData, vec::Vec}; use tfchain_support::types::{PublicIP, IP4}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; @@ -16,7 +18,10 @@ impl OnRuntimeUpgrade for FixFarmPublicIps { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V16Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V16Struct, + DispatchError::Other("Unexpected pallet version") + ); let farms_count: u64 = Farms::::iter().count() as u64; info!( @@ -40,15 +45,17 @@ impl OnRuntimeUpgrade for FixFarmPublicIps { #[cfg(feature = "try-runtime")] fn post_upgrade(pre_farms_count: Vec) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - assert!(PalletVersion::::get() >= types::StorageVersion::V17Struct); + ensure!( + PalletVersion::::get() >= types::StorageVersion::V17Struct, + DispatchError::Other("Unexpected pallet version") + ); // Check number of farms against pre-check result let pre_farms_count: u64 = Decode::decode(&mut pre_farms_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - Farms::::iter().count() as u64, - pre_farms_count, - "Number of farms migrated does not match" + ensure!( + Farms::::iter().count() as u64 == pre_farms_count, + DispatchError::Other("Number of farms migrated does not match") ); info!( diff --git a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs index 74e87d3b4..53075edd9 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs @@ -3,6 +3,8 @@ use frame_support::log::{debug, info}; use frame_support::{traits::Get, traits::OnRuntimeUpgrade, weights::Weight}; use sp_std::marker::PhantomData; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; @@ -12,9 +14,10 @@ impl OnRuntimeUpgrade for MigrateBurnTransactionsV2 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - if PalletVersion::::get() != types::StorageVersion::V1 { - return Ok(Vec::::new()); - }; + ensure!( + PalletVersion::::get() == types::StorageVersion::V1, + DispatchError::Other("Unexpected pallet version") + ); let burn_transactions_count: u64 = migrations::types::v1::BurnTransactions::::iter().count() as u64; @@ -48,9 +51,11 @@ impl OnRuntimeUpgrade for MigrateBurnTransactionsV2 { _pre_burn_transactions_count: Vec, ) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); - if PalletVersion::::get() != types::StorageVersion::V2 { - return Ok(()); - } + ensure!( + PalletVersion::::get() == types::StorageVersion::V2, + DispatchError::Other("Unexpected pallet version") + ); + let burn_transactions_count: u64 = migrations::types::v2::BurnTransactions::::iter().count() as u64; info!( diff --git a/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs b/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs index 61098abf8..df07f5f5a 100644 --- a/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs +++ b/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs @@ -15,6 +15,8 @@ use frame_support::{ use log::{debug, info}; use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::DispatchError, ensure}; #[cfg(feature = "try-runtime")] use parity_scale_codec::Decode; #[cfg(feature = "try-runtime")] @@ -39,9 +41,10 @@ impl OnRuntimeUpgrade for Migrate { "current pallet version: {:?}", pallet_tfgrid::PalletVersion::::get() ); - assert!( + ensure!( pallet_tfgrid::PalletVersion::::get() - >= pallet_tfgrid::types::StorageVersion::V14Struct + >= pallet_tfgrid::types::StorageVersion::V14Struct, + DispatchError::Other("Unexpected pallet version") ); let twins_count: u64 = pallet_tfgrid::Twins::::iter().count() as u64; @@ -97,18 +100,18 @@ impl OnRuntimeUpgrade for Migrate { "current pallet version: {:?}", pallet_tfgrid::PalletVersion::::get() ); - assert!( + ensure!( pallet_tfgrid::PalletVersion::::get() - >= pallet_tfgrid::types::StorageVersion::V15Struct + >= pallet_tfgrid::types::StorageVersion::V15Struct, + DispatchError::Other("Unexpected pallet version") ); // Check number of twins against pre-check result let pre_twins_count: u64 = Decode::decode(&mut pre_twins_count.as_slice()) .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!( - pallet_tfgrid::Twins::::iter().count() as u64, - pre_twins_count, - "Number of twins migrated does not match" + ensure!( + pallet_tfgrid::Twins::::iter().count() as u64 == pre_twins_count, + DispatchError::Other("Number of twins migrated does not match") ); info!( From d4dd71f3ad12a303c7329edffbe6f1d95babb2c3 Mon Sep 17 00:00:00 2001 From: renauter Date: Sat, 25 Nov 2023 23:16:42 -0300 Subject: [PATCH 07/31] fix outdated CLI options --- substrate-node/tests/SubstrateNetwork.py | 28 ++++++++++-------------- substrate-node/tests/TfChainClient.py | 4 ++-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/substrate-node/tests/SubstrateNetwork.py b/substrate-node/tests/SubstrateNetwork.py index 1daaf828d..80da5d14a 100644 --- a/substrate-node/tests/SubstrateNetwork.py +++ b/substrate-node/tests/SubstrateNetwork.py @@ -15,7 +15,7 @@ SUBSTRATE_NODE_DIR = dirname(os.getcwd()) TFCHAIN_EXE = join(SUBSTRATE_NODE_DIR, "target", "release", "tfchain") -RE_NODE_STARTED = re.compile("Running JSON-RPC WS server") +RE_NODE_STARTED = re.compile("Running JSON-RPC server") RE_FIRST_BLOCK = re.compile("Prepared block for proposing at") TIMEOUT_STARTUP_IN_SECONDS = 600 @@ -78,7 +78,7 @@ def execute_command(cmd: list, log_file: str | None = None): return p, fd -def run_node(log_file: str, base_path: str, predefined_account: str, port: int, ws_port: int, rpc_port: int, node_key: str | None = None, bootnodes: str | None = None): +def run_node(log_file: str, base_path: str, predefined_account: str, port: int, rpc_port: int, node_key: str | None = None, bootnodes: str | None = None): logging.info("Starting node with logfile %s", log_file) if not isfile(TFCHAIN_EXE): @@ -90,9 +90,8 @@ def run_node(log_file: str, base_path: str, predefined_account: str, port: int, "--chain", "local", f"--{predefined_account.lower()}", "--port", f"{port}", - "--ws-port", f"{ws_port}", "--rpc-port", f"{rpc_port}", - "--telemetry-url", "wss://telemetry.polkadot.io/submit/ 0", + "--no-telemetry", "--validator", "--rpc-methods", "Unsafe", "--rpc-cors", "all" @@ -108,7 +107,7 @@ def run_node(log_file: str, base_path: str, predefined_account: str, port: int, return execute_command(cmd, log_file) -def run_single_node(log_file: str, base_path: str, port: int, ws_port: int, rpc_port: int, node_key: str | None = None, bootnodes: str | None = None): +def run_single_node(log_file: str, base_path: str, port: int, rpc_port: int, node_key: str | None = None, bootnodes: str | None = None): logging.info("Starting node with logfile %s", log_file) if not isfile(TFCHAIN_EXE): @@ -117,10 +116,9 @@ def run_single_node(log_file: str, base_path: str, port: int, ws_port: int, rpc_ cmd = [TFCHAIN_EXE, "--dev", - "--ws-external", + "--rpc-external", "--base-path", f"{base_path}", "--port", f"{port}", - "--ws-port", f"{ws_port}", "--rpc-port", f"{rpc_port}", "--validator", "--rpc-methods", "Unsafe", @@ -153,34 +151,32 @@ def setup_multi_node_network(self, log_name: str = "", amt: int = 1): rmtree(output_dir_network, ignore_errors=True) port = 30333 - ws_port = 9944 - rpc_port = 9933 + rpc_port = 9944 if amt == 1: log_file_alice = join(output_dir_network, "node_alice.log") - self._nodes["alice"] = run_single_node(log_file_alice, "/tmp/alice", port, ws_port, rpc_port) + self._nodes["alice"] = run_single_node(log_file_alice, "/tmp/alice", port, rpc_port) wait_till_node_ready(log_file_alice) - setup_offchain_workers(ws_port, "Alice") + setup_offchain_workers(rpc_port, "Alice") wait_till_first_block(log_file_alice) else: log_file_alice = join(output_dir_network, "node_alice.log") - self._nodes["alice"] = run_node(log_file_alice, "/tmp/alice", "alice", port, ws_port, + self._nodes["alice"] = run_node(log_file_alice, "/tmp/alice", "alice", port, rpc_port, node_key="0000000000000000000000000000000000000000000000000000000000000001") wait_till_node_ready(log_file_alice) - setup_offchain_workers(ws_port, "Alice") + setup_offchain_workers(rpc_port, "Alice") log_file = "" for x in range(1, amt): port += 1 - ws_port += 1 rpc_port += 1 name = list(PREDEFINED_KEYS.keys())[x].lower() log_file = join(output_dir_network, f"node_{name}.log") - self._nodes[name] = run_node(log_file, f"/tmp/{name}", name, port, ws_port, rpc_port, node_key=None, + self._nodes[name] = run_node(log_file, f"/tmp/{name}", name, port, rpc_port, node_key=None, bootnodes="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp") wait_till_node_ready(log_file) - setup_offchain_workers(ws_port, "Bob") + setup_offchain_workers(rpc_port, "Bob") wait_till_first_block(log_file_alice) diff --git a/substrate-node/tests/TfChainClient.py b/substrate-node/tests/TfChainClient.py index 4b918c047..1b205ae2c 100644 --- a/substrate-node/tests/TfChainClient.py +++ b/substrate-node/tests/TfChainClient.py @@ -116,8 +116,8 @@ def propose_council_motion(self, substrate, who, call): for event in response.triggered_events: if event.value["event_id"] == "Proposed": - proposal_hash = event.value["event"]["attributes"][2] - proposal_index = event.value["event"]["attributes"][1] + proposal_hash = event.value["event"]["attributes"]["proposal_hash"] + proposal_index = event.value["event"]["attributes"]["proposal_index"] return proposal_hash, proposal_index From dd1dc755e0c70dd83ff97b953310570b84817b36 Mon Sep 17 00:00:00 2001 From: renauter Date: Sat, 25 Nov 2023 23:17:36 -0300 Subject: [PATCH 08/31] fix outdated CLI options (continuation) --- clients/tfchain-client-go/readme.md | 101 +++++++++--------- docs/development/README.md | 26 ++--- docs/development/fork-off-substrate.md | 28 ++--- docs/development/local_multinode.md | 35 +++--- docs/misc/creating_validator.md | 78 +++++++------- .../.devcontainer/devcontainer.json | 21 ++-- .../substrate-node/templates/deployment.yaml | 14 +-- .../substrate-node/templates/service.yaml | 4 - .../charts/substrate-node/values.yaml | 6 +- 9 files changed, 153 insertions(+), 160 deletions(-) diff --git a/clients/tfchain-client-go/readme.md b/clients/tfchain-client-go/readme.md index b449ae9bc..190c55ef4 100644 --- a/clients/tfchain-client-go/readme.md +++ b/clients/tfchain-client-go/readme.md @@ -2,83 +2,84 @@ # **TFchain go client** -- This library is a go implementation of a client for the TFChain. -- Internally, our own [fork](https://github.com/threefoldtech/go-substrate-rpc-client) of is used to make substrate rpc calls. -- Used in multiple repos like [zos](https://github.com/threefoldtech/zos), [rmb-go](https://github.com/threefoldtech/rmb_go), and [terraform-provider-grid](https://github.com/threefoldtech/terraform-provider-grid). +* This library is a go implementation of a client for the TFChain. +* Internally, our own [fork](https://github.com/threefoldtech/go-substrate-rpc-client) of is used to make substrate rpc calls. +* Used in multiple repos like [zos](https://github.com/threefoldtech/zos), [rmb-go](https://github.com/threefoldtech/rmb_go), and [terraform-provider-grid](https://github.com/threefoldtech/terraform-provider-grid). ## **Usage** To make substrate calls: -- First, start a substrate connection against the desired url for the chain: +* First, start a substrate connection against the desired url for the chain: - ```go - manager := NewManager("wss://tfchain.grid.tf/ws") - substrateConnection, err := manager.Substrate() - ``` + ```go + manager := NewManager("wss://tfchain.grid.tf/ws") + substrateConnection, err := manager.Substrate() + ``` + +* These are the urls for different chain networks: -- These are the urls for different chain networks: - - - devnet: - - testnet: - - qanet: - - mainnet: + * devnet: + * testnet: + * qanet: + * mainnet: -- It is the user's responsibility to close the connection. +* It is the user's responsibility to close the connection. - ```go - defer substrateConnection.Close() - ``` + ```go + defer substrateConnection.Close() + ``` -- Then, a user could use the provided api calls to communicate with the chain. like: +* Then, a user could use the provided api calls to communicate with the chain. like: - ```go - contractID, err := substrateConnection.CreateNodeContract(identity, nodeID, body, hash, publicIPsCount, solutionProviderID) - ``` + ```go + contractID, err := substrateConnection.CreateNodeContract(identity, nodeID, body, hash, publicIPsCount, solutionProviderID) + ``` -- Also, if a connection is closed for some reason like timing out, internally, it is reopened if nothing blocks. -- All provided api calls are found under the Substrate struct. +* Also, if a connection is closed for some reason like timing out, internally, it is reopened if nothing blocks. + +* All provided api calls are found under the Substrate struct. ## **Run tests** - To run the tests, you could either run it against a local docker image of the TFChain, or against devnet +To run the tests, you could either run it against a local docker image of the TFChain, or against devnet -- ### **Run against local docker image** +* ### **Run against local docker image** - To run tests against a local docker image of tfchain, you need to set CI environment variable to anything actually. + To run tests against a local docker image of tfchain, you need to set CI environment variable to anything actually. - ```bash - docker run -d -p 9944:9944 threefolddev/tfchain:2.2.0-rc8 --dev --ws-external - sleep 3 - export CI="true" - go test . -v - ``` + ```bash + docker run -d -p 9944:9944 threefolddev/tfchain:2.2.0-rc8 --dev --rpc-external + sleep 3 + export CI="true" + go test . -v + ``` -- ### **Run against devnet** +* ### **Run against devnet** - ```bash - unset CI - go test . -v - ``` + ```bash + unset CI + go test . -v + ``` ### **Test Coverage** -- 30.6% of statements +* 30.6% of statements ## **Workflows** -- ### **Test** - - - This workflow runs all tests found in the root directory against a local docker image of the [TFChain](https://github.com/threefoldtech/tfchain) found [here](https://hub.docker.com/r/threefolddev/tfchain). +* ### **Test** -- ### **Lint** + * This workflow runs all tests found in the root directory against a local docker image of the [TFChain](https://github.com/threefoldtech/tfchain) found [here](https://hub.docker.com/r/threefolddev/tfchain). - - This workflow ensures linting, so make sure to run these commands without any errors before pushing code: +* ### **Lint** - ```bash - golangci-lint run - ``` + * This workflow ensures linting, so make sure to run these commands without any errors before pushing code: - ```bash - gofmt -d -l . - ``` + ```bash + golangci-lint run + ``` + + ```bash + gofmt -d -l . + ``` diff --git a/docs/development/README.md b/docs/development/README.md index aa721798b..1883d6db1 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -26,14 +26,16 @@ cargo build ``` ## Run a dev node + A dev node is a single-node network that runs on your local machine. It is useful for testing and debugging purposes. To run a dev node, you need to do the following: ```sh cd tfchain/substrate-node cargo build -./target/debug/tfchain --dev --ws-external --pruning archive +./target/debug/tfchain --dev --rpc-external --pruning archive ``` + This will run the node in default development mode. This flag sets `--chain=dev`, `--force-authoring`, `--rpc-cors=all`, `--alice`, and `--tmp` flags, unless explicitly overridden. ## Run multiple local nodes @@ -45,11 +47,12 @@ If you want to run tfchain in a multi node network (more than one node), see [lo You can use the Polkadot JS Apps ui to connect to your dev node. You can access the web interface at https://polkadot.js.org/apps/ and change the settings to use a local node with the address `ws://127.0.0.1:9944`. This will allow you to interact with your dev node and perform basic operations. -- Use the Polkadot JS Apps to interact with your nodes. You can access the web interface at https://polkadot.js.org/apps/ and change the settings to use a local node or a remote node with the appropriate address. -- Use the `Accounts` tab to manage your accounts and balances. You can create new accounts, import existing accounts, transfer tokens, and view your transaction history. -- Use the `Explorer` tab to view the network status and activity. You can see the latest blocks, events, validators, and peers. -- Use the `Chain State` tab to query the state of the network. You can select a module and a storage item and see its value at any given block. -- Use the `Extrinsics` tab to submit extrinsics to the network. You can select an account, a module, and a function and provide any required parameters. + +* Use the Polkadot JS Apps to interact with your nodes. You can access the web interface at https://polkadot.js.org/apps/ and change the settings to use a local node or a remote node with the appropriate address. +* Use the `Accounts` tab to manage your accounts and balances. You can create new accounts, import existing accounts, transfer tokens, and view your transaction history. +* Use the `Explorer` tab to view the network status and activity. You can see the latest blocks, events, validators, and peers. +* Use the `Chain State` tab to query the state of the network. You can select a module and a storage item and see its value at any given block. +* Use the `Extrinsics` tab to submit extrinsics to the network. You can select an account, a module, and a function and provide any required parameters. ## Create an account @@ -79,19 +82,18 @@ A pallet is a modular component that defines some logic and functionality for th To learn about pallet development, you can start by checking these resources: -- Get start by reading The substrate [Build application logic tutorials](https://docs.substrate.io/tutorials/build-application-logic/). these tutorials focus on how you can customize the runtime using pallets, creating a custom pallet using macros, adding it to the runtime, and testing its functionality. - -- Check the [the Substrate collectibles workshop](https://docs.substrate.io/tutorials/collectibles-workshop/runtime-and-pallets/). This is an interactive, hands-on, and self-paced workshop that introduces the basic steps for building a blockchain-based application using Substrate. +* Get start by reading The substrate [Build application logic tutorials](https://docs.substrate.io/tutorials/build-application-logic/). these tutorials focus on how you can customize the runtime using pallets, creating a custom pallet using macros, adding it to the runtime, and testing its functionality. -- Explore other existing pallets on the [Substrate GitHub repository](https://github.com/paritytech/substrate/tree/master/frame) and learn from their code. You can see how different pallets implement different features and patterns, such as storage, events, errors, hooks, traits, weights, origins, calls, etc. +* Check the [the Substrate collectibles workshop](https://docs.substrate.io/tutorials/collectibles-workshop/runtime-and-pallets/). This is an interactive, hands-on, and self-paced workshop that introduces the basic steps for building a blockchain-based application using Substrate. +* Explore other existing pallets on the [Substrate GitHub repository](https://github.com/paritytech/substrate/tree/master/frame) and learn from their code. You can see how different pallets implement different features and patterns, such as storage, events, errors, hooks, traits, weights, origins, calls, etc. ## Writing tests for pallets Every pallet should have all functionality tested, you can write unit tests and integration tests for a pallet: -- Unit tests: check this [guide](https://docs.substrate.io/reference/how-to-guides/testing/) -- Integration tests: see this [document](../../substrate-node/tests/readme.md) +* Unit tests: check this [guide](https://docs.substrate.io/reference/how-to-guides/testing/) +* Integration tests: see this [document](../../substrate-node/tests/readme.md) ## Upgrading Substrate version diff --git a/docs/development/fork-off-substrate.md b/docs/development/fork-off-substrate.md index 382942c95..3937fbee8 100644 --- a/docs/development/fork-off-substrate.md +++ b/docs/development/fork-off-substrate.md @@ -5,51 +5,53 @@ The fork-off-substrate tool is a handy tool that allows you to download and run In this guide, we will show you how to use the tool to create a local fork of the TFchain network. ### Prerequisites + Before you start, you need to have the following items: -- The executable binary and the runtime WASM blob of the target blockchain. You can either compile them from the source code of the blockchain project, or copy them from a trusted node that runs the blockchain. For TFchain, you can find the source code [here](https://github.com/threefoldtech/tfchain) and the instructions on how to compile it [here](https://github.com/threefoldtech/tfchain/tree/development/docs/development). Find the Wasm binary file in the target directory. The file name should be `tfchain_runtime.compact.wasm` and the file path should be something like this: +* The executable binary and the runtime WASM blob of the target blockchain. You can either compile them from the source code of the blockchain project, or copy them from a trusted node that runs the blockchain. For TFchain, you can find the source code [here](https://github.com/threefoldtech/tfchain) and the instructions on how to compile it [here](https://github.com/threefoldtech/tfchain/tree/development/docs/development). Find the Wasm binary file in the target directory. The file name should be `tfchain_runtime.compact.wasm` and the file path should be something like this: ```bash ./substrate-node/target/debug/wbuild/tfchain-runtime/tfchain_runtime.compact.wasm ``` ### Steps -- Install the `fork-off-substrate` tool dependencies on your computer, go to `tfchain` directory then follow these steps: + +* Install the `fork-off-substrate` tool dependencies on your computer, go to `tfchain` directory then follow these steps: ```bash cd ./tools/fork-off-substrate npm i ``` -- Create a folder called data inside the top folder (fork-off-substrate). +* Create a folder called data inside the top folder (fork-off-substrate). ```bash mkdir data ``` -- Copy the executable/binary of your substrate based node inside the data folder and rename it to `binary` +* Copy the executable/binary of your substrate based node inside the data folder and rename it to `binary` ```bash cp ../../substrate-node/target/debug/tfchain ./data/binary ``` -- Copy the runtime WASM blob of your substrate based blockchain to the data folder and rename it to `runtime.wasm`. +* Copy the runtime WASM blob of your substrate based blockchain to the data folder and rename it to `runtime.wasm`. ```bash cp ../../substrate-node/target/debug/wbuild/tfchain-runtime/tfchain_runtime.compact.wasm ./data/runtime.wasm ``` -- Run a full node for your blockchain locally (Recommended but should be fully synced) or have an external endpoint handy (but should be running with `--rpc-methods Unsafe` flag) +* Run a full node for your blockchain locally (Recommended but should be fully synced) or have an external endpoint handy (but should be running with `--rpc-methods Unsafe` flag) ```bash - ../../substrate-node/target/debug/tfchain --chain ../../substrate-node/chainspecs/dev/chainSpecRaw.json --ws-external --rpc-methods Unsafe + ../../substrate-node/target/debug/tfchain --chain ../../substrate-node/chainspecs/dev/chainSpecRaw.json --rpc-external --rpc-methods Unsafe ``` -- Run the script +* Run the script - - If using a local node, simply run the script using + * If using a local node, simply run the script using ```bash npm start ``` - - If you are using an external/non-default endpoint, you need to provide it to the script via the HTTP_RPC_ENDPOINT environment variable + * If you are using an external/non-default endpoint, you need to provide it to the script via the HTTP\_RPC\_ENDPOINT environment variable ```bash HTTP_RPC_ENDPOINT=https:// npm start ``` -- You should have the genesis file for the forked chain inside the data folder. It will be called `fork.json`. -- You can now run a new chain using this genesis file +* You should have the genesis file for the forked chain inside the data folder. It will be called `fork.json`. +* You can now run a new chain using this genesis file ```bash ./data/binary --chain ./data/fork.json --alice ``` -for more information about this tool, you can read this [blog post](https://mudit.blog/fork-substrate-blockchain/). \ No newline at end of file +for more information about this tool, you can read this [blog post](https://mudit.blog/fork-substrate-blockchain/). diff --git a/docs/development/local_multinode.md b/docs/development/local_multinode.md index 43f2eb528..82cd5b21e 100644 --- a/docs/development/local_multinode.md +++ b/docs/development/local_multinode.md @@ -9,7 +9,8 @@ cd substrate-node cargo build ``` -you can +you can + ## Start the network In a terminal window execute the following command: @@ -20,8 +21,7 @@ In a terminal window execute the following command: --chain local \ --alice \ --port 30333 \ - --ws-port 9945 \ - --rpc-port 9933 \ + --rpc-port 9945 \ --node-key 0000000000000000000000000000000000000000000000000000000000000001 \ --validator ``` @@ -36,8 +36,7 @@ In a second terminal window executing the following command: --chain local \ --bob \ --port 30334 \ - --ws-port 9946 \ - --rpc-port 9934 \ + --rpc-port 9946 \ --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \ --validator \ --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp @@ -73,25 +72,23 @@ Verify that you see lines similar to the following in the terminal where you sta In these lines, you can see the following information about your blockchain: -- The second node identity was discovered on the network (12D3KooWBCbmQovz78Hq7MzPxdx9d1gZzXMsn6HtWj29bW51YUKB). -- The node has a one peer (1 peers). -- The nodes have produced some blocks (best: #3 (0x0c55…d51b)). -- The blocks are being finalized (finalized #1 (0xf086…9847)). +* The second node identity was discovered on the network (12D3KooWBCbmQovz78Hq7MzPxdx9d1gZzXMsn6HtWj29bW51YUKB). +* The node has a one peer (1 peers). +* The nodes have produced some blocks (best: #3 (0x0c55…d51b)). +* The blocks are being finalized (finalized #1 (0xf086…9847)). ## Review the command-line options Before moving on, have a look at how the following options are used to start the node. -- --base-path Specifies the directory for storing all of the data related to this chain. -- --chain local Specifies the chain specification to use. Valid predefined chain specifications include local, development, and staging. -- --alice Adds the predefined keys for the alice account to the node's keystore. With this setting, the alice account is used for block production and finalization. -- --port 30333 Specifies the port to listen on for peer-to-peer (p2p) traffic. Because this tutorial uses two nodes running on the same physical computer to simulate a network, you must explicitly specify a different port for at least one account. -- --ws-port 9945 Specifies the port to listen on for incoming WebSocket traffic. The default port is 9944. This tutorial uses a custom web socket port number (9945). -- --rpc-port 9933 Specifies the port to listen on for incoming RPC traffic. The default port is 9933. -- --node-key Specifies the Ed25519 secret key to use for libp2p networking. You should only use this option for development and testing. -- --telemetry-url Specifies where to send telemetry data. For this tutorial, you can send telemetry data to a server hosted by Parity that is available for anyone to use. -- --validator Specifies that this node participates in block production and finalization for the network. - +* \--base-path Specifies the directory for storing all of the data related to this chain. +* \--chain local Specifies the chain specification to use. Valid predefined chain specifications include local, development, and staging. +* \--alice Adds the predefined keys for the alice account to the node's keystore. With this setting, the alice account is used for block production and finalization. +* \--port 30333 Specifies the port to listen on for peer-to-peer (p2p) traffic. Because this tutorial uses two nodes running on the same physical computer to simulate a network, you must explicitly specify a different port for at least one account. +* \--rpc-port 9945 Specifies the port to listen on for incoming RPC traffic. The default port is 9944. +* \--node-key Specifies the Ed25519 secret key to use for libp2p networking. You should only use this option for development and testing. +* \--telemetry-url Specifies where to send telemetry data. For this tutorial, you can send telemetry data to a server hosted by Parity that is available for anyone to use. +* \--validator Specifies that this node participates in block production and finalization for the network. ## What next diff --git a/docs/misc/creating_validator.md b/docs/misc/creating_validator.md index 78a9b963e..97d43e24d 100644 --- a/docs/misc/creating_validator.md +++ b/docs/misc/creating_validator.md @@ -10,9 +10,9 @@ The transactions weights in TFchain were benchmarked on standard hardware. It is Standard Hardware For the full details of the standard hardware please see here. -- CPU - Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz -- Storage - A NVMe solid state drive. Should be reasonably sized to deal with blockchain growth. Starting around 80GB - 160GB will be okay for the first six months of TFchain, but will need to be re-evaluated every six months. -- Memory - 64GB ECC. +* CPU - Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz +* Storage - A NVMe solid state drive. Should be reasonably sized to deal with blockchain growth. Starting around 80GB - 160GB will be okay for the first six months of TFchain, but will need to be re-evaluated every six months. +* Memory - 64GB ECC. The specs posted above are by no means the minimum specs that you could use when running a validator, however you should be aware that if you are using less you may need to toggle some extra optimizations in order to be equal to other validators that are running the standard. @@ -101,9 +101,9 @@ You can now start synchronising chain data. Bootnodes examples: -- Devnet bootnode: `/ip4/185.206.122.7/tcp/30333/p2p/12D3KooWLcMLBg9itjQL1EXsAqkJFPhqESHqJKY7CBKmhhhL8fdp` -- Testnet bootnode: `/ip4/51.68.204.40/tcp/30333/p2p/12D3KooWHe8Wbn6dDbyxXietaXSRTZJfykPRgrkJDjXh9xZ4383k` -- Mainnet bootnode: `/ip4/185.206.122.83/tcp/30333/p2p/12D3KooWLtsdtQHswnXkLRH7e8vZJHktsh7gfuL5PoADV51JJ6wY` +* Devnet bootnode: `/ip4/185.206.122.7/tcp/30333/p2p/12D3KooWLcMLBg9itjQL1EXsAqkJFPhqESHqJKY7CBKmhhhL8fdp` +* Testnet bootnode: `/ip4/51.68.204.40/tcp/30333/p2p/12D3KooWHe8Wbn6dDbyxXietaXSRTZJfykPRgrkJDjXh9xZ4383k` +* Mainnet bootnode: `/ip4/185.206.122.83/tcp/30333/p2p/12D3KooWLtsdtQHswnXkLRH7e8vZJHktsh7gfuL5PoADV51JJ6wY` You can begin syncing your node by running the following command: @@ -147,16 +147,16 @@ If you are interested in determining how much longer you have to go, your server ## Create a Validator object -- dev: -- test: -- main: +* dev: +* test: +* main: Open polkadot js link in the browser based on the network you want to validate on. -- Browse to `accounts` and click `Add Account`, create an account and name it `VALIDATOR_ACCOUNT`. Take note of the mnemonic. - This account will be your account that manages the Validator and manages your council membership (voting). Make sure to send some TFT to this account. -- (Optional) Create another account and name it `ANYNAME_STASH`. This account will be your stash account. -- Create one more account and call it `VALIDATOR_NODE_ACCOUNT`, this account will be used to participate in consensus. +* Browse to `accounts` and click `Add Account`, create an account and name it `VALIDATOR_ACCOUNT`. Take note of the mnemonic. + This account will be your account that manages the Validator and manages your council membership (voting). Make sure to send some TFT to this account. +* (Optional) Create another account and name it `ANYNAME_STASH`. This account will be your stash account. +* Create one more account and call it `VALIDATOR_NODE_ACCOUNT`, this account will be used to participate in consensus. You now should have 3 accounts. @@ -180,11 +180,11 @@ This call needs to be signed with your account (`VALIDATOR_ACCOUNT`) that manage Information needed: -- validator_node_account: Account ID generated from previous step (`VALIDATOR_NODE_ACCOUNT`) -- stash_account: Stash account, can be your `VALIDATOR_ACCOUNT` -- description: Reason why I want to become a validator -- tfconnectid: Your Threefold connect name -- info: link to webpage or linked in profile +* validator\_node\_account: Account ID generated from previous step (`VALIDATOR_NODE_ACCOUNT`) +* stash\_account: Stash account, can be your `VALIDATOR_ACCOUNT` +* description: Reason why I want to become a validator +* tfconnectid: Your Threefold connect name +* info: link to webpage or linked in profile If all information is filled in correctly. Click on `Submit transaction` and sign. If all goes well, the Council will approve your request. @@ -204,7 +204,7 @@ Transfer some balance to this account (you can see the address in the polkadot U Restart tfchain with: ```sh -./target/release/tfchain ...otherArgs --ws-external --rpc-methods Unsafe --rpc-external --telemetry-url 'wss://shard1.telemetry.tfchain.grid.tf/submit 1' +./target/release/tfchain ...otherArgs --rpc-external --rpc-methods Unsafe --telemetry-url 'wss://shard1.telemetry.tfchain.grid.tf/submit 1' ``` #### Using polkodatjs @@ -220,7 +220,7 @@ yarn yarn start ``` -Browse to and connect to the new node over its public ip. Make sure to specify the port, like: ws://YOUR_MACHINE_PUBLIC_IP:9944 +Browse to and connect to the new node over its public ip. Make sure to specify the port, like: ws://YOUR\_MACHINE\_PUBLIC\_IP:9944 First insert the types: Go to `Settings` -> `Developer` -> Copy paste output of following [file](https://raw.githubusercontent.com/threefoldtech/tfchain_client_js/master/types.json) @@ -240,14 +240,12 @@ Go to `Extrinsics` -> `session` -> `setKeys` -> (make sure to use the created no input: -``` -keys: the key from rotate keys ouput -proofs: 0 -``` + keys: the key from rotate keys ouput + proofs: 0 Now we can start the node in Validator mode: -Restart tfchain and remove flags: `--ws-external --rpc-methods Unsafe --rpc-external` and replace that with `--validator` +Restart tfchain and remove flags: `--rpc-external --rpc-methods Unsafe` and replace that with `--validator` Your node is now running in validator mode. Next up you need to manually activate the validator. @@ -265,22 +263,20 @@ Select `ActivateValidatorNode` and click Submit Transaction. Example systemd file: -``` -[Unit] -Description=TFchain service -After=network.target -StartLimitIntervalSec=0 - -[Service] -Type=simple -Restart=always -RestartSec=1 -User=user -ExecStart=/home/user/tfchain/substrate-node/target/release/tfchain --chain /home/user/tfchain/substrate-node/chainspecs/dev/chainSpec.json --pruning=archive --bootnodes /ip4/185.206.122.7/tcp/30333/p2p/12D3KooWLcMLBg9itjQL1EXsAqkJFPhqESHqJKY7CBKmhhhL8fdp --validator --telemetry-url 'wss://shard1.telemetry.tfchain.grid.tf/submit 1' - -[Install] -WantedBy=multi-user.target -``` + [Unit] + Description=TFchain service + After=network.target + StartLimitIntervalSec=0 + + [Service] + Type=simple + Restart=always + RestartSec=1 + User=user + ExecStart=/home/user/tfchain/substrate-node/target/release/tfchain --chain /home/user/tfchain/substrate-node/chainspecs/dev/chainSpec.json --pruning=archive --bootnodes /ip4/185.206.122.7/tcp/30333/p2p/12D3KooWLcMLBg9itjQL1EXsAqkJFPhqESHqJKY7CBKmhhhL8fdp --validator --telemetry-url 'wss://shard1.telemetry.tfchain.grid.tf/submit 1' + + [Install] + WantedBy=multi-user.target Replace `user` by your username. diff --git a/substrate-node/.devcontainer/devcontainer.json b/substrate-node/.devcontainer/devcontainer.json index 9452e0ade..3dc8a239a 100644 --- a/substrate-node/.devcontainer/devcontainer.json +++ b/substrate-node/.devcontainer/devcontainer.json @@ -14,12 +14,19 @@ 3000, 9944 ], - "preCreateCommand": ["cargo build", "cargo check"], - "postStartCommand": "./target/debug/node-template --dev --ws-external", + "preCreateCommand": [ + "cargo build", + "cargo check" + ], + "postStartCommand": "./target/debug/node-template --dev --rpc-external", "menuActions": [ - {"id": "polkadotjs", - "label": "Open PolkadotJS Apps", - "type": "external-preview", - "args": ["https://polkadot.js.org/apps/?rpc=wss%3A%2F%2F/$HOST/wss"]} + { + "id": "polkadotjs", + "label": "Open PolkadotJS Apps", + "type": "external-preview", + "args": [ + "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2F/$HOST/wss" + ] + } ] -} +} \ No newline at end of file diff --git a/substrate-node/charts/substrate-node/templates/deployment.yaml b/substrate-node/charts/substrate-node/templates/deployment.yaml index a4ba61e16..de6a2111e 100644 --- a/substrate-node/charts/substrate-node/templates/deployment.yaml +++ b/substrate-node/charts/substrate-node/templates/deployment.yaml @@ -38,24 +38,19 @@ spec: - name: rpc containerPort: {{ .Values.rpc_port }} protocol: TCP - - name: ws - containerPort: {{ .Values.ws_port }} - protocol: TCP env: - name: SUBSTRATE_NAME value: {{ .Values.name }} - name: SUBSTRATE_PORT value: {{ .Values.port | quote }} - - name: SUBSTRATE_WS_PORT - value: {{ .Values.ws_port | quote }} - name: SUBSTRATE_RPC_PORT value: {{ .Values.rpc_port | quote }} - name: SUBSTRATE_BOOT_NODE value: {{ .Values.boot_node }} - name: CHAINSPEC value: {{ .Values.chainspec }} - - name: WS_MAX_CONNECTIONS - value: {{ .Values.ws_max_connections | quote }} + - name: RPC_MAX_CONNECTIONS + value: {{ .Values.rpc_max_connections | quote }} - name: SUBSTRATE_RPC_METHODS value: {{ .Values.rpc_methods }} args: [ @@ -66,7 +61,6 @@ spec: "--keystore-path=/keystore", "--chain=$(CHAINSPEC)", "--port", "$(SUBSTRATE_PORT)", - "--ws-port", "$(SUBSTRATE_WS_PORT)", "--rpc-port", "$(SUBSTRATE_RPC_PORT)", {{ if .Values.boot_node }} "--bootnodes", "$(SUBSTRATE_BOOT_NODE)", @@ -76,9 +70,9 @@ spec: "--validator", "--pruning", "archive", {{ else }} - "--ws-external", + "--rpc-external", {{ end }} - "--ws-max-connections", "$(WS_MAX_CONNECTIONS)", + "--rpc-max-connections", "$(RPC_MAX_CONNECTIONS)", {{ if .Values.telemetry_url }} "--telemetry-url", {{ .Values.telemetry_url | quote }}, {{ end }} diff --git a/substrate-node/charts/substrate-node/templates/service.yaml b/substrate-node/charts/substrate-node/templates/service.yaml index f2b1c6a95..b817b8c8c 100644 --- a/substrate-node/charts/substrate-node/templates/service.yaml +++ b/substrate-node/charts/substrate-node/templates/service.yaml @@ -8,10 +8,6 @@ metadata: spec: type: {{ .Values.service.type }} ports: - - port: 80 - targetPort: {{ .Values.ws_port }} - protocol: TCP - name: ws - port: {{ .Values.port }} protocol: TCP name: http diff --git a/substrate-node/charts/substrate-node/values.yaml b/substrate-node/charts/substrate-node/values.yaml index 114ead932..4ef36de3b 100644 --- a/substrate-node/charts/substrate-node/values.yaml +++ b/substrate-node/charts/substrate-node/values.yaml @@ -43,15 +43,13 @@ name: 'tfchainnode01' port: 30333 -ws_port: 9944 - -rpc_port: 9933 +rpc_port: 9944 is_validator: true chainspec: '/etc/chainspecs/dev/chainSpecRaw.json' -ws_max_connections: 1048576 +rpc_max_connections: 1048576 #rpc_methods: "Unsafe" From 67da2473d6bf737000088b02ee9222ff1ba7b910 Mon Sep 17 00:00:00 2001 From: renauter Date: Sun, 26 Nov 2023 19:39:49 -0300 Subject: [PATCH 09/31] fix codacy --- substrate-node/tests/SubstrateNetwork.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/substrate-node/tests/SubstrateNetwork.py b/substrate-node/tests/SubstrateNetwork.py index 80da5d14a..9fbc8670b 100644 --- a/substrate-node/tests/SubstrateNetwork.py +++ b/substrate-node/tests/SubstrateNetwork.py @@ -13,6 +13,7 @@ SUBSTRATE_NODE_DIR = dirname(os.getcwd()) +TMP_DIR = "\tmp" TFCHAIN_EXE = join(SUBSTRATE_NODE_DIR, "target", "release", "tfchain") RE_NODE_STARTED = re.compile("Running JSON-RPC server") @@ -151,17 +152,17 @@ def setup_multi_node_network(self, log_name: str = "", amt: int = 1): rmtree(output_dir_network, ignore_errors=True) port = 30333 - rpc_port = 9944 + rpc_port = 994 if amt == 1: log_file_alice = join(output_dir_network, "node_alice.log") - self._nodes["alice"] = run_single_node(log_file_alice, "/tmp/alice", port, rpc_port) + self._nodes["alice"] = run_single_node(log_file_alice, f"{TMP_DIR}/alice", port, rpc_port) wait_till_node_ready(log_file_alice) setup_offchain_workers(rpc_port, "Alice") wait_till_first_block(log_file_alice) else: log_file_alice = join(output_dir_network, "node_alice.log") - self._nodes["alice"] = run_node(log_file_alice, "/tmp/alice", "alice", port, + self._nodes["alice"] = run_node(log_file_alice, f"{TMP_DIR}/alice", "alice", port, rpc_port, node_key="0000000000000000000000000000000000000000000000000000000000000001") wait_till_node_ready(log_file_alice) setup_offchain_workers(rpc_port, "Alice") @@ -173,7 +174,7 @@ def setup_multi_node_network(self, log_name: str = "", amt: int = 1): rpc_port += 1 name = list(PREDEFINED_KEYS.keys())[x].lower() log_file = join(output_dir_network, f"node_{name}.log") - self._nodes[name] = run_node(log_file, f"/tmp/{name}", name, port, rpc_port, node_key=None, + self._nodes[name] = run_node(log_file, f"{TMP_DIR}/{name}", name, port, rpc_port, node_key=None, bootnodes="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp") wait_till_node_ready(log_file) setup_offchain_workers(rpc_port, "Bob") From 85031442dbefad2203b8160ca0b93d5ac8f6da8d Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 00:19:18 -0300 Subject: [PATCH 10/31] fix integration tests --- substrate-node/tests/SubstrateNetwork.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate-node/tests/SubstrateNetwork.py b/substrate-node/tests/SubstrateNetwork.py index 9fbc8670b..d6b8794bc 100644 --- a/substrate-node/tests/SubstrateNetwork.py +++ b/substrate-node/tests/SubstrateNetwork.py @@ -152,7 +152,7 @@ def setup_multi_node_network(self, log_name: str = "", amt: int = 1): rmtree(output_dir_network, ignore_errors=True) port = 30333 - rpc_port = 994 + rpc_port = 9944 if amt == 1: log_file_alice = join(output_dir_network, "node_alice.log") From 79d7d8670c92e7422f959b58c5bf2b71e2a7292f Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 00:58:53 -0300 Subject: [PATCH 11/31] upgrade to polkadot 1.0.0 --- substrate-node/Cargo.toml | 132 +++++++++++++++--------------- substrate-node/runtime/Cargo.toml | 2 +- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/substrate-node/Cargo.toml b/substrate-node/Cargo.toml index 45247f26d..fa48fdca1 100644 --- a/substrate-node/Cargo.toml +++ b/substrate-node/Cargo.toml @@ -60,73 +60,73 @@ tfchain-support = { path = "support", default-features = false } tfchain-runtime = { path = "runtime", default-features = false } # Benchmarking (with default disabled) -frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} # Substrate (with default disabled) -frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-session-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-transaction-payment-rpc = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-storage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-keystore = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} -sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43"} +frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-session-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-transaction-payment-rpc = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-storage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-keystore = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} # Client-only (with default enabled) -polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.43"} -polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.43"} -polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.43"} -sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-chain-spec = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-rpc = { git = "https://github.com/paritytech/substrate.git", "branch" = "polkadot-v0.9.43" } -sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -sp-timestamp = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -substrate-frame-rpc-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} -substrate-prometheus-endpoint = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"} +polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0"} +polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0"} +polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0"} +sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-chain-spec = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-rpc = { git = "https://github.com/paritytech/substrate.git", "branch" = "polkadot-v1.0.0" } +sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sp-timestamp = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +substrate-frame-rpc-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +substrate-prometheus-endpoint = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} diff --git a/substrate-node/runtime/Cargo.toml b/substrate-node/runtime/Cargo.toml index 05206d0ea..9c2b11fec 100644 --- a/substrate-node/runtime/Cargo.toml +++ b/substrate-node/runtime/Cargo.toml @@ -14,7 +14,7 @@ version.workspace = true targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } [dependencies] smallvec.workspace = true From 5d485960ef631d56884f73e452e8b835601fb84a Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 01:01:23 -0300 Subject: [PATCH 12/31] upgrade parity-scale-codec --- substrate-node/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate-node/Cargo.toml b/substrate-node/Cargo.toml index fa48fdca1..9328401e4 100644 --- a/substrate-node/Cargo.toml +++ b/substrate-node/Cargo.toml @@ -24,7 +24,7 @@ resolver = "2" base58 = {version = "0.2.0", default-features = false} bitflags = {version = "1.3.2", default-features = false} clap = "4.0.9" -parity-scale-codec = { version = "3.2.2", default-features = false } +parity-scale-codec = { version = "3.6.1", default-features = false } env_logger = "0.10.0" futures = {version = "0.3.21", default-features = false} hex = {version = "0.4.0", default-features = false} From a663505c7d016b91dd0bd7cefd37d21ae995f7b0 Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 21:43:29 -0300 Subject: [PATCH 13/31] update node --- substrate-node/Cargo.toml | 1 + substrate-node/node/Cargo.toml | 1 + .../{command_helper.rs => benchmarking.rs} | 108 +++++++++++------- substrate-node/node/src/chain_spec.rs | 14 ++- substrate-node/node/src/cli.rs | 1 + substrate-node/node/src/command.rs | 66 ++++++----- substrate-node/node/src/main.rs | 4 +- substrate-node/node/src/rpc.rs | 4 +- substrate-node/node/src/service.rs | 35 ++++-- 9 files changed, 146 insertions(+), 88 deletions(-) rename substrate-node/node/src/{command_helper.rs => benchmarking.rs} (59%) diff --git a/substrate-node/Cargo.toml b/substrate-node/Cargo.toml index 9328401e4..a0caf5172 100644 --- a/substrate-node/Cargo.toml +++ b/substrate-node/Cargo.toml @@ -123,6 +123,7 @@ sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polka sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-offchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} diff --git a/substrate-node/node/Cargo.toml b/substrate-node/node/Cargo.toml index 4fb2d5fd9..b759c1045 100644 --- a/substrate-node/node/Cargo.toml +++ b/substrate-node/node/Cargo.toml @@ -34,6 +34,7 @@ sc-telemetry.workspace = true sc-keystore.workspace = true sc-transaction-pool.workspace = true sc-transaction-pool-api.workspace = true +sc-offchain.workspace = true sc-consensus-aura.workspace = true sp-consensus-aura.workspace = true sp-consensus.workspace = true diff --git a/substrate-node/node/src/command_helper.rs b/substrate-node/node/src/benchmarking.rs similarity index 59% rename from substrate-node/node/src/command_helper.rs rename to substrate-node/node/src/benchmarking.rs index de991eaf2..06f55b394 100644 --- a/substrate-node/node/src/command_helper.rs +++ b/substrate-node/node/src/benchmarking.rs @@ -1,53 +1,41 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! Contains code to setup the command invocations in [`super::command`] which would -//! otherwise bloat that module. +//! Setup code for [`super::command`] which would otherwise bloat that module. +//! +//! Should only be used for benchmarking as it may break in other contexts. use crate::service::FullClient; -use runtime::SystemCall; +use runtime::{AccountId, Balance, BalancesCall, SystemCall}; use sc_cli::Result; use sc_client_api::BlockBackend; use sp_core::{Encode, Pair}; -use sp_inherents::InherentData; +use sp_inherents::{InherentData, InherentDataProvider}; use sp_keyring::Sr25519Keyring; use sp_runtime::{OpaqueExtrinsic, SaturatedConversion}; -use std::sync::Arc; use tfchain_runtime as runtime; +use std::{sync::Arc, time::Duration}; + /// Generates extrinsics for the `benchmark overhead` command. /// /// Note: Should only be used for benchmarking. -pub struct BenchmarkExtrinsicBuilder { +pub struct RemarkBuilder { client: Arc, } -impl BenchmarkExtrinsicBuilder { +impl RemarkBuilder { /// Creates a new [`Self`] from the given client. pub fn new(client: Arc) -> Self { Self { client } } } -impl frame_benchmarking_cli::ExtrinsicBuilder for BenchmarkExtrinsicBuilder { +impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder { + fn pallet(&self) -> &str { + "system" + } + fn extrinsic(&self) -> &str { - todo!() + "remark" } fn build(&self, nonce: u32) -> std::result::Result { @@ -62,9 +50,52 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for BenchmarkExtrinsicBuilder { Ok(extrinsic) } +} + +/// Generates `Balances::TransferKeepAlive` extrinsics for the benchmarks. +/// +/// Note: Should only be used for benchmarking. +pub struct TransferKeepAliveBuilder { + client: Arc, + dest: AccountId, + value: Balance, +} + +impl TransferKeepAliveBuilder { + /// Creates a new [`Self`] from the given client. + pub fn new(client: Arc, dest: AccountId, value: Balance) -> Self { + Self { + client, + dest, + value, + } + } +} +impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder { fn pallet(&self) -> &str { - todo!() + "balances" + } + + fn extrinsic(&self) -> &str { + "transfer_keep_alive" + } + + fn build(&self, nonce: u32) -> std::result::Result { + let acc = Sr25519Keyring::Bob.pair(); + let extrinsic: OpaqueExtrinsic = create_benchmark_extrinsic( + self.client.as_ref(), + acc, + BalancesCall::transfer_keep_alive { + dest: self.dest.clone().into(), + value: self.value, + } + .into(), + nonce, + ) + .into(); + + Ok(extrinsic) } } @@ -120,10 +151,10 @@ pub fn create_benchmark_extrinsic( let signature = raw_payload.using_encoded(|e| sender.sign(e)); runtime::UncheckedExtrinsic::new_signed( - call.clone(), + call, sp_runtime::AccountId32::from(sender.public()).into(), - runtime::Signature::Sr25519(signature.clone()), - extra.clone(), + runtime::Signature::Sr25519(signature), + extra, ) } @@ -131,12 +162,11 @@ pub fn create_benchmark_extrinsic( /// /// Note: Should only be used for benchmarking. pub fn inherent_benchmark_data() -> Result { - // TODO, see if we can fix this later - // let mut inherent_data = InherentData::new(); - // let d = Duration::from_millis(0); - // let timestamp = sp_timestamp::InherentDataProvider::new(d.into()); - // timestamp - // .provide_inherent_data(&mut inherent_data) - // .map_err(|e| format!("creating inherent data: {:?}", e))?; - Ok(InherentData::new()) + let mut inherent_data = InherentData::new(); + let d = Duration::from_millis(0); + let timestamp = sp_timestamp::InherentDataProvider::new(d.into()); + + futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data)) + .map_err(|e| format!("creating inherent data: {:?}", e))?; + Ok(inherent_data) } diff --git a/substrate-node/node/src/chain_spec.rs b/substrate-node/node/src/chain_spec.rs index d5c827ce2..50b809e22 100644 --- a/substrate-node/node/src/chain_spec.rs +++ b/substrate-node/node/src/chain_spec.rs @@ -6,8 +6,8 @@ use sp_runtime::traits::{IdentifyAccount, Verify}; use std::convert::TryInto; use tfchain_runtime::opaque::SessionKeys; use tfchain_runtime::{ - AccountId, AuraConfig, BalancesConfig, CouncilConfig, CouncilMembershipConfig, GenesisConfig, - GrandpaConfig, SessionConfig, Signature, SmartContractModuleConfig, SystemConfig, + AccountId, AuraConfig, BalancesConfig, CouncilConfig, CouncilMembershipConfig, GrandpaConfig, + RuntimeGenesisConfig, SessionConfig, Signature, SmartContractModuleConfig, SystemConfig, TFTBridgeModuleConfig, TFTPriceModuleConfig, TfgridModuleConfig, ValidatorSetConfig, WASM_BINARY, }; @@ -16,7 +16,7 @@ use tfchain_runtime::{ // 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; +pub type ChainSpec = sc_service::GenericChainSpec; /// Generate a crypto pair from seed. pub fn get_from_seed(seed: &str) -> ::Public { @@ -303,12 +303,12 @@ fn testnet_genesis( max_tft_price: u32, billing_frequency: u64, council_members: Vec, -) -> GenesisConfig { - GenesisConfig { +) -> RuntimeGenesisConfig { + RuntimeGenesisConfig { system: SystemConfig { // Add Wasm runtime to storage. code: wasm_binary.to_vec(), - // changes_trie_config: Default::default(), + ..Default::default() }, balances: BalancesConfig { // Configure endowed accounts with initial balance of 1 << 60. @@ -342,6 +342,7 @@ fn testnet_genesis( }, grandpa: GrandpaConfig { authorities: vec![], + ..Default::default() }, tfgrid_module: TfgridModuleConfig { su_price_value: 50000, @@ -388,6 +389,7 @@ fn testnet_genesis( }, smart_contract_module: SmartContractModuleConfig { billing_frequency: billing_frequency, + _data: std::marker::PhantomData, }, } } diff --git a/substrate-node/node/src/cli.rs b/substrate-node/node/src/cli.rs index 5d8513a1f..965bf3533 100644 --- a/substrate-node/node/src/cli.rs +++ b/substrate-node/node/src/cli.rs @@ -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)] diff --git a/substrate-node/node/src/command.rs b/substrate-node/node/src/command.rs index 86c53e4f5..fb3bd365b 100644 --- a/substrate-node/node/src/command.rs +++ b/substrate-node/node/src/command.rs @@ -1,13 +1,14 @@ use crate::{ + benchmarking::{inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder}, chain_spec, cli::{Cli, Subcommand}, - command_helper::{inherent_benchmark_data, BenchmarkExtrinsicBuilder}, service, }; -use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; -use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli}; +use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE}; +use sc_cli::SubstrateCli; use sc_service::PartialComponents; -use tfchain_runtime::Block; +use sp_keyring::Sr25519Keyring; +use tfchain_runtime::{Block, EXISTENTIAL_DEPOSIT}; impl SubstrateCli for Cli { fn impl_name() -> String { @@ -44,10 +45,6 @@ impl SubstrateCli for Cli { )?), }) } - - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &tfchain_runtime::VERSION - } } /// Parse and run command line arguments @@ -142,7 +139,7 @@ pub fn run() -> sc_cli::Result<()> { ); } - cmd.run::(config) + cmd.run::(config) } BenchmarkCmd::Block(cmd) => { let PartialComponents { client, .. } = service::new_partial(&config)?; @@ -165,7 +162,7 @@ pub fn run() -> sc_cli::Result<()> { } BenchmarkCmd::Overhead(cmd) => { let PartialComponents { client, .. } = service::new_partial(&config)?; - let ext_builder = BenchmarkExtrinsicBuilder::new(client.clone()); + let ext_builder = RemarkBuilder::new(client.clone()); cmd.run( config, @@ -175,12 +172,23 @@ pub fn run() -> sc_cli::Result<()> { &ext_builder, ) } + BenchmarkCmd::Extrinsic(cmd) => { + let PartialComponents { client, .. } = service::new_partial(&config)?; + // Register the *Remark* and *TKA* builders. + let ext_factory = ExtrinsicFactory(vec![ + Box::new(RemarkBuilder::new(client.clone())), + Box::new(TransferKeepAliveBuilder::new( + client.clone(), + Sr25519Keyring::Alice.to_account_id(), + EXISTENTIAL_DEPOSIT, + )), + ]); + + cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) + } BenchmarkCmd::Machine(cmd) => { cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()) } - BenchmarkCmd::Extrinsic(_cmd) => { - todo!() - } } }) } @@ -192,22 +200,22 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(cmd)?; runner.async_run(|config| { - // we don't need any of the components of new_partial, just a runtime, or a task - // manager to do `async_run`. - let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(config.tokio_handle.clone(), registry) - .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; - let info_provider = timestamp_with_aura_info(6000); - - Ok(( - cmd.run::::ExtendHostFunctions, - >, _>(Some(info_provider)), - task_manager, - )) - }) + // we don't need any of the components of new_partial, just a runtime, or a task + // manager to do `async_run`. + let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); + let task_manager = + sc_service::TaskManager::new(config.tokio_handle.clone(), registry) + .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; + let info_provider = timestamp_with_aura_info(6000); + + Ok(( + cmd.run::::ExtendHostFunctions, + >, _>(Some(info_provider)), + task_manager, + )) + }) } #[cfg(not(feature = "try-runtime"))] Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \ diff --git a/substrate-node/node/src/main.rs b/substrate-node/node/src/main.rs index 5d5bd2d90..33c3195e0 100644 --- a/substrate-node/node/src/main.rs +++ b/substrate-node/node/src/main.rs @@ -4,11 +4,11 @@ mod chain_spec; #[macro_use] mod service; +mod benchmarking; mod cli; mod command; mod rpc; -mod command_helper; fn main() -> sc_cli::Result<()> { - command::run() + command::run() } diff --git a/substrate-node/node/src/rpc.rs b/substrate-node/node/src/rpc.rs index d02be6a23..d26b0d2cd 100644 --- a/substrate-node/node/src/rpc.rs +++ b/substrate-node/node/src/rpc.rs @@ -14,7 +14,7 @@ use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use tfchain_runtime::{opaque::Block, AccountId, Balance, Index}; +use tfchain_runtime::{opaque::Block, AccountId, Balance, Nonce}; /// Full client dependencies. pub struct FullDeps { @@ -34,7 +34,7 @@ where C: ProvideRuntimeApi, C: HeaderBackend + HeaderMetadata + 'static, C: Send + Sync + 'static, - C::Api: substrate_frame_rpc_system::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, diff --git a/substrate-node/node/src/service.rs b/substrate-node/node/src/service.rs index 05117164a..4a93bef6f 100644 --- a/substrate-node/node/src/service.rs +++ b/substrate-node/node/src/service.rs @@ -1,11 +1,13 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. -use sc_client_api::BlockBackend; +use futures::FutureExt; +use sc_client_api::{Backend, BlockBackend}; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_consensus_grandpa::SharedVoterState; pub use sc_executor::NativeElseWasmExecutor; use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams}; use sc_telemetry::{Telemetry, TelemetryWorker}; +use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use std::{sync::Arc, time::Duration}; use tfchain_runtime::{self, opaque::Block, RuntimeApi}; @@ -35,6 +37,7 @@ pub type FullClient = type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; +#[allow(clippy::type_complexity)] pub fn new_partial( config: &Configuration, ) -> Result< @@ -68,8 +71,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::( &config, @@ -97,7 +99,7 @@ pub fn new_partial( let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( client.clone(), - &(client.clone() as Arc<_>), + &client, select_chain.clone(), telemetry.as_ref().map(|x| x.handle()), )?; @@ -201,11 +203,23 @@ pub fn new_full(config: Configuration) -> Result { })?; 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(), ); } @@ -265,7 +279,7 @@ pub fn new_full(config: Configuration) -> Result { let proposer_factory = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client.clone(), - transaction_pool, + transaction_pool.clone(), prometheus_registry.as_ref(), telemetry.as_ref().map(|x| x.handle()), ); @@ -344,6 +358,7 @@ pub fn new_full(config: Configuration) -> Result { prometheus_registry, shared_voter_state: SharedVoterState::empty(), telemetry: telemetry.as_ref().map(|x| x.handle()), + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool), }; // the GRANDPA voter task is considered infallible, i.e. From a10d86143d10ab5a795f71c3a82c562cfa337100 Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 21:44:15 -0300 Subject: [PATCH 14/31] update runtime --- substrate-node/runtime/src/lib.rs | 42 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/substrate-node/runtime/src/lib.rs b/substrate-node/runtime/src/lib.rs index 679bd3c86..4f8f6be3b 100644 --- a/substrate-node/runtime/src/lib.rs +++ b/substrate-node/runtime/src/lib.rs @@ -35,7 +35,10 @@ use tfchain_support::{ // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU8, EitherOfDiverse, FindAuthor, KeyOwnerProofSystem, PrivilegeCmp, Randomness}, + traits::{ + ConstBool, ConstU8, EitherOfDiverse, FindAuthor, KeyOwnerProofSystem, PrivilegeCmp, + Randomness, + }, weights::{ constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, @@ -100,7 +103,7 @@ pub type AccountIndex = u32; pub type Balance = u128; /// Index of a transaction in the chain. -pub type Index = u32; +pub type Nonce = u32; /// A hash of some data used by the chain. pub type Hash = sp_core::H256; @@ -143,6 +146,7 @@ pub fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys { /// Constant values used within the runtime. pub mod constants; +#[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("substrate-threefold"), impl_name: create_runtime_str!("substrate-threefold"), @@ -188,6 +192,8 @@ parameter_types! { impl frame_system::Config for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = frame_support::traits::Everything; + /// The block type for the runtime. + type Block = Block; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). @@ -198,16 +204,12 @@ impl frame_system::Config for Runtime { type RuntimeCall = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; - /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; + /// The type for storing how many extrinsics an account has signed. + type Nonce = Nonce; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; - /// The header type. - type Header = generic::Header; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. @@ -246,6 +248,7 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); type MaxAuthorities = MaxAuthorities; + type AllowMultipleBlocksPerSlot = ConstBool; } impl pallet_grandpa::Config for Runtime { @@ -271,8 +274,11 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = (); } +/// Existential deposit. +pub const EXISTENTIAL_DEPOSIT: u128 = 500; + parameter_types! { - pub const ExistentialDeposit: u128 = 500; + pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; } @@ -291,7 +297,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -514,7 +520,7 @@ where call: RuntimeCall, public: ::Signer, account: AccountId, - index: Index, + index: Nonce, ) -> Option<( RuntimeCall, ::SignaturePayload, @@ -690,10 +696,7 @@ impl pallet_utility::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // System support System: frame_system = 0, @@ -770,7 +773,10 @@ pub type Executive = frame_executive::Executive< // All migrations executed on runtime upgrade as a nested tuple of types implementing // `OnRuntimeUpgrade`. -type Migrations = (pallet_tfgrid::migrations::v17::FixFarmPublicIps, pallet_tft_bridge::migrations::v2::MigrateBurnTransactionsV2); +type Migrations = ( + pallet_tfgrid::migrations::v17::FixFarmPublicIps, + pallet_tft_bridge::migrations::v2::MigrateBurnTransactionsV2, +); // follows Substrate's non destructive way of eliminating otherwise required // repetion: https://github.com/paritytech/substrate/pull/10592 @@ -919,8 +925,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } From 50e224ee534ffd7aa9a53c4979921877fe1e3425 Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 21:46:33 -0300 Subject: [PATCH 15/31] update pallets --- .../pallets/pallet-burning/src/lib.rs | 4 +- substrate-node/pallets/pallet-dao/src/dao.rs | 5 +- substrate-node/pallets/pallet-dao/src/lib.rs | 6 +- .../pallet-smart-contract/src/billing.rs | 9 ++- .../pallets/pallet-smart-contract/src/lib.rs | 18 ++---- .../pallets/pallet-tfgrid/src/benchmarking.rs | 6 +- .../pallets/pallet-tfgrid/src/farm.rs | 3 +- .../pallets/pallet-tfgrid/src/lib.rs | 60 +++++-------------- .../pallet-tfgrid/src/migrations/v14.rs | 3 +- .../pallets/pallet-tfgrid/src/pricing.rs | 13 ++-- .../pallets/pallet-tft-bridge/src/lib.rs | 36 ++++------- .../pallet-tft-bridge/src/migrations/types.rs | 10 ++-- .../pallet-tft-bridge/src/migrations/v2.rs | 17 ++++-- .../pallet-tft-bridge/src/tft_bridge.rs | 6 +- .../pallets/pallet-tft-price/src/lib.rs | 20 ++----- .../pallets/pallet-tft-price/src/tft_price.rs | 11 ++-- .../pallets/pallet-validator/src/lib.rs | 12 +--- .../substrate-validator-set/src/lib.rs | 22 +++---- 18 files changed, 100 insertions(+), 161 deletions(-) diff --git a/substrate-node/pallets/pallet-burning/src/lib.rs b/substrate-node/pallets/pallet-burning/src/lib.rs index f957d94fc..2d63e18c4 100644 --- a/substrate-node/pallets/pallet-burning/src/lib.rs +++ b/substrate-node/pallets/pallet-burning/src/lib.rs @@ -51,7 +51,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - BurnTransactionCreated(T::AccountId, BalanceOf, T::BlockNumber, Vec), + BurnTransactionCreated(T::AccountId, BalanceOf, BlockNumberFor, Vec), } #[pallet::error] @@ -62,7 +62,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn burns)] pub type Burns = - StorageValue<_, Vec, T::BlockNumber>>, OptionQuery>; + StorageValue<_, Vec, BlockNumberFor>>, OptionQuery>; #[pallet::call] impl Pallet { diff --git a/substrate-node/pallets/pallet-dao/src/dao.rs b/substrate-node/pallets/pallet-dao/src/dao.rs index 569ee1303..2a04497c4 100644 --- a/substrate-node/pallets/pallet-dao/src/dao.rs +++ b/substrate-node/pallets/pallet-dao/src/dao.rs @@ -14,6 +14,7 @@ use frame_support::{ traits::Get, weights::Weight, }; +use frame_system::pallet_prelude::BlockNumberFor; use pallet_tfgrid::pallet::{InterfaceOf, LocationOf, SerialNumberOf, TfgridNode}; use sp_runtime::traits::{Dispatchable, Hash}; use sp_std::prelude::*; @@ -29,7 +30,7 @@ impl Pallet { action: Box<::Proposal>, description: Vec, link: Vec, - duration: Option, + duration: Option>, ) -> DispatchResultWithPostInfo { Self::is_council_member(who.clone())?; @@ -43,7 +44,7 @@ impl Pallet { let mut end = now + T::MotionDuration::get(); if let Some(motion_duration) = duration { ensure!( - motion_duration < T::BlockNumber::from(constants::time::DAYS * 30), + motion_duration < BlockNumberFor::::from(constants::time::DAYS * 30), Error::::InvalidProposalDuration ); end = now + motion_duration; diff --git a/substrate-node/pallets/pallet-dao/src/lib.rs b/substrate-node/pallets/pallet-dao/src/lib.rs index 622d3c618..e87a2a036 100644 --- a/substrate-node/pallets/pallet-dao/src/lib.rs +++ b/substrate-node/pallets/pallet-dao/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { + GetDispatchInfo; /// The time-out for council motions. - type MotionDuration: Get; + type MotionDuration: Get>; /// The minimum amount of vetos to dissaprove a proposal type MinVetos: Get; @@ -100,7 +100,7 @@ pub mod pallet { _, Identity, T::Hash, - proposal::DaoVotes, + proposal::DaoVotes, T::AccountId>, OptionQuery, >; @@ -189,7 +189,7 @@ pub mod pallet { action: Box<::Proposal>, description: Vec, link: Vec, - duration: Option, + duration: Option>, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; Self::_propose(who, threshold, action, description, link, duration) diff --git a/substrate-node/pallets/pallet-smart-contract/src/billing.rs b/substrate-node/pallets/pallet-smart-contract/src/billing.rs index 5e31716dc..8f5b8ff22 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/billing.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/billing.rs @@ -4,7 +4,10 @@ use frame_support::{ ensure, traits::{Currency, ExistenceRequirement, LockableCurrency, OnUnbalanced, WithdrawReasons}, }; -use frame_system::offchain::{SendSignedTransaction, SignMessage, Signer}; +use frame_system::{ + offchain::{SendSignedTransaction, SignMessage, Signer}, + pallet_prelude::BlockNumberFor, +}; use sp_core::Get; use sp_runtime::{ traits::{CheckedAdd, CheckedSub, Convert, Zero}, @@ -13,7 +16,7 @@ use sp_runtime::{ use sp_std::vec::Vec; impl Pallet { - pub fn bill_conttracts_for_block(block_number: T::BlockNumber) { + pub fn bill_conttracts_for_block(block_number: BlockNumberFor) { // Let offchain worker check if there are contracts on // billing loop at current index and try to bill them let index = Self::get_billing_loop_index_from_block_number(block_number); @@ -619,7 +622,7 @@ impl Pallet { // Billing index is block number % (mod) Billing Frequency // So index belongs to [0; billing_frequency - 1] range - pub fn get_billing_loop_index_from_block_number(block_number: T::BlockNumber) -> u64 { + pub fn get_billing_loop_index_from_block_number(block_number: BlockNumberFor) -> u64 { block_number.saturated_into::() % BillingFrequency::::get() } diff --git a/substrate-node/pallets/pallet-smart-contract/src/lib.rs b/substrate-node/pallets/pallet-smart-contract/src/lib.rs index 9b8fea12e..09726b04b 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/lib.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/lib.rs @@ -389,22 +389,14 @@ pub mod pallet { } #[pallet::genesis_config] - pub struct GenesisConfig { + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { pub billing_frequency: u64, - } - - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - billing_frequency: 600, - } - } + pub _data: PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { BillingFrequency::::put(self.billing_frequency); } @@ -670,7 +662,7 @@ pub mod pallet { weight_used } - fn offchain_worker(block_number: T::BlockNumber) { + fn offchain_worker(block_number: BlockNumberFor) { Self::bill_conttracts_for_block(block_number); } } diff --git a/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs b/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs index ba6c73d82..17e5800b6 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs @@ -497,7 +497,7 @@ benchmarks! { let nu = 10; let ipv4 = 8; let minimal_uptime = 9999; - let policy_end = T::BlockNumber::max_value(); + let policy_end = BlockNumberFor::max_value(); let immutable = true; let default = true; let node_certification = NodeCertification::Diy; @@ -680,7 +680,7 @@ benchmarks! { let power = Power::Down; }: _(RawOrigin::Signed(caller), power) verify { - let power_state = PowerState::Down(T::BlockNumber::from(1 as u32)); + let power_state = PowerState::Down(BlockNumberFor::from(1 as u32)); let node_power = TfgridModule::::node_power_state(node_id); assert_eq!(node_power.state, power_state); assert_last_event::(Event::PowerStateChanged { @@ -812,7 +812,7 @@ fn _create_farming_policy() { let nu = 10; let ipv4 = 8; let minimal_uptime = 9999; - let policy_end = T::BlockNumber::max_value(); + let policy_end = BlockNumberFor::max_value(); let immutable = true; let default = true; let node_certification = NodeCertification::Diy; diff --git a/substrate-node/pallets/pallet-tfgrid/src/farm.rs b/substrate-node/pallets/pallet-tfgrid/src/farm.rs index c92f85172..d4f72a9d6 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/farm.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/farm.rs @@ -6,6 +6,7 @@ use frame_support::{ traits::Get, BoundedVec, RuntimeDebug, }; +use frame_system::pallet_prelude::BlockNumberFor; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_std::{marker::PhantomData, vec, vec::Vec}; @@ -269,7 +270,7 @@ impl Pallet { let now = frame_system::Pallet::::block_number(); // Policy end is expressed in number of blocks - if farming_policy.policy_end != T::BlockNumber::from(0 as u32) + if farming_policy.policy_end != BlockNumberFor::::from(0 as u32) && now >= farming_policy.policy_created + farming_policy.policy_end { return Err(DispatchErrorWithPostInfo::from( diff --git a/substrate-node/pallets/pallet-tfgrid/src/lib.rs b/substrate-node/pallets/pallet-tfgrid/src/lib.rs index 0c17d14f9..2888d5e14 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/lib.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/lib.rs @@ -201,7 +201,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn farming_policies_map)] pub type FarmingPoliciesMap = - StorageMap<_, Blake2_128Concat, u32, types::FarmingPolicy, ValueQuery>; + StorageMap<_, Blake2_128Concat, u32, types::FarmingPolicy>, ValueQuery>; // Concrete type for location pub type TermsAndConditionsOf = ::TermsAndConditions; @@ -259,7 +259,7 @@ pub mod pallet { _, Blake2_128Concat, u32, - tfchain_support::types::NodePower, + tfchain_support::types::NodePower>, ValueQuery, >; @@ -412,14 +412,14 @@ pub mod pallet { PricingPolicyStored(types::PricingPolicy), // CertificationCodeStored(types::CertificationCodes), - FarmingPolicyStored(types::FarmingPolicy), + FarmingPolicyStored(types::FarmingPolicy>), FarmPayoutV2AddressRegistered(u32, Vec), FarmMarkedAsDedicated(u32), ConnectionPriceSet(u32), NodeCertificationSet(u32, NodeCertification), NodeCertifierAdded(T::AccountId), NodeCertifierRemoved(T::AccountId), - FarmingPolicyUpdated(types::FarmingPolicy), + FarmingPolicyUpdated(types::FarmingPolicy>), FarmingPolicySet(u32, Option), FarmCertificationSet(u32, FarmCertification), @@ -434,7 +434,7 @@ pub mod pallet { PowerStateChanged { farm_id: u32, node_id: u32, - power_state: PowerState, + power_state: PowerState>, }, } @@ -572,6 +572,7 @@ pub mod pallet { } #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub su_price_value: u32, pub su_price_unit: u32, @@ -599,41 +600,8 @@ pub mod pallet { pub connection_price: u32, } - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - su_price_value: Default::default(), - su_price_unit: Default::default(), - nu_price_value: Default::default(), - nu_price_unit: Default::default(), - ipu_price_value: Default::default(), - ipu_price_unit: Default::default(), - cu_price_value: Default::default(), - cu_price_unit: Default::default(), - domain_name_price_value: Default::default(), - unique_name_price_value: Default::default(), - foundation_account: None, - sales_account: None, - discount_for_dedication_nodes: Default::default(), - farming_policy_diy_cu: Default::default(), - farming_policy_diy_nu: Default::default(), - farming_policy_diy_su: Default::default(), - farming_policy_diy_ipu: Default::default(), - farming_policy_diy_minimal_uptime: Default::default(), - farming_policy_certified_cu: Default::default(), - farming_policy_certified_nu: Default::default(), - farming_policy_certified_su: Default::default(), - farming_policy_certified_ipu: Default::default(), - farming_policy_certified_minimal_uptime: Default::default(), - connection_price: Default::default(), - } - } - } - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { let su = types::Policy { value: self.su_price_value, @@ -701,8 +669,8 @@ pub mod pallet { nu: self.farming_policy_diy_nu, ipv4: self.farming_policy_diy_ipu, minimal_uptime: self.farming_policy_diy_minimal_uptime, - policy_created: T::BlockNumber::from(0 as u32), - policy_end: T::BlockNumber::from(0 as u32), + policy_created: BlockNumberFor::::from(0 as u32), + policy_end: BlockNumberFor::::from(0 as u32), immutable: false, default: true, node_certification: NodeCertification::Diy, @@ -723,8 +691,8 @@ pub mod pallet { nu: self.farming_policy_certified_nu, ipv4: self.farming_policy_certified_ipu, minimal_uptime: self.farming_policy_certified_minimal_uptime, - policy_created: T::BlockNumber::from(0 as u32), - policy_end: T::BlockNumber::from(0 as u32), + policy_created: BlockNumberFor::::from(0 as u32), + policy_end: BlockNumberFor::::from(0 as u32), immutable: false, default: true, node_certification: NodeCertification::Certified, @@ -1069,7 +1037,7 @@ pub mod pallet { nu: u32, ipv4: u32, minimal_uptime: u16, - policy_end: T::BlockNumber, + policy_end: BlockNumberFor, immutable: bool, default: bool, node_certification: NodeCertification, @@ -1172,7 +1140,7 @@ pub mod pallet { nu: u32, ipv4: u32, minimal_uptime: u16, - policy_end: T::BlockNumber, + policy_end: BlockNumberFor, default: bool, node_certification: NodeCertification, farm_certification: FarmCertification, @@ -1266,4 +1234,4 @@ pub mod pallet { // #[pallet::call_index(39)] // #[pallet::weight(::WeightInfo::set_node_gpu_status())] } -} \ No newline at end of file +} diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs index 967c9ce73..68dd5c6ba 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs @@ -1,5 +1,6 @@ use crate::{types::FarmingPolicy, *}; use frame_support::{traits::Get, traits::OnRuntimeUpgrade, weights::Weight}; +use frame_system::pallet_prelude::BlockNumberFor; use log::{debug, info}; use sp_std::marker::PhantomData; @@ -69,7 +70,7 @@ pub fn fix_farming_policies_map_migration_() -> frame_support::weight info!(" >>> Migrating farming policies storage..."); let mut read_writes = 0; - FarmingPoliciesMap::::translate::, _>(|k, fp| { + FarmingPoliciesMap::::translate::>, _>(|k, fp| { debug!("Farming policy #{:?}: start migrating", k); debug!(" id was: {:?}", fp.id); let mut new_farming_policy = fp.clone(); diff --git a/substrate-node/pallets/pallet-tfgrid/src/pricing.rs b/substrate-node/pallets/pallet-tfgrid/src/pricing.rs index eb00645eb..9441bbcaf 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/pricing.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/pricing.rs @@ -4,6 +4,7 @@ use frame_support::{ ensure, sp_runtime::SaturatedConversion, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_std::vec::Vec; use tfchain_support::types::{FarmCertification, NodeCertification}; @@ -108,7 +109,7 @@ impl Pallet { nu: u32, ipv4: u32, minimal_uptime: u16, - policy_end: T::BlockNumber, + policy_end: BlockNumberFor, immutable: bool, default: bool, node_certification: NodeCertification, @@ -152,7 +153,7 @@ impl Pallet { nu: u32, ipv4: u32, minimal_uptime: u16, - policy_end: T::BlockNumber, + policy_end: BlockNumberFor, default: bool, node_certification: NodeCertification, farm_certification: FarmCertification, @@ -190,7 +191,7 @@ impl Pallet { pub fn get_farming_policy( node: &TfgridNode, - ) -> Result, DispatchErrorWithPostInfo> { + ) -> Result>, DispatchErrorWithPostInfo> { let mut farm = Farms::::get(node.farm_id).ok_or(Error::::FarmNotExists)?; // If there is a farming policy defined on the @@ -260,7 +261,7 @@ impl Pallet { // policy which certifications best fit the current // node and farm certifications, considering that in all // cases a default policy would be preferable - let mut policies: Vec> = + let mut policies: Vec>> = FarmingPoliciesMap::::iter().map(|p| p.1).collect(); policies.sort(); @@ -290,8 +291,8 @@ impl Pallet { // Set the default farming policy as the last best certified // farming policy amoung all the default farming policies fn get_default_farming_policy( - ) -> Result, DispatchErrorWithPostInfo> { - let mut policies: Vec> = + ) -> Result>, DispatchErrorWithPostInfo> { + let mut policies: Vec>> = FarmingPoliciesMap::::iter().map(|p| p.1).collect(); policies.sort(); diff --git a/substrate-node/pallets/pallet-tft-bridge/src/lib.rs b/substrate-node/pallets/pallet-tft-bridge/src/lib.rs index 410c5d0a8..077928233 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/lib.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/lib.rs @@ -61,7 +61,7 @@ pub mod pallet { _, Blake2_128Concat, Vec, - MintTransaction, + MintTransaction>, OptionQuery, >; @@ -71,7 +71,7 @@ pub mod pallet { _, Blake2_128Concat, Vec, - MintTransaction, + MintTransaction>, OptionQuery, >; @@ -81,7 +81,7 @@ pub mod pallet { _, Blake2_128Concat, u64, - BurnTransaction, + BurnTransaction>, OptionQuery, >; @@ -91,19 +91,19 @@ pub mod pallet { _, Blake2_128Concat, u64, - BurnTransaction, + BurnTransaction>, OptionQuery, >; #[pallet::storage] #[pallet::getter(fn refund_transactions)] pub type RefundTransactions = - StorageMap<_, Blake2_128Concat, Vec, RefundTransaction, ValueQuery>; + StorageMap<_, Blake2_128Concat, Vec, RefundTransaction>, ValueQuery>; #[pallet::storage] #[pallet::getter(fn executed_refund_transactions)] pub type ExecutedRefundTransactions = - StorageMap<_, Blake2_128Concat, Vec, RefundTransaction, ValueQuery>; + StorageMap<_, Blake2_128Concat, Vec, RefundTransaction>, ValueQuery>; #[pallet::storage] #[pallet::getter(fn burn_transaction_id)] @@ -147,20 +147,20 @@ pub mod pallet { // Minting events MintTransactionProposed(Vec, T::AccountId, u64), MintTransactionVoted(Vec), - MintCompleted(MintTransaction), + MintCompleted(MintTransaction>), MintTransactionExpired(Vec, u64, T::AccountId), // Burn events BurnTransactionCreated(u64, T::AccountId, Vec, u64), BurnTransactionProposed(u64, Vec, u64), BurnTransactionSignatureAdded(u64, StellarSignature), BurnTransactionReady(u64), - BurnTransactionProcessed(BurnTransaction), + BurnTransactionProcessed(BurnTransaction>), BurnTransactionExpired(u64, Option, Vec, u64), // Refund events RefundTransactionCreated(Vec, Vec, u64), RefundTransactionsignatureAdded(Vec, StellarSignature), RefundTransactionReady(Vec), - RefundTransactionProcessed(RefundTransaction), + RefundTransactionProcessed(RefundTransaction>), RefundTransactionExpired(Vec, Vec, u64), } @@ -190,6 +190,7 @@ pub mod pallet { } #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub validator_accounts: Option>, pub fee_account: Option, @@ -197,21 +198,8 @@ pub mod pallet { pub deposit_fee: u64, } - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - validator_accounts: None, - fee_account: None, - withdraw_fee: Default::default(), - deposit_fee: Default::default(), - } - } - } - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { if let Some(validator_accounts) = &self.validator_accounts { Validators::::put(validator_accounts); @@ -227,7 +215,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(block: T::BlockNumber) { + fn on_finalize(block: BlockNumberFor) { let current_block_u64: u64 = block.saturated_into::(); for (tx_id, mut tx) in BurnTransactions::::iter() { diff --git a/substrate-node/pallets/pallet-tft-bridge/src/migrations/types.rs b/substrate-node/pallets/pallet-tft-bridge/src/migrations/types.rs index ad24ae41b..11ae84552 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/migrations/types.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/migrations/types.rs @@ -1,5 +1,6 @@ pub mod v1 { use frame_support::{pallet_prelude::ValueQuery, storage_alias, Blake2_128Concat}; + use frame_system::pallet_prelude::BlockNumberFor; use parity_scale_codec::{Decode, Encode}; use scale_info::{prelude::vec::Vec, TypeInfo}; @@ -19,7 +20,7 @@ pub mod v1 { Pallet, Blake2_128Concat, u64, - BurnTransaction<::BlockNumber>, + BurnTransaction>, ValueQuery, >; @@ -28,13 +29,14 @@ pub mod v1 { Pallet, Blake2_128Concat, u64, - BurnTransaction<::BlockNumber>, + BurnTransaction>, ValueQuery, >; } pub mod v2 { use frame_support::{pallet_prelude::OptionQuery, storage_alias, Blake2_128Concat}; + use frame_system::pallet_prelude::BlockNumberFor; use parity_scale_codec::{Decode, Encode}; use scale_info::{prelude::vec::Vec, TypeInfo}; @@ -55,7 +57,7 @@ pub mod v2 { Pallet, Blake2_128Concat, u64, - BurnTransaction<::AccountId, ::BlockNumber>, + BurnTransaction<::AccountId, BlockNumberFor>, OptionQuery, >; @@ -64,7 +66,7 @@ pub mod v2 { Pallet, Blake2_128Concat, u64, - BurnTransaction<::AccountId, ::BlockNumber>, + BurnTransaction<::AccountId, BlockNumberFor>, OptionQuery, >; } diff --git a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs index 53075edd9..28cd2598c 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs @@ -1,6 +1,11 @@ use crate::*; -use frame_support::log::{debug, info}; -use frame_support::{traits::Get, traits::OnRuntimeUpgrade, weights::Weight}; +use frame_support::{ + log::{debug, info}, + traits::Get, + traits::OnRuntimeUpgrade, + weights::Weight, +}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] @@ -80,13 +85,13 @@ pub fn migrate_burn_transactions() -> frame_support::weights::Weight let mut read_writes = 0; migrations::types::v2::BurnTransactions::::translate::< - super::types::v1::BurnTransaction, + super::types::v1::BurnTransaction>, _, >(|k, burn_transaction| { debug!("migrated burn transaction: {:?}", k); let new_burn_transaction = - migrations::types::v2::BurnTransaction:: { + migrations::types::v2::BurnTransaction::> { block: burn_transaction.block, amount: burn_transaction.amount, source: None, @@ -100,13 +105,13 @@ pub fn migrate_burn_transactions() -> frame_support::weights::Weight }); migrations::types::v2::ExecutedBurnTransactions::::translate::< - super::types::v1::BurnTransaction, + super::types::v1::BurnTransaction>, _, >(|k, executed_burn_transaction| { debug!("migrated executed burn transaction: {:?}", k); let new_executed_burn_transaction = - migrations::types::v2::BurnTransaction:: { + migrations::types::v2::BurnTransaction::> { block: executed_burn_transaction.block, amount: executed_burn_transaction.amount, source: None, diff --git a/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs b/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs index 5b74b3a49..775f27832 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs @@ -5,7 +5,7 @@ use frame_support::{ pallet_prelude::DispatchResultWithPostInfo, traits::{Currency, ExistenceRequirement, OnUnbalanced, WithdrawReasons}, }; -use frame_system as system; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::SaturatedConversion; use sp_std::prelude::*; use substrate_stellar_sdk as stellar; @@ -13,7 +13,7 @@ use substrate_stellar_sdk as stellar; impl Pallet { pub fn mint_tft( tx_id: Vec, - mut tx: MintTransaction, + mut tx: MintTransaction>, ) -> DispatchResultWithPostInfo { let deposit_fee = DepositFee::::get(); ensure!( @@ -37,7 +37,7 @@ impl Pallet { // Remove tx from storage MintTransactions::::remove(tx_id.clone()); // Insert into executed transactions - let now = >::block_number(); + let now = >::block_number(); tx.block = now; ExecutedMintTransactions::::insert(tx_id, &tx); diff --git a/substrate-node/pallets/pallet-tft-price/src/lib.rs b/substrate-node/pallets/pallet-tft-price/src/lib.rs index f07904c54..9357886ed 100644 --- a/substrate-node/pallets/pallet-tft-price/src/lib.rs +++ b/substrate-node/pallets/pallet-tft-price/src/lib.rs @@ -112,7 +112,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn last_block_set)] - pub type LastBlockSet = StorageValue<_, T::BlockNumber, ValueQuery>; + pub type LastBlockSet = StorageValue<_, BlockNumberFor, ValueQuery>; #[pallet::storage] #[pallet::getter(fn average_tft_price)] @@ -141,7 +141,7 @@ pub mod pallet { pub fn set_prices( origin: OriginFor, price: u32, - block_number: T::BlockNumber, + block_number: BlockNumberFor, ) -> DispatchResultWithPostInfo { let address = ensure_signed(origin)?; @@ -180,7 +180,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn offchain_worker(block_number: T::BlockNumber) { + fn offchain_worker(block_number: BlockNumberFor) { match Self::offchain_signed_tx(block_number) { Ok(_) => log::info!("offchain worker done."), Err(err) => log::error!("{:?}", err), @@ -189,25 +189,15 @@ pub mod pallet { } #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub min_tft_price: u32, pub max_tft_price: u32, pub _data: PhantomData, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - min_tft_price: 10, - max_tft_price: 1000, - _data: PhantomData, - } - } - } - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { MinTftPrice::::put(self.min_tft_price); MaxTftPrice::::put(self.max_tft_price); diff --git a/substrate-node/pallets/pallet-tft-price/src/tft_price.rs b/substrate-node/pallets/pallet-tft-price/src/tft_price.rs index a5609f466..9e9f0e6b0 100644 --- a/substrate-node/pallets/pallet-tft-price/src/tft_price.rs +++ b/substrate-node/pallets/pallet-tft-price/src/tft_price.rs @@ -1,6 +1,9 @@ use super::*; use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::Pays}; -use frame_system::offchain::{SendSignedTransaction, SignMessage, Signer}; +use frame_system::{ + offchain::{SendSignedTransaction, SignMessage, Signer}, + pallet_prelude::BlockNumberFor, +}; use ringbuffer::{RingBufferTrait, RingBufferTransient}; use scale_info::prelude::format; use serde_json::Value; @@ -24,7 +27,7 @@ pub const DST_AMOUNT: u32 = 100; impl Pallet { pub(crate) fn calculate_and_set_price( price: u32, - block_number: T::BlockNumber, + block_number: BlockNumberFor, ) -> DispatchResultWithPostInfo { log::info!("price {:?}", price); @@ -111,7 +114,7 @@ impl Pallet { Ok(tft_usd) } - pub(crate) fn offchain_signed_tx(block_number: T::BlockNumber) -> Result<(), Error> { + pub(crate) fn offchain_signed_tx(block_number: BlockNumberFor) -> Result<(), Error> { let signer = Signer::::AuthorityId>::any_account(); // Only allow the author of the next block to trigger price fetching @@ -120,7 +123,7 @@ impl Pallet { Err(_) => return Ok(()), } - let last_block_set: T::BlockNumber = LastBlockSet::::get(); + let last_block_set: BlockNumberFor = LastBlockSet::::get(); // Fetch the price every 1 minutes if block_number.saturated_into::() - last_block_set.saturated_into::() < 10 { return Ok(()); diff --git a/substrate-node/pallets/pallet-validator/src/lib.rs b/substrate-node/pallets/pallet-validator/src/lib.rs index 1d71586ca..e8263a172 100644 --- a/substrate-node/pallets/pallet-validator/src/lib.rs +++ b/substrate-node/pallets/pallet-validator/src/lib.rs @@ -93,21 +93,13 @@ pub mod pallet { impl Hooks> for Pallet {} #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub validators: Vec, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - validators: Vec::new(), - } - } - } - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) {} } diff --git a/substrate-node/pallets/substrate-validator-set/src/lib.rs b/substrate-node/pallets/substrate-validator-set/src/lib.rs index 73547359d..31c94b3e9 100644 --- a/substrate-node/pallets/substrate-validator-set/src/lib.rs +++ b/substrate-node/pallets/substrate-validator-set/src/lib.rs @@ -102,21 +102,13 @@ pub mod pallet { impl Hooks> for Pallet {} #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub initial_validators: Vec, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - initial_validators: Default::default(), - } - } - } - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Pallet::::initialize_validators(&self.initial_validators); } @@ -206,20 +198,20 @@ pub mod pallet { fn start_session(_start_index: u32) {} } - impl EstimateNextSessionRotation for Pallet { - fn average_session_length() -> T::BlockNumber { + impl EstimateNextSessionRotation> for Pallet { + fn average_session_length() -> BlockNumberFor { Zero::zero() } fn estimate_current_session_progress( - _now: T::BlockNumber, + _now: BlockNumberFor, ) -> (Option, frame_support::dispatch::Weight) { (None, Zero::zero()) } fn estimate_next_session_rotation( - _now: T::BlockNumber, - ) -> (Option, frame_support::dispatch::Weight) { + _now: BlockNumberFor, + ) -> (Option>, frame_support::dispatch::Weight) { (None, Zero::zero()) } } From c8439313daab6774110c45728a78fd677a744b03 Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 23:14:13 -0300 Subject: [PATCH 16/31] update pallets mock --- .../pallets/pallet-burning/src/mock.rs | 30 +++++------ substrate-node/pallets/pallet-dao/src/mock.rs | 28 ++++------ .../pallets/pallet-kvstore/README.md | 52 +++++++++++-------- .../pallets/pallet-kvstore/src/tests.rs | 27 ++++------ .../pallets/pallet-smart-contract/src/mock.rs | 33 +++++------- .../pallets/pallet-tfgrid/src/mock.rs | 35 +++++-------- .../pallets/pallet-tft-bridge/src/mock.rs | 29 +++++------ .../pallets/pallet-tft-price/src/mock.rs | 29 +++++------ .../pallets/pallet-validator/src/mock.rs | 31 +++++------ .../pallets/substrate-validator-set/readme.md | 29 +++++------ .../substrate-validator-set/src/mock.rs | 31 +++++------ 11 files changed, 156 insertions(+), 198 deletions(-) diff --git a/substrate-node/pallets/pallet-burning/src/mock.rs b/substrate-node/pallets/pallet-burning/src/mock.rs index a8701a91e..24a7faac0 100644 --- a/substrate-node/pallets/pallet-burning/src/mock.rs +++ b/substrate-node/pallets/pallet-burning/src/mock.rs @@ -6,10 +6,9 @@ use frame_support::{construct_runtime, parameter_types, traits::ConstU32}; use pallet_balances; use sp_core::{sr25519, Pair, Public, H256}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, traits::{IdentifyAccount, Verify}, - MultiSignature, + BuildStorage, MultiSignature, }; use sp_std::convert::{TryFrom, TryInto}; @@ -17,16 +16,12 @@ pub type Signature = MultiSignature; pub type AccountId = <::Signer as IdentifyAccount>::AccountId; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, BurningModule: pallet_burning::{Pallet, Call, Event}, } @@ -38,25 +33,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = AccountId; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = pallet_balances::AccountData; type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -83,7 +77,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -121,8 +115,8 @@ pub fn bob() -> AccountId { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let genesis = pallet_balances::GenesisConfig:: { balances: vec![(alice(), 1000000000000), (bob(), 2500000000)], diff --git a/substrate-node/pallets/pallet-dao/src/mock.rs b/substrate-node/pallets/pallet-dao/src/mock.rs index e15828f0a..3044ba6be 100644 --- a/substrate-node/pallets/pallet-dao/src/mock.rs +++ b/substrate-node/pallets/pallet-dao/src/mock.rs @@ -1,4 +1,3 @@ -use crate::mock::sp_api_hidden_includes_construct_runtime::hidden_include::traits::GenesisBuild; use crate::{self as pallet_dao}; use frame_support::{construct_runtime, parameter_types, traits::ConstU32, BoundedVec}; use frame_system::EnsureRoot; @@ -14,24 +13,20 @@ use pallet_tfgrid::{ use pallet_timestamp; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use sp_std::convert::{TryFrom, TryInto}; use tfchain_support::traits::{ChangeNode, PublicIpModifier}; use tfchain_support::types::PublicIP; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, DaoModule: pallet_dao::pallet::{Pallet, Call, Storage, Event}, TfgridModule: pallet_tfgrid::{Pallet, Call, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, @@ -46,25 +41,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = (); type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -235,8 +229,8 @@ pub(crate) fn get_longitude_input(longitude_input: &[u8]) -> LongitudeInput { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let genesis = pallet_collective::GenesisConfig::::default(); diff --git a/substrate-node/pallets/pallet-kvstore/README.md b/substrate-node/pallets/pallet-kvstore/README.md index 6710d114c..47fcd9d51 100644 --- a/substrate-node/pallets/pallet-kvstore/README.md +++ b/substrate-node/pallets/pallet-kvstore/README.md @@ -7,9 +7,10 @@ Some use cases for this module are storing user profiles, preferences, or settin ## Overview The Key-value Store Pallet provides [dictionary-like data storage](https://paritytech.github.io/substrate/master/frame_support/storage/trait.StorageDoubleMap.html#) and functions for: -- Storing key-value pairs. -- Retrieving the value associated with the specified key. -- Removing a value associated with the specified key. + +* Storing key-value pairs. +* Retrieving the value associated with the specified key. +* Removing a value associated with the specified key. The key value store uses under hood a map with two keys @@ -17,36 +18,42 @@ The key value store uses under hood a map with two keys **Key1** is provided by the runtime set to the account that signed the extrinsic. **Key2** and **Value** are user provided -You can think of the key1 as namespace that make it easier to come up with unique names which distinguished from other accounts' names. +You can think of the key1 as namespace that make it easier to come up with unique names which distinguished from other accounts' names. The key value store pallet impose restrictions on the size of the keys and values. see [Assumptions](#assumptions) section. ## Terminology -- Key-value store: A key-value store, or key-value database is a simple database that uses an associative array (think of a map or dictionary) as the fundamental data model where each key is associated with one and only one value in a collection. This relationship is referred to as a key-value pair. + +* Key-value store: A key-value store, or key-value database is a simple database that uses an associative array (think of a map or dictionary) as the fundamental data model where each key is associated with one and only one value in a collection. This relationship is referred to as a key-value pair. ## Implementations + NA ## Interface + ### Dispatchable Functions -- `set(key: Vec, value: Vec)` store value for a pair of keys (key1, key2) in the store. The first key is automatically set to the account ID of the signer of the transaction, while the second key is given by the user. This way, you can assign ownership of a key to the account that created it, and also use freely any name for a key that might be already taken by someone else. If the key pair already exists in the store, the value is overwritten with the new one. Emits `EntrySet` event. -- `delete(key: Vec)` remove a value stored under a pair of keys (key1, key2) from the store. The first key is automatically set to the account ID of the sender of the transaction, while the second key is given by the user. so by design, only the owner of a key pair can delete it from the store. Emits `EntryTaken` event. +* `set(key: Vec, value: Vec)` store value for a pair of keys (key1, key2) in the store. The first key is automatically set to the account ID of the signer of the transaction, while the second key is given by the user. This way, you can assign ownership of a key to the account that created it, and also use freely any name for a key that might be already taken by someone else. If the key pair already exists in the store, the value is overwritten with the new one. Emits `EntrySet` event. +* `delete(key: Vec)` remove a value stored under a pair of keys (key1, key2) from the store. The first key is automatically set to the account ID of the sender of the transaction, while the second key is given by the user. so by design, only the owner of a key pair can delete it from the store. Emits `EntryTaken` event. ### Events -- `EntrySet(T::AccountId, Vec, Vec)` The value for the specified key has been stored/updated. -- `EntryGot(T::AccountId, Vec, Vec)` The value for the specified key has been queried. (This Event Defined But Not Used By the runtime) -- `EntryTaken(T::AccountId, Vec, Vec)` The value stored under the specified key has been removed. + +* `EntrySet(T::AccountId, Vec, Vec)` The value for the specified key has been stored/updated. +* `EntryGot(T::AccountId, Vec, Vec)` The value for the specified key has been queried. (This Event Defined But Not Used By the runtime) +* `EntryTaken(T::AccountId, Vec, Vec)` The value stored under the specified key has been removed. All events included account id, the user key name and the value. ### Errors -- `NoValueStored` The double key (Account ID, Provided Key) is not in the `StorageDoubleMap` -- `KeyIsTooLarge` The key length exceed the maximum length. see [Assumptions](#assumptions) section. -- `ValueIsTooLarge` The key length exceed the maximum length. see [Assumptions](#assumptions) section. + +* `NoValueStored` The double key (Account ID, Provided Key) is not in the `StorageDoubleMap` +* `KeyIsTooLarge` The key length exceed the maximum length. see [Assumptions](#assumptions) section. +* `ValueIsTooLarge` The key length exceed the maximum length. see [Assumptions](#assumptions) section. ## Config + ```rust pub trait Config: Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -59,6 +66,7 @@ The main purpose of this trait is to act as an interface between this pallet and Consequently, a runtime that wants to include this pallet must implement this trait. ### Required Associated Types + ```rust type RuntimeEvent: From> + IsType<::RuntimeEvent> ``` @@ -72,17 +80,16 @@ type WeightInfo: WeightInfo Weight information for extrinsics in this pallet. ## Usage + The following example shows how to use the key value store pallet in your runtime: + ```rust // Import the key value store pallet pub use pallet_kvstore; // Add it to your runtime configuration construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // ... KeyValueStore: pallet_kvstore::{Pallet, Call, Storage, Event}, @@ -95,11 +102,14 @@ impl pallet_kvstore::Config for Runtime { type WeightInfo = pallet_kvstore::weights::SubstrateWeight; } ``` + ## Genesis config + NA ## Assumptions -- The key length must not exceed 512 bytes. -- The value length must not exceed 2048 bytes. -- The user is responsible for ensuring the uniqueness of the key within their account, otherwise the previous value associated with the key will be replaced or updated. -- The stored information is publicly accessible and queryable. This means that anyone can see your data without your permission. The user must not store any sensitive information unencrypted, such as personal details, passwords, credit card numbers, or confidential information. Doing so can have serious consequences. Please use encryption tools to protect your sensitive data before storing it on this store. + +* The key length must not exceed 512 bytes. +* The value length must not exceed 2048 bytes. +* The user is responsible for ensuring the uniqueness of the key within their account, otherwise the previous value associated with the key will be replaced or updated. +* The stored information is publicly accessible and queryable. This means that anyone can see your data without your permission. The user must not store any sensitive information unencrypted, such as personal details, passwords, credit card numbers, or confidential information. Doing so can have serious consequences. Please use encryption tools to protect your sensitive data before storing it on this store. diff --git a/substrate-node/pallets/pallet-kvstore/src/tests.rs b/substrate-node/pallets/pallet-kvstore/src/tests.rs index 8f12d1e95..461060f1a 100644 --- a/substrate-node/pallets/pallet-kvstore/src/tests.rs +++ b/substrate-node/pallets/pallet-kvstore/src/tests.rs @@ -6,21 +6,17 @@ use frame_system::{EventRecord, Phase}; use sp_core::H256; use sp_io::TestExternalities; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use sp_std::convert::{TryFrom, TryInto}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, TFKVStoreModule: pallet_kvstore::{Pallet, Call, Storage, Event}, } ); @@ -31,25 +27,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = (); type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -66,8 +61,8 @@ pub struct ExternalityBuilder; impl ExternalityBuilder { pub fn build() -> TestExternalities { - let storage = frame_system::GenesisConfig::default() - .build_storage::() + let storage = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let mut ext = TestExternalities::from(storage); ext.execute_with(|| System::set_block_number(1)); diff --git a/substrate-node/pallets/pallet-smart-contract/src/mock.rs b/substrate-node/pallets/pallet-smart-contract/src/mock.rs index a79e65af6..cc765f286 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/mock.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/mock.rs @@ -6,7 +6,7 @@ use frame_support::{ dispatch::DispatchErrorWithPostInfo, dispatch::PostDispatchInfo, parameter_types, - traits::{ConstU32, EitherOfDiverse, GenesisBuild}, + traits::{ConstU32, EitherOfDiverse}, BoundedVec, }; use frame_system::EnsureRoot; @@ -33,11 +33,11 @@ use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use sp_runtime::{ impl_opaque_keys, offchain::TransactionPool, - testing::{Header, TestXt, UintAuthorityId}, + testing::{TestXt, UintAuthorityId}, traits::{ BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, OpaqueKeys, Verify, }, - AccountId32, MultiSignature, + AccountId32, BuildStorage, MultiSignature, }; use sp_std::{ convert::{TryFrom, TryInto}, @@ -96,16 +96,12 @@ pub type AccountId = <::Signer as IdentifyAccount>::Account pub type Moment = u64; pub type Extrinsic = TestXt; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, TfgridModule: pallet_tfgrid::{Pallet, Call, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, @@ -125,25 +121,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = AccountId; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = pallet_balances::AccountData; type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -172,7 +167,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -512,8 +507,8 @@ pub fn new_test_ext() -> sp_io::TestExternalities { // for showing logs in tests let _ = env_logger::try_init(); - let mut storage = frame_system::GenesisConfig::default() - .build_storage::() + let mut storage = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let genesis = pallet_balances::GenesisConfig:: { balances: vec![ diff --git a/substrate-node/pallets/pallet-tfgrid/src/mock.rs b/substrate-node/pallets/pallet-tfgrid/src/mock.rs index e7c8d6d4d..5b636a10d 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/mock.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/mock.rs @@ -2,7 +2,6 @@ use crate::{ self as tfgridModule, farm::FarmName, interface::{InterfaceIp, InterfaceMac, InterfaceName}, - mock::sp_api_hidden_includes_construct_runtime::hidden_include::traits::GenesisBuild, node::{CityName, CountryName, Location, SerialNumber}, terms_cond::TermsAndConditions, weights, CityNameInput, Config, CountryNameInput, DocumentHashInput, DocumentLinkInput, @@ -15,9 +14,8 @@ use frame_system::EnsureRoot; use sp_core::{ed25519, sr25519, Pair, Public, H256}; use sp_io::TestExternalities; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, - MultiSignature, + BuildStorage, MultiSignature, }; use sp_std::prelude::*; @@ -29,17 +27,13 @@ pub type Signature = MultiSignature; pub type AccountId = <::Signer as IdentifyAccount>::AccountId; pub type Moment = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, TfgridModule: tfgridModule::{Pallet, Call, Storage, Config, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Council: pallet_collective::::{Pallet, Call, Origin, Event, Config}, @@ -54,25 +48,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = AccountId; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = pallet_balances::AccountData; type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -158,7 +151,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -208,8 +201,8 @@ impl ExternalityBuilder { pub fn build() -> TestExternalities { let _ = env_logger::try_init(); - let storage = frame_system::GenesisConfig::default() - .build_storage::() + let storage = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let mut ext = TestExternalities::from(storage); ext.execute_with(|| System::set_block_number(1)); @@ -221,8 +214,8 @@ type AccountPublic = ::Signer; pub fn new_test_ext() -> sp_io::TestExternalities { let _ = env_logger::try_init(); - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let genesis = pallet_balances::GenesisConfig:: { diff --git a/substrate-node/pallets/pallet-tft-bridge/src/mock.rs b/substrate-node/pallets/pallet-tft-bridge/src/mock.rs index 106df1d76..0f3c32605 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/mock.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/mock.rs @@ -8,8 +8,8 @@ use sp_core::{sr25519, Pair, Public, H256}; use sp_runtime::traits::{IdentifyAccount, Verify}; use sp_runtime::MultiSignature; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use pallet_balances; @@ -18,16 +18,12 @@ pub type Signature = MultiSignature; pub type AccountId = <::Signer as IdentifyAccount>::AccountId; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, TFTBridgeModule: pallet_tft_bridge::{Pallet, Storage, Call, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, } @@ -42,25 +38,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = AccountId; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = pallet_balances::AccountData; type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -86,7 +81,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -138,8 +133,8 @@ pub fn eve() -> AccountId { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let genesis = pallet_balances::GenesisConfig:: { balances: vec![(alice(), 1000000000000), (bob(), 2500000000)], diff --git a/substrate-node/pallets/pallet-tft-price/src/mock.rs b/substrate-node/pallets/pallet-tft-price/src/mock.rs index d089ad626..2fe51e333 100644 --- a/substrate-node/pallets/pallet-tft-price/src/mock.rs +++ b/substrate-node/pallets/pallet-tft-price/src/mock.rs @@ -2,7 +2,6 @@ use super::*; use crate::{self as pallet_tft_price, tft_price::KEY_TYPE}; -use frame_support::traits::GenesisBuild; use frame_support::{construct_runtime, parameter_types, traits::ConstU32}; use frame_system::mocking; use frame_system::EnsureRoot; @@ -17,11 +16,11 @@ use sp_io::TestExternalities; use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use sp_runtime::{ impl_opaque_keys, - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{ BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, OpaqueKeys, Verify, }, - MultiSignature, + BuildStorage, MultiSignature, }; use sp_std::marker::PhantomData; use std::cell::RefCell; @@ -71,12 +70,9 @@ impl OpaqueKeys for PreUpgradeMockSessionKeys { // For testing the module, we construct a mock runtime. construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, TFTPriceModule: pallet_tft_price::{Pallet, Call, Storage, Config, Event}, Authorship: pallet_authorship::{Pallet, Storage}, ValidatorSet: substrate_validator_set::{Event}, @@ -90,25 +86,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = AccountId; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = (); type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -274,8 +269,8 @@ impl ExternalityBuilder { .sr25519_generate_new(KEY_TYPE, Some(&format!("{}/hunter1", PHRASE))) .unwrap(); - let mut storage = frame_system::GenesisConfig::default() - .build_storage::() + let mut storage = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let session_genesis = pallet_session::GenesisConfig:: { diff --git a/substrate-node/pallets/pallet-validator/src/mock.rs b/substrate-node/pallets/pallet-validator/src/mock.rs index 137208f5e..b89849f8b 100644 --- a/substrate-node/pallets/pallet-validator/src/mock.rs +++ b/substrate-node/pallets/pallet-validator/src/mock.rs @@ -1,27 +1,23 @@ use crate as pallet_validator; use core::cell::RefCell; -use frame_support::{bounded_vec, construct_runtime, parameter_types, traits::{ConstU32, GenesisBuild}}; +use frame_support::{bounded_vec, construct_runtime, parameter_types, traits::ConstU32}; use frame_system::EnsureRoot; use pallet_session::{SessionHandler, ShouldEndSession}; use sp_core::{crypto::key_types::DUMMY, H256}; use sp_runtime::{ impl_opaque_keys, - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{BlakeTwo256, IdentityLookup, OpaqueKeys}, - RuntimeAppPublic, + BuildStorage, RuntimeAppPublic, }; use sp_std::convert::{TryFrom, TryInto}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, ValidatorModule: pallet_validator::{Pallet, Call, Storage, Event}, Council: pallet_collective::::{Pallet, Call, Origin, Event, Config}, @@ -44,25 +40,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = (); type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -181,8 +176,8 @@ impl pallet_membership::Config for TestRuntime { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let genesis = pallet_collective::GenesisConfig::::default(); diff --git a/substrate-node/pallets/substrate-validator-set/readme.md b/substrate-node/pallets/substrate-validator-set/readme.md index 3780c09a7..e1eb2ca35 100644 --- a/substrate-node/pallets/substrate-validator-set/readme.md +++ b/substrate-node/pallets/substrate-validator-set/readme.md @@ -4,7 +4,7 @@ Code changes are in `diff.patch` -A [Substrate](https://github.com/paritytech/substrate/) pallet to add/remove validators using extrinsics, in Substrate-based PoA networks. +A [Substrate](https://github.com/paritytech/substrate/) pallet to add/remove validators using extrinsics, in Substrate-based PoA networks. **Note: Current build is compatible with Substrate [v3.0.0](https://github.com/paritytech/substrate/releases/tag/v3.0.0) release.** @@ -14,7 +14,7 @@ To see this pallet in action in a Substrate runtime, watch this video - https:// ## Setup with Substrate Node Template -* Add the module's dependency in the `Cargo.toml` of your runtime directory. Make sure to enter the correct path or git url of the pallet as per your setup. +* Add the module's dependency in the `Cargo.toml` of your runtime directory. Make sure to enter the correct path or git url of the pallet as per your setup. ```toml validatorset = { @@ -33,9 +33,9 @@ std = [ ] ``` -* Make sure that you also have the Substrate [session pallet](https://github.com/paritytech/substrate/tree/master/frame/session) as part of your runtime. This is because the validator-set pallet is based on the session pallet. +* Make sure that you also have the Substrate [session pallet](https://github.com/paritytech/substrate/tree/master/frame/session) as part of your runtime. This is because the validator-set pallet is based on the session pallet. -* Import `OpaqueKeys` in your `runtime/src/lib.rs`. +* Import `OpaqueKeys` in your `runtime/src/lib.rs`. ```rust use sp_runtime::traits::{ @@ -43,7 +43,7 @@ use sp_runtime::traits::{ }; ``` -* Declare the pallet in your `runtime/src/lib.rs`. +* Declare the pallet in your `runtime/src/lib.rs`. ```rust impl validatorset::Config for Runtime { @@ -51,7 +51,7 @@ impl validatorset::Config for Runtime { } ``` -* Also, declare the session pallet in your `runtime/src/lib.rs`. The type configuration of session pallet would depend on the ValidatorSet pallet as shown below. +* Also, declare the session pallet in your `runtime/src/lib.rs`. The type configuration of session pallet would depend on the ValidatorSet pallet as shown below. ```rust impl pallet_session::Config for Runtime { @@ -68,17 +68,14 @@ impl pallet_session::Config for Runtime { } ``` -* Add both `session` and `validatorset` pallets in `construct_runtime` macro. **Make sure to add them before `Aura` and `Grandpa` pallets and after `Balances`.** +* Add both `session` and `validatorset` pallets in `construct_runtime` macro. **Make sure to add them before `Aura` and `Grandpa` pallets and after `Balances`.** ```rust construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { ... - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + Balances: pallet_balances::{Module, Call, Storage, Config, Event}, Session: pallet_session::{Module, Call, Storage, Event, Config}, ValidatorSet: validatorset::{Module, Call, Storage, Event, Config}, Aura: aura::{Module, Config, Inherent(Timestamp)}, @@ -89,7 +86,7 @@ construct_runtime!( ); ``` -* Add genesis config in the `chain_spec.rs` file for `session` and `validatorset` pallets, and update it for `Aura` and `Grandpa` pallets. Because the validators are provided by the `session` pallet, we do not initialize them explicitly for `Aura` and `Grandpa` pallets. Order is important, notice that `pallet_session` is declared after `pallet_balances` since it depends on it (session accounts should have some balance). +* Add genesis config in the `chain_spec.rs` file for `session` and `validatorset` pallets, and update it for `Aura` and `Grandpa` pallets. Because the validators are provided by the `session` pallet, we do not initialize them explicitly for `Aura` and `Grandpa` pallets. Order is important, notice that `pallet_session` is declared after `pallet_balances` since it depends on it (session accounts should have some balance). ```rust fn testnet_genesis(initial_authorities: Vec<(AccountId, AuraId, GrandpaId)>, @@ -119,7 +116,7 @@ fn testnet_genesis(initial_authorities: Vec<(AccountId, AuraId, GrandpaId)>, } ``` -* Make sure you have the same number and order of session keys for your runtime. First in `runtime/src/lib.rs`: +* Make sure you have the same number and order of session keys for your runtime. First in `runtime/src/lib.rs`: ```rust pub struct SessionKeys { @@ -128,7 +125,7 @@ pub struct SessionKeys { } ``` -* And then in `src/chain_spec.rs`: +* And then in `src/chain_spec.rs`: ```rust fn session_keys( @@ -151,7 +148,7 @@ pub fn authority_keys_from_seed(seed: &str) -> ( } ``` -* `cargo build --release` and then `cargo run --release -- --dev` +* `cargo build --release` and then `cargo run --release -- --dev` ## Sample diff --git a/substrate-node/pallets/substrate-validator-set/src/mock.rs b/substrate-node/pallets/substrate-validator-set/src/mock.rs index 59baa0ea3..0b5ecdeec 100644 --- a/substrate-node/pallets/substrate-validator-set/src/mock.rs +++ b/substrate-node/pallets/substrate-validator-set/src/mock.rs @@ -3,16 +3,16 @@ #![cfg(test)] use crate as validator_set; -use frame_support::{parameter_types, traits::ConstU32, traits::GenesisBuild, BasicExternalities}; +use frame_support::{parameter_types, traits::ConstU32, BasicExternalities}; use frame_system::EnsureRoot; use pallet_session::*; use parity_scale_codec::{Decode, Encode}; use sp_core::{crypto::key_types::DUMMY, H256}; use sp_runtime::{ impl_opaque_keys, - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{BlakeTwo256, IdentityLookup, OpaqueKeys}, - KeyTypeId, RuntimeAppPublic, + BuildStorage, KeyTypeId, RuntimeAppPublic, }; use sp_std::convert::{TryFrom, TryInto}; use std::cell::RefCell; @@ -54,16 +54,12 @@ impl OpaqueKeys for PreUpgradeMockSessionKeys { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, ValidatorSet: validator_set::{Pallet, Call, Storage, Event, Config}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } @@ -124,8 +120,8 @@ pub fn authorities() -> Vec { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let keys: Vec<_> = NEXT_VALIDATORS.with(|l| { l.borrow() @@ -159,25 +155,24 @@ parameter_types! { impl frame_system::Config for TestRuntime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; type BlockWeights = (); type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type AccountId = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Lookup = IdentityLookup; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); + type AccountData = (); type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); From b47b484572a541ceedf1e1c4aee30ff9f6f45f7a Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 27 Nov 2023 23:44:30 -0300 Subject: [PATCH 17/31] update pallets benchmarking --- substrate-node/pallets/pallet-burning/src/benchmarking.rs | 4 ++-- .../pallets/pallet-smart-contract/src/benchmarking.rs | 6 +++--- substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs | 8 ++++---- .../pallets/pallet-tft-price/src/benchmarking.rs | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/substrate-node/pallets/pallet-burning/src/benchmarking.rs b/substrate-node/pallets/pallet-burning/src/benchmarking.rs index 6ce893530..591ec0bd3 100644 --- a/substrate-node/pallets/pallet-burning/src/benchmarking.rs +++ b/substrate-node/pallets/pallet-burning/src/benchmarking.rs @@ -4,7 +4,7 @@ use super::*; use crate::Pallet as BurningModule; use frame_benchmarking::{benchmarks, whitelisted_caller, Zero}; use frame_support::traits::Currency; -use frame_system::{EventRecord, Pallet as System, RawOrigin}; +use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; use sp_runtime::{traits::StaticLookup, SaturatedConversion}; use sp_std::vec; @@ -20,7 +20,7 @@ benchmarks! { verify { let burns = BurningModule::::burns().unwrap_or(vec![]); assert_eq!(burns.len(), 1); - let block = T::BlockNumber::from(1 as u32); + let block = BlockNumberFor::::from(1 as u32); assert_eq!(T::Currency::free_balance(&target), BalanceOf::::zero()); assert_last_event::(Event::BurnTransactionCreated(target, amount, block, message).into()); } diff --git a/substrate-node/pallets/pallet-smart-contract/src/benchmarking.rs b/substrate-node/pallets/pallet-smart-contract/src/benchmarking.rs index 8e6ff1d37..a66fb40f2 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/benchmarking.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/benchmarking.rs @@ -8,7 +8,7 @@ use frame_support::{ traits::{OnFinalize, OnInitialize}, BoundedVec, }; -use frame_system::{EventRecord, Pallet as System, RawOrigin}; +use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; use pallet_balances::Pallet as Balances; use pallet_tfgrid::{ types::{self as tfgrid_types, LocationInput}, @@ -515,7 +515,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { assert_eq!(event, &system_event); } -pub fn run_to_block(n: T::BlockNumber) { +pub fn run_to_block(n: BlockNumberFor) { while System::::block_number() < n { crate::Pallet::::on_finalize(System::::block_number()); System::::on_finalize(System::::block_number()); @@ -586,7 +586,7 @@ fn _create_farming_policy() { 10, 8, 9999, - ::BlockNumber::max_value(), + BlockNumberFor::::max_value(), true, true, NodeCertification::Diy, diff --git a/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs b/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs index 17e5800b6..958880ad6 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs @@ -4,7 +4,7 @@ use super::*; use crate::Pallet as TfgridModule; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; use frame_support::{assert_ok, BoundedVec}; -use frame_system::{EventRecord, Pallet as System, RawOrigin}; +use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; // use hex; // use scale_info::prelude::format; // use sp_core::{ed25519, Pair, Public}; @@ -497,7 +497,7 @@ benchmarks! { let nu = 10; let ipv4 = 8; let minimal_uptime = 9999; - let policy_end = BlockNumberFor::max_value(); + let policy_end = BlockNumberFor::::max_value(); let immutable = true; let default = true; let node_certification = NodeCertification::Diy; @@ -680,7 +680,7 @@ benchmarks! { let power = Power::Down; }: _(RawOrigin::Signed(caller), power) verify { - let power_state = PowerState::Down(BlockNumberFor::from(1 as u32)); + let power_state = PowerState::Down(BlockNumberFor::::from(1 as u32)); let node_power = TfgridModule::::node_power_state(node_id); assert_eq!(node_power.state, power_state); assert_last_event::(Event::PowerStateChanged { @@ -812,7 +812,7 @@ fn _create_farming_policy() { let nu = 10; let ipv4 = 8; let minimal_uptime = 9999; - let policy_end = BlockNumberFor::max_value(); + let policy_end = BlockNumberFor::::max_value(); let immutable = true; let default = true; let node_certification = NodeCertification::Diy; diff --git a/substrate-node/pallets/pallet-tft-price/src/benchmarking.rs b/substrate-node/pallets/pallet-tft-price/src/benchmarking.rs index cbc14ed6e..3a5f92131 100644 --- a/substrate-node/pallets/pallet-tft-price/src/benchmarking.rs +++ b/substrate-node/pallets/pallet-tft-price/src/benchmarking.rs @@ -3,7 +3,7 @@ use super::*; use crate::Pallet as TFTPriceModule; use frame_benchmarking::benchmarks; -use frame_system::{EventRecord, Pallet as System, RawOrigin}; +use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; use pallet_session::Pallet as Session; benchmarks! { @@ -14,7 +14,7 @@ benchmarks! { // set_prices() set_prices { - let block = T::BlockNumber::from(1u32); + let block = BlockNumberFor::::from(1u32); let price = 500; let validators = Session::::validators(); From 3574ed047ac258a91d7eb11aeba7a6d2a0277354 Mon Sep 17 00:00:00 2001 From: renauter Date: Tue, 28 Nov 2023 11:37:22 -0300 Subject: [PATCH 18/31] fix merge --- substrate-node/pallets/pallet-tft-bridge/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate-node/pallets/pallet-tft-bridge/src/lib.rs b/substrate-node/pallets/pallet-tft-bridge/src/lib.rs index 077928233..d0d9e85ea 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/lib.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/lib.rs @@ -147,7 +147,7 @@ pub mod pallet { // Minting events MintTransactionProposed(Vec, T::AccountId, u64), MintTransactionVoted(Vec), - MintCompleted(MintTransaction>), + MintCompleted(MintTransaction>, Vec), MintTransactionExpired(Vec, u64, T::AccountId), // Burn events BurnTransactionCreated(u64, T::AccountId, Vec, u64), From 53fe6181749a07b8ac40bf142a6d71288f55dd38 Mon Sep 17 00:00:00 2001 From: renauter Date: Wed, 29 Nov 2023 17:00:18 -0300 Subject: [PATCH 19/31] update pallets node and runtime --- substrate-node/Cargo.toml | 136 +++++++++--------- substrate-node/node/src/service.rs | 9 +- substrate-node/pallets/pallet-dao/src/dao.rs | 7 +- substrate-node/pallets/pallet-dao/src/lib.rs | 11 +- .../pallets/pallet-tfgrid/Cargo.toml | 1 + .../pallets/pallet-tfgrid/src/farm.rs | 3 +- .../pallets/pallet-tfgrid/src/interface.rs | 3 +- .../pallet-tfgrid/src/migrations/v10.rs | 3 +- .../pallets/pallet-tfgrid/src/node.rs | 3 +- .../pallets/pallet-tfgrid/src/terms_cond.rs | 3 +- .../pallets/pallet-tft-bridge/Cargo.toml | 1 + .../pallet-tft-bridge/src/migrations/v2.rs | 8 +- .../pallet-tft-bridge/src/tft_bridge.rs | 2 +- .../substrate-validator-set/Cargo.toml | 1 + .../substrate-validator-set/src/lib.rs | 4 +- substrate-node/runtime/Cargo.toml | 2 +- substrate-node/runtime/src/lib.rs | 1 + 17 files changed, 105 insertions(+), 93 deletions(-) diff --git a/substrate-node/Cargo.toml b/substrate-node/Cargo.toml index a0caf5172..ebf22664b 100644 --- a/substrate-node/Cargo.toml +++ b/substrate-node/Cargo.toml @@ -40,6 +40,7 @@ smallvec = "1.8.0" valip = "0.4.0" lite-json = { version = "0.1", default-features = false } parking_lot = '0.11' +libp2p-identity = "0.1.3" # Internal pallets pallet-burning = { path = "pallets/pallet-burning", default-features = false } @@ -60,74 +61,75 @@ tfchain-support = { path = "support", default-features = false } tfchain-runtime = { path = "runtime", default-features = false } # Benchmarking (with default disabled) -frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } # Substrate (with default disabled) -frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-session-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-transaction-payment-rpc = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-storage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-keystore = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-session-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-version = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-storage = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } # Client-only (with default enabled) -polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0"} -polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0"} -polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0"} -sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-chain-spec = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-rpc = { git = "https://github.com/paritytech/substrate.git", "branch" = "polkadot-v1.0.0" } -sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-telemetry = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-tracing = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-offchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sp-timestamp = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -substrate-frame-rpc-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -substrate-prometheus-endpoint = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-network = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-service = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-sysinfo = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-tracing = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } diff --git a/substrate-node/node/src/service.rs b/substrate-node/node/src/service.rs index 4a93bef6f..4f824f347 100644 --- a/substrate-node/node/src/service.rs +++ b/substrate-node/node/src/service.rs @@ -37,6 +37,10 @@ pub type FullClient = type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; +/// The minimum period of blocks on which justifications will be +/// imported and generated. +const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512; + #[allow(clippy::type_complexity)] pub fn new_partial( config: &Configuration, @@ -45,7 +49,7 @@ pub fn new_partial( FullClient, FullBackend, FullSelectChain, - sc_consensus::DefaultImportQueue, + sc_consensus::DefaultImportQueue, sc_transaction_pool::FullPool, ( sc_consensus_grandpa::GrandpaBlockImport< @@ -99,6 +103,7 @@ pub fn new_partial( let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( client.clone(), + GRANDPA_JUSTIFICATION_PERIOD, &client, select_chain.clone(), telemetry.as_ref().map(|x| x.handle()), @@ -335,7 +340,7 @@ pub fn new_full(config: Configuration) -> Result { let grandpa_config = sc_consensus_grandpa::Config { // FIXME #1578 make this available through chainspec gossip_duration: Duration::from_millis(333), - justification_period: 512, + justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD, name: Some(name), observer_enabled: false, keystore, diff --git a/substrate-node/pallets/pallet-dao/src/dao.rs b/substrate-node/pallets/pallet-dao/src/dao.rs index 2a04497c4..26119a98a 100644 --- a/substrate-node/pallets/pallet-dao/src/dao.rs +++ b/substrate-node/pallets/pallet-dao/src/dao.rs @@ -8,7 +8,7 @@ use crate::{ proposal::ProposalIndex, }; use frame_support::{ - dispatch::{DispatchError, DispatchResultWithPostInfo, GetDispatchInfo}, + dispatch::{DispatchResultWithPostInfo, GetDispatchInfo}, ensure, pallet_prelude::Pays, traits::Get, @@ -16,7 +16,10 @@ use frame_support::{ }; use frame_system::pallet_prelude::BlockNumberFor; use pallet_tfgrid::pallet::{InterfaceOf, LocationOf, SerialNumberOf, TfgridNode}; -use sp_runtime::traits::{Dispatchable, Hash}; +use sp_runtime::{ + traits::{Dispatchable, Hash}, + DispatchError, +}; use sp_std::prelude::*; use tfchain_support::{ constants, diff --git a/substrate-node/pallets/pallet-dao/src/lib.rs b/substrate-node/pallets/pallet-dao/src/lib.rs index e87a2a036..8f836f08c 100644 --- a/substrate-node/pallets/pallet-dao/src/lib.rs +++ b/substrate-node/pallets/pallet-dao/src/lib.rs @@ -27,18 +27,15 @@ pub mod pallet { use crate::proposal::ProposalIndex; use crate::weights::WeightInfo; use frame_support::{ - dispatch::{ - DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, - PostDispatchInfo, - }, + dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, + pallet_prelude::*, traits::{EnsureOrigin, Get}, }; - use tfchain_support::traits::{ChangeNode, Tfgrid}; - - use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use pallet_tfgrid::farm::FarmName; + use sp_runtime::traits::Dispatchable; use sp_std::convert::TryInto; + use tfchain_support::traits::{ChangeNode, Tfgrid}; #[pallet::config] pub trait Config: diff --git a/substrate-node/pallets/pallet-tfgrid/Cargo.toml b/substrate-node/pallets/pallet-tfgrid/Cargo.toml index aed02a9ac..a4bdcf6ed 100644 --- a/substrate-node/pallets/pallet-tfgrid/Cargo.toml +++ b/substrate-node/pallets/pallet-tfgrid/Cargo.toml @@ -34,6 +34,7 @@ sp-storage.workspace = true pallet-timestamp.workspace = true sp-core.workspace = true sp-io.workspace = true +sp-weights.workspace = true frame-try-runtime.workspace = true # Benchmarking diff --git a/substrate-node/pallets/pallet-tfgrid/src/farm.rs b/substrate-node/pallets/pallet-tfgrid/src/farm.rs index d4f72a9d6..b4875f0d7 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/farm.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/farm.rs @@ -2,9 +2,10 @@ use crate::*; use frame_support::{ dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo}, ensure, + pallet_prelude::RuntimeDebug, sp_runtime::SaturatedConversion, traits::Get, - BoundedVec, RuntimeDebug, + BoundedVec, }; use frame_system::pallet_prelude::BlockNumberFor; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; diff --git a/substrate-node/pallets/pallet-tfgrid/src/interface.rs b/substrate-node/pallets/pallet-tfgrid/src/interface.rs index 8f7932c27..e2add26c4 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/interface.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/interface.rs @@ -1,6 +1,7 @@ use crate::{Config, Error, InterfaceIpInput, InterfaceMacInput, InterfaceNameInput}; use frame_support::{ - ensure, sp_runtime::SaturatedConversion, traits::ConstU32, BoundedVec, RuntimeDebug, + ensure, pallet_prelude::RuntimeDebug, sp_runtime::SaturatedConversion, traits::ConstU32, + BoundedVec, }; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs index 8e772f748..324996078 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs @@ -1,8 +1,9 @@ use crate::*; -use frame_support::{dispatch::Weight, traits::Get, traits::OnRuntimeUpgrade}; +use frame_support::{traits::Get, traits::OnRuntimeUpgrade}; use log::{debug, info}; use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData}; use sp_std::{vec, vec::Vec}; +use sp_weights::Weight; #[cfg(feature = "try-runtime")] use frame_support::{dispatch::DispatchError, ensure}; diff --git a/substrate-node/pallets/pallet-tfgrid/src/node.rs b/substrate-node/pallets/pallet-tfgrid/src/node.rs index 45656967f..4b4534770 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/node.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/node.rs @@ -2,9 +2,10 @@ use crate::*; use frame_support::{ dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Pays}, ensure, + pallet_prelude::RuntimeDebug, sp_runtime::SaturatedConversion, traits::ConstU32, - BoundedVec, RuntimeDebug, + BoundedVec, }; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; diff --git a/substrate-node/pallets/pallet-tfgrid/src/terms_cond.rs b/substrate-node/pallets/pallet-tfgrid/src/terms_cond.rs index aac56dcf2..b793f00da 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/terms_cond.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/terms_cond.rs @@ -1,6 +1,7 @@ use crate::{Config, Error, TermsAndConditionsInput}; use frame_support::{ - ensure, sp_runtime::SaturatedConversion, traits::ConstU32, BoundedVec, RuntimeDebug, + ensure, pallet_prelude::RuntimeDebug, sp_runtime::SaturatedConversion, traits::ConstU32, + BoundedVec, }; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; diff --git a/substrate-node/pallets/pallet-tft-bridge/Cargo.toml b/substrate-node/pallets/pallet-tft-bridge/Cargo.toml index 5d9be8f45..d453c5246 100644 --- a/substrate-node/pallets/pallet-tft-bridge/Cargo.toml +++ b/substrate-node/pallets/pallet-tft-bridge/Cargo.toml @@ -17,6 +17,7 @@ targets = ['x86_64-unknown-linux-gnu'] # Substrate packages parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = { workspace = true, features = ["derive"] } +log.workspace = true frame-support.workspace = true frame-system.workspace = true diff --git a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs index 28cd2598c..167c8aa67 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs @@ -1,11 +1,7 @@ use crate::*; -use frame_support::{ - log::{debug, info}, - traits::Get, - traits::OnRuntimeUpgrade, - weights::Weight, -}; +use frame_support::{traits::Get, traits::OnRuntimeUpgrade, weights::Weight}; use frame_system::pallet_prelude::BlockNumberFor; +use log::{debug, info}; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] diff --git a/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs b/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs index 4daf76b89..217ef1959 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/tft_bridge.rs @@ -1,7 +1,7 @@ use super::{types::*, *}; use frame_support::{ dispatch::DispatchErrorWithPostInfo, - ensure, log, + ensure, pallet_prelude::DispatchResultWithPostInfo, traits::{Currency, ExistenceRequirement, OnUnbalanced, WithdrawReasons}, }; diff --git a/substrate-node/pallets/substrate-validator-set/Cargo.toml b/substrate-node/pallets/substrate-validator-set/Cargo.toml index 306e63a10..1ee695c54 100644 --- a/substrate-node/pallets/substrate-validator-set/Cargo.toml +++ b/substrate-node/pallets/substrate-validator-set/Cargo.toml @@ -23,6 +23,7 @@ frame-support.workspace = true frame-system.workspace = true pallet-session.workspace = true sp-io.workspace = true +sp-weights.workspace = true frame-benchmarking.workspace = true [dev-dependencies] diff --git a/substrate-node/pallets/substrate-validator-set/src/lib.rs b/substrate-node/pallets/substrate-validator-set/src/lib.rs index 31c94b3e9..9ae92f603 100644 --- a/substrate-node/pallets/substrate-validator-set/src/lib.rs +++ b/substrate-node/pallets/substrate-validator-set/src/lib.rs @@ -205,13 +205,13 @@ pub mod pallet { fn estimate_current_session_progress( _now: BlockNumberFor, - ) -> (Option, frame_support::dispatch::Weight) { + ) -> (Option, sp_weights::Weight) { (None, Zero::zero()) } fn estimate_next_session_rotation( _now: BlockNumberFor, - ) -> (Option>, frame_support::dispatch::Weight) { + ) -> (Option>, sp_weights::Weight) { (None, Zero::zero()) } } diff --git a/substrate-node/runtime/Cargo.toml b/substrate-node/runtime/Cargo.toml index 9c2b11fec..b98009d25 100644 --- a/substrate-node/runtime/Cargo.toml +++ b/substrate-node/runtime/Cargo.toml @@ -14,7 +14,7 @@ version.workspace = true targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } +substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } [dependencies] smallvec.workspace = true diff --git a/substrate-node/runtime/src/lib.rs b/substrate-node/runtime/src/lib.rs index 4f8f6be3b..ce81ce546 100644 --- a/substrate-node/runtime/src/lib.rs +++ b/substrate-node/runtime/src/lib.rs @@ -256,6 +256,7 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); type MaxAuthorities = MaxAuthorities; + type MaxNominators = frame_support::traits::ConstU32<0>; type MaxSetIdSessionEntries = MaxSetIdSessionEntries; type KeyOwnerProof = sp_core::Void; From 43d956d62201df1d989c7c8b2c6f99a6a45c403d Mon Sep 17 00:00:00 2001 From: renauter Date: Wed, 29 Nov 2023 17:47:14 -0300 Subject: [PATCH 20/31] update tests --- substrate-node/Cargo.toml | 1 + substrate-node/pallets/pallet-dao/src/tests.rs | 4 ++-- substrate-node/pallets/pallet-smart-contract/src/tests.rs | 4 ++-- substrate-node/pallets/pallet-tfgrid/src/tests.rs | 3 +-- substrate-node/pallets/pallet-validator/src/mock.rs | 4 ++-- substrate-node/pallets/substrate-validator-set/Cargo.toml | 1 + substrate-node/pallets/substrate-validator-set/src/mock.rs | 4 ++-- substrate-node/support/src/tests.rs | 3 +-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/substrate-node/Cargo.toml b/substrate-node/Cargo.toml index ebf22664b..eeaa3da1e 100644 --- a/substrate-node/Cargo.toml +++ b/substrate-node/Cargo.toml @@ -102,6 +102,7 @@ try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", default- sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } # Client-only (with default enabled) polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } diff --git a/substrate-node/pallets/pallet-dao/src/tests.rs b/substrate-node/pallets/pallet-dao/src/tests.rs index 7fb41600a..484956cda 100644 --- a/substrate-node/pallets/pallet-dao/src/tests.rs +++ b/substrate-node/pallets/pallet-dao/src/tests.rs @@ -1,10 +1,10 @@ use crate::pallet::Event as DaoEvent; use crate::{mock::RuntimeEvent as MockEvent, mock::*, pallet::Error}; -use frame_support::{assert_noop, assert_ok, bounded_vec, dispatch::GetDispatchInfo}; +use frame_support::{assert_noop, assert_ok, dispatch::GetDispatchInfo}; use frame_system::{EventRecord, Phase, RawOrigin}; use log::info; use pallet_tfgrid::{types::LocationInput, PublicIpListInput, ResourcesInput}; -use sp_core::H256; +use sp_core::{bounded_vec, H256}; use sp_runtime::traits::{BlakeTwo256, Hash}; use std::convert::TryInto; use tfchain_support::types::{FarmCertification, NodeCertification, IP4}; diff --git a/substrate-node/pallets/pallet-smart-contract/src/tests.rs b/substrate-node/pallets/pallet-smart-contract/src/tests.rs index fad3debb3..93f0a2092 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/tests.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/tests.rs @@ -3,7 +3,7 @@ use crate::{ Event as SmartContractEvent, }; use frame_support::{ - assert_noop, assert_ok, bounded_vec, + assert_noop, assert_ok, dispatch::Pays, traits::{LockableCurrency, WithdrawReasons}, BoundedVec, @@ -14,7 +14,7 @@ use pallet_tfgrid::{ types::{self as pallet_tfgrid_types, LocationInput}, ResourcesInput, }; -use sp_core::H256; +use sp_core::{bounded_vec, H256}; use sp_runtime::{assert_eq_error_rate, traits::SaturatedConversion, Perbill, Percent}; use sp_std::convert::{TryFrom, TryInto}; use substrate_fixed::types::U64F64; diff --git a/substrate-node/pallets/pallet-tfgrid/src/tests.rs b/substrate-node/pallets/pallet-tfgrid/src/tests.rs index 12d52a622..9845d6f16 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/tests.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/tests.rs @@ -5,8 +5,7 @@ use crate::{ }; use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase, RawOrigin}; -use sp_core::bounded_vec; -use sp_core::H256; +use sp_core::{bounded_vec, H256}; use tfchain_support::types::{ FarmCertification, FarmingPolicyLimit, Interface, NodeCertification, Power, PowerState, PublicConfig, PublicIpError, IP4, IP6, diff --git a/substrate-node/pallets/pallet-validator/src/mock.rs b/substrate-node/pallets/pallet-validator/src/mock.rs index b89849f8b..656ab72e5 100644 --- a/substrate-node/pallets/pallet-validator/src/mock.rs +++ b/substrate-node/pallets/pallet-validator/src/mock.rs @@ -1,9 +1,9 @@ use crate as pallet_validator; use core::cell::RefCell; -use frame_support::{bounded_vec, construct_runtime, parameter_types, traits::ConstU32}; +use frame_support::{construct_runtime, parameter_types, traits::ConstU32}; use frame_system::EnsureRoot; use pallet_session::{SessionHandler, ShouldEndSession}; -use sp_core::{crypto::key_types::DUMMY, H256}; +use sp_core::{bounded_vec, crypto::key_types::DUMMY, H256}; use sp_runtime::{ impl_opaque_keys, testing::UintAuthorityId, diff --git a/substrate-node/pallets/substrate-validator-set/Cargo.toml b/substrate-node/pallets/substrate-validator-set/Cargo.toml index 1ee695c54..4072162ca 100644 --- a/substrate-node/pallets/substrate-validator-set/Cargo.toml +++ b/substrate-node/pallets/substrate-validator-set/Cargo.toml @@ -24,6 +24,7 @@ frame-system.workspace = true pallet-session.workspace = true sp-io.workspace = true sp-weights.workspace = true +sp-state-machine.workspace = true frame-benchmarking.workspace = true [dev-dependencies] diff --git a/substrate-node/pallets/substrate-validator-set/src/mock.rs b/substrate-node/pallets/substrate-validator-set/src/mock.rs index 0b5ecdeec..0d90d7508 100644 --- a/substrate-node/pallets/substrate-validator-set/src/mock.rs +++ b/substrate-node/pallets/substrate-validator-set/src/mock.rs @@ -3,7 +3,7 @@ #![cfg(test)] use crate as validator_set; -use frame_support::{parameter_types, traits::ConstU32, BasicExternalities}; +use frame_support::{parameter_types, traits::ConstU32}; use frame_system::EnsureRoot; use pallet_session::*; use parity_scale_codec::{Decode, Encode}; @@ -130,7 +130,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { .map(|i| (i, i, UintAuthorityId(i).into())) .collect() }); - BasicExternalities::execute_with_storage(&mut t, || { + sp_state_machine::BasicExternalities::execute_with_storage(&mut t, || { for (ref k, ..) in &keys { frame_system::Pallet::::inc_providers(k); } diff --git a/substrate-node/support/src/tests.rs b/substrate-node/support/src/tests.rs index f62fc71ff..7b9147f43 100644 --- a/substrate-node/support/src/tests.rs +++ b/substrate-node/support/src/tests.rs @@ -1,7 +1,6 @@ use crate::resources::{Resources, GIGABYTE}; use crate::types::{PublicIpError, IP4, IP6}; -use frame_support::storage::bounded_vec::BoundedVec; -use frame_support::{assert_err, assert_ok}; +use frame_support::{assert_err, assert_ok, storage::bounded_vec::BoundedVec}; #[test] fn test_calc_cu_falsy_values() { From 599378e5a3f5807b8527c73ba8d4fd8e28f803a1 Mon Sep 17 00:00:00 2001 From: renauter Date: Thu, 30 Nov 2023 08:13:45 -0300 Subject: [PATCH 21/31] update pallets benchmarking --- .../pallets/pallet-burning/src/benchmarking.rs | 7 +++++-- substrate-node/pallets/pallet-dao/src/benchmarking.rs | 9 +++++++-- substrate-node/runtime/src/lib.rs | 11 ++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/substrate-node/pallets/pallet-burning/src/benchmarking.rs b/substrate-node/pallets/pallet-burning/src/benchmarking.rs index 591ec0bd3..626f0ac45 100644 --- a/substrate-node/pallets/pallet-burning/src/benchmarking.rs +++ b/substrate-node/pallets/pallet-burning/src/benchmarking.rs @@ -2,10 +2,13 @@ use super::*; use crate::Pallet as BurningModule; -use frame_benchmarking::{benchmarks, whitelisted_caller, Zero}; +use frame_benchmarking::{benchmarks, whitelisted_caller}; use frame_support::traits::Currency; use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; -use sp_runtime::{traits::StaticLookup, SaturatedConversion}; +use sp_runtime::{ + traits::{StaticLookup, Zero}, + SaturatedConversion, +}; use sp_std::vec; benchmarks! { diff --git a/substrate-node/pallets/pallet-dao/src/benchmarking.rs b/substrate-node/pallets/pallet-dao/src/benchmarking.rs index 88a041394..793378882 100644 --- a/substrate-node/pallets/pallet-dao/src/benchmarking.rs +++ b/substrate-node/pallets/pallet-dao/src/benchmarking.rs @@ -3,7 +3,7 @@ use crate::pallet::Pallet as DaoModule; use crate::pallet::Pallet; use crate::pallet::{Call, Config, Event}; -use frame_benchmarking::{account, benchmarks, whitelisted_caller, vec, Vec, Box}; +use frame_benchmarking::{account, benchmarks, whitelisted_caller}; use frame_support::{assert_ok, BoundedVec}; use frame_system::{Call as SystemCall, EventRecord, Pallet as System, RawOrigin}; use pallet_membership::Pallet as CouncilMembership; @@ -16,7 +16,12 @@ use sp_runtime::{ traits::{Hash, StaticLookup}, DispatchError, }; -use sp_std::convert::{TryFrom, TryInto}; +use sp_std::{ + boxed::Box, + convert::{TryFrom, TryInto}, + vec, + vec::Vec, +}; use tfchain_support::types::IP4; const GIGABYTE: u64 = 1024 * 1024 * 1024; diff --git a/substrate-node/runtime/src/lib.rs b/substrate-node/runtime/src/lib.rs index ce81ce546..9ad6b68c9 100644 --- a/substrate-node/runtime/src/lib.rs +++ b/substrate-node/runtime/src/lib.rs @@ -21,8 +21,11 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, }; -use sp_std::convert::{TryFrom, TryInto}; -use sp_std::{cmp::Ordering, prelude::*}; +use sp_std::{ + cmp::Ordering, + convert::{TryFrom, TryInto}, + prelude::*, +}; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -977,7 +980,9 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch}; + use frame_support::traits::TrackedStorageKey; + use frame_system_benchmarking::Pallet as SystemBench; use frame_benchmarking::baseline::Pallet as Baseline; From a39da215f2fb12b62c468927d50f84df59f811cc Mon Sep 17 00:00:00 2001 From: renauter Date: Thu, 30 Nov 2023 10:10:40 -0300 Subject: [PATCH 22/31] update try-runtime --- substrate-node/node/src/cli.rs | 9 +++---- substrate-node/node/src/command.rs | 25 +------------------ .../src/migrations/v10.rs | 4 ++- .../src/migrations/v11.rs | 4 ++- .../src/migrations/v6.rs | 4 ++- .../src/migrations/v8.rs | 4 ++- .../src/migrations/v9.rs | 4 ++- .../pallet-tfgrid/src/migrations/v10.rs | 4 ++- .../pallet-tfgrid/src/migrations/v11.rs | 4 ++- .../pallet-tfgrid/src/migrations/v12.rs | 4 ++- .../pallet-tfgrid/src/migrations/v13.rs | 4 ++- .../pallet-tfgrid/src/migrations/v14.rs | 4 ++- .../pallet-tfgrid/src/migrations/v15.rs | 4 ++- .../pallet-tfgrid/src/migrations/v17.rs | 4 ++- .../pallet-tft-bridge/src/migrations/v2.rs | 4 ++- .../tfgrid_v15_smart_contract_v8.rs | 4 ++- 16 files changed, 46 insertions(+), 44 deletions(-) diff --git a/substrate-node/node/src/cli.rs b/substrate-node/node/src/cli.rs index 965bf3533..dda86d7e1 100644 --- a/substrate-node/node/src/cli.rs +++ b/substrate-node/node/src/cli.rs @@ -41,12 +41,9 @@ pub enum Subcommand { #[clap(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), - /// Try some command against runtime state. - #[cfg(feature = "try-runtime")] - TryRuntime(try_runtime_cli::TryRuntimeCmd), - - /// Try some command against runtime state. Note: `try-runtime` feature must be enabled. - #[cfg(not(feature = "try-runtime"))] + /// Try-runtime has migrated to a standalone CLI + /// (). The subcommand exists as a stub and + /// deprecation notice. It will be removed entirely some time after Janurary 2024. TryRuntime, /// Db meta columns information. diff --git a/substrate-node/node/src/command.rs b/substrate-node/node/src/command.rs index fb3bd365b..46fd3bca7 100644 --- a/substrate-node/node/src/command.rs +++ b/substrate-node/node/src/command.rs @@ -193,30 +193,7 @@ pub fn run() -> sc_cli::Result<()> { }) } #[cfg(feature = "try-runtime")] - Some(Subcommand::TryRuntime(cmd)) => { - use crate::service::ExecutorDispatch; - use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch}; - use try_runtime_cli::block_building_info::timestamp_with_aura_info; - - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - // we don't need any of the components of new_partial, just a runtime, or a task - // manager to do `async_run`. - let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(config.tokio_handle.clone(), registry) - .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; - let info_provider = timestamp_with_aura_info(6000); - - Ok(( - cmd.run::::ExtendHostFunctions, - >, _>(Some(info_provider)), - task_manager, - )) - }) - } + Some(Subcommand::TryRuntime) => Err(try_runtime_cli::DEPRECATION_NOTICE.into()), #[cfg(not(feature = "try-runtime"))] Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \ You can enable it with `--features try-runtime`." diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs index fa255505b..36ebd5e0d 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v10.rs @@ -6,7 +6,9 @@ use sp_runtime::Saturating; use sp_std::{marker::PhantomData, vec}; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs index 3346a4e9d..f790b4ab6 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v11.rs @@ -9,7 +9,9 @@ use sp_runtime::traits::Zero; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; #[cfg(feature = "try-runtime")] use sp_std::{vec, vec::Vec}; diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs index 34010b446..e4d5c3764 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v6.rs @@ -5,9 +5,11 @@ use sp_core::Get; use sp_std::{marker::PhantomData, vec::Vec}; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; pub struct ContractMigrationV5(PhantomData); diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs index 4fcb53bf3..945916f10 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v8.rs @@ -9,7 +9,9 @@ use sp_runtime::traits::{CheckedSub, SaturatedConversion}; use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData}; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; #[cfg(feature = "try-runtime")] use sp_std::{vec, vec::Vec}; diff --git a/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs b/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs index abc3ca0eb..fc4c7661f 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs @@ -7,7 +7,9 @@ use sp_core::Get; use sp_std::{marker::PhantomData, vec, vec::Vec}; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; pub struct CleanStorageState(PhantomData); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs index 324996078..863fcf837 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v10.rs @@ -6,9 +6,11 @@ use sp_std::{vec, vec::Vec}; use sp_weights::Weight; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; pub struct FixFarmNodeIndexMap(PhantomData); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs index a6bb51408..d6c7b6656 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v11.rs @@ -4,10 +4,12 @@ use log::{debug, info}; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; +#[cfg(feature = "try-runtime")] use sp_std::vec::Vec; pub struct FixFarmingPolicy(PhantomData); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs index be66a58ae..373c30378 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v12.rs @@ -7,10 +7,12 @@ use log::{debug, info}; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; +#[cfg(feature = "try-runtime")] use sp_std::vec::Vec; // Storage alias from Node v12 diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs index 8b70e9588..b08eea8be 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v13.rs @@ -10,10 +10,12 @@ use tfchain_support::{ }; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; +#[cfg(feature = "try-runtime")] use sp_std::vec::Vec; pub struct FixPublicIP(PhantomData); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs index 68dd5c6ba..cd1e7137c 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v14.rs @@ -5,10 +5,12 @@ use log::{debug, info}; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; +#[cfg(feature = "try-runtime")] use sp_std::vec::Vec; pub struct FixFarmingPoliciesMap(PhantomData); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs index 637160796..b3c611527 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v15.rs @@ -4,10 +4,12 @@ use log::{debug, info}; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::Decode; #[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; +#[cfg(feature = "try-runtime")] use sp_std::vec::Vec; pub struct MigrateTwinsV15(PhantomData); diff --git a/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs b/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs index 3e95841c8..1b2bea8f7 100644 --- a/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs +++ b/substrate-node/pallets/pallet-tfgrid/src/migrations/v17.rs @@ -8,9 +8,11 @@ use sp_std::{marker::PhantomData, vec::Vec}; use tfchain_support::types::{PublicIP, IP4}; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::{Decode, Encode}; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; pub struct FixFarmPublicIps(PhantomData); diff --git a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs index 167c8aa67..855bcdd97 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs @@ -5,7 +5,9 @@ use log::{debug, info}; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; +#[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; diff --git a/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs b/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs index df07f5f5a..26499dd37 100644 --- a/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs +++ b/substrate-node/runtime/src/migrations/tfgrid_v15_smart_contract_v8.rs @@ -16,10 +16,12 @@ use log::{debug, info}; use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData}; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::DispatchError, ensure}; +use frame_support::ensure; #[cfg(feature = "try-runtime")] use parity_scale_codec::Decode; #[cfg(feature = "try-runtime")] +use sp_runtime::DispatchError; +#[cfg(feature = "try-runtime")] use sp_std::vec::Vec; // Storage alias from Twin v12 From 340744df890f22bb0becc31e13a997116e9b3dcd Mon Sep 17 00:00:00 2001 From: renauter Date: Thu, 30 Nov 2023 17:33:22 -0300 Subject: [PATCH 23/31] upgrade to polkadot 1.2.0 --- substrate-node/Cargo.toml | 143 +++++++++++++++-------------- substrate-node/node/src/service.rs | 1 + substrate-node/runtime/Cargo.toml | 4 +- substrate-node/runtime/src/lib.rs | 11 +++ 4 files changed, 87 insertions(+), 72 deletions(-) diff --git a/substrate-node/Cargo.toml b/substrate-node/Cargo.toml index eeaa3da1e..9748d60b1 100644 --- a/substrate-node/Cargo.toml +++ b/substrate-node/Cargo.toml @@ -23,7 +23,7 @@ resolver = "2" # External (without extra features and with default disabled if necessary) base58 = {version = "0.2.0", default-features = false} bitflags = {version = "1.3.2", default-features = false} -clap = "4.0.9" +clap = { version = "4.4.4", features = ["derive"] } parity-scale-codec = { version = "3.6.1", default-features = false } env_logger = "0.10.0" futures = {version = "0.3.21", default-features = false} @@ -34,7 +34,7 @@ libsecp256k1 = {version = "0.7", default-features = false} log = "0.4.17" scale-info = {version = "2.5.0", default-features = false} serde = { version = "1.0.144", default-features = false, features = ["derive"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +serde_json = { version = "1.0.108", default-features = false, features = ["alloc"] } sha3 = {version = "0.10.0", default-features = false} smallvec = "1.8.0" valip = "0.4.0" @@ -61,76 +61,77 @@ tfchain-support = { path = "support", default-features = false } tfchain-runtime = { path = "runtime", default-features = false } # Benchmarking (with default disabled) -frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } # Substrate (with default disabled) -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-session-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-storage = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } -sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" } +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-session-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-version = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-storage = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } +sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.2.0" } # Client-only (with default enabled) -polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-network = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-sysinfo = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-tracing = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-network = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-service = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-sysinfo = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-tracing = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } diff --git a/substrate-node/node/src/service.rs b/substrate-node/node/src/service.rs index 4f824f347..b6476461b 100644 --- a/substrate-node/node/src/service.rs +++ b/substrate-node/node/src/service.rs @@ -205,6 +205,7 @@ pub fn new_full(config: Configuration) -> Result { import_queue, block_announce_validator_builder: None, warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)), + block_relay: None, })?; if config.offchain_worker.enabled { diff --git a/substrate-node/runtime/Cargo.toml b/substrate-node/runtime/Cargo.toml index b98009d25..c496d2877 100644 --- a/substrate-node/runtime/Cargo.toml +++ b/substrate-node/runtime/Cargo.toml @@ -14,7 +14,7 @@ version.workspace = true targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.1.0" } +substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.2.0" } [dependencies] smallvec.workspace = true @@ -59,6 +59,7 @@ sp-api.workspace = true sp-block-builder.workspace = true sp-consensus-aura.workspace = true sp-core.workspace = true +sp-genesis-builder.workspace = true sp-inherents.workspace = true sp-offchain.workspace = true sp-runtime.workspace = true @@ -99,6 +100,7 @@ std = [ "sp-block-builder/std", "sp-consensus-aura/std", "sp-core/std", + "sp-genesis-builder/std", "sp-inherents/std", "sp-offchain/std", "sp-runtime/std", diff --git a/substrate-node/runtime/src/lib.rs b/substrate-node/runtime/src/lib.rs index 9ad6b68c9..8a2f7f85b 100644 --- a/substrate-node/runtime/src/lib.rs +++ b/substrate-node/runtime/src/lib.rs @@ -35,6 +35,7 @@ use tfchain_support::{ types::PublicIP, }; +use frame_support::genesis_builder_helper::{build_config, create_default_config}; // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, parameter_types, @@ -1040,4 +1041,14 @@ impl_runtime_apis! { Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap() } } + + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn create_default_config() -> Vec { + create_default_config::() + } + + fn build_config(config: Vec) -> sp_genesis_builder::Result { + build_config::(config) + } + } } From 116b8a3b44149e12c614ca6b982ff17a528c5bc5 Mon Sep 17 00:00:00 2001 From: renauter Date: Thu, 30 Nov 2023 17:33:45 -0300 Subject: [PATCH 24/31] update pallets- tests --- .../pallet-smart-contract/src/tests.rs | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/substrate-node/pallets/pallet-smart-contract/src/tests.rs b/substrate-node/pallets/pallet-smart-contract/src/tests.rs index 93f0a2092..0bd83d244 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/tests.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/tests.rs @@ -5,7 +5,7 @@ use crate::{ use frame_support::{ assert_noop, assert_ok, dispatch::Pays, - traits::{LockableCurrency, WithdrawReasons}, + traits::{Currency, ExistenceRequirement, LockableCurrency, WithdrawReasons}, BoundedVec, }; use frame_system::{EventRecord, Phase, RawOrigin}; @@ -1506,9 +1506,10 @@ fn test_node_contract_billing_cycles_cancel_contract_during_cycle_without_balanc let extrinsic_fee = 10000; Balances::transfer( - RuntimeOrigin::signed(bob()), - alice(), + &bob(), + &alice(), initial_twin_balance - total_amount_billed - extrinsic_fee, + ExistenceRequirement::AllowDeath, ) .unwrap(); @@ -1641,7 +1642,13 @@ fn test_restore_node_contract_in_grace_works() { run_to_block(31, Some(&mut pool_state)); run_to_block(41, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); + Balances::transfer( + &bob(), + &charlie(), + 100000000, + ExistenceRequirement::AllowDeath, + ) + .unwrap(); run_to_block(52, Some(&mut pool_state)); run_to_block(62, Some(&mut pool_state)); @@ -1881,7 +1888,13 @@ fn test_rent_contract_billing_cancel_should_bill_reserved_balance() { let twin = TfgridModule::twins(2).unwrap(); let usable_balance = Balances::usable_balance(&twin.account_id); assert_ne!(usable_balance, 0); - Balances::transfer(RuntimeOrigin::signed(bob()), alice(), usable_balance).unwrap(); + Balances::transfer( + &bob(), + &alice(), + usable_balance, + ExistenceRequirement::AllowDeath, + ) + .unwrap(); // Last amount due is the same as the first one assert_ne!(amount_due_as_u128, 0); @@ -2258,7 +2271,13 @@ fn test_restore_rent_contract_in_grace_works() { run_to_block(31, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); + Balances::transfer( + &bob(), + &charlie(), + 100000000, + ExistenceRequirement::AllowDeath, + ) + .unwrap(); pool_state .write() @@ -2361,7 +2380,13 @@ fn test_restore_rent_contract_and_node_contracts_in_grace_works() { run_to_block(32, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); + Balances::transfer( + &bob(), + &charlie(), + 100000000, + ExistenceRequirement::AllowDeath, + ) + .unwrap(); pool_state .write() @@ -3319,7 +3344,13 @@ fn test_service_contract_bill_out_of_funds_fails() { // Drain consumer account let consumer_twin = TfgridModule::twins(2).unwrap(); let consumer_balance = Balances::free_balance(&consumer_twin.account_id); - Balances::transfer(RuntimeOrigin::signed(bob()), alice(), consumer_balance).unwrap(); + Balances::transfer( + &bob(), + &alice(), + consumer_balance, + ExistenceRequirement::AllowDeath, + ) + .unwrap(); let consumer_balance = Balances::free_balance(&consumer_twin.account_id); assert_eq!(consumer_balance, 0); From b4bdb28b227cc0c11cccc5d7ad13866bb32c8553 Mon Sep 17 00:00:00 2001 From: renauter Date: Sat, 2 Dec 2023 12:32:55 -0300 Subject: [PATCH 25/31] change transfer() to transfer_keep_alive() --- clients/tfchain-client-go/transfer.go | 2 +- .../pallets/pallet-smart-contract/src/mock.rs | 6 +- .../pallet-smart-contract/src/tests.rs | 91 +++++++------------ 3 files changed, 35 insertions(+), 64 deletions(-) diff --git a/clients/tfchain-client-go/transfer.go b/clients/tfchain-client-go/transfer.go index 5648a851e..ec50f1a9b 100644 --- a/clients/tfchain-client-go/transfer.go +++ b/clients/tfchain-client-go/transfer.go @@ -19,7 +19,7 @@ func (s *Substrate) Transfer(identity Identity, amount uint64, destination Accou } bal := big.NewInt(int64(amount)) - c, err := types.NewCall(meta, "Balances.transfer", dest, types.NewUCompact(bal)) + c, err := types.NewCall(meta, "Balances.transfer_keep_alive", dest, types.NewUCompact(bal)) if err != nil { panic(err) } diff --git a/substrate-node/pallets/pallet-smart-contract/src/mock.rs b/substrate-node/pallets/pallet-smart-contract/src/mock.rs index cc765f286..dbc7e5a8e 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/mock.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/mock.rs @@ -145,12 +145,12 @@ impl frame_system::Config for TestRuntime { type MaxConsumers = ConstU32<16>; } -pub const EXISTENTIAL_DEPOSIT: u64 = 500; +pub const EXISTENTIAL_DEPOSIT: u64 = 2; parameter_types! { pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; - pub const ExistentialDepositBalance: u64 = EXISTENTIAL_DEPOSIT; + pub const ExistentialDeposit: u64 = EXISTENTIAL_DEPOSIT; } impl pallet_balances::Config for TestRuntime { @@ -162,7 +162,7 @@ impl pallet_balances::Config for TestRuntime { /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; type DustRemoval = (); - type ExistentialDeposit = ExistentialDepositBalance; + type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); diff --git a/substrate-node/pallets/pallet-smart-contract/src/tests.rs b/substrate-node/pallets/pallet-smart-contract/src/tests.rs index 0bd83d244..ccbc5159c 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/tests.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/tests.rs @@ -5,7 +5,7 @@ use crate::{ use frame_support::{ assert_noop, assert_ok, dispatch::Pays, - traits::{Currency, ExistenceRequirement, LockableCurrency, WithdrawReasons}, + traits::{LockableCurrency, WithdrawReasons}, BoundedVec, }; use frame_system::{EventRecord, Phase, RawOrigin}; @@ -1505,11 +1505,10 @@ fn test_node_contract_billing_cycles_cancel_contract_during_cycle_without_balanc let total_amount_billed = initial_twin_balance - usable_balance; let extrinsic_fee = 10000; - Balances::transfer( - &bob(), - &alice(), + Balances::transfer_keep_alive( + RuntimeOrigin::signed(bob()), + alice(), initial_twin_balance - total_amount_billed - extrinsic_fee, - ExistenceRequirement::AllowDeath, ) .unwrap(); @@ -1642,13 +1641,7 @@ fn test_restore_node_contract_in_grace_works() { run_to_block(31, Some(&mut pool_state)); run_to_block(41, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer( - &bob(), - &charlie(), - 100000000, - ExistenceRequirement::AllowDeath, - ) - .unwrap(); + Balances::transfer_keep_alive(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); run_to_block(52, Some(&mut pool_state)); run_to_block(62, Some(&mut pool_state)); @@ -1861,7 +1854,9 @@ fn test_rent_contract_billing_cancel_should_bill_reserved_balance() { .should_call_bill_contract(contract_id, Ok(Pays::Yes.into()), 11); run_to_block(11, Some(&mut pool_state)); - let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, 2, 10); + let bob_twin_id = 2; + let (amount_due_as_u128, discount_received) = + calculate_tft_cost(contract_id, bob_twin_id, 10); assert_ne!(amount_due_as_u128, 0); check_report_cost( contract_id, @@ -1870,39 +1865,33 @@ fn test_rent_contract_billing_cancel_should_bill_reserved_balance() { discount_received.clone(), ); - let twin = TfgridModule::twins(2).unwrap(); - let usable_balance = Balances::usable_balance(&twin.account_id); - let free_balance = Balances::free_balance(&twin.account_id); - assert_ne!(usable_balance, free_balance); + let bob_twin = TfgridModule::twins(bob_twin_id).unwrap(); + let usable_balance = Balances::usable_balance(&bob_twin.account_id); + let free_balance = Balances::free_balance(&bob_twin.account_id); + assert_ne!(usable_balance, free_balance); // there is some locked balance + let locked_balance = free_balance - usable_balance; run_to_block(13, Some(&mut pool_state)); // cancel contract // it will bill before removing the contract and it should bill all // reserved balance - let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, 2, 2); + let (amount_due_as_u128, discount_received) = + calculate_tft_cost(contract_id, bob_twin_id, 2); + assert_ok!(SmartContractModule::cancel_contract( RuntimeOrigin::signed(bob()), contract_id )); - let twin = TfgridModule::twins(2).unwrap(); - let usable_balance = Balances::usable_balance(&twin.account_id); - assert_ne!(usable_balance, 0); - Balances::transfer( - &bob(), - &alice(), - usable_balance, - ExistenceRequirement::AllowDeath, - ) - .unwrap(); - // Last amount due is the same as the first one assert_ne!(amount_due_as_u128, 0); check_report_cost(contract_id, amount_due_as_u128, 13, discount_received); - let usable_balance = Balances::usable_balance(&twin.account_id); - let free_balance = Balances::free_balance(&twin.account_id); - assert_eq!(usable_balance, free_balance); + let usable_balance = Balances::usable_balance(&bob_twin.account_id); + let past_free_balance = free_balance; + let free_balance = Balances::free_balance(&bob_twin.account_id); + assert_eq!(usable_balance, free_balance); // there is no more locked balance + assert_eq!(past_free_balance - free_balance, locked_balance); // locked balance was transfered to alice }); } @@ -2271,13 +2260,7 @@ fn test_restore_rent_contract_in_grace_works() { run_to_block(31, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer( - &bob(), - &charlie(), - 100000000, - ExistenceRequirement::AllowDeath, - ) - .unwrap(); + Balances::transfer_keep_alive(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); pool_state .write() @@ -2380,13 +2363,7 @@ fn test_restore_rent_contract_and_node_contracts_in_grace_works() { run_to_block(32, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer( - &bob(), - &charlie(), - 100000000, - ExistenceRequirement::AllowDeath, - ) - .unwrap(); + Balances::transfer_keep_alive(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); pool_state .write() @@ -3342,17 +3319,11 @@ fn test_service_contract_bill_out_of_funds_fails() { approve_service_consumer_contract(service_contract_id); // Drain consumer account - let consumer_twin = TfgridModule::twins(2).unwrap(); - let consumer_balance = Balances::free_balance(&consumer_twin.account_id); - Balances::transfer( - &bob(), - &alice(), - consumer_balance, - ExistenceRequirement::AllowDeath, - ) - .unwrap(); - let consumer_balance = Balances::free_balance(&consumer_twin.account_id); - assert_eq!(consumer_balance, 0); + let consumer_twin_id = 2; + let consumer_twin = TfgridModule::twins(consumer_twin_id).unwrap(); + Balances::transfer_all(RuntimeOrigin::signed(bob()), alice(), true).unwrap(); + let consumer_free_balance = Balances::free_balance(&consumer_twin.account_id); + assert_eq!(consumer_free_balance, EXISTENTIAL_DEPOSIT); // Bill 1h after contract approval run_to_block(601, Some(&mut pool_state)); @@ -3412,7 +3383,7 @@ fn test_lock() { let id: u64 = 1; // Try to lock less than EXISTENTIAL_DEPOSIT should fail - Balances::set_lock(id.to_be_bytes(), &bob(), 100, WithdrawReasons::all()); + Balances::set_lock(id.to_be_bytes(), &bob(), 1, WithdrawReasons::all()); // usable balance should now return free balance - EXISTENTIAL_DEPOSIT cause there was some activity let usable_balance = Balances::usable_balance(&bob()); @@ -3421,7 +3392,7 @@ fn test_lock() { // ----- INITIAL ------ // // Try to lock more than EXISTENTIAL_DEPOSIT should succeed - let to_lock = 100 + EXISTENTIAL_DEPOSIT; + let to_lock = 1 + EXISTENTIAL_DEPOSIT; Balances::set_lock(id.to_be_bytes(), &bob(), to_lock, WithdrawReasons::all()); @@ -3432,7 +3403,7 @@ fn test_lock() { // ----- UPDATE ------ // // updating a lock should succeed - let to_lock = 500 + EXISTENTIAL_DEPOSIT; + let to_lock = 10 + EXISTENTIAL_DEPOSIT; Balances::set_lock(id.to_be_bytes(), &bob(), to_lock, WithdrawReasons::all()); From a782d2725e7f4a7ce30afce41ef2d7c2e9a65516 Mon Sep 17 00:00:00 2001 From: renauter Date: Thu, 29 Aug 2024 23:33:53 -0300 Subject: [PATCH 26/31] update Cargo.lock --- substrate-node/Cargo.lock | 298 +++++++++++++++++++------------------- 1 file changed, 147 insertions(+), 151 deletions(-) diff --git a/substrate-node/Cargo.lock b/substrate-node/Cargo.lock index a284cc150..68a68d8c6 100644 --- a/substrate-node/Cargo.lock +++ b/substrate-node/Cargo.lock @@ -315,24 +315,10 @@ dependencies = [ "parity-scale-codec 3.6.9", ] -[[package]] -name = "ark-scale" -version = "0.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f69c00b3b529be29528a6f2fd5fa7b1790f8bed81b9cdca17e326538545a179" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-serialize", - "ark-std", - "parity-scale-codec 3.6.9", - "scale-info", -] - [[package]] name = "ark-secret-scalar" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=f4fe253#f4fe2534ccc6d916cd10d9c16891e673728ec8b4" dependencies = [ "ark-ec", "ark-ff", @@ -380,7 +366,7 @@ dependencies = [ [[package]] name = "ark-transcript" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=f4fe253#f4fe2534ccc6d916cd10d9c16891e673728ec8b4" dependencies = [ "ark-ff", "ark-serialize", @@ -573,13 +559,12 @@ dependencies = [ [[package]] name = "bandersnatch_vrfs" version = "0.0.1" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=f4fe253#f4fe2534ccc6d916cd10d9c16891e673728ec8b4" dependencies = [ "ark-bls12-381", "ark-ec", "ark-ed-on-bls12-381-bandersnatch", "ark-ff", - "ark-scale 0.0.12", "ark-serialize", "ark-std", "dleq_vrf", @@ -1076,7 +1061,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +source = "git+https://github.com/w3f/ring-proof?rev=8657210#86572101f4210647984ab4efedba6b3fcc890895" dependencies = [ "ark-ec", "ark-ff", @@ -1085,6 +1070,7 @@ dependencies = [ "ark-std", "fflonk", "merlin 3.0.0", + "rand_chacha 0.3.1", ] [[package]] @@ -1608,9 +1594,9 @@ dependencies = [ [[package]] name = "directories" -version = "4.0.1" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" dependencies = [ "dirs-sys", ] @@ -1627,13 +1613,14 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1661,11 +1648,11 @@ dependencies = [ [[package]] name = "dleq_vrf" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=f4fe253#f4fe2534ccc6d916cd10d9c16891e673728ec8b4" dependencies = [ "ark-ec", "ark-ff", - "ark-scale 0.0.10", + "ark-scale", "ark-secret-scalar", "ark-serialize", "ark-std", @@ -2062,7 +2049,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", ] @@ -2085,7 +2072,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support", "frame-support-procedural", @@ -2110,7 +2097,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "Inflector", "array-bytes", @@ -2158,7 +2145,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -2169,7 +2156,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2186,7 +2173,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support", "frame-system", @@ -2216,7 +2203,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-recursion", "futures", @@ -2238,7 +2225,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -2278,7 +2265,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "Inflector", "cfg-expr", @@ -2296,7 +2283,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.3", @@ -2308,7 +2295,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "proc-macro2", "quote", @@ -2318,7 +2305,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "cfg-if", "frame-support", @@ -2337,7 +2324,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-support", @@ -2352,7 +2339,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -2361,7 +2348,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support", "parity-scale-codec 3.6.9", @@ -4542,10 +4529,16 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support", "frame-system", @@ -4562,7 +4555,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support", "frame-system", @@ -4576,7 +4569,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-support", @@ -4609,7 +4602,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-support", @@ -4649,7 +4642,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-support", @@ -4688,7 +4681,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-support", @@ -4717,7 +4710,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "docify", "frame-benchmarking", @@ -4735,7 +4728,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support", "frame-system", @@ -4757,7 +4750,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-support", @@ -4805,7 +4798,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4901,8 +4894,9 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", @@ -4920,7 +4914,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-support", "frame-system", @@ -4936,7 +4930,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -4952,7 +4946,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "pallet-transaction-payment", "parity-scale-codec 3.6.9", @@ -4964,7 +4958,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-benchmarking", "frame-support", @@ -5925,13 +5919,14 @@ dependencies = [ [[package]] name = "ring" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +source = "git+https://github.com/w3f/ring-proof?rev=8657210#86572101f4210647984ab4efedba6b3fcc890895" dependencies = [ "ark-ec", "ark-ff", "ark-poly", "ark-serialize", "ark-std", + "blake2", "common", "fflonk", "merlin 3.0.0", @@ -6174,7 +6169,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "log", "sp-core", @@ -6185,7 +6180,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "futures", "futures-timer", @@ -6208,7 +6203,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "sc-client-api", @@ -6223,7 +6218,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -6242,7 +6237,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -6253,7 +6248,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "chrono", @@ -6292,7 +6287,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "fnv", "futures", @@ -6312,13 +6307,14 @@ dependencies = [ "sp-state-machine", "sp-statement-store", "sp-storage", + "sp-trie", "substrate-prometheus-endpoint", ] [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "hash-db", "kvdb", @@ -6344,7 +6340,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "futures", @@ -6369,7 +6365,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "futures", @@ -6398,7 +6394,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "ahash 0.8.7", "array-bytes", @@ -6439,7 +6435,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "futures", @@ -6462,7 +6458,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "parking_lot 0.12.1", @@ -6484,7 +6480,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -6496,7 +6492,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "anyhow", "cfg-if", @@ -6513,7 +6509,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "ansi_term", "futures", @@ -6529,7 +6525,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "parking_lot 0.12.1", @@ -6543,7 +6539,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "async-channel", @@ -6584,7 +6580,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-channel", "cid", @@ -6604,7 +6600,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -6621,7 +6617,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "ahash 0.8.7", "futures", @@ -6639,7 +6635,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "async-channel", @@ -6660,7 +6656,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "async-channel", @@ -6694,7 +6690,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "futures", @@ -6712,7 +6708,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "bytes", @@ -6746,7 +6742,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -6755,7 +6751,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "futures", "jsonrpsee", @@ -6786,7 +6782,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "jsonrpsee", "parity-scale-codec 3.6.9", @@ -6805,7 +6801,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "http", "jsonrpsee", @@ -6820,7 +6816,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", "futures", @@ -6848,7 +6844,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "directories", @@ -6912,7 +6908,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "log", "parity-scale-codec 3.6.9", @@ -6923,7 +6919,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "futures", "libc", @@ -6942,7 +6938,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "chrono", "futures", @@ -6961,7 +6957,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "ansi_term", "atty", @@ -6990,7 +6986,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -7001,7 +6997,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "futures", @@ -7027,7 +7023,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "futures", @@ -7043,7 +7039,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-channel", "futures", @@ -7474,7 +7470,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "hash-db", "log", @@ -7495,7 +7491,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "Inflector", "blake2", @@ -7509,7 +7505,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -7522,7 +7518,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "integer-sqrt", "num-traits", @@ -7536,7 +7532,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "sp-api", "sp-inherents", @@ -7547,7 +7543,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "futures", "log", @@ -7565,7 +7561,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "futures", @@ -7580,7 +7576,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "parity-scale-codec 3.6.9", @@ -7597,7 +7593,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "parity-scale-codec 3.6.9", @@ -7616,7 +7612,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "finality-grandpa", "log", @@ -7634,7 +7630,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -7646,10 +7642,9 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "array-bytes", - "arrayvec 0.7.4", "bandersnatch_vrfs", "bitflags 1.3.2", "blake2", @@ -7693,7 +7688,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "blake2b_simd", "byteorder", @@ -7706,7 +7701,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "quote", "sp-core-hashing", @@ -7716,7 +7711,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -7725,7 +7720,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "proc-macro2", "quote", @@ -7735,7 +7730,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "environmental", "parity-scale-codec 3.6.9", @@ -7746,7 +7741,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "serde_json", "sp-api", @@ -7757,7 +7752,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -7771,7 +7766,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "bytes", "ed25519-dalek", @@ -7795,7 +7790,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "lazy_static", "sp-core", @@ -7806,7 +7801,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "parking_lot 0.12.1", @@ -7818,7 +7813,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "thiserror", "zstd 0.12.4", @@ -7827,7 +7822,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-metadata", "parity-scale-codec 3.6.9", @@ -7838,7 +7833,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -7852,7 +7847,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "sp-api", "sp-core", @@ -7862,7 +7857,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "backtrace", "lazy_static", @@ -7872,7 +7867,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "rustc-hash", "serde", @@ -7882,7 +7877,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "either", "hash256-std-hasher", @@ -7904,7 +7899,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -7922,7 +7917,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "Inflector", "proc-macro-crate 1.1.3", @@ -7934,7 +7929,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -7949,7 +7944,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec 3.6.9", @@ -7963,7 +7958,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "hash-db", "log", @@ -7984,7 +7979,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "aes-gcm", "curve25519-dalek 4.1.1", @@ -8013,12 +8008,12 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6f [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "impl-serde", "parity-scale-codec 3.6.9", @@ -8031,7 +8026,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "parity-scale-codec 3.6.9", @@ -8044,7 +8039,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "sp-std 8.0.0", @@ -8056,7 +8051,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "sp-api", "sp-runtime", @@ -8065,7 +8060,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "parity-scale-codec 3.6.9", @@ -8080,7 +8075,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "ahash 0.8.7", "hash-db", @@ -8103,7 +8098,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "impl-serde", "parity-scale-codec 3.6.9", @@ -8120,7 +8115,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "proc-macro2", @@ -8131,7 +8126,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -8144,7 +8139,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -8307,7 +8302,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" [[package]] name = "substrate-fixed" @@ -8321,7 +8316,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -8340,7 +8335,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "hyper", "log", @@ -8352,7 +8347,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "jsonrpsee", @@ -8400,7 +8395,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "ansi_term", "build-helper", @@ -8604,6 +8599,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-offchain", "sp-runtime", @@ -9032,9 +9028,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" +checksum = "ff28e0f815c2fea41ebddf148e008b077d2faddb026c9555b29696114d602642" dependencies = [ "hash-db", "hashbrown 0.13.2", @@ -9107,7 +9103,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-v1.2.0#72c453563937c36b895c543bc5e852e213a54f19" dependencies = [ "async-trait", "clap", From 6ea53f8584ff337ba4d3ffa931aaeaa8ffdf3cda Mon Sep 17 00:00:00 2001 From: renauter Date: Thu, 29 Aug 2024 23:36:56 -0300 Subject: [PATCH 27/31] update smart-contract tests --- .../pallet-smart-contract/src/tests.rs | 86 ++++++++++++------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/substrate-node/pallets/pallet-smart-contract/src/tests.rs b/substrate-node/pallets/pallet-smart-contract/src/tests.rs index 8fe7572e9..94c41b6fa 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/tests.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/tests.rs @@ -981,7 +981,8 @@ fn test_node_contract_billing_details() { TFTPriceModule::set_prices(RuntimeOrigin::signed(alice()), 50, 101).unwrap(); - let twin = TfgridModule::twins(2).unwrap(); + let twin_id = 2; + let twin = TfgridModule::twins(twin_id).unwrap(); let initial_twin_balance = Balances::total_balance(&twin.account_id); assert_ok!(SmartContractModule::create_node_contract( @@ -1040,7 +1041,8 @@ fn test_node_contract_billing_works_for_non_existing_accounts() { TFTPriceModule::set_prices(RuntimeOrigin::signed(alice()), 50, 101).unwrap(); - let twin = TfgridModule::twins(2).unwrap(); + let twin_id = 2; + let twin = TfgridModule::twins(twin_id).unwrap(); let initial_twin_balance = Balances::total_balance(&twin.account_id); assert_ok!(SmartContractModule::create_node_contract( @@ -1124,7 +1126,8 @@ fn test_billing_node_contract_in_graceperiod_should_reset_unbilled_network_consu assert_eq!(c1.state, types::ContractState::GracePeriod(11)); // contract payment should be overdrawn - let contract_payment_state = SmartContractModule::contract_payment_state(contract_id).unwrap(); + let contract_payment_state = + SmartContractModule::contract_payment_state(contract_id).unwrap(); assert_ne!(contract_payment_state.get_overdraft(), 0); // amount unbilled should have been reset after adding the amount to the contract overdraft @@ -1148,7 +1151,8 @@ fn test_node_contract_billing_details_with_solution_provider() { TFTPriceModule::set_prices(RuntimeOrigin::signed(alice()), 50, 101).unwrap(); - let twin = TfgridModule::twins(2).unwrap(); + let twin_id = 2; + let twin = TfgridModule::twins(twin_id).unwrap(); let initial_twin_balance = Balances::free_balance(&twin.account_id); let initial_farmer_balance = Balances::free_balance(alice()); @@ -1623,7 +1627,8 @@ fn test_node_contract_billing_cycles_cancel_contract_during_cycle_without_balanc TFTPriceModule::set_prices(RuntimeOrigin::signed(alice()), 50, 101).unwrap(); - let twin = TfgridModule::twins(2).unwrap(); + let twin_id = 2; + let twin = TfgridModule::twins(twin_id).unwrap(); let initial_twin_balance = Balances::free_balance(&twin.account_id); info!("initial twin balance: {:?}", initial_twin_balance); let initial_farmer_balance = Balances::free_balance(alice()); @@ -1637,7 +1642,6 @@ fn test_node_contract_billing_cycles_cancel_contract_during_cycle_without_balanc None )); let contract_id = 1; - let twin_id = 2; push_contract_resources_used(contract_id); let (amount_due_1, discount_received) = calculate_tft_cost(contract_id, twin_id, 10); @@ -1663,7 +1667,7 @@ fn test_node_contract_billing_cycles_cancel_contract_during_cycle_without_balanc info!("total amount billed: {:?}", total_amount_billed); let leave = 1000; - Balances::transfer( + Balances::transfer_allow_death( RuntimeOrigin::signed(bob()), charlie(), initial_twin_balance - total_amount_billed - leave, @@ -1816,7 +1820,7 @@ fn test_restore_node_contract_in_grace_works() { run_to_block(31, Some(&mut pool_state)); run_to_block(41, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); + Balances::transfer_allow_death(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); run_to_block(52, Some(&mut pool_state)); run_to_block(62, Some(&mut pool_state)); @@ -2009,6 +2013,7 @@ fn test_rent_contract_billing() { node_id, None )); + let twin_id = 2; let contract_id = 1; let contract = SmartContractModule::contracts(contract_id).unwrap(); @@ -2038,7 +2043,7 @@ fn test_rent_contract_billing() { run_to_block(21, Some(&mut pool_state)); // should bill partial cycle 2 [15-21], 6 blocks - let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, 2, 6); + let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, twin_id, 6); assert_ne!(amount_due_as_u128, 0); check_report_cost(contract_id, amount_due_as_u128, 21, discount_received); @@ -2075,7 +2080,7 @@ fn test_rent_contract_billing() { run_to_block(51, Some(&mut pool_state)); // should bill partial cycle 5 [45-51], 6 blocks - let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, 2, 6); + let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, twin_id, 6); assert_ne!(amount_due_as_u128, 0); check_report_cost(contract_id, amount_due_as_u128, 51, discount_received); }); @@ -2159,6 +2164,7 @@ fn test_rent_contract_billing_cancel_should_bill_reserved_balance() { node_id, None )); + let twin_id = 2; let contract_id = 1; let contract = SmartContractModule::contracts(contract_id).unwrap(); @@ -2173,7 +2179,8 @@ fn test_rent_contract_billing_cancel_should_bill_reserved_balance() { .should_call_bill_contract(contract_id, Ok(Pays::Yes.into()), 11); run_to_block(11, Some(&mut pool_state)); - let (amount_due_1_as_u128, discount_received) = calculate_tft_cost(contract_id, 2, 10); + let (amount_due_1_as_u128, discount_received) = + calculate_tft_cost(contract_id, twin_id, 10); assert_ne!(amount_due_1_as_u128, 0); check_report_cost( contract_id, @@ -2182,7 +2189,7 @@ fn test_rent_contract_billing_cancel_should_bill_reserved_balance() { discount_received.clone(), ); - let twin = TfgridModule::twins(2).unwrap(); + let twin = TfgridModule::twins(twin_id).unwrap(); let total_balance = Balances::total_balance(&twin.account_id); let free_balance = Balances::free_balance(&twin.account_id); assert_ne!(total_balance, free_balance); @@ -2191,16 +2198,16 @@ fn test_rent_contract_billing_cancel_should_bill_reserved_balance() { // cancel contract // it will bill before removing the contract and it should bill all // reserved balance - let (amount_due_2_as_u128, discount_received) = calculate_tft_cost(contract_id, 2, 2); + let (amount_due_2_as_u128, discount_received) = calculate_tft_cost(contract_id, twin_id, 2); assert_ok!(SmartContractModule::cancel_contract( RuntimeOrigin::signed(bob()), contract_id )); - let twin = TfgridModule::twins(2).unwrap(); let usable_balance = Balances::usable_balance(&twin.account_id); assert_ne!(usable_balance, 0); - Balances::transfer(RuntimeOrigin::signed(bob()), alice(), usable_balance).unwrap(); + Balances::transfer_allow_death(RuntimeOrigin::signed(bob()), alice(), usable_balance) + .unwrap(); // Last amount due is not the same as the first one assert_ne!(amount_due_1_as_u128, amount_due_2_as_u128); @@ -2229,9 +2236,10 @@ fn test_rent_contract_overdrawn_and_partial_bill() { node_id, None )); + let twin_id = 3; let contract_id = 1; - let twin = TfgridModule::twins(3).unwrap(); + let twin = TfgridModule::twins(twin_id).unwrap(); let initial_reservable_balance = Balances::usable_balance(&twin.account_id) - EXISTENTIAL_DEPOSIT; @@ -2247,7 +2255,7 @@ fn test_rent_contract_overdrawn_and_partial_bill() { .should_call_bill_contract(contract_id, Ok(Pays::Yes.into()), 11); run_to_block(11, Some(&mut pool_state)); - let (amount_due_per_cycle, _) = calculate_tft_cost(contract_id, 2, 10); + let (amount_due_per_cycle, _) = calculate_tft_cost(contract_id, twin_id, 10); assert_ne!(amount_due_per_cycle, 0); // expect contractPaymentOverdarwn event with partially billed amount @@ -2264,7 +2272,8 @@ fn test_rent_contract_overdrawn_and_partial_bill() { true ); - let contract_payment_state = SmartContractModule::contract_payment_state(contract_id).unwrap(); + let contract_payment_state = + SmartContractModule::contract_payment_state(contract_id).unwrap(); assert_eq!( contract_payment_state.get_reserve(), initial_reservable_balance @@ -2295,7 +2304,8 @@ fn test_rent_contract_overdrawn_and_partial_bill() { ))), true ); - let contract_payment_state = SmartContractModule::contract_payment_state(contract_id).unwrap(); + let contract_payment_state = + SmartContractModule::contract_payment_state(contract_id).unwrap(); assert_eq!( contract_payment_state.get_reserve(), initial_reservable_balance @@ -2307,7 +2317,7 @@ fn test_rent_contract_overdrawn_and_partial_bill() { let should_have_next_cycle = amount_due_per_cycle * 3 - initial_reservable_balance; // transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer( + Balances::transfer_allow_death( RuntimeOrigin::signed(bob()), charlie(), should_have_next_cycle, @@ -2319,7 +2329,8 @@ fn test_rent_contract_overdrawn_and_partial_bill() { .should_call_bill_contract(contract_id, Ok(Pays::Yes.into()), 31); run_to_block(31, Some(&mut pool_state)); - let contract_payment_state = SmartContractModule::contract_payment_state(contract_id).unwrap(); + let contract_payment_state = + SmartContractModule::contract_payment_state(contract_id).unwrap(); assert_eq!( contract_payment_state.get_reserve(), amount_due_per_cycle * 3 @@ -2349,6 +2360,7 @@ fn test_rent_contract_canceled_mid_cycle_should_bill_for_remainder() { node_id, None )); + let twin_id = 2; let contract_id = 1; let contract = SmartContractModule::contracts(contract_id).unwrap(); @@ -2358,14 +2370,14 @@ fn test_rent_contract_canceled_mid_cycle_should_bill_for_remainder() { types::ContractData::RentContract(rent_contract) ); - let twin = TfgridModule::twins(2).unwrap(); + let twin = TfgridModule::twins(twin_id).unwrap(); let reserved_balance = Balances::reserved_balance(&twin.account_id); info!("reserved balance: {:?}", reserved_balance); run_to_block(8, Some(&mut pool_state)); // Calculate the cost for 7 blocks of runtime (created a block 1, canceled at block 8) - let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, 2, 7); + let (amount_due_as_u128, discount_received) = calculate_tft_cost(contract_id, twin_id, 7); // cancel rent contract at block 8 assert_ok!(SmartContractModule::cancel_contract( RuntimeOrigin::signed(bob()), @@ -2380,7 +2392,7 @@ fn test_rent_contract_canceled_mid_cycle_should_bill_for_remainder() { ); // Twin should have no more reserved balance - let twin = TfgridModule::twins(2).unwrap(); + let twin = TfgridModule::twins(twin_id).unwrap(); let reserved_balance = Balances::reserved_balance(&twin.account_id); assert_eq!(reserved_balance, 0); }); @@ -2413,6 +2425,7 @@ fn test_create_rent_contract_and_node_contract_excludes_node_contract_from_billi 0, None )); + let twin_id = 2; let node_contract_id = 2; push_contract_resources_used(node_contract_id); @@ -2425,7 +2438,8 @@ fn test_create_rent_contract_and_node_contract_excludes_node_contract_from_billi .should_call_bill_contract(node_contract_id, Ok(Pays::Yes.into()), 12); run_to_block(12, Some(&mut pool_state)); - let (amount_due_as_u128, discount_received) = calculate_tft_cost(rent_contract_id, 2, 10); + let (amount_due_as_u128, discount_received) = + calculate_tft_cost(rent_contract_id, twin_id, 10); assert_ne!(amount_due_as_u128, 0); check_report_cost(rent_contract_id, amount_due_as_u128, 11, discount_received); @@ -2567,6 +2581,7 @@ fn test_create_rent_contract_and_node_contract_with_ip_billing_works() { node_id, None )); + let twin_id = 2; let rent_contract_id = 1; run_to_block(2, Some(&mut pool_state)); @@ -2588,7 +2603,8 @@ fn test_create_rent_contract_and_node_contract_with_ip_billing_works() { run_to_block(11, Some(&mut pool_state)); // check contract 1 costs (Rent Contract) - let (amount_due_as_u128, discount_received) = calculate_tft_cost(rent_contract_id, 2, 10); + let (amount_due_as_u128, discount_received) = + calculate_tft_cost(rent_contract_id, twin_id, 10); assert_ne!(amount_due_as_u128, 0); check_report_cost(rent_contract_id, amount_due_as_u128, 11, discount_received); @@ -2598,7 +2614,8 @@ fn test_create_rent_contract_and_node_contract_with_ip_billing_works() { run_to_block(12, Some(&mut pool_state)); // check contract 2 costs (Node Contract) - let (amount_due_as_u128, discount_received) = calculate_tft_cost(node_contract_id, 2, 10); + let (amount_due_as_u128, discount_received) = + calculate_tft_cost(node_contract_id, twin_id, 10); assert_ne!(amount_due_as_u128, 0); check_report_cost(node_contract_id, amount_due_as_u128, 12, discount_received); @@ -2700,7 +2717,7 @@ fn test_restore_rent_contract_in_grace_works() { run_to_block(31, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); + Balances::transfer_allow_death(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); pool_state .write() @@ -2805,7 +2822,7 @@ fn test_restore_rent_contract_and_node_contracts_in_grace_works() { run_to_block(32, Some(&mut pool_state)); // Transfer some balance to the owner of the contract to trigger the grace period to stop - Balances::transfer(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); + Balances::transfer_allow_death(RuntimeOrigin::signed(bob()), charlie(), 100000000).unwrap(); pool_state .write() @@ -3576,7 +3593,8 @@ fn test_service_contract_bill_works() { get_timestamp_in_seconds_for_block(1) ); - let consumer_twin = TfgridModule::twins(2).unwrap(); + let consumer_twin_id = 2; + let consumer_twin = TfgridModule::twins(consumer_twin_id).unwrap(); let consumer_balance = Balances::free_balance(&consumer_twin.account_id); assert_eq!(consumer_balance, 2500000000); @@ -3584,7 +3602,7 @@ fn test_service_contract_bill_works() { run_to_block(201, Some(&mut pool_state)); assert_ok!(SmartContractModule::service_contract_bill( RuntimeOrigin::signed(alice()), - 1, + service_contract_id, VARIABLE_AMOUNT, b"bill_metadata_1".to_vec(), )); @@ -3766,9 +3784,11 @@ fn test_service_contract_bill_out_of_funds_fails() { approve_service_consumer_contract(service_contract_id); // Drain consumer account - let consumer_twin = TfgridModule::twins(2).unwrap(); + let twin_id = 2; + let consumer_twin = TfgridModule::twins(twin_id).unwrap(); let consumer_balance = Balances::free_balance(&consumer_twin.account_id); - Balances::transfer(RuntimeOrigin::signed(bob()), alice(), consumer_balance).unwrap(); + Balances::transfer_allow_death(RuntimeOrigin::signed(bob()), alice(), consumer_balance) + .unwrap(); let consumer_balance = Balances::free_balance(&consumer_twin.account_id); assert_eq!(consumer_balance, 0); From 3116f40b78d3130ca404768233917a8f19e0862f Mon Sep 17 00:00:00 2001 From: renauter Date: Fri, 30 Aug 2024 00:31:32 -0300 Subject: [PATCH 28/31] skip check-benchmark-weights From b876984b436885c715af4226b8a5c6dcec84ec71 Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 2 Sep 2024 13:56:27 -0300 Subject: [PATCH 29/31] restore EXISTENTIAL_DEPOSIT value for tests --- substrate-node/pallets/pallet-smart-contract/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate-node/pallets/pallet-smart-contract/src/mock.rs b/substrate-node/pallets/pallet-smart-contract/src/mock.rs index 4f4a07c5e..2a4f00357 100644 --- a/substrate-node/pallets/pallet-smart-contract/src/mock.rs +++ b/substrate-node/pallets/pallet-smart-contract/src/mock.rs @@ -145,7 +145,7 @@ impl frame_system::Config for TestRuntime { type MaxConsumers = ConstU32<16>; } -pub const EXISTENTIAL_DEPOSIT: u64 = 2; +pub const EXISTENTIAL_DEPOSIT: u64 = 500; parameter_types! { pub const MaxLocks: u32 = 50; From e26cd25f46efe221f6d641fa3086a16f82a0c618 Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 2 Sep 2024 13:57:40 -0300 Subject: [PATCH 30/31] ensure migration idempotency --- .../pallets/pallet-tft-bridge/src/migrations/v2.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs index 28dc6dc8b..abb85715a 100644 --- a/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs +++ b/substrate-node/pallets/pallet-tft-bridge/src/migrations/v2.rs @@ -18,7 +18,7 @@ impl OnRuntimeUpgrade for MigrateBurnTransactionsV2 { fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); ensure!( - PalletVersion::::get() == types::StorageVersion::V1, + PalletVersion::::get() >= types::StorageVersion::V1, DispatchError::Other("Unexpected pallet version") ); @@ -36,7 +36,7 @@ impl OnRuntimeUpgrade for MigrateBurnTransactionsV2 { executed_burn_transactions_count ); - info!("👥 TFT-BRIDGE pallet to V1 passes PRE migrate checks ✅",); + info!("👥 TFT-BRIDGE pallet to V2 passes PRE migrate checks ✅",); Ok(Vec::::new()) } @@ -55,7 +55,7 @@ impl OnRuntimeUpgrade for MigrateBurnTransactionsV2 { ) -> Result<(), sp_runtime::TryRuntimeError> { info!("current pallet version: {:?}", PalletVersion::::get()); ensure!( - PalletVersion::::get() == types::StorageVersion::V2, + PalletVersion::::get() >= types::StorageVersion::V2, DispatchError::Other("Unexpected pallet version") ); From 0966b08ed375a304966b731aecb6d0364520a3ff Mon Sep 17 00:00:00 2001 From: renauter Date: Mon, 2 Sep 2024 14:00:45 -0300 Subject: [PATCH 31/31] skip check-benchmark-weights