Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update evm and switch to shanghai hardfork #2691

Merged
merged 24 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e666a3c
update PrecompileHandle ref: https://github.com/rust-ethereum/evm/pul…
zjb0807 Jan 11, 2024
5655b15
update fee calculation ref: https://github.com/rust-ethereum/evm/pull…
zjb0807 Jan 11, 2024
2e362fc
add code_size/code_hash fn in StackState trait ref: https://github.co…
zjb0807 Jan 12, 2024
37e4925
update evm call stack ref: https://github.com/rust-ethereum/evm/pull/136
zjb0807 Jan 13, 2024
d8729c0
update evm call stack ref: https://github.com/rust-ethereum/evm/pull/155
zjb0807 Jan 14, 2024
e5e853f
add shanghai eips 3651, 3855, 3860 ref: https://github.com/rust-ether…
zjb0807 Jan 15, 2024
26ae671
update is_precompile ref: https://github.com/rust-ethereum/evm/pull/157
zjb0807 Jan 16, 2024
25f55c1
fix eip-3860 ref: https://github.com/rust-ethereum/evm/pull/160
zjb0807 Jan 16, 2024
5a41d40
update runtime config ref: https://github.com/rust-ethereum/evm/pull/161
zjb0807 Jan 17, 2024
05f6418
add eip-4399 ref: https://github.com/rust-ethereum/evm/pull/162
zjb0807 Jan 17, 2024
47cb26f
fix eip-2618 ref: https://github.com/rust-ethereum/evm/pull/163
zjb0807 Jan 17, 2024
8d17aa8
fix nonce back to U256 ref: https://github.com/rust-ethereum/evm/pull…
zjb0807 Jan 17, 2024
298a300
remove exit_substate in create functions ref: https://github.com/rust…
zjb0807 Jan 17, 2024
8a5dbb9
record external cost ref: https://github.com/rust-ethereum/evm/pull/170
zjb0807 Jan 18, 2024
322eca3
add record_external_operation ref: https://github.com/rust-ethereum/e…
zjb0807 Jan 18, 2024
f46585e
add storage_growth ref: https://github.com/rust-ethereum/evm/pull/173
zjb0807 Jan 20, 2024
ba375e9
update evm
zjb0807 Jan 20, 2024
4076783
switch to shanghai hardfork
zjb0807 Jan 22, 2024
d7ca9ff
fix tests
zjb0807 Jan 22, 2024
4a5127a
Merge remote-tracking branch 'origin/master' into update-evm
zjb0807 Jan 22, 2024
2c7f562
fix tests
zjb0807 Jan 24, 2024
f0013a4
fix evm-tests
zjb0807 Jan 24, 2024
4027f4d
update ecrecover ref: https://github.com/polkadot-evm/frontier/pull/9…
zjb0807 Jan 28, 2024
17b3d02
merge origin/master
zjb0807 Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 25 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion evm-bench
Submodule evm-bench updated 1 files
+4 −4 build/benches.json
4 changes: 2 additions & 2 deletions modules/asset-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub fn deploy_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand Down Expand Up @@ -242,7 +242,7 @@ pub fn deploy_contracts_same_prefix() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand Down
2 changes: 1 addition & 1 deletion modules/currencies/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ pub fn deploy_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand Down
6 changes: 3 additions & 3 deletions modules/evm-bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn deploy_contracts() {
H256::from_slice(&buf).as_bytes().to_vec()
},
}],
used_gas: 1235081,
used_gas: 1235455,
used_storage: 5131,
}));

Expand All @@ -230,7 +230,7 @@ pub fn deploy_liquidation_ok_contracts() {
from: alice_evm_addr(),
contract: erc20_address(),
logs: vec![],
used_gas: 235274,
used_gas: 235330,
used_storage: 844,
}));

Expand All @@ -257,7 +257,7 @@ pub fn deploy_liquidation_err_contracts() {
from: alice_evm_addr(),
contract: erc20_address(),
logs: vec![],
used_gas: 228284,
used_gas: 228338,
used_storage: 818,
}));

Expand Down
8 changes: 4 additions & 4 deletions modules/evm-utility/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ sha3 = { workspace = true }

sp-std = { workspace = true }

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

[features]
default = ["std"]
Expand Down
8 changes: 7 additions & 1 deletion modules/evm/src/bench/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ fn whitelist_keys(b: &mut Bencher, from: H160, code: Vec<u8>) -> H160 {
let state = SubstrateStackState::<Runtime>::new(&vicinity, metadata);
let mut executor = StackExecutor::new_with_precompiles(state, config, &());

let mut runtime = EVMRuntime::new(Rc::new(code.clone()), Rc::new(Vec::new()), context, config);
let mut runtime = EVMRuntime::new(
Rc::new(code.clone()),
Rc::new(Vec::new()),
context,
config.stack_limit,
config.memory_limit,
);
let reason = executor.execute(&mut runtime);

assert!(reason.is_succeed(), "{:?}", reason);
Expand Down
23 changes: 16 additions & 7 deletions modules/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

pub use crate::runner::{
stack::SubstrateStackState,
state::{PrecompileSet, StackExecutor, StackSubstateMetadata},
state::{PrecompileResult, StackExecutor, StackSubstateMetadata},
storage_meter::StorageMeter,
Runner,
};
Expand All @@ -46,7 +46,11 @@ use frame_system::{ensure_root, ensure_signed, pallet_prelude::*, EnsureRoot, En
use hex_literal::hex;
pub use module_evm_utility::{
ethereum::{AccessListItem, Log, TransactionAction},
evm::{self, Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed},
evm::{
self,
executor::stack::{IsPrecompileResult, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileSet},
Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed, ExternalOperation,
},
Account,
};
pub use module_support::{
Expand Down Expand Up @@ -100,17 +104,17 @@ pub type NegativeImbalanceOf<T> =
pub const RESERVE_ID_STORAGE_DEPOSIT: ReserveIdentifier = ReserveIdentifier::EvmStorageDeposit;
pub const RESERVE_ID_DEVELOPER_DEPOSIT: ReserveIdentifier = ReserveIdentifier::EvmDeveloperDeposit;

// Initially based on London hard fork configuration.
// Initially based on shanghai hard fork configuration.
static ACALA_CONFIG: EvmConfig = EvmConfig {
refund_sstore_clears: 0, // no gas refund
sstore_gas_metering: false, // no gas refund
sstore_revert_under_stipend: false, // ignored
create_contract_limit: Some(MaxCodeSize::get() as usize),
..module_evm_utility::evm::Config::london()
..module_evm_utility::evm::Config::shanghai()
};

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

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

let mut runtime =
evm::Runtime::new(Rc::new(account.code.clone()), Rc::new(Vec::new()), context, T::config());
let mut runtime = evm::Runtime::new(
Rc::new(account.code.clone()),
Rc::new(Vec::new()),
context,
T::config().stack_limit,
T::config().memory_limit,
);
let reason = executor.execute(&mut runtime);

assert!(
Expand Down
Loading
Loading