Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
revert to empty CheckInherents
  • Loading branch information
slumber committed Aug 7, 2023
commit 4387fdc29183da89ccf21deee81c03a0ab75fe2c
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,4 @@ runtime-benchmarks = [

try-runtime = ["frame-support/try-runtime"]

parameterized-consensus-hook = [
"cumulus-pallet-parachain-system-proc-macro/parameterized-consensus-hook",
]
parameterized-consensus-hook = []
1 change: 0 additions & 1 deletion pallets/parachain-system/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ proc-macro-crate = "1.3.1"
[features]
default = [ "std" ]
std = []
parameterized-consensus-hook = []
32 changes: 7 additions & 25 deletions pallets/parachain-system/proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod keywords {
struct Input {
runtime: Path,
block_executor: Path,
check_inherents: Option<Path>,
check_inherents: Path,
}

impl Parse for Input {
Expand Down Expand Up @@ -59,7 +59,11 @@ impl Parse for Input {
}
}

while !input.is_empty() || runtime.is_none() || block_executor.is_none() {
while !input.is_empty() ||
runtime.is_none() ||
block_executor.is_none() ||
check_inherents.is_none()
{
let lookahead = input.lookahead1();

if lookahead.peek(keywords::Runtime) {
Expand All @@ -76,7 +80,7 @@ impl Parse for Input {
Ok(Self {
runtime: runtime.expect("Everything is parsed before; qed"),
block_executor: block_executor.expect("Everything is parsed before; qed"),
check_inherents,
check_inherents: check_inherents.expect("Everything is parsed before; qed"),
})
}
}
Expand All @@ -102,28 +106,6 @@ pub fn register_validate_block(input: proc_macro::TokenStream) -> proc_macro::To
Err(e) => return e.into_compile_error().into(),
};

let check_inherents = match check_inherents {
Some(_check_inherents) => {
#[cfg(not(feature = "parameterized-consensus-hook"))]
quote::quote! { #_check_inherents }
#[cfg(feature = "parameterized-consensus-hook")]
return Error::new(
Span::call_site(),
"CheckInherents is incompatible with consensus hook feature",
)
.into_compile_error()
.into()
},
None => {
#[cfg(feature = "parameterized-consensus-hook")]
quote::quote! { #crate_::DummyCheckInherents<<#runtime as #crate_::validate_block::GetRuntimeBlockType>::RuntimeBlock> }
#[cfg(not(feature = "parameterized-consensus-hook"))]
return Error::new(Span::call_site(), "missing CheckInherents input")
.into_compile_error()
.into()
},
};

if cfg!(not(feature = "std")) {
quote::quote! {
#[doc(hidden)]
Expand Down
21 changes: 6 additions & 15 deletions pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ pub use consensus_hook::{ConsensusHook, ExpectParentIncluded};
/// ```
/// struct BlockExecutor;
/// struct Runtime;
/// struct CheckInherents;
///
/// cumulus_pallet_parachain_system::register_validate_block! {
/// Runtime = Runtime,
/// BlockExecutor = Executive,
/// CheckInherents = CheckInherents,
/// }
///
/// # fn main() {}
Expand Down Expand Up @@ -1498,7 +1500,10 @@ impl<T: Config> UpwardMessageSender for Pallet<T> {
}

/// Something that can check the inherents of a block.
#[deprecated = "use `cumulus-pallet-aura-ext::FixedVelocityConsensusHook` instead"]
#[cfg_attr(
feature = "parameterized-consensus-hook",
deprecated = "consider switching to `cumulus-pallet-parachain-system::ConsensusHook`"
)]
pub trait CheckInherents<Block: BlockT> {
/// Check all inherents of the block.
///
Expand All @@ -1510,20 +1515,6 @@ pub trait CheckInherents<Block: BlockT> {
) -> frame_support::inherent::CheckInherentsResult;
}

/// Struct that always returns `Ok` on inherents check, needed for backwards-compatibility.
#[doc(hidden)]
pub struct DummyCheckInherents<Block>(sp_std::marker::PhantomData<Block>);

#[allow(deprecated)]
impl<Block: BlockT> CheckInherents<Block> for DummyCheckInherents<Block> {
fn check_inherents(
_: &Block,
_: &RelayChainStateProof,
) -> frame_support::inherent::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

/// Something that should be informed about system related events.
///
/// This includes events like [`on_validation_data`](Self::on_validation_data) that is being
Expand Down
6 changes: 4 additions & 2 deletions pallets/parachain-system/src/validate_block/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ fn with_externalities<F: FnOnce(&mut dyn Externalities) -> R, R>(f: F) -> R {
/// we have the in-memory database that contains all the values from the state of the parachain
/// that we require to verify the block.
///
/// 5. The last step is to execute the entire block in the machinery we just have setup. Executing
/// 5. We are going to run `check_inherents`. This is important to check stuff like the timestamp
/// matching the real world time.
///
/// 6. The last step is to execute the entire block in the machinery we just have setup. Executing
/// the blocks include running all transactions in the block against our in-memory database and
/// ensuring that the final storage root matches the storage root in the header of the block. In the
/// end we return back the [`ValidationResult`] with all the required information for the validator.
Expand Down Expand Up @@ -164,7 +167,6 @@ where
sp_io::offchain_index::host_clear.replace_implementation(host_offchain_index_clear),
);

#[cfg(not(feature = "parameterized-consensus-hook"))]
run_with_externalities::<B, _, _>(&backend, || {
let relay_chain_proof = crate::RelayChainStateProof::new(
PSC::SelfParaId::get(),
Expand Down
13 changes: 13 additions & 0 deletions parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,20 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}
13 changes: 13 additions & 0 deletions parachains/runtimes/assets/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,22 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}

#[cfg(feature = "state-trie-version-1")]
Expand Down
13 changes: 13 additions & 0 deletions parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,22 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}

#[cfg(test)]
Expand Down
13 changes: 13 additions & 0 deletions parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,9 +1355,22 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}

pub mod migrations {
Expand Down
13 changes: 13 additions & 0 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,20 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}
13 changes: 13 additions & 0 deletions parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,20 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}
13 changes: 13 additions & 0 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,22 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}

#[cfg(test)]
Expand Down
13 changes: 13 additions & 0 deletions parachains/runtimes/collectives/collectives-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,20 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}
13 changes: 13 additions & 0 deletions parachains/runtimes/contracts/contracts-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,20 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
}
13 changes: 13 additions & 0 deletions parachains/runtimes/glutton/glutton-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,20 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = Executive,
CheckInherents = CheckInherents,
}
13 changes: 13 additions & 0 deletions parachains/runtimes/starters/seedling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,20 @@ impl_runtime_apis! {
}
}

struct CheckInherents;

#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &Block,
_: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
sp_inherents::CheckInherentsResult::new()
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = Executive,
CheckInherents = CheckInherents,
}
Loading