From 7b9add7a715bad73018a76c8aa2373bdd1036b0a Mon Sep 17 00:00:00 2001 From: tgmichel Date: Tue, 2 Jun 2020 17:18:45 +0200 Subject: [PATCH] pallet-evm ensure gas_price + Storage getter (#6191) * evm: move gas price check to top-level dispatchable * Add AccountCodes get fn and account_exists helper * Remove account_exists, evm handles non-existing accounts * Runtime bump impl_version 251/2 * Fix Runtime impl_version and spec_version Co-authored-by: Wei Tang --- substrate/bin/node/runtime/src/lib.rs | 2 +- substrate/frame/evm/src/lib.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 229aa3a9be..0f09940a4c 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -94,7 +94,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. spec_version: 251, - impl_version: 1, + impl_version: 2, apis: RUNTIME_API_VERSIONS, transaction_version: 1, }; diff --git a/substrate/frame/evm/src/lib.rs b/substrate/frame/evm/src/lib.rs index eab3c80a93..c5df79fdb8 100644 --- a/substrate/frame/evm/src/lib.rs +++ b/substrate/frame/evm/src/lib.rs @@ -158,7 +158,7 @@ pub struct GenesisAccount { decl_storage! { trait Store for Module as EVM { Accounts get(fn accounts): map hasher(blake2_128_concat) H160 => Account; - AccountCodes: map hasher(blake2_128_concat) H160 => Vec; + AccountCodes get(fn account_codes): map hasher(blake2_128_concat) H160 => Vec; AccountStorages: double_map hasher(blake2_128_concat) H160, hasher(blake2_128_concat) H256 => H256; } @@ -288,6 +288,8 @@ decl_module! { gas_price: U256, nonce: Option, ) -> DispatchResult { + ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::::GasPriceTooLow); + let sender = ensure_signed(origin)?; let source = T::ConvertAccountId::convert_account_id(&sender); @@ -318,6 +320,8 @@ decl_module! { gas_price: U256, nonce: Option, ) -> DispatchResult { + ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::::GasPriceTooLow); + let sender = ensure_signed(origin)?; let source = T::ConvertAccountId::convert_account_id(&sender); @@ -350,6 +354,8 @@ decl_module! { gas_price: U256, nonce: Option, ) -> DispatchResult { + ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::::GasPriceTooLow); + let sender = ensure_signed(origin)?; let source = T::ConvertAccountId::convert_account_id(&sender); @@ -498,8 +504,6 @@ impl Module { ) -> Result> where F: FnOnce(&mut StackExecutor>) -> (R, ExitReason), { - ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::::GasPriceTooLow); - let vicinity = Vicinity { gas_price, origin: source,