Make ExecuteBlock::execute_block return the final block header (#8244)

This pr changes the `ExecuteBlock` trait to return the final header that
results from executing the given block.
This commit is contained in:
Bastian Köcher
2021-03-03 09:44:34 +01:00
committed by GitHub
parent dc190a69f2
commit 4de4662480
9 changed files with 48 additions and 37 deletions
+20 -3
View File
@@ -26,9 +26,9 @@ use sp_runtime::{
RuntimeAppPublic, RuntimeDebug, BoundToRuntimeAppPublic,
ConsensusEngineId, DispatchResult, DispatchError,
traits::{
MaybeSerializeDeserialize, AtLeast32Bit, Saturating, TrailingZeroInput, Bounded, Zero,
BadOrigin, AtLeast32BitUnsigned, Convert, UniqueSaturatedFrom, UniqueSaturatedInto,
SaturatedConversion, StoredMapError,
MaybeSerializeDeserialize, AtLeast32Bit, Saturating, TrailingZeroInput, Bounded, Zero,
BadOrigin, AtLeast32BitUnsigned, Convert, UniqueSaturatedFrom, UniqueSaturatedInto,
SaturatedConversion, StoredMapError, Block as BlockT,
},
};
use sp_staking::SessionIndex;
@@ -2228,6 +2228,23 @@ pub trait GetPalletVersion {
fn storage_version() -> Option<PalletVersion>;
}
/// Something that can execute a given block.
///
/// Executing a block means that all extrinsics in a given block will be executed and the resulting
/// header will be checked against the header of the given block.
pub trait ExecuteBlock<Block: BlockT> {
/// Execute the given `block`.
///
/// This will execute all extrinsics in the block and check that the resulting header is correct.
///
/// Returns the result header.
///
/// # Panic
///
/// Panics when an extrinsics panics or the resulting header doesn't match the expected header.
fn execute_block(block: Block) -> Block::Header;
}
#[cfg(test)]
mod tests {
use super::*;