pallet-evm: configurable gasometer config (#5320)

* pallet-evm: configurable gasometer config

* Bump runtime impl_version

* Update evm to 0.16.1

Documentation updates

Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
Wei Tang
2020-03-23 13:30:40 +01:00
committed by GitHub
parent ad1876bf94
commit 14249913a6
3 changed files with 18 additions and 16 deletions
-5
View File
@@ -7,7 +7,6 @@ use sp_core::{U256, H256, H160};
use sp_runtime::traits::UniqueSaturatedInto;
use frame_support::storage::{StorageMap, StorageDoubleMap};
use sha3::{Keccak256, Digest};
use evm::Config;
use evm::backend::{Backend as BackendT, ApplyBackend, Apply};
use crate::{Trait, Accounts, AccountStorages, AccountCodes, Module, Event};
@@ -43,10 +42,6 @@ pub struct Vicinity {
pub origin: H160,
}
/// Gasometer config used for executor. Currently this is hard-coded to
/// Istanbul hard fork.
pub static GASOMETER_CONFIG: Config = Config::istanbul();
/// Substrate backend for EVM.
pub struct Backend<'vicinity, T> {
vicinity: &'vicinity Vicinity,
+9 -2
View File
@@ -35,7 +35,7 @@ use sp_runtime::{
DispatchResult, traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion},
};
use sha3::{Digest, Keccak256};
use evm::{ExitReason, ExitSucceed, ExitError};
use evm::{ExitReason, ExitSucceed, ExitError, Config};
use evm::executor::StackExecutor;
use evm::backend::ApplyBackend;
@@ -116,6 +116,8 @@ impl Precompiles for () {
}
}
static ISTANBUL_CONFIG: Config = Config::istanbul();
/// EVM module trait
pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
/// Calculator for current gas price.
@@ -128,6 +130,11 @@ pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
/// Precompiles associated with this EVM engine.
type Precompiles: Precompiles;
/// EVM config used in the module.
fn config() -> &'static Config {
&ISTANBUL_CONFIG
}
}
decl_storage! {
@@ -381,7 +388,7 @@ impl<T: Trait> Module<T> {
let mut executor = StackExecutor::new_with_precompile(
&backend,
gas_limit as usize,
&backend::GASOMETER_CONFIG,
T::config(),
T::Precompiles::execute,
);