Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
ggwpez committed Jul 6, 2023
1 parent b7869da commit 2ce81eb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
1 change: 0 additions & 1 deletion client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ where
let mut block_builder =
self.client.new_block_at(self.parent_hash, inherent_digests, PR::ENABLED)?;

// The executive mode does not influence the execution of inherents:
self.apply_inherents(&mut block_builder, inherent_data)?;

let block_timer = time::Instant::now();
Expand Down
16 changes: 6 additions & 10 deletions frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,8 @@ impl<
}

Self::after_inherents(mode);
if mode == RuntimeExecutiveMode::Minimal {
if num_inherents < extrinsics.len() {
return Err(InvalidTransaction::NonMandatory.into())
}
if mode == RuntimeExecutiveMode::Minimal && extrinsics.len() > num_inherents {
return Err(InvalidTransaction::NonMandatory.into())
}
// Apply transactions:
for e in extrinsics.iter().skip(num_inherents) {
Expand Down Expand Up @@ -551,12 +549,10 @@ impl<
// Process inherents (if any).
Self::apply_extrinsics(extrinsics.iter().take(num_inherents), mode);
Self::after_inherents(mode);
if mode == RuntimeExecutiveMode::Minimal {
if num_inherents < extrinsics.len() {
// Note: It would be possible to not explicitly panic here since the state-root
// check should already catch any mismatch, but this makes it easier to debug.
panic!("Only inherents are allowed in 'Minimal' blocks");
}
if mode == RuntimeExecutiveMode::Minimal && extrinsics.len() > num_inherents {
// Note: It would be possible to not explicitly panic here since the state-root
// check should already catch any mismatch, but this makes it easier to debug.
panic!("Only inherents are allowed in 'Minimal' blocks");
}
// Process transactions (if any).
Self::apply_extrinsics(extrinsics.iter().skip(num_inherents), mode);
Expand Down
2 changes: 1 addition & 1 deletion primitives/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,9 @@ decl_runtime_apis! {
fn execute_block(block: Block);
/// Initialize a block with the given header.
#[changed_in(5)]
#[renamed("initialise_block", 2)]
fn initialize_block(header: &<Block as BlockT>::Header);
/// Initialize a block with the given header and return the runtime executive mode.
#[renamed("initialise_block", 2)]
fn initialize_block(header: &<Block as BlockT>::Header) -> RuntimeExecutiveMode;
}

Expand Down
4 changes: 2 additions & 2 deletions primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,14 @@ pub enum RuntimeExecutiveMode {
/// - Extrinsics with dispatch class `Normal`.
/// - `on_idle` hook.
Normal,
/// Only _really necessary_ logic is allowed to run.
/// Only _necessary_ logic is allowed to run.
///
/// Explicitly forbidden are:
/// - Extrinsics with dispatch classes `Normal` and `Operational`.
/// - `on_idle` and `poll` hooks.
///
/// Explicitly allowed are:
/// - Mandatory inherents and extrinsics (i.e. via OCW).
/// - Mandatory extrinsics (i.e. via OCW).
/// - `on_initialize` and `on_finalize` hooks.
/// - Storage migrations.
///
Expand Down
6 changes: 0 additions & 6 deletions test-utils/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,8 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(), // no migrations
MockedRuntimeExecutiveMode,
>;

parameter_types! {
pub storage MockedRuntimeExecutiveMode: sp_runtime::RuntimeExecutiveMode = Default::default();
}

#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct CheckSubstrateCall;

Expand Down

0 comments on commit 2ce81eb

Please sign in to comment.