Skip to content

Commit 97bfc23

Browse files
authored
Update evm and switch to shanghai hardfork (#2691)
* update PrecompileHandle ref: rust-ethereum/evm#122 * update fee calculation ref: rust-ethereum/evm#132 * add code_size/code_hash fn in StackState trait ref: rust-ethereum/evm#140 * update evm call stack ref: rust-ethereum/evm#136 * update evm call stack ref: rust-ethereum/evm#155 * add shanghai eips 3651, 3855, 3860 ref: rust-ethereum/evm#152 * update is_precompile ref: rust-ethereum/evm#157 * fix eip-3860 ref: rust-ethereum/evm#160 * update runtime config ref: rust-ethereum/evm#161 * add eip-4399 ref: rust-ethereum/evm#162 * fix eip-2618 ref: rust-ethereum/evm#163 * fix nonce back to U256 ref: rust-ethereum/evm#166 * remove exit_substate in create functions ref: rust-ethereum/evm#168 * record external cost ref: rust-ethereum/evm#170 * add record_external_operation ref: rust-ethereum/evm#171 * add storage_growth ref: rust-ethereum/evm#173 * update evm * switch to shanghai hardfork * update ecrecover ref: polkadot-evm/frontier#964 (#2696)
1 parent dd482ac commit 97bfc23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1565
-1262
lines changed

Cargo.lock

+25-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

evm-bench

modules/asset-registry/src/mock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub fn deploy_contracts() {
201201
H256::from_slice(&buf).as_bytes().to_vec()
202202
},
203203
}],
204-
used_gas: 1235081,
204+
used_gas: 1235455,
205205
used_storage: 5131,
206206
}));
207207

@@ -242,7 +242,7 @@ pub fn deploy_contracts_same_prefix() {
242242
H256::from_slice(&buf).as_bytes().to_vec()
243243
},
244244
}],
245-
used_gas: 1235081,
245+
used_gas: 1235455,
246246
used_storage: 5131,
247247
}));
248248

modules/currencies/src/mock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ pub fn deploy_contracts() {
303303
H256::from_slice(&buf).as_bytes().to_vec()
304304
},
305305
}],
306-
used_gas: 1235081,
306+
used_gas: 1235455,
307307
used_storage: 5131,
308308
}));
309309

modules/evm-bridge/src/mock.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub fn deploy_contracts() {
203203
H256::from_slice(&buf).as_bytes().to_vec()
204204
},
205205
}],
206-
used_gas: 1235081,
206+
used_gas: 1235455,
207207
used_storage: 5131,
208208
}));
209209

@@ -230,7 +230,7 @@ pub fn deploy_liquidation_ok_contracts() {
230230
from: alice_evm_addr(),
231231
contract: erc20_address(),
232232
logs: vec![],
233-
used_gas: 235274,
233+
used_gas: 235330,
234234
used_storage: 844,
235235
}));
236236

@@ -257,7 +257,7 @@ pub fn deploy_liquidation_err_contracts() {
257257
from: alice_evm_addr(),
258258
contract: erc20_address(),
259259
logs: vec![],
260-
used_gas: 228284,
260+
used_gas: 228338,
261261
used_storage: 818,
262262
}));
263263

modules/evm-utility/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ sha3 = { workspace = true }
99

1010
sp-std = { workspace = true }
1111

12-
evm = { git = "https://github.com/rust-blockchain/evm", rev = "13240a8a551586fdef0b5028ed73af80b248092a", default-features = false, features = ["with-codec"] }
13-
evm-gasometer = { git = "https://github.com/rust-blockchain/evm", rev = "13240a8a551586fdef0b5028ed73af80b248092a", default-features = false }
14-
evm-runtime = { git = "https://github.com/rust-blockchain/evm", rev = "13240a8a551586fdef0b5028ed73af80b248092a", default-features = false }
15-
ethereum = { version = "0.14.0", default-features = false, features = ["with-codec"] }
12+
evm = { version = "0.41.1", default-features = false, features = ["with-codec"] }
13+
evm-gasometer = { version = "0.41.0", default-features = false }
14+
evm-runtime = { version = "0.41.0", default-features = false }
15+
ethereum = { version = "0.15.0", default-features = false, features = ["with-codec"] }
1616

1717
[features]
1818
default = ["std"]

modules/evm/src/bench/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ fn whitelist_keys(b: &mut Bencher, from: H160, code: Vec<u8>) -> H160 {
8080
let state = SubstrateStackState::<Runtime>::new(&vicinity, metadata);
8181
let mut executor = StackExecutor::new_with_precompiles(state, config, &());
8282

83-
let mut runtime = EVMRuntime::new(Rc::new(code.clone()), Rc::new(Vec::new()), context, config);
83+
let mut runtime = EVMRuntime::new(
84+
Rc::new(code.clone()),
85+
Rc::new(Vec::new()),
86+
context,
87+
config.stack_limit,
88+
config.memory_limit,
89+
);
8490
let reason = executor.execute(&mut runtime);
8591

8692
assert!(reason.is_succeed(), "{:?}", reason);

modules/evm/src/lib.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
pub use crate::runner::{
2626
stack::SubstrateStackState,
27-
state::{PrecompileSet, StackExecutor, StackSubstateMetadata},
27+
state::{PrecompileResult, StackExecutor, StackSubstateMetadata},
2828
storage_meter::StorageMeter,
2929
Runner,
3030
};
@@ -46,7 +46,11 @@ use frame_system::{ensure_root, ensure_signed, pallet_prelude::*, EnsureRoot, En
4646
use hex_literal::hex;
4747
pub use module_evm_utility::{
4848
ethereum::{AccessListItem, Log, TransactionAction},
49-
evm::{self, Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed},
49+
evm::{
50+
self,
51+
executor::stack::{IsPrecompileResult, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileSet},
52+
Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed, ExternalOperation,
53+
},
5054
Account,
5155
};
5256
pub use module_support::{
@@ -100,17 +104,17 @@ pub type NegativeImbalanceOf<T> =
100104
pub const RESERVE_ID_STORAGE_DEPOSIT: ReserveIdentifier = ReserveIdentifier::EvmStorageDeposit;
101105
pub const RESERVE_ID_DEVELOPER_DEPOSIT: ReserveIdentifier = ReserveIdentifier::EvmDeveloperDeposit;
102106

103-
// Initially based on London hard fork configuration.
107+
// Initially based on shanghai hard fork configuration.
104108
static ACALA_CONFIG: EvmConfig = EvmConfig {
105109
refund_sstore_clears: 0, // no gas refund
106110
sstore_gas_metering: false, // no gas refund
107111
sstore_revert_under_stipend: false, // ignored
108112
create_contract_limit: Some(MaxCodeSize::get() as usize),
109-
..module_evm_utility::evm::Config::london()
113+
..module_evm_utility::evm::Config::shanghai()
110114
};
111115

112116
/// Create an empty contract `contract Empty { }`.
113-
pub const BASE_CREATE_GAS: u64 = 67_066;
117+
pub const BASE_CREATE_GAS: u64 = 67_072;
114118
/// Call function that just set a storage `function store(uint256 num) public { number = num; }`.
115119
pub const BASE_CALL_GAS: u64 = 43_702;
116120

@@ -410,8 +414,13 @@ pub mod module {
410414
let state = SubstrateStackState::<T>::new(&vicinity, metadata);
411415
let mut executor = StackExecutor::new_with_precompiles(state, T::config(), &());
412416

413-
let mut runtime =
414-
evm::Runtime::new(Rc::new(account.code.clone()), Rc::new(Vec::new()), context, T::config());
417+
let mut runtime = evm::Runtime::new(
418+
Rc::new(account.code.clone()),
419+
Rc::new(Vec::new()),
420+
context,
421+
T::config().stack_limit,
422+
T::config().memory_limit,
423+
);
415424
let reason = executor.execute(&mut runtime);
416425

417426
assert!(

0 commit comments

Comments
 (0)