Skip to content

Commit d404931

Browse files
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 <[email protected]>
1 parent bee2811 commit d404931

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/backend.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use sp_core::{U256, H256, H160};
77
use sp_runtime::traits::UniqueSaturatedInto;
88
use frame_support::storage::{StorageMap, StorageDoubleMap};
99
use sha3::{Keccak256, Digest};
10-
use evm::Config;
1110
use evm::backend::{Backend as BackendT, ApplyBackend, Apply};
1211
use crate::{Trait, Accounts, AccountStorages, AccountCodes, Module, Event};
1312

@@ -43,10 +42,6 @@ pub struct Vicinity {
4342
pub origin: H160,
4443
}
4544

46-
/// Gasometer config used for executor. Currently this is hard-coded to
47-
/// Istanbul hard fork.
48-
pub static GASOMETER_CONFIG: Config = Config::istanbul();
49-
5045
/// Substrate backend for EVM.
5146
pub struct Backend<'vicinity, T> {
5247
vicinity: &'vicinity Vicinity,

src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use sp_runtime::{
3535
DispatchResult, traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion},
3636
};
3737
use sha3::{Digest, Keccak256};
38-
use evm::{ExitReason, ExitSucceed, ExitError};
38+
use evm::{ExitReason, ExitSucceed, ExitError, Config};
3939
use evm::executor::StackExecutor;
4040
use evm::backend::ApplyBackend;
4141

@@ -116,6 +116,8 @@ impl Precompiles for () {
116116
}
117117
}
118118

119+
static ISTANBUL_CONFIG: Config = Config::istanbul();
120+
119121
/// EVM module trait
120122
pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
121123
/// Calculator for current gas price.
@@ -128,6 +130,11 @@ pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
128130
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
129131
/// Precompiles associated with this EVM engine.
130132
type Precompiles: Precompiles;
133+
134+
/// EVM config used in the module.
135+
fn config() -> &'static Config {
136+
&ISTANBUL_CONFIG
137+
}
131138
}
132139

133140
decl_storage! {
@@ -381,7 +388,7 @@ impl<T: Trait> Module<T> {
381388
let mut executor = StackExecutor::new_with_precompile(
382389
&backend,
383390
gas_limit as usize,
384-
&backend::GASOMETER_CONFIG,
391+
T::config(),
385392
T::Precompiles::execute,
386393
);
387394

0 commit comments

Comments
 (0)