mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 14:41:11 +00:00
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:
@@ -18,7 +18,6 @@ sp-consensus-aura = { version = "0.9.0", default-features = false, path = "../..
|
||||
sp-consensus-babe = { version = "0.9.0", default-features = false, path = "../../primitives/consensus/babe" }
|
||||
sp-block-builder = { version = "3.0.0", default-features = false, path = "../../primitives/block-builder" }
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
frame-executive = { version = "3.0.0", default-features = false, path = "../../frame/executive" }
|
||||
sp-inherents = { version = "3.0.0", default-features = false, path = "../../primitives/inherents" }
|
||||
sp-keyring = { version = "3.0.0", optional = true, path = "../../primitives/keyring" }
|
||||
memory-db = { version = "0.26.0", default-features = false }
|
||||
@@ -68,7 +67,6 @@ std = [
|
||||
"sp-consensus-babe/std",
|
||||
"sp-block-builder/std",
|
||||
"codec/std",
|
||||
"frame-executive/std",
|
||||
"sp-inherents/std",
|
||||
"sp-keyring",
|
||||
"log/std",
|
||||
|
||||
@@ -615,7 +615,7 @@ cfg_if! {
|
||||
}
|
||||
|
||||
fn execute_block(block: Block) {
|
||||
system::execute_block(block)
|
||||
system::execute_block(block);
|
||||
}
|
||||
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
@@ -869,7 +869,7 @@ cfg_if! {
|
||||
}
|
||||
|
||||
fn execute_block(block: Block) {
|
||||
system::execute_block(block)
|
||||
system::execute_block(block);
|
||||
}
|
||||
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
|
||||
@@ -107,11 +107,11 @@ pub fn polish_block(block: &mut Block) {
|
||||
execute_block_with_state_root_handler(block, Mode::Overwrite);
|
||||
}
|
||||
|
||||
pub fn execute_block(mut block: Block) {
|
||||
execute_block_with_state_root_handler(&mut block, Mode::Verify);
|
||||
pub fn execute_block(mut block: Block) -> Header {
|
||||
execute_block_with_state_root_handler(&mut block, Mode::Verify)
|
||||
}
|
||||
|
||||
fn execute_block_with_state_root_handler(block: &mut Block, mode: Mode) {
|
||||
fn execute_block_with_state_root_handler(block: &mut Block, mode: Mode) -> Header {
|
||||
let header = &mut block.header;
|
||||
|
||||
initialize_block(header);
|
||||
@@ -142,14 +142,16 @@ fn execute_block_with_state_root_handler(block: &mut Block, mode: Mode) {
|
||||
"Transaction trie root must be valid.",
|
||||
);
|
||||
}
|
||||
|
||||
new_header
|
||||
}
|
||||
|
||||
/// The block executor.
|
||||
pub struct BlockExecutor;
|
||||
|
||||
impl frame_executive::ExecuteBlock<Block> for BlockExecutor {
|
||||
fn execute_block(block: Block) {
|
||||
execute_block(block);
|
||||
impl frame_support::traits::ExecuteBlock<Block> for BlockExecutor {
|
||||
fn execute_block(block: Block) -> Header {
|
||||
execute_block(block)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +409,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn block_import_works_native() {
|
||||
block_import_works(|b, ext| ext.execute_with(|| execute_block(b)));
|
||||
block_import_works(|b, ext| ext.execute_with(|| { execute_block(b); }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -507,7 +509,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn block_import_with_transaction_works_native() {
|
||||
block_import_with_transaction_works(|b, ext| ext.execute_with(|| execute_block(b)));
|
||||
block_import_with_transaction_works(|b, ext| ext.execute_with(|| { execute_block(b); }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user