diff --git a/node/src/service/client.rs b/node/src/service/client.rs index b4a1d696ce9ec5b444e4e4c1d843f497999cb2a8..3ff70a9caa8601df212a6bc0749aa113cbcf9a10 100644 --- a/node/src/service/client.rs +++ b/node/src/service/client.rs @@ -16,8 +16,8 @@ use common_runtime::{AccountId, Balance, Block, BlockNumber, Hash, Header, Index}; use sc_client_api::{ - AuxStore, Backend as BackendT, BlockchainEvents, KeysIter, MerkleValue, PairsIter, - UsageProvider, + AuxStore, Backend as BackendT, BlockBackend, BlockchainEvents, KeysIter, MerkleValue, + PairsIter, UsageProvider, }; use sp_api::{CallApiAt, ProvideRuntimeApi}; use sp_blockchain::{HeaderBackend, HeaderMetadata}; @@ -26,7 +26,7 @@ use sp_core::{Encode, Pair}; use sp_runtime::{ generic::SignedBlock, traits::{BlakeTwo256, Block as BlockT}, - Justifications, + Justifications, SaturatedConversion, }; use sp_storage::{ChildInfo, StorageData, StorageKey}; use std::sync::Arc; @@ -380,16 +380,17 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for Client { fn build(&self, nonce: u32) -> std::result::Result<sp_runtime::OpaqueExtrinsic, &'static str> { with_client! { - self, client, { - let call = super::runtime_executor::runtime::RuntimeCall::System(super::runtime_executor::runtime::SystemCall::remark { remark: vec![] }); - let signer = sp_keyring::Sr25519Keyring::Bob.pair(); + self, client, { + let call = super::runtime_executor::runtime::RuntimeCall::System(super::runtime_executor::runtime::SystemCall::remark { remark: vec![] }); + let signer = sp_keyring::Sr25519Keyring::Bob.pair(); - let period = super::runtime_executor::runtime::BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64; - let genesis = client.usage_info().chain.best_hash; + let period = super::runtime_executor::runtime::BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64; + let genesis = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); + let best_block = client.chain_info().best_number; - Ok(client.sign_call(call, nonce, 0, period, genesis, signer)) - } - } + Ok(client.sign_call(call, nonce, best_block.saturated_into(), period, genesis, signer)) + } + } } }