mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 02:41:08 +00:00
Make runtime api calls native when possible (#1302)
* Add simple benchmark for the runtime api * Make the executor support native calls * Some documentation * Hide behind `feature = "std"` * Rework the native calls * Make all tests compile again * Make every parameter using the Block serialized/deserialized in the native call * Forward `UnwindSafe` requirement * Remove debug stuff * Add some documentation * Fixes warnings * Fixes errors after master rebase * Fixes compilation after master rebase * Fixes compilation after rebase
This commit is contained in:
@@ -135,7 +135,8 @@ pub trait StartRPC<C: Components> {
|
||||
}
|
||||
|
||||
impl<C: Components> StartRPC<Self> for C where
|
||||
C::RuntimeApi: Metadata<ComponentBlock<C>>,
|
||||
ComponentClient<C>: ProvideRuntimeApi,
|
||||
<ComponentClient<C> as ProvideRuntimeApi>::Api: Metadata<ComponentBlock<C>>,
|
||||
{
|
||||
type ServersHandle = (Option<rpc::HttpServer>, Option<Mutex<rpc::WsServer>>);
|
||||
|
||||
@@ -189,10 +190,10 @@ fn on_block_imported<Api, Backend, Block, Executor, PoolApi>(
|
||||
client: &Client<Backend, Executor, Block, Api>,
|
||||
transaction_pool: &TransactionPool<PoolApi>,
|
||||
) -> error::Result<()> where
|
||||
Api: TaggedTransactionQueue<Block>,
|
||||
Block: BlockT<Hash = <Blake2Hasher as ::primitives::Hasher>::Out>,
|
||||
Backend: client::backend::Backend<Block, Blake2Hasher>,
|
||||
Client<Backend, Executor, Block, Api>: ProvideRuntimeApi<Api = Api>,
|
||||
Client<Backend, Executor, Block, Api>: ProvideRuntimeApi,
|
||||
<Client<Backend, Executor, Block, Api> as ProvideRuntimeApi>::Api: TaggedTransactionQueue<Block>,
|
||||
Executor: client::CallExecutor<Block, Blake2Hasher>,
|
||||
PoolApi: txpool::ChainApi<Hash = Block::Hash, Block = Block>,
|
||||
{
|
||||
@@ -210,7 +211,7 @@ fn on_block_imported<Api, Backend, Block, Executor, PoolApi>(
|
||||
let parent_id = BlockId::hash(*block.block.header().parent_hash());
|
||||
let mut tags = vec![];
|
||||
for tx in block.block.extrinsics() {
|
||||
let tx = client.runtime_api().validate_transaction(&parent_id, &tx)?;
|
||||
let tx = client.runtime_api().validate_transaction(&parent_id, tx.clone())?;
|
||||
match tx {
|
||||
TransactionValidity::Valid { mut provides, .. } => {
|
||||
tags.append(&mut provides);
|
||||
@@ -230,8 +231,8 @@ fn on_block_imported<Api, Backend, Block, Executor, PoolApi>(
|
||||
}
|
||||
|
||||
impl<C: Components> MaintainTransactionPool<Self> for C where
|
||||
ComponentClient<C>: ProvideRuntimeApi<Api = C::RuntimeApi>,
|
||||
C::RuntimeApi: TaggedTransactionQueue<ComponentBlock<C>>,
|
||||
ComponentClient<C>: ProvideRuntimeApi,
|
||||
<ComponentClient<C> as ProvideRuntimeApi>::Api: TaggedTransactionQueue<ComponentBlock<C>>,
|
||||
{
|
||||
// TODO [ToDr] Optimize and re-use tags from the pool.
|
||||
fn on_block_imported(
|
||||
|
||||
@@ -181,10 +181,7 @@ impl<F: ServiceFactory> TestNet<F> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn connectivity<F: ServiceFactory, Inherent>(spec: FactoryChainSpec<F>) where
|
||||
<F as ServiceFactory>::RuntimeApi:
|
||||
client::block_builder::api::BlockBuilder<<F as service::ServiceFactory>::Block, Inherent>
|
||||
{
|
||||
pub fn connectivity<F: ServiceFactory, Inherent>(spec: FactoryChainSpec<F>) {
|
||||
const NUM_NODES: u32 = 10;
|
||||
{
|
||||
let temp = TempDir::new("substrate-connectivity-test").expect("Error creating test dir");
|
||||
@@ -228,9 +225,6 @@ where
|
||||
F: ServiceFactory,
|
||||
B: Fn(&F::FullService) -> ImportBlock<F::Block>,
|
||||
E: Fn(&F::FullService) -> FactoryExtrinsic<F>,
|
||||
<F as ServiceFactory>::RuntimeApi:
|
||||
client::block_builder::api::BlockBuilder<<F as service::ServiceFactory>::Block, ()> +
|
||||
client::runtime_api::TaggedTransactionQueue<<F as service::ServiceFactory>::Block>
|
||||
{
|
||||
const NUM_NODES: u32 = 10;
|
||||
const NUM_BLOCKS: usize = 512;
|
||||
@@ -265,10 +259,8 @@ where
|
||||
}
|
||||
|
||||
pub fn consensus<F>(spec: FactoryChainSpec<F>, authorities: Vec<String>)
|
||||
where
|
||||
F: ServiceFactory,
|
||||
<F as ServiceFactory>::RuntimeApi:
|
||||
client::block_builder::api::BlockBuilder<<F as service::ServiceFactory>::Block, ()>
|
||||
where
|
||||
F: ServiceFactory,
|
||||
{
|
||||
const NUM_NODES: u32 = 20;
|
||||
const NUM_BLOCKS: u64 = 200;
|
||||
|
||||
Reference in New Issue
Block a user