Remove execute_extrinsics_without_checks as it will not be required (#2145)

This functionality was added by me for Cumulus, but after better
understanding Cumulus, this will not be required.
This commit is contained in:
Bastian Köcher
2019-04-01 15:37:59 +02:00
committed by Gav Wood
parent eca163ba64
commit 137409f02a
5 changed files with 9 additions and 35 deletions
+7 -15
View File
@@ -21,7 +21,7 @@ use rstd::prelude::*;
use runtime_io::{storage_root, enumerated_trie_root, storage_changes_root, twox_128};
use runtime_support::storage::{self, StorageValue, StorageMap};
use runtime_support::storage_items;
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256, Digest as DigestT, NumberFor, Block as BlockT};
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256, Digest as DigestT};
use runtime_primitives::generic;
use runtime_primitives::{ApplyError, ApplyOutcome, ApplyResult, transaction_validity::TransactionValidity};
use parity_codec::{KeyedVec, Encode};
@@ -70,15 +70,6 @@ pub fn initialize_block(header: &Header) {
storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32);
}
fn execute_extrinsics_without_checks(extrinsics: Vec<<Block as BlockT>::Extrinsic>) {
// execute transactions
extrinsics.into_iter().enumerate().for_each(|(i, e)| {
storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &(i as u32));
execute_transaction_backend(&e).unwrap_or_else(|_| panic!("Invalid transaction"));
storage::unhashed::kill(well_known_keys::EXTRINSIC_INDEX);
});
}
/// Actually execute all transitioning for `block`.
pub fn polish_block(block: &mut Block) {
let header = &mut block.header;
@@ -120,7 +111,12 @@ pub fn execute_block(block: Block) {
info_expect_equal_hash(&txs_root, &header.extrinsics_root);
assert!(txs_root == header.extrinsics_root, "Transaction trie root must be valid.");
execute_extrinsics_without_checks(block.extrinsics);
// execute transactions
block.extrinsics.into_iter().enumerate().for_each(|(i, e)| {
storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &(i as u32));
execute_transaction_backend(&e).unwrap_or_else(|_| panic!("Invalid transaction"));
storage::unhashed::kill(well_known_keys::EXTRINSIC_INDEX);
});
// check storage root.
let storage_root = storage_root().into();
@@ -145,10 +141,6 @@ impl executive::ExecuteBlock<Block> for BlockExecutor {
fn execute_block(block: Block) {
execute_block(block);
}
fn execute_extrinsics_without_checks(_: NumberFor<Block>, extrinsics: Vec<<Block as BlockT>::Extrinsic>) {
execute_extrinsics_without_checks(extrinsics);
}
}
/// Execute a transaction outside of the block execution function.
+2 -2
View File
@@ -59,8 +59,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node"),
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 54,
impl_version: 54,
spec_version: 55,
impl_version: 55,
apis: RUNTIME_API_VERSIONS,
};
-18
View File
@@ -52,8 +52,6 @@ mod internal {
pub trait ExecuteBlock<Block: BlockT> {
/// Actually execute all transitioning for `block`.
fn execute_block(block: Block);
/// Execute all extrinsics like when executing a `block`, but with dropping intial and final checks.
fn execute_extrinsics_without_checks(block_number: NumberFor<Block>, extrinsics: Vec<Block::Extrinsic>);
}
pub struct Executive<System, Block, Context, Payment, AllModules>(
@@ -75,10 +73,6 @@ impl<
fn execute_block(block: Block) {
Executive::<System, Block, Context, Payment, AllModules>::execute_block(block);
}
fn execute_extrinsics_without_checks(block_number: NumberFor<Block>, extrinsics: Vec<Block::Extrinsic>) {
Executive::<System, Block, Context, Payment, AllModules>::execute_extrinsics_without_checks(block_number, extrinsics);
}
}
impl<
@@ -134,18 +128,6 @@ impl<
Self::final_checks(&header);
}
/// Execute all extrinsics like when executing a `block`, but with dropping intial and final checks.
pub fn execute_extrinsics_without_checks(block_number: NumberFor<Block>, extrinsics: Vec<Block::Extrinsic>) {
// Make the api happy, but maybe we should not set them at all.
let parent_hash = <Block::Header as Header>::Hashing::hash(b"parent_hash");
let extrinsics_root = <Block::Header as Header>::Hashing::hash(b"extrinsics_root");
Self::initialize_block_impl(&block_number, &parent_hash, &extrinsics_root);
// execute extrinsics
Self::execute_extrinsics_with_book_keeping(extrinsics, block_number);
}
/// Execute given extrinsics and take care of post-extrinsics book-keeping
fn execute_extrinsics_with_book_keeping(extrinsics: Vec<Block::Extrinsic>, block_number: NumberFor<Block>) {
extrinsics.into_iter().for_each(Self::apply_extrinsic_no_note);