From b7b75ff0543d12f7408601ce1938be5d41263529 Mon Sep 17 00:00:00 2001 From: cheme Date: Mon, 7 Nov 2022 11:41:45 +0100 Subject: [PATCH] Add trie migration rpc to polkadot-parachain (#1424) * add trie migration rpc to polkadot-parachain * pass backend * fix --- cumulus/Cargo.lock | 1 + cumulus/polkadot-parachain/Cargo.toml | 1 + cumulus/polkadot-parachain/src/rpc.rs | 9 +++++++-- cumulus/polkadot-parachain/src/service.rs | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cumulus/Cargo.lock b/cumulus/Cargo.lock index ac4347eeeb..abdbcaab60 100644 --- a/cumulus/Cargo.lock +++ b/cumulus/Cargo.lock @@ -7698,6 +7698,7 @@ dependencies = [ "substrate-build-script-utils", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", + "substrate-state-trie-migration-rpc", "tempfile", "tokio", "try-runtime-cli", diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index 2d1a51f096..d01bff2b52 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -64,6 +64,7 @@ try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "m sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } +substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } # Polkadot polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/cumulus/polkadot-parachain/src/rpc.rs b/cumulus/polkadot-parachain/src/rpc.rs index 8bd91075c4..43752fd8d1 100644 --- a/cumulus/polkadot-parachain/src/rpc.rs +++ b/cumulus/polkadot-parachain/src/rpc.rs @@ -42,8 +42,9 @@ pub struct FullDeps { } /// Instantiate all RPC extensions. -pub fn create_full( +pub fn create_full( deps: FullDeps, + backend: Arc, ) -> Result> where C: ProvideRuntimeApi @@ -57,15 +58,19 @@ where C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, + B: sc_client_api::Backend + Send + Sync + 'static, + B::State: sc_client_api::backend::StateBackend>, { use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; - module.merge(TransactionPayment::new(client).into_rpc())?; + module.merge(TransactionPayment::new(client.clone()).into_rpc())?; + module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; Ok(module) } diff --git a/cumulus/polkadot-parachain/src/service.rs b/cumulus/polkadot-parachain/src/service.rs index a350a10cd0..cba3fbdfb3 100644 --- a/cumulus/polkadot-parachain/src/service.rs +++ b/cumulus/polkadot-parachain/src/service.rs @@ -560,6 +560,7 @@ where let client = client.clone(); let transaction_pool = transaction_pool.clone(); + let backend_for_rpc = backend.clone(); Box::new(move |deny_unsafe, _| { let deps = rpc::FullDeps { client: client.clone(), @@ -567,7 +568,7 @@ where deny_unsafe, }; - rpc::create_full(deps).map_err(Into::into) + rpc::create_full(deps, backend_for_rpc.clone()).map_err(Into::into) }) };