From 137409f02ae6ad83be881b6cc07be23e3fb2bc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 1 Apr 2019 15:37:59 +0200 Subject: [PATCH] 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. --- substrate/core/test-runtime/src/system.rs | 22 ++++++------------ .../substrate_test_runtime.compact.wasm | Bin 60111 -> 60091 bytes substrate/node/runtime/src/lib.rs | 4 ++-- .../release/node_runtime.compact.wasm | Bin 948993 -> 948993 bytes substrate/srml/executive/src/lib.rs | 18 -------------- 5 files changed, 9 insertions(+), 35 deletions(-) diff --git a/substrate/core/test-runtime/src/system.rs b/substrate/core/test-runtime/src/system.rs index a119c8b62d..266b7130d4 100644 --- a/substrate/core/test-runtime/src/system.rs +++ b/substrate/core/test-runtime/src/system.rs @@ -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<::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 for BlockExecutor { fn execute_block(block: Block) { execute_block(block); } - - fn execute_extrinsics_without_checks(_: NumberFor, extrinsics: Vec<::Extrinsic>) { - execute_extrinsics_without_checks(extrinsics); - } } /// Execute a transaction outside of the block execution function. diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 7b81180d05a2dd1a5b2cb440a3db144553c444f1..efeca728ef9b23e8f3e3bb108bc041d65b9ff870 100644 GIT binary patch delta 154 zcmX?qm3jA7<_*c0Jqs8Z7?^_gY`0~t>jQrA) z_~eY#8Y%L)E3RI_oBz_RcHUi?a zXyS)~Vmd&)5GW3!VdftKvV9mBoEh?g5+IE*iSIx*$Uz=Jadjl||3Eei5WnR{wV0K$ Oy`+S9dr1jjFB<@(!73X7 diff --git a/substrate/srml/executive/src/lib.rs b/substrate/srml/executive/src/lib.rs index 48908a01b3..37b1b709f7 100644 --- a/substrate/srml/executive/src/lib.rs +++ b/substrate/srml/executive/src/lib.rs @@ -52,8 +52,6 @@ mod internal { pub trait ExecuteBlock { /// 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, extrinsics: Vec); } pub struct Executive( @@ -75,10 +73,6 @@ impl< fn execute_block(block: Block) { Executive::::execute_block(block); } - - fn execute_extrinsics_without_checks(block_number: NumberFor, extrinsics: Vec) { - Executive::::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, extrinsics: Vec) { - // Make the api happy, but maybe we should not set them at all. - let parent_hash = ::Hashing::hash(b"parent_hash"); - let extrinsics_root = ::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_number: NumberFor) { extrinsics.into_iter().for_each(Self::apply_extrinsic_no_note);