Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded compatibility code #3341

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading