companion #8738 (jsonrpsee) (#823)

* update polkadot and substrate

* add jsonrpsee glue code

* fix tests

* update substrate & polkadot

* update substrate & polkadot

* update Cargo.lock

* revert Cargo.toml

* revert changes in Cargo.toml

* update companion

* revert substrate change

* add Cargo.lock

* update substrate manually

* update polkadot
This commit is contained in:
Niklas Adolfsson
2022-05-10 12:53:21 +02:00
committed by GitHub
parent f5c12a38bc
commit 2d506dfcd7
17 changed files with 586 additions and 909 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ statemint-runtime = { path = "statemint" }
statemine-runtime = { path = "statemine" }
westmint-runtime = { path = "westmint" }
canvas-kusama-runtime = { path = "canvas-kusama" }
jsonrpc-core = "18.0.0"
jsonrpsee = { version = "0.12.0", features = ["server"] }
parachains-common = { path = "parachains-common" }
# Substrate
+23 -18
View File
@@ -20,7 +20,6 @@
use std::sync::Arc;
use pallet_contracts_rpc::{Contracts, ContractsApi};
use parachains_common::{AccountId, Balance, Block, BlockNumber, Hash, Index as Nonce};
use sc_client_api::AuxStore;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
@@ -30,7 +29,7 @@ use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
pub type RpcExtension = jsonrpsee::RpcModule<()>;
/// Full client dependencies
pub struct FullDeps<C, P> {
@@ -43,7 +42,9 @@ pub struct FullDeps<C, P> {
}
/// Instantiate all RPC extensions.
pub fn create_full<C, P>(deps: FullDeps<C, P>) -> RpcExtension
pub fn create_full<C, P>(
deps: FullDeps<C, P>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
+ HeaderBackend<Block>
@@ -57,20 +58,22 @@ where
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
use frame_rpc_system::{FullSystem, SystemApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
use frame_rpc_system::{SystemApiServer, SystemRpc};
use pallet_transaction_payment_rpc::{TransactionPaymentApiServer, TransactionPaymentRpc};
let mut io = jsonrpc_core::IoHandler::default();
let mut module = RpcExtension::new(());
let FullDeps { client, pool, deny_unsafe } = deps;
io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe)));
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone())));
module.merge(SystemRpc::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPaymentRpc::new(client.clone()).into_rpc())?;
io
Ok(module)
}
/// Instantiate all RPCs we want at the canvas-kusama chain.
pub fn create_canvas_kusama<C, P>(deps: FullDeps<C, P>) -> RpcExtension
pub fn create_canvas_kusama<C, P>(
deps: FullDeps<C, P>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
+ sc_client_api::BlockBackend<Block>
@@ -86,16 +89,18 @@ where
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
use frame_rpc_system::{FullSystem, SystemApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
use frame_rpc_system::{SystemApiServer, SystemRpc};
use pallet_contracts_rpc::{ContractsApiServer, ContractsRpc};
use pallet_transaction_payment_rpc::{TransactionPaymentApiServer, TransactionPaymentRpc};
use sc_rpc::dev::{Dev, DevApiServer};
let mut io = jsonrpc_core::IoHandler::default();
let mut module = RpcExtension::new(());
let FullDeps { client, pool, deny_unsafe } = deps;
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(ContractsApi::to_delegate(Contracts::new(client.clone())));
io.extend_with(sc_rpc::dev::DevApi::to_delegate(sc_rpc::dev::Dev::new(client, deny_unsafe)));
module.merge(SystemRpc::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPaymentRpc::new(client.clone()).into_rpc())?;
module.merge(ContractsRpc::new(client.clone()).into_rpc())?;
module.merge(Dev::new(client, deny_unsafe).into_rpc())?;
io
Ok(module)
}
+17 -15
View File
@@ -34,6 +34,8 @@ use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;
use polkadot_service::CollatorPair;
use sp_core::Pair;
use jsonrpsee::RpcModule;
use crate::rpc;
pub use parachains_common::{AccountId, Balance, Block, BlockNumber, Hash, Header, Index as Nonce};
@@ -340,7 +342,7 @@ where
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
RB: Fn(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
+ Send
+ 'static,
BIQ: FnOnce(
@@ -421,10 +423,10 @@ where
})?;
let rpc_client = client.clone();
let rpc_extensions_builder = Box::new(move |_, _| rpc_ext_builder(rpc_client.clone()));
let rpc_builder = Box::new(move |_, _| rpc_ext_builder(rpc_client.clone()));
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
rpc_extensions_builder,
rpc_builder,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
@@ -542,7 +544,7 @@ where
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
RB: Fn(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
+ Send
+ 'static,
BIQ: FnOnce(
@@ -621,7 +623,7 @@ where
warp_sync: None,
})?;
let rpc_extensions_builder = {
let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();
@@ -632,12 +634,12 @@ where
deny_unsafe,
};
Ok(rpc::create_full(deps))
rpc::create_full(deps).map_err(Into::into)
})
};
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
rpc_extensions_builder,
rpc_builder,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
@@ -782,7 +784,7 @@ pub async fn start_rococo_parachain_node(
polkadot_config,
collator_options,
id,
|_| Ok(Default::default()),
|_| Ok(RpcModule::new(())),
rococo_parachain_build_import_queue,
|client,
prometheus_registry,
@@ -925,7 +927,7 @@ where
polkadot_config,
collator_options,
id,
|_| Ok(Default::default()),
|_| Ok(RpcModule::new(())),
shell_build_import_queue,
|client,
prometheus_registry,
@@ -1200,7 +1202,7 @@ where
polkadot_config,
collator_options,
id,
|_| Ok(Default::default()),
|_| Ok(RpcModule::new(())),
statemint_build_import_queue::<_, AuraId>,
|client,
prometheus_registry,
@@ -1365,7 +1367,7 @@ where
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
RB: Fn(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
+ Send
+ 'static,
BIQ: FnOnce(
@@ -1444,7 +1446,7 @@ where
warp_sync: None,
})?;
let rpc_extensions_builder = {
let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();
@@ -1455,12 +1457,12 @@ where
deny_unsafe,
};
Ok(crate::rpc::create_canvas_kusama(deps))
crate::rpc::create_canvas_kusama(deps).map_err(Into::into)
})
};
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
rpc_extensions_builder,
rpc_builder,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
@@ -1603,7 +1605,7 @@ pub async fn start_canvas_kusama_node(
polkadot_config,
collator_options,
id,
|_| Ok(Default::default()),
|_| Ok(RpcModule::new(())),
canvas_kusama_build_import_queue,
|client,
prometheus_registry,