Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add trie migration rpc to polkadot-parachain #1424

Merged
merged 4 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
9 changes: 7 additions & 2 deletions polkadot-parachain/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ pub struct FullDeps<C, P> {
}

/// Instantiate all RPC extensions.
pub fn create_full<C, P>(
pub fn create_full<C, P, B>(
deps: FullDeps<C, P>,
backend: Arc<B>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
Expand All @@ -57,15 +58,19 @@ where
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
{
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)
}
Expand Down
3 changes: 2 additions & 1 deletion polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,14 +593,15 @@ 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(),
pool: transaction_pool.clone(),
deny_unsafe,
};

rpc::create_full(deps).map_err(Into::into)
rpc::create_full(deps, backend_for_rpc.clone()).map_err(Into::into)
})
};

Expand Down