From ef76ba7b98dab867c17579be68e8bca5bdf6e688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lo=C3=AFs?= Date: Wed, 3 Jan 2024 12:56:57 +0100 Subject: [PATCH] Restore CheckInherents for relay validation (#2609) * restore CheckInherents for all runtimes * fix runtimes compilation --- runtime/moonbase/src/lib.rs | 25 +++++++++++++++++++++++++ runtime/moonbeam/Cargo.toml | 1 + runtime/moonbeam/src/lib.rs | 25 +++++++++++++++++++++++++ runtime/moonriver/Cargo.toml | 1 + runtime/moonriver/src/lib.rs | 25 +++++++++++++++++++++++++ 5 files changed, 77 insertions(+) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index cf42f2b26e..d8a33f4191 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -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 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::, + CheckInherents = CheckInherents, ); moonbeam_runtime_common::impl_self_contained_call!(); diff --git a/runtime/moonbeam/Cargo.toml b/runtime/moonbeam/Cargo.toml index 43bc57cb3d..ad0242301e 100644 --- a/runtime/moonbeam/Cargo.toml +++ b/runtime/moonbeam/Cargo.toml @@ -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", diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index dcc4c50853..77e104017d 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -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 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::, + CheckInherents = CheckInherents, ); moonbeam_runtime_common::impl_self_contained_call!(); diff --git a/runtime/moonriver/Cargo.toml b/runtime/moonriver/Cargo.toml index e5b41b924d..971085b327 100644 --- a/runtime/moonriver/Cargo.toml +++ b/runtime/moonriver/Cargo.toml @@ -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", diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index b5624aec99..ee0a90e0b1 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -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 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::, + CheckInherents = CheckInherents, ); moonbeam_runtime_common::impl_self_contained_call!();