Struct frame_executive::Executive
source · pub struct Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade = ()>(_);
Expand description
Main entry point for certain runtime actions as e.g. execute_block
.
Generic parameters:
System
: Something that implementsframe_system::Config
Block
: The block type of the runtimeContext
: The context that is used when checking an extrinsic.UnsignedValidator
: The unsigned transaction validator of the runtime.AllPalletsWithSystem
: Tuple that contains all pallets including frame system pallet. Will be used to call hooks e.g.on_initialize
.OnRuntimeUpgrade
: Custom logic that should be called after a runtime upgrade. Modules are already called byAllPalletsWithSystem
. It will be called before all modules will be called.
Implementations§
source§impl<System: Config + EnsureInherentsAreFirst<Block>, Block: Block<Header = System::Header, Hash = System::Hash>, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade + OnInitialize<System::BlockNumber> + OnIdle<System::BlockNumber> + OnFinalize<System::BlockNumber> + OffchainWorker<System::BlockNumber>, COnRuntimeUpgrade: OnRuntimeUpgrade> Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, COnRuntimeUpgrade>where
Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>: Applyable + GetDispatchInfo,
CallOf<Block::Extrinsic, Context>: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
OriginOf<Block::Extrinsic, Context>: From<Option<System::AccountId>>,
UnsignedValidator: ValidateUnsigned<Call = CallOf<Block::Extrinsic, Context>>,
impl<System: Config + EnsureInherentsAreFirst<Block>, Block: Block<Header = System::Header, Hash = System::Hash>, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade + OnInitialize<System::BlockNumber> + OnIdle<System::BlockNumber> + OnFinalize<System::BlockNumber> + OffchainWorker<System::BlockNumber>, COnRuntimeUpgrade: OnRuntimeUpgrade> Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, COnRuntimeUpgrade>where
Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>: Applyable + GetDispatchInfo,
CallOf<Block::Extrinsic, Context>: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
OriginOf<Block::Extrinsic, Context>: From<Option<System::AccountId>>,
UnsignedValidator: ValidateUnsigned<Call = CallOf<Block::Extrinsic, Context>>,
sourcepub fn execute_on_runtime_upgrade() -> Weight
pub fn execute_on_runtime_upgrade() -> Weight
Execute all OnRuntimeUpgrade
of this runtime, and return the aggregate weight.
Examples found in repository?
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
fn initialize_block_impl(
block_number: &System::BlockNumber,
parent_hash: &System::Hash,
digest: &Digest,
) {
// Reset events before apply runtime upgrade hook.
// This is required to preserve events from runtime upgrade hook.
// This means the format of all the event related storages must always be compatible.
<frame_system::Pallet<System>>::reset_events();
let mut weight = Weight::zero();
if Self::runtime_upgraded() {
weight = weight.saturating_add(Self::execute_on_runtime_upgrade());
}
<frame_system::Pallet<System>>::initialize(block_number, parent_hash, digest);
weight = weight.saturating_add(<AllPalletsWithSystem as OnInitialize<
System::BlockNumber,
>>::on_initialize(*block_number));
weight = weight.saturating_add(
<System::BlockWeights as frame_support::traits::Get<_>>::get().base_block,
);
<frame_system::Pallet<System>>::register_extra_weight_unchecked(
weight,
DispatchClass::Mandatory,
);
frame_system::Pallet::<System>::note_finished_initialize();
}
sourcepub fn initialize_block(header: &System::Header)
pub fn initialize_block(header: &System::Header)
Start the execution of a particular block.
Examples found in repository?
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
pub fn execute_block(block: Block) {
sp_io::init_tracing();
sp_tracing::within_span! {
sp_tracing::info_span!("execute_block", ?block);
Self::initialize_block(block.header());
// any initial checks
Self::initial_checks(&block);
let signature_batching = sp_runtime::SignatureBatching::start();
// execute extrinsics
let (header, extrinsics) = block.deconstruct();
Self::execute_extrinsics_with_book_keeping(extrinsics, *header.number());
if !signature_batching.verify() {
panic!("Signature verification failed.");
}
// any final checks
Self::final_checks(&header);
}
}
sourcepub fn execute_block(block: Block)
pub fn execute_block(block: Block)
Actually execute all transitions for block
.
sourcepub fn finalize_block() -> System::Header
pub fn finalize_block() -> System::Header
Finalize the block - it is up the caller to ensure that all header fields are valid except state-root.
sourcepub fn apply_extrinsic(uxt: Block::Extrinsic) -> ApplyExtrinsicResult
pub fn apply_extrinsic(uxt: Block::Extrinsic) -> ApplyExtrinsicResult
Apply extrinsic outside of the block execution function.
This doesn’t attempt to validate anything regarding the block, but it builds a list of uxt hashes.
Examples found in repository?
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
fn execute_extrinsics_with_book_keeping(
extrinsics: Vec<Block::Extrinsic>,
block_number: NumberFor<Block>,
) {
extrinsics.into_iter().for_each(|e| {
if let Err(e) = Self::apply_extrinsic(e) {
let err: &'static str = e.into();
panic!("{}", err)
}
});
// post-extrinsics book-keeping
<frame_system::Pallet<System>>::note_finished_extrinsics();
Self::idle_and_finalize_hook(block_number);
}
sourcepub fn validate_transaction(
source: TransactionSource,
uxt: Block::Extrinsic,
block_hash: Block::Hash
) -> TransactionValidity
pub fn validate_transaction(
source: TransactionSource,
uxt: Block::Extrinsic,
block_hash: Block::Hash
) -> TransactionValidity
Check a given signed transaction for validity. This doesn’t execute any side-effects; it merely checks whether the transaction would panic if it were included or not.
Changes made to storage should be discarded.
sourcepub fn offchain_worker(header: &System::Header)
pub fn offchain_worker(header: &System::Header)
Start an offchain worker and generate extrinsics.
Trait Implementations§
source§impl<System: Config + EnsureInherentsAreFirst<Block>, Block: Block<Header = System::Header, Hash = System::Hash>, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade + OnInitialize<System::BlockNumber> + OnIdle<System::BlockNumber> + OnFinalize<System::BlockNumber> + OffchainWorker<System::BlockNumber>, COnRuntimeUpgrade: OnRuntimeUpgrade> ExecuteBlock<Block> for Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, COnRuntimeUpgrade>where
Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>: Applyable + GetDispatchInfo,
CallOf<Block::Extrinsic, Context>: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
OriginOf<Block::Extrinsic, Context>: From<Option<System::AccountId>>,
UnsignedValidator: ValidateUnsigned<Call = CallOf<Block::Extrinsic, Context>>,
impl<System: Config + EnsureInherentsAreFirst<Block>, Block: Block<Header = System::Header, Hash = System::Hash>, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade + OnInitialize<System::BlockNumber> + OnIdle<System::BlockNumber> + OnFinalize<System::BlockNumber> + OffchainWorker<System::BlockNumber>, COnRuntimeUpgrade: OnRuntimeUpgrade> ExecuteBlock<Block> for Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, COnRuntimeUpgrade>where
Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>: Applyable + GetDispatchInfo,
CallOf<Block::Extrinsic, Context>: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
OriginOf<Block::Extrinsic, Context>: From<Option<System::AccountId>>,
UnsignedValidator: ValidateUnsigned<Call = CallOf<Block::Extrinsic, Context>>,
source§fn execute_block(block: Block)
fn execute_block(block: Block)
block
. Read moreAuto Trait Implementations§
impl<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade> RefUnwindSafe for Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade>where
AllPalletsWithSystem: RefUnwindSafe,
Block: RefUnwindSafe,
Context: RefUnwindSafe,
OnRuntimeUpgrade: RefUnwindSafe,
System: RefUnwindSafe,
UnsignedValidator: RefUnwindSafe,
impl<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade> Send for Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade>where
AllPalletsWithSystem: Send,
Block: Send,
Context: Send,
OnRuntimeUpgrade: Send,
System: Send,
UnsignedValidator: Send,
impl<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade> Sync for Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade>where
AllPalletsWithSystem: Sync,
Block: Sync,
Context: Sync,
OnRuntimeUpgrade: Sync,
System: Sync,
UnsignedValidator: Sync,
impl<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade> Unpin for Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade>where
AllPalletsWithSystem: Unpin,
Block: Unpin,
Context: Unpin,
OnRuntimeUpgrade: Unpin,
System: Unpin,
UnsignedValidator: Unpin,
impl<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade> UnwindSafe for Executive<System, Block, Context, UnsignedValidator, AllPalletsWithSystem, OnRuntimeUpgrade>where
AllPalletsWithSystem: UnwindSafe,
Block: UnwindSafe,
Context: UnwindSafe,
OnRuntimeUpgrade: UnwindSafe,
System: UnwindSafe,
UnsignedValidator: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.