From 8f784d592a80e65b9bd573d481fc9f65225ae0f3 Mon Sep 17 00:00:00 2001 From: cheme <emericchevalier.pro@gmail.com> Date: Mon, 4 Apr 2022 09:33:35 +0200 Subject: [PATCH] Trie State migration rpc (#5180) * update * unsafe * switch remote * update rpc usage * update cargo.lock * lock from master * updated lock --- polkadot/Cargo.lock | 24 ++++++++++++++++++++++++ polkadot/node/service/src/lib.rs | 3 ++- polkadot/rpc/Cargo.toml | 1 + polkadot/rpc/src/lib.rs | 5 +++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index 7ce86291027..d46733dacdd 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/Cargo.lock @@ -7275,6 +7275,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-frame-rpc-system", + "substrate-state-trie-migration-rpc", ] [[package]] @@ -11021,6 +11022,29 @@ dependencies = [ "tokio", ] +[[package]] +name = "substrate-state-trie-migration-rpc" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#7a09b82772b0597cdae224f4b124d660dda9e82b" +dependencies = [ + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "log", + "parity-scale-codec", + "sc-client-api", + "sc-rpc-api", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "trie-db", +] + [[package]] name = "substrate-test-client" version = "2.0.1" diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index f9350a4f725..fb27d8509f7 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -512,6 +512,7 @@ where let transaction_pool = transaction_pool.clone(); let select_chain = select_chain.clone(); let chain_spec = config.chain_spec.cloned_box(); + let backend = backend.clone(); move |deny_unsafe, subscription_executor: polkadot_rpc::SubscriptionTaskExecutor| @@ -541,7 +542,7 @@ where }, }; - polkadot_rpc::create_full(deps).map_err(Into::into) + polkadot_rpc::create_full(deps, backend.clone()).map_err(Into::into) } }; diff --git a/polkadot/rpc/Cargo.toml b/polkadot/rpc/Cargo.toml index ff994325337..a3388753697 100644 --- a/polkadot/rpc/Cargo.toml +++ b/polkadot/rpc/Cargo.toml @@ -29,3 +29,4 @@ pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrat sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "master" } beefy-gadget-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } +substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/polkadot/rpc/src/lib.rs b/polkadot/rpc/src/lib.rs index 048afa063ef..dffff5ac1b8 100644 --- a/polkadot/rpc/src/lib.rs +++ b/polkadot/rpc/src/lib.rs @@ -95,6 +95,7 @@ pub struct FullDeps<C, P, SC, B> { /// Instantiate all RPC extensions. pub fn create_full<C, P, SC, B>( deps: FullDeps<C, P, SC, B>, + backend: Arc<B>, ) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>> where C: ProvideRuntimeApi<Block> @@ -132,6 +133,10 @@ where finality_provider, } = grandpa; + io.extend_with(substrate_state_trie_migration_rpc::StateMigrationApi::to_delegate( + substrate_state_trie_migration_rpc::MigrationRpc::new(client.clone(), backend, deny_unsafe), + )); + io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe))); io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone()))); io.extend_with(MmrApi::to_delegate(Mmr::new(client.clone()))); -- GitLab