diff --git a/client/rpc/src/eth/pending.rs b/client/rpc/src/eth/pending.rs index 822562ded0..24a7886e5e 100644 --- a/client/rpc/src/eth/pending.rs +++ b/client/rpc/src/eth/pending.rs @@ -37,6 +37,7 @@ use sp_runtime::{ use sp_timestamp::TimestampInherentData; use crate::eth::{Eth, EthConfig}; +use fp_rpc::EthereumRuntimeRPCApi; const LOG_TARGET: &str = "eth-pending"; @@ -60,6 +61,7 @@ where B: BlockT, C: ProvideRuntimeApi, C::Api: BlockBuilderApi, + C::Api: EthereumRuntimeRPCApi, C: HeaderBackend + StorageProvider + 'static, BE: Backend, A: ChainApi, @@ -100,7 +102,12 @@ where ); // Initialize the pending block header - api.initialize_block(best_hash, &pending_header)?; + if api + .initialize_pending_block(best_hash, &pending_header) + .is_err() + { + api.initialize_block(best_hash, &pending_header)? + } // Apply inherents to the pending block. let inherents = api.execute_in_transaction(move |api| { diff --git a/primitives/rpc/src/lib.rs b/primitives/rpc/src/lib.rs index 45e4bb1aa2..3eab2d7628 100644 --- a/primitives/rpc/src/lib.rs +++ b/primitives/rpc/src/lib.rs @@ -245,6 +245,8 @@ sp_api::decl_runtime_apis! { fn pending_block( xts: Vec<::Extrinsic>, ) -> (Option, Option>); + /// initialize the pending block + fn initialize_pending_block(header: &::Header); } #[api_version(2)] diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index b8c25248f2..bf9203e456 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -876,6 +876,10 @@ impl_runtime_apis! { pallet_ethereum::CurrentTransactionStatuses::::get() ) } + + fn initialize_pending_block(header: &::Header) { + Executive::initialize_block(header) + } } impl fp_rpc::ConvertTransactionRuntimeApi for Runtime {