Skip to content

Commit

Permalink
Restore CheckInherents for relay validation (#2609)
Browse files Browse the repository at this point in the history
* restore CheckInherents for all runtimes

* fix runtimes compilation
  • Loading branch information
librelois authored Jan 3, 2024
1 parent 3e3253d commit ef76ba7
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
25 changes: 25 additions & 0 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1626,10 +1626,35 @@ moonbeam_runtime_common::impl_runtime_apis_plus_common! {
}
}

struct CheckInherents;

// Parity has decided to depreciate this trait, but does not offer a satisfactory replacement,
// see issue: https://github.com/paritytech/polkadot-sdk/issues/2841
#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
block: &Block,
relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
let relay_chain_slot = relay_state_proof
.read_slot()
.expect("Could not read the relay chain slot from the proof");
let inherent_data =
cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
relay_chain_slot,
sp_std::time::Duration::from_secs(6),
)
.create_inherent_data()
.expect("Could not create the timestamp inherent data");
inherent_data.check_extrinsics(block)
}
}

// Nimbus's Executive wrapper allows relay validators to verify the seal digest
cumulus_pallet_parachain_system::register_validate_block!(
Runtime = Runtime,
BlockExecutor = pallet_author_inherent::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
);

moonbeam_runtime_common::impl_self_contained_call!();
Expand Down
1 change: 1 addition & 0 deletions runtime/moonbeam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ substrate-wasm-builder = { workspace = true }
default = [ "std" ]
std = [
"account/std",
"async-backing-primitives/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcm/std",
Expand Down
25 changes: 25 additions & 0 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,10 +1645,35 @@ moonbeam_runtime_common::impl_runtime_apis_plus_common! {
}
}

struct CheckInherents;

// Parity has decided to depreciate this trait, but does not offer a satisfactory replacement,
// see issue: https://github.com/paritytech/polkadot-sdk/issues/2841
#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
block: &Block,
relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
let relay_chain_slot = relay_state_proof
.read_slot()
.expect("Could not read the relay chain slot from the proof");
let inherent_data =
cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
relay_chain_slot,
sp_std::time::Duration::from_secs(6),
)
.create_inherent_data()
.expect("Could not create the timestamp inherent data");
inherent_data.check_extrinsics(block)
}
}

// Nimbus's Executive wrapper allows relay validators to verify the seal digest
cumulus_pallet_parachain_system::register_validate_block!(
Runtime = Runtime,
BlockExecutor = pallet_author_inherent::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
);

moonbeam_runtime_common::impl_self_contained_call!();
Expand Down
1 change: 1 addition & 0 deletions runtime/moonriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ substrate-wasm-builder = { workspace = true }
default = [ "std" ]
std = [
"account/std",
"async-backing-primitives/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcm/std",
Expand Down
25 changes: 25 additions & 0 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,10 +1646,35 @@ moonbeam_runtime_common::impl_runtime_apis_plus_common! {
}
}

struct CheckInherents;

// Parity has decided to depreciate this trait, but does not offer a satisfactory replacement,
// see issue: https://github.com/paritytech/polkadot-sdk/issues/2841
#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
block: &Block,
relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
let relay_chain_slot = relay_state_proof
.read_slot()
.expect("Could not read the relay chain slot from the proof");
let inherent_data =
cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
relay_chain_slot,
sp_std::time::Duration::from_secs(6),
)
.create_inherent_data()
.expect("Could not create the timestamp inherent data");
inherent_data.check_extrinsics(block)
}
}

// Nimbus's Executive wrapper allows relay validators to verify the seal digest
cumulus_pallet_parachain_system::register_validate_block!(
Runtime = Runtime,
BlockExecutor = pallet_author_inherent::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
);

moonbeam_runtime_common::impl_self_contained_call!();
Expand Down

0 comments on commit ef76ba7

Please sign in to comment.