Skip to content

Commit

Permalink
Merge pull request #3341 from autonomys/cleanup-compatibility-code
Browse files Browse the repository at this point in the history
Remove unneeded compatibility code
  • Loading branch information
vedhavyas authored Jan 10, 2025
2 parents 9ce216e + aee81f7 commit abfc5b1
Showing 1 changed file with 12 additions and 46 deletions.
58 changes: 12 additions & 46 deletions domains/client/block-preprocessor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::inherents::is_runtime_upgraded;
use codec::Encode;
use domain_runtime_primitives::opaque::AccountId;
use sc_client_api::BlockBackend;
use sp_api::{ApiError, Core, ProvideRuntimeApi};
use sp_api::{ApiError, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_core::H256;
use sp_domains::core_api::DomainCoreApi;
Expand All @@ -29,8 +29,7 @@ use sp_domains::{
};
use sp_messenger::MessengerApi;
use sp_mmr_primitives::MmrApi;
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header, NumberFor};
use sp_runtime::DigestItem;
use sp_runtime::traits::{Block as BlockT, Hash as HashT, NumberFor};
use sp_state_machine::LayoutV1;
use sp_subspace_mmr::ConsensusChainMmrLeafProof;
use sp_weights::Weight;
Expand Down Expand Up @@ -208,13 +207,6 @@ where
Vec<InboxedBundle<Block::Hash>>,
Vec<(Option<AccountId>, Block::Extrinsic)>,
)> {
let consensus_spec_version = self
.consensus_client
.runtime_api()
.version(at_consensus_hash)
.map_err(sp_blockchain::Error::RuntimeApiError)?
.spec_version;

let mut inboxed_bundles = Vec::with_capacity(bundles.len());
let mut valid_extrinsics = Vec::new();

Expand All @@ -230,42 +222,16 @@ where
// NOTE: The receipt's `domain_block_number` is verified by the consensus runtime while
// the `domain_block_hash` is not (which is take care of by the fraud proof) so we can't
// check the parent domain block hash here.
// TODO: remove consensus runtime version check before next network
if consensus_spec_version >= 6
&& bundle.receipt().domain_block_number != parent_domain_number
{
// If there consensus runtime just upgraded to spec version 6, which bring the receipt
// gap check, the bundle that included in the same block is doesn't perform the check
// because the new runtime take effect in the next block so skip the check here too.
let is_consensus_runtime_upgraded_to_6 = {
let consensus_header = self
.consensus_client
.header(at_consensus_hash)?
.ok_or_else(|| {
sp_blockchain::Error::Backend(format!(
"Consensus block header of {at_consensus_hash:?} unavailable"
))
})?;

let runtime_upgraded = consensus_header
.digest()
.logs()
.iter()
.any(|di| di == &DigestItem::RuntimeEnvironmentUpdated);

runtime_upgraded && consensus_spec_version == 6
};
if !is_consensus_runtime_upgraded_to_6 {
return Err(sp_blockchain::Error::RuntimeApiError(
ApiError::Application(
format!(
"Unexpected bundle in consensus block: {:?}, something must be wrong",
at_consensus_hash
)
.into(),
),
));
}
if bundle.receipt().domain_block_number != parent_domain_number {
return Err(sp_blockchain::Error::RuntimeApiError(
ApiError::Application(
format!(
"Unexpected bundle in consensus block: {:?}, something must be wrong",
at_consensus_hash
)
.into(),
),
));
}

let extrinsic_root = bundle.extrinsics_root();
Expand Down

0 comments on commit abfc5b1

Please sign in to comment.