mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 16:11:05 +00:00
Use correct ExecutionContext for check_inherents (#9483)
Before we used the `other` context, while we are actually either in the import or sync context.
This commit is contained in:
@@ -41,7 +41,7 @@ use sp_consensus_aura::{
|
|||||||
AURA_ENGINE_ID,
|
AURA_ENGINE_ID,
|
||||||
};
|
};
|
||||||
use sp_consensus_slots::Slot;
|
use sp_consensus_slots::Slot;
|
||||||
use sp_core::crypto::Pair;
|
use sp_core::{crypto::Pair, ExecutionContext};
|
||||||
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider as _};
|
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider as _};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::{BlockId, OpaqueDigestItemId},
|
generic::{BlockId, OpaqueDigestItemId},
|
||||||
@@ -149,6 +149,7 @@ where
|
|||||||
block_id: BlockId<B>,
|
block_id: BlockId<B>,
|
||||||
inherent_data: sp_inherents::InherentData,
|
inherent_data: sp_inherents::InherentData,
|
||||||
create_inherent_data_providers: CIDP::InherentDataProviders,
|
create_inherent_data_providers: CIDP::InherentDataProviders,
|
||||||
|
execution_context: ExecutionContext,
|
||||||
) -> Result<(), Error<B>>
|
) -> Result<(), Error<B>>
|
||||||
where
|
where
|
||||||
C: ProvideRuntimeApi<B>,
|
C: ProvideRuntimeApi<B>,
|
||||||
@@ -169,7 +170,7 @@ where
|
|||||||
let inherent_res = self
|
let inherent_res = self
|
||||||
.client
|
.client
|
||||||
.runtime_api()
|
.runtime_api()
|
||||||
.check_inherents(&block_id, block, inherent_data)
|
.check_inherents_with_context(&block_id, execution_context, block, inherent_data)
|
||||||
.map_err(|e| Error::Client(e.into()))?;
|
.map_err(|e| Error::Client(e.into()))?;
|
||||||
|
|
||||||
if !inherent_res.ok() {
|
if !inherent_res.ok() {
|
||||||
@@ -261,6 +262,7 @@ where
|
|||||||
BlockId::Hash(parent_hash),
|
BlockId::Hash(parent_hash),
|
||||||
inherent_data,
|
inherent_data,
|
||||||
create_inherent_data_providers,
|
create_inherent_data_providers,
|
||||||
|
block.origin.into(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ use sp_consensus::{
|
|||||||
};
|
};
|
||||||
use sp_consensus_babe::inherents::BabeInherentData;
|
use sp_consensus_babe::inherents::BabeInherentData;
|
||||||
use sp_consensus_slots::Slot;
|
use sp_consensus_slots::Slot;
|
||||||
use sp_core::crypto::Public;
|
use sp_core::{crypto::Public, ExecutionContext};
|
||||||
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
|
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
|
||||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -1006,6 +1006,7 @@ where
|
|||||||
block_id: BlockId<Block>,
|
block_id: BlockId<Block>,
|
||||||
inherent_data: InherentData,
|
inherent_data: InherentData,
|
||||||
create_inherent_data_providers: CIDP::InherentDataProviders,
|
create_inherent_data_providers: CIDP::InherentDataProviders,
|
||||||
|
execution_context: ExecutionContext,
|
||||||
) -> Result<(), Error<Block>> {
|
) -> Result<(), Error<Block>> {
|
||||||
if let Err(e) = self.can_author_with.can_author_with(&block_id) {
|
if let Err(e) = self.can_author_with.can_author_with(&block_id) {
|
||||||
debug!(
|
debug!(
|
||||||
@@ -1020,7 +1021,7 @@ where
|
|||||||
let inherent_res = self
|
let inherent_res = self
|
||||||
.client
|
.client
|
||||||
.runtime_api()
|
.runtime_api()
|
||||||
.check_inherents(&block_id, block, inherent_data)
|
.check_inherents_with_context(&block_id, execution_context, block, inherent_data)
|
||||||
.map_err(Error::RuntimeApi)?;
|
.map_err(Error::RuntimeApi)?;
|
||||||
|
|
||||||
if !inherent_res.ok() {
|
if !inherent_res.ok() {
|
||||||
@@ -1244,6 +1245,7 @@ where
|
|||||||
BlockId::Hash(parent_hash),
|
BlockId::Hash(parent_hash),
|
||||||
inherent_data,
|
inherent_data,
|
||||||
create_inherent_data_providers,
|
create_inherent_data_providers,
|
||||||
|
block.origin.into(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ use sp_consensus::{
|
|||||||
CanAuthorWith, Environment, Error as ConsensusError, Proposer, SelectChain, SyncOracle,
|
CanAuthorWith, Environment, Error as ConsensusError, Proposer, SelectChain, SyncOracle,
|
||||||
};
|
};
|
||||||
use sp_consensus_pow::{Seal, TotalDifficulty, POW_ENGINE_ID};
|
use sp_consensus_pow::{Seal, TotalDifficulty, POW_ENGINE_ID};
|
||||||
|
use sp_core::ExecutionContext;
|
||||||
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
|
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::{BlockId, Digest, DigestItem},
|
generic::{BlockId, Digest, DigestItem},
|
||||||
@@ -272,6 +273,7 @@ where
|
|||||||
block: B,
|
block: B,
|
||||||
block_id: BlockId<B>,
|
block_id: BlockId<B>,
|
||||||
inherent_data_providers: CIDP::InherentDataProviders,
|
inherent_data_providers: CIDP::InherentDataProviders,
|
||||||
|
execution_context: ExecutionContext,
|
||||||
) -> Result<(), Error<B>> {
|
) -> Result<(), Error<B>> {
|
||||||
if *block.header().number() < self.check_inherents_after {
|
if *block.header().number() < self.check_inherents_after {
|
||||||
return Ok(())
|
return Ok(())
|
||||||
@@ -294,7 +296,7 @@ where
|
|||||||
let inherent_res = self
|
let inherent_res = self
|
||||||
.client
|
.client
|
||||||
.runtime_api()
|
.runtime_api()
|
||||||
.check_inherents(&block_id, block, inherent_data)
|
.check_inherents_with_context(&block_id, execution_context, block, inherent_data)
|
||||||
.map_err(|e| Error::Client(e.into()))?;
|
.map_err(|e| Error::Client(e.into()))?;
|
||||||
|
|
||||||
if !inherent_res.ok() {
|
if !inherent_res.ok() {
|
||||||
@@ -360,6 +362,7 @@ where
|
|||||||
self.create_inherent_data_providers
|
self.create_inherent_data_providers
|
||||||
.create_inherent_data_providers(parent_hash, ())
|
.create_inherent_data_providers(parent_hash, ())
|
||||||
.await?,
|
.await?,
|
||||||
|
block.origin.into(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ use sp_consensus::{BlockOrigin, BlockStatus, Error as ConsensusError};
|
|||||||
use sp_core::{
|
use sp_core::{
|
||||||
convert_hash,
|
convert_hash,
|
||||||
storage::{well_known_keys, ChildInfo, PrefixedStorageKey, StorageData, StorageKey},
|
storage::{well_known_keys, ChildInfo, PrefixedStorageKey, StorageData, StorageKey},
|
||||||
ChangesTrieConfiguration, ExecutionContext, NativeOrEncoded,
|
ChangesTrieConfiguration, NativeOrEncoded,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "test-helpers")]
|
#[cfg(feature = "test-helpers")]
|
||||||
use sp_keystore::SyncCryptoStorePtr;
|
use sp_keystore::SyncCryptoStorePtr;
|
||||||
@@ -958,11 +958,7 @@ where
|
|||||||
// block.
|
// block.
|
||||||
(true, None, Some(ref body)) => {
|
(true, None, Some(ref body)) => {
|
||||||
let runtime_api = self.runtime_api();
|
let runtime_api = self.runtime_api();
|
||||||
let execution_context = if import_block.origin == BlockOrigin::NetworkInitialSync {
|
let execution_context = import_block.origin.into();
|
||||||
ExecutionContext::Syncing
|
|
||||||
} else {
|
|
||||||
ExecutionContext::Importing
|
|
||||||
};
|
|
||||||
|
|
||||||
runtime_api.execute_block_with_context(
|
runtime_api.execute_block_with_context(
|
||||||
&at,
|
&at,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ async-trait = "0.1.42"
|
|||||||
codec = { package = "parity-scale-codec", version = "2.0.0", features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "2.0.0", features = ["derive"] }
|
||||||
futures = { version = "0.3.1", features = ["thread-pool"] }
|
futures = { version = "0.3.1", features = ["thread-pool"] }
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
sp-core = { path= "../../core", version = "4.0.0-dev"}
|
sp-core = { path = "../../core", version = "4.0.0-dev"}
|
||||||
sp-inherents = { version = "4.0.0-dev", path = "../../inherents" }
|
sp-inherents = { version = "4.0.0-dev", path = "../../inherents" }
|
||||||
sp-state-machine = { version = "0.10.0-dev", path = "../../state-machine" }
|
sp-state-machine = { version = "0.10.0-dev", path = "../../state-machine" }
|
||||||
futures-timer = "3.0.1"
|
futures-timer = "3.0.1"
|
||||||
|
|||||||
@@ -75,6 +75,16 @@ pub enum BlockOrigin {
|
|||||||
File,
|
File,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<BlockOrigin> for sp_core::ExecutionContext {
|
||||||
|
fn from(origin: BlockOrigin) -> Self {
|
||||||
|
if origin == BlockOrigin::NetworkInitialSync {
|
||||||
|
sp_core::ExecutionContext::Syncing
|
||||||
|
} else {
|
||||||
|
sp_core::ExecutionContext::Importing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Environment for a Consensus instance.
|
/// Environment for a Consensus instance.
|
||||||
///
|
///
|
||||||
/// Creates proposer instance.
|
/// Creates proposer instance.
|
||||||
|
|||||||
Reference in New Issue
Block a user