From e6d53624b9346e9fee241112fb97e0ecdda3cb0e Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 5 Jan 2024 15:40:03 +0100 Subject: [PATCH 1/6] rpc: add `rpc v2 chainSpec` to polkadot,cumulus --- Cargo.lock | 2 ++ cumulus/parachain-template/node/Cargo.toml | 1 + cumulus/parachain-template/node/src/rpc.rs | 7 +++++++ cumulus/polkadot-parachain/Cargo.toml | 1 + cumulus/polkadot-parachain/src/rpc.rs | 6 ++++++ .../runtime_vs_smart_contract.rs | 21 ++++++++++++------- .../node/core/candidate-validation/src/lib.rs | 6 +++--- .../core/candidate-validation/src/tests.rs | 2 +- polkadot/rpc/Cargo.toml | 1 + polkadot/rpc/src/lib.rs | 7 +++++++ substrate/bin/node-template/node/src/rpc.rs | 6 ++++++ .../client/consensus/beefy/src/import.rs | 2 +- substrate/client/consensus/beefy/src/lib.rs | 2 +- .../src/protocol/notifications/behaviour.rs | 2 +- substrate/frame/contracts/fixtures/build.rs | 6 +++--- .../src/construct_runtime/expand/task.rs | 2 +- substrate/frame/system/src/tests.rs | 2 +- substrate/primitives/core/src/address_uri.rs | 2 +- substrate/primitives/core/src/crypto.rs | 4 ++-- .../utils/wasm-builder/src/wasm_project.rs | 2 +- 20 files changed, 61 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 466fa26d4344..3376d3fdccff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13070,6 +13070,7 @@ dependencies = [ "sc-network", "sc-network-sync", "sc-rpc", + "sc-rpc-spec-v2", "sc-service", "sc-sysinfo", "sc-telemetry", @@ -13178,6 +13179,7 @@ dependencies = [ "sc-consensus-grandpa", "sc-consensus-grandpa-rpc", "sc-rpc", + "sc-rpc-spec-v2", "sc-sync-state-rpc", "sc-transaction-pool-api", "sp-api", diff --git a/cumulus/parachain-template/node/Cargo.toml b/cumulus/parachain-template/node/Cargo.toml index 865f310cd125..113ab3c568a6 100644 --- a/cumulus/parachain-template/node/Cargo.toml +++ b/cumulus/parachain-template/node/Cargo.toml @@ -39,6 +39,7 @@ sc-executor = { path = "../../../substrate/client/executor" } sc-network = { path = "../../../substrate/client/network" } sc-network-sync = { path = "../../../substrate/client/network/sync" } sc-rpc = { path = "../../../substrate/client/rpc" } +sc-rpc-spec-v2 = { path = "../../../substrate/client/rpc-spec-v2" } sc-service = { path = "../../../substrate/client/service" } sc-sysinfo = { path = "../../../substrate/client/sysinfo" } sc-telemetry = { path = "../../../substrate/client/telemetry" } diff --git a/cumulus/parachain-template/node/src/rpc.rs b/cumulus/parachain-template/node/src/rpc.rs index bb52b974f0ce..6eaa1933cfc7 100644 --- a/cumulus/parachain-template/node/src/rpc.rs +++ b/cumulus/parachain-template/node/src/rpc.rs @@ -45,12 +45,19 @@ where P: TransactionPool + Sync + Send + 'static, { use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; + let chain_name = chain_spec.name().to_string(); + let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + let properties = chain_spec.properties(); + + module.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client).into_rpc())?; + Ok(module) } diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index 34243f473e8d..db90de00f1d6 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -71,6 +71,7 @@ sp-block-builder = { path = "../../substrate/primitives/block-builder" } sp-keystore = { path = "../../substrate/primitives/keystore" } sc-chain-spec = { path = "../../substrate/client/chain-spec" } sc-rpc = { path = "../../substrate/client/rpc" } +sc-rpc-spec-v2 = { path = "../../substrate/client/rpc-spec-v2" } sp-version = { path = "../../substrate/primitives/version" } sc-tracing = { path = "../../substrate/client/tracing" } sp-offchain = { path = "../../substrate/primitives/offchain" } diff --git a/cumulus/polkadot-parachain/src/rpc.rs b/cumulus/polkadot-parachain/src/rpc.rs index caee14e55522..f69c560f379d 100644 --- a/cumulus/polkadot-parachain/src/rpc.rs +++ b/cumulus/polkadot-parachain/src/rpc.rs @@ -63,11 +63,17 @@ where { use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; + let chain_name = chain_spec.name().to_string(); + let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + let properties = chain_spec.properties(); + io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; + module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; module.merge(StateMigration::new(client, backend, deny_unsafe).into_rpc())?; diff --git a/docs/sdk/src/reference_docs/runtime_vs_smart_contract.rs b/docs/sdk/src/reference_docs/runtime_vs_smart_contract.rs index 16db44d8be49..099512cf4ee1 100644 --- a/docs/sdk/src/reference_docs/runtime_vs_smart_contract.rs +++ b/docs/sdk/src/reference_docs/runtime_vs_smart_contract.rs @@ -32,14 +32,21 @@ //! //! ## Comparative Table //! -//! | Aspect | Runtime | Smart Contracts | +//! | Aspect | Runtime +//! | Smart Contracts | //! |-----------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------| -//! | **Design Philosophy** | Core logic of a blockchain, allowing broad and deep customization. | Designed for DApps deployed on the blockchain runtime.| -//! | **Development Complexity** | Requires in-depth knowledge of Rust and Substrate. Suitable for complex blockchain architectures. | Easier to develop with knowledge of Smart Contract languages like Solidity or [ink!](https://use.ink/). | -//! | **Upgradeability and Flexibility** | Offers comprehensive upgradeability with migration logic and on-chain governance, allowing modifications to the entire blockchain logic without hard forks. | Less flexible in upgrade migrations but offers more straightforward deployment and iteration. | -//! | **Performance and Efficiency** | More efficient, optimized for specific needs of the blockchain. | Can be less efficient due to its generic nature (e.g. the overhead of a virtual machine). | -//! | **Security Considerations** | Security flaws can affect the entire blockchain. | Security risks usually localized to the individual contract. | -//! | **Weighing and Metering** | Operations can be weighed, allowing for precise benchmarking. | Execution is metered, allowing for measurement of resource consumption. | +//! | **Design Philosophy** | Core logic of a blockchain, allowing broad and deep customization. +//! | Designed for DApps deployed on the blockchain runtime.| | **Development Complexity** | Requires in-depth knowledge of Rust and Substrate. Suitable for complex blockchain architectures. | Easier to develop with knowledge of Smart Contract languages like Solidity or [ink!](https://use.ink/). | +//! | **Upgradeability and Flexibility** | Offers comprehensive upgradeability with migration logic +//! and on-chain governance, allowing modifications to the entire blockchain logic without hard +//! forks. | Less flexible in upgrade migrations but offers more straightforward deployment and +//! iteration. | | **Performance and Efficiency** | More efficient, optimized for specific needs of +//! the blockchain. | Can be less efficient due to its generic nature (e.g. the overhead of a +//! virtual machine). | | **Security Considerations** | Security flaws can affect the entire +//! blockchain. | Security risks usually localized to the individual +//! contract. | | **Weighing and Metering** | Operations can be weighed, allowing for precise +//! benchmarking. | Execution is metered, allowing for measurement of resource +//! consumption. | //! //! We will now explore these differences in more detail. //! diff --git a/polkadot/node/core/candidate-validation/src/lib.rs b/polkadot/node/core/candidate-validation/src/lib.rs index 5c4e449b2c90..18c279689158 100644 --- a/polkadot/node/core/candidate-validation/src/lib.rs +++ b/polkadot/node/core/candidate-validation/src/lib.rs @@ -773,21 +773,21 @@ trait ValidationBackend { if num_death_retries_left > 0 { num_death_retries_left -= 1; } else { - break; + break }, Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::JobError(_))) => if num_job_error_retries_left > 0 { num_job_error_retries_left -= 1; } else { - break; + break }, Err(ValidationError::Internal(_)) => if num_internal_retries_left > 0 { num_internal_retries_left -= 1; } else { - break; + break }, Ok(_) | Err(ValidationError::Invalid(_) | ValidationError::Preparation(_)) => break, diff --git a/polkadot/node/core/candidate-validation/src/tests.rs b/polkadot/node/core/candidate-validation/src/tests.rs index 110785804652..f646f8535495 100644 --- a/polkadot/node/core/candidate-validation/src/tests.rs +++ b/polkadot/node/core/candidate-validation/src/tests.rs @@ -726,7 +726,7 @@ fn candidate_validation_retry_on_error_helper( ExecutorParams::default(), exec_kind, &Default::default(), - )); + )) } #[test] diff --git a/polkadot/rpc/Cargo.toml b/polkadot/rpc/Cargo.toml index 8c582c623baf..dcb7a13f6f31 100644 --- a/polkadot/rpc/Cargo.toml +++ b/polkadot/rpc/Cargo.toml @@ -21,6 +21,7 @@ sp-consensus = { path = "../../substrate/primitives/consensus/common" } sp-consensus-babe = { path = "../../substrate/primitives/consensus/babe" } sc-chain-spec = { path = "../../substrate/client/chain-spec" } sc-rpc = { path = "../../substrate/client/rpc" } +sc-rpc-spec-v2 = { path = "../../substrate/client/rpc-spec-v2" } sc-consensus-babe = { path = "../../substrate/client/consensus/babe" } sc-consensus-babe-rpc = { path = "../../substrate/client/consensus/babe/rpc" } sc-consensus-beefy = { path = "../../substrate/client/consensus/beefy" } diff --git a/polkadot/rpc/src/lib.rs b/polkadot/rpc/src/lib.rs index bf9daddba505..5fd408a0e46a 100644 --- a/polkadot/rpc/src/lib.rs +++ b/polkadot/rpc/src/lib.rs @@ -99,6 +99,7 @@ pub fn create_full( ) -> Result> where C: ProvideRuntimeApi + + sc_client_api::BlockBackend + HeaderBackend + AuxStore + HeaderMetadata @@ -121,6 +122,7 @@ where use sc_consensus_babe_rpc::{Babe, BabeApiServer}; use sc_consensus_beefy_rpc::{Beefy, BeefyApiServer}; use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer}; + use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; use sc_sync_state_rpc::{SyncState, SyncStateApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; @@ -134,6 +136,11 @@ where finality_provider, } = grandpa; + let chain_name = chain_spec.name().to_string(); + let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + let properties = chain_spec.properties(); + + io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; io.merge(StateMigration::new(client.clone(), backend.clone(), deny_unsafe).into_rpc())?; io.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?; io.merge(TransactionPayment::new(client.clone()).into_rpc())?; diff --git a/substrate/bin/node-template/node/src/rpc.rs b/substrate/bin/node-template/node/src/rpc.rs index f4f1540f732f..68347e4ce8d0 100644 --- a/substrate/bin/node-template/node/src/rpc.rs +++ b/substrate/bin/node-template/node/src/rpc.rs @@ -45,6 +45,12 @@ where let mut module = RpcModule::new(()); let FullDeps { client, pool, deny_unsafe } = deps; + // Enable the `chainSpec rpc v2` interface. + let chain_name = chain_spec.name().to_string(); + let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + let properties = chain_spec.properties(); + io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; + module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client).into_rpc())?; diff --git a/substrate/client/consensus/beefy/src/import.rs b/substrate/client/consensus/beefy/src/import.rs index 5bbf07fba70a..6eced17b58ff 100644 --- a/substrate/client/consensus/beefy/src/import.rs +++ b/substrate/client/consensus/beefy/src/import.rs @@ -148,7 +148,7 @@ where // The block is imported as part of some chain sync. // The voter doesn't need to process it now. // It will be detected and processed as part of the voter state init. - return Ok(inner_import_result); + return Ok(inner_import_result) }, } diff --git a/substrate/client/consensus/beefy/src/lib.rs b/substrate/client/consensus/beefy/src/lib.rs index 51e82b6a8112..2e2e22288e3b 100644 --- a/substrate/client/consensus/beefy/src/lib.rs +++ b/substrate/client/consensus/beefy/src/lib.rs @@ -398,7 +398,7 @@ where header = wait_for_parent_header(backend.blockchain(), header, HEADER_SYNC_DELAY).await?; } - return Ok(state); + return Ok(state) } // No valid voter-state persisted, re-initialize from pallet genesis. diff --git a/substrate/client/network/src/protocol/notifications/behaviour.rs b/substrate/client/network/src/protocol/notifications/behaviour.rs index cdbf2a71b932..9ad41e376e82 100644 --- a/substrate/client/network/src/protocol/notifications/behaviour.rs +++ b/substrate/client/network/src/protocol/notifications/behaviour.rs @@ -1037,7 +1037,7 @@ impl Notifications { peerset_rejected, incoming_index, }; - return self.report_reject(index).map_or((), |_| ()); + return self.report_reject(index).map_or((), |_| ()) } trace!( diff --git a/substrate/frame/contracts/fixtures/build.rs b/substrate/frame/contracts/fixtures/build.rs index de95d199b448..45ab9f8b0482 100644 --- a/substrate/frame/contracts/fixtures/build.rs +++ b/substrate/frame/contracts/fixtures/build.rs @@ -104,7 +104,7 @@ fn collect_entries(contracts_dir: &Path, out_dir: &Path) -> Vec { .filter_map(|file| { let path = file.expect("file exists; qed").path(); if path.extension().map_or(true, |ext| ext != "rs") { - return None; + return None } let entry = Entry::new(path); @@ -303,7 +303,7 @@ fn find_workspace_root(current_dir: &Path) -> Option { let cargo_toml_contents = std::fs::read_to_string(current_dir.join("Cargo.toml")).ok()?; if cargo_toml_contents.contains("[workspace]") { - return Some(current_dir); + return Some(current_dir) } } @@ -321,7 +321,7 @@ fn main() -> Result<()> { let entries = collect_entries(&contracts_dir, &out_dir); if entries.is_empty() { - return Ok(()); + return Ok(()) } let tmp_dir = tempfile::tempdir()?; diff --git a/substrate/frame/support/procedural/src/construct_runtime/expand/task.rs b/substrate/frame/support/procedural/src/construct_runtime/expand/task.rs index bd952202bbbe..6531c0e9e070 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/expand/task.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/expand/task.rs @@ -31,7 +31,7 @@ pub fn expand_outer_task( let mut task_paths = Vec::new(); for decl in pallet_decls { if decl.find_part("Task").is_none() { - continue; + continue } let variant_name = &decl.name; diff --git a/substrate/frame/system/src/tests.rs b/substrate/frame/system/src/tests.rs index 053cec24f89c..e437e7f9f39b 100644 --- a/substrate/frame/system/src/tests.rs +++ b/substrate/frame/system/src/tests.rs @@ -828,7 +828,7 @@ fn last_runtime_upgrade_spec_version_usage() { // a runtime upgrade in the pipeline of being applied, you should use the spec version // of this upgrade. if System::last_runtime_upgrade_spec_version() > 1337 { - return Weight::zero(); + return Weight::zero() } // Do the migration. diff --git a/substrate/primitives/core/src/address_uri.rs b/substrate/primitives/core/src/address_uri.rs index 862747c9a4b6..211d47c0093d 100644 --- a/substrate/primitives/core/src/address_uri.rs +++ b/substrate/primitives/core/src/address_uri.rs @@ -184,7 +184,7 @@ impl<'a> AddressUri<'a> { Error::in_pass(initial_input, initial_input_len - input.len()) } else { Error::in_phrase(initial_input, initial_input_len - input.len()) - }); + }) } } diff --git a/substrate/primitives/core/src/crypto.rs b/substrate/primitives/core/src/crypto.rs index 1f3ae7445332..2da38d44be4b 100644 --- a/substrate/primitives/core/src/crypto.rs +++ b/substrate/primitives/core/src/crypto.rs @@ -434,7 +434,7 @@ impl + AsRef<[u8]> + Public + Derive> Ss58Codec for T { fn from_string(s: &str) -> Result { let cap = AddressUri::parse(s)?; if cap.pass.is_some() { - return Err(PublicError::PasswordNotAllowed); + return Err(PublicError::PasswordNotAllowed) } let s = cap.phrase.unwrap_or(DEV_ADDRESS); let addr = if let Some(stripped) = s.strip_prefix("0x") { @@ -454,7 +454,7 @@ impl + AsRef<[u8]> + Public + Derive> Ss58Codec for T { fn from_string_with_version(s: &str) -> Result<(Self, Ss58AddressFormat), PublicError> { let cap = AddressUri::parse(s)?; if cap.pass.is_some() { - return Err(PublicError::PasswordNotAllowed); + return Err(PublicError::PasswordNotAllowed) } let (addr, v) = Self::from_ss58check_with_version(cap.phrase.unwrap_or(DEV_ADDRESS))?; if cap.paths.is_empty() { diff --git a/substrate/utils/wasm-builder/src/wasm_project.rs b/substrate/utils/wasm-builder/src/wasm_project.rs index 5bf44c2c9b20..2126a49bd7ff 100644 --- a/substrate/utils/wasm-builder/src/wasm_project.rs +++ b/substrate/utils/wasm-builder/src/wasm_project.rs @@ -935,7 +935,7 @@ fn generate_rerun_if_changed_instructions( while let Some(dependency) = dependencies.pop() { // Ignore all dev dependencies if dependency.kind == DependencyKind::Development { - continue; + continue } let path_or_git_dep = From 9dc54f9a38ce5a23fc2e463745b0ba15407b0192 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 5 Jan 2024 15:58:07 +0100 Subject: [PATCH 2/6] update Cargo.lock --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index 3376d3fdccff..9f8bbf92d445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11252,6 +11252,7 @@ dependencies = [ "sc-network-sync", "sc-offchain", "sc-rpc", + "sc-rpc-spec-v2", "sc-service", "sc-sysinfo", "sc-telemetry", From 8a20511409c96e2e562efd4fb0c52c64286f03f0 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 5 Jan 2024 16:13:24 +0100 Subject: [PATCH 3/6] make it compile --- substrate/bin/node-template/node/src/rpc.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/substrate/bin/node-template/node/src/rpc.rs b/substrate/bin/node-template/node/src/rpc.rs index 68347e4ce8d0..246391adcbbe 100644 --- a/substrate/bin/node-template/node/src/rpc.rs +++ b/substrate/bin/node-template/node/src/rpc.rs @@ -45,12 +45,6 @@ where let mut module = RpcModule::new(()); let FullDeps { client, pool, deny_unsafe } = deps; - // Enable the `chainSpec rpc v2` interface. - let chain_name = chain_spec.name().to_string(); - let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); - let properties = chain_spec.properties(); - io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; - module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client).into_rpc())?; @@ -59,5 +53,12 @@ where // to call into the runtime. // `module.merge(YourRpcTrait::into_rpc(YourRpcStruct::new(ReferenceToClient, ...)))?;` + // You probably want to enable the `rpc v2 chainSpec` API as well + // + // let chain_name = chain_spec.name().to_string(); + // let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + // let properties = chain_spec.properties(); + // module.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; + Ok(module) } From 57c3bbfec9b8e60f4a3bc9b5614cd5263e9d0572 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 5 Jan 2024 16:20:14 +0100 Subject: [PATCH 4/6] revert more stuff that doesn't compile --- Cargo.lock | 2 -- cumulus/parachain-template/node/Cargo.toml | 1 - cumulus/parachain-template/node/src/rpc.rs | 7 ------- cumulus/polkadot-parachain/Cargo.toml | 1 - cumulus/polkadot-parachain/src/rpc.rs | 6 ------ 5 files changed, 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f8bbf92d445..4404bd23d667 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11252,7 +11252,6 @@ dependencies = [ "sc-network-sync", "sc-offchain", "sc-rpc", - "sc-rpc-spec-v2", "sc-service", "sc-sysinfo", "sc-telemetry", @@ -13071,7 +13070,6 @@ dependencies = [ "sc-network", "sc-network-sync", "sc-rpc", - "sc-rpc-spec-v2", "sc-service", "sc-sysinfo", "sc-telemetry", diff --git a/cumulus/parachain-template/node/Cargo.toml b/cumulus/parachain-template/node/Cargo.toml index 113ab3c568a6..865f310cd125 100644 --- a/cumulus/parachain-template/node/Cargo.toml +++ b/cumulus/parachain-template/node/Cargo.toml @@ -39,7 +39,6 @@ sc-executor = { path = "../../../substrate/client/executor" } sc-network = { path = "../../../substrate/client/network" } sc-network-sync = { path = "../../../substrate/client/network/sync" } sc-rpc = { path = "../../../substrate/client/rpc" } -sc-rpc-spec-v2 = { path = "../../../substrate/client/rpc-spec-v2" } sc-service = { path = "../../../substrate/client/service" } sc-sysinfo = { path = "../../../substrate/client/sysinfo" } sc-telemetry = { path = "../../../substrate/client/telemetry" } diff --git a/cumulus/parachain-template/node/src/rpc.rs b/cumulus/parachain-template/node/src/rpc.rs index 6eaa1933cfc7..bb52b974f0ce 100644 --- a/cumulus/parachain-template/node/src/rpc.rs +++ b/cumulus/parachain-template/node/src/rpc.rs @@ -45,19 +45,12 @@ where P: TransactionPool + Sync + Send + 'static, { use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; - let chain_name = chain_spec.name().to_string(); - let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); - let properties = chain_spec.properties(); - - module.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client).into_rpc())?; - Ok(module) } diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index db90de00f1d6..34243f473e8d 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -71,7 +71,6 @@ sp-block-builder = { path = "../../substrate/primitives/block-builder" } sp-keystore = { path = "../../substrate/primitives/keystore" } sc-chain-spec = { path = "../../substrate/client/chain-spec" } sc-rpc = { path = "../../substrate/client/rpc" } -sc-rpc-spec-v2 = { path = "../../substrate/client/rpc-spec-v2" } sp-version = { path = "../../substrate/primitives/version" } sc-tracing = { path = "../../substrate/client/tracing" } sp-offchain = { path = "../../substrate/primitives/offchain" } diff --git a/cumulus/polkadot-parachain/src/rpc.rs b/cumulus/polkadot-parachain/src/rpc.rs index f69c560f379d..caee14e55522 100644 --- a/cumulus/polkadot-parachain/src/rpc.rs +++ b/cumulus/polkadot-parachain/src/rpc.rs @@ -63,17 +63,11 @@ where { use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; - let chain_name = chain_spec.name().to_string(); - let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); - let properties = chain_spec.properties(); - io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; - module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; module.merge(StateMigration::new(client, backend, deny_unsafe).into_rpc())?; From 3ada1393cdbfde4a7e3a6121d0501511fd89696f Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Mon, 8 Jan 2024 10:06:05 +0100 Subject: [PATCH 5/6] grumbles: remove trait bound BlockBackend --- polkadot/rpc/src/lib.rs | 3 +-- substrate/bin/node/rpc/src/lib.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/polkadot/rpc/src/lib.rs b/polkadot/rpc/src/lib.rs index 5fd408a0e46a..4455efd3b533 100644 --- a/polkadot/rpc/src/lib.rs +++ b/polkadot/rpc/src/lib.rs @@ -99,7 +99,6 @@ pub fn create_full( ) -> Result> where C: ProvideRuntimeApi - + sc_client_api::BlockBackend + HeaderBackend + AuxStore + HeaderMetadata @@ -137,7 +136,7 @@ where } = grandpa; let chain_name = chain_spec.name().to_string(); - let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + let genesis_hash = client.hash(0).ok().flatten().expect("Genesis block exists; qed"); let properties = chain_spec.properties(); io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; diff --git a/substrate/bin/node/rpc/src/lib.rs b/substrate/bin/node/rpc/src/lib.rs index acc58777e912..ce33efbdbc5e 100644 --- a/substrate/bin/node/rpc/src/lib.rs +++ b/substrate/bin/node/rpc/src/lib.rs @@ -113,7 +113,6 @@ pub fn create_full( ) -> Result, Box> where C: ProvideRuntimeApi - + sc_client_api::BlockBackend + HeaderBackend + AuxStore + HeaderMetadata @@ -156,7 +155,7 @@ where } = grandpa; let chain_name = chain_spec.name().to_string(); - let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + let genesis_hash = client.hash(0).ok().flatten().expect("Genesis block exists; qed"); let properties = chain_spec.properties(); io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; From 0ab6f4f5e9feea22e1fb7d29eb0dedae3e37147d Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Mon, 8 Jan 2024 10:28:30 +0100 Subject: [PATCH 6/6] revert substrate node --- substrate/bin/node/rpc/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/bin/node/rpc/src/lib.rs b/substrate/bin/node/rpc/src/lib.rs index 52c8e248477a..4646524a25ba 100644 --- a/substrate/bin/node/rpc/src/lib.rs +++ b/substrate/bin/node/rpc/src/lib.rs @@ -129,6 +129,7 @@ pub fn create_full( ) -> Result, Box> where C: ProvideRuntimeApi + + sc_client_api::BlockBackend + HeaderBackend + AuxStore + HeaderMetadata @@ -172,7 +173,7 @@ where } = grandpa; let chain_name = chain_spec.name().to_string(); - let genesis_hash = client.hash(0).ok().flatten().expect("Genesis block exists; qed"); + let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); let properties = chain_spec.properties(); io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?;