Skip to content

Commit

Permalink
Merge branch 'feat/prague-hard-fork' into feat/mega-eof
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Oct 17, 2024
2 parents 8e8b3b2 + d42b60d commit 7b21250
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:

- name: Clippy
run: cargo clippy --workspace --all-targets -- -D clippy::all -D clippy::nursery

- name: Clippy no_std
run: cargo clippy --no-default-features -- -D clippy::all -D clippy::nursery
- name: Clippy with features
run: cargo clippy --features tracing,create-fixed -- -D clippy::all -D clippy::nursery

build:
runs-on: ubuntu-latest
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ keywords.workspace = true
edition.workspace = true

[workspace.dependencies]
evm = { version = "0.46.0", path = "." }
evm-core = { version = "0.46.0", path = "core", default-features = false }
evm-gasometer = { version = "0.46.0", path = "gasometer", default-features = false }
evm-runtime = { version = "0.46.0", path = "runtime", default-features = false }
evm = { version = "0.46.1", path = "." }
evm-core = { version = "0.46.1", path = "core", default-features = false }
evm-gasometer = { version = "0.46.1", path = "gasometer", default-features = false }
evm-runtime = { version = "0.46.1", path = "runtime", default-features = false }
primitive-types = { version = "0.12", default-features = false }
auto_impl = "1.0"
sha3 = { version = "0.10", default-features = false }
Expand Down Expand Up @@ -88,7 +88,7 @@ create-fixed = []
print-debug = ["evm-gasometer/print-debug"]

[workspace.package]
version = "0.46.0"
version = "0.46.1"
license = "Apache-2.0"
authors = ["Aurora Labs <[email protected]>", "Wei Tang <[email protected]>", "Parity Technologies <[email protected]>"]
description = "Portable Ethereum Virtual Machine implementation written in pure Rust."
Expand Down
53 changes: 22 additions & 31 deletions src/executor/stack/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,18 +595,12 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
gas_limit: u64,
access_list: Vec<(H160, Vec<H256>)>, // See EIP-2930
) -> (ExitReason, Vec<u8>) {
if self.nonce(caller) >= U64_MAX {
return (ExitError::MaxNonce.into(), Vec::new());
}

let address = self.create_address(CreateScheme::Legacy { caller });

event!(TransactCreate {
caller,
value,
init_code: &init_code,
gas_limit,
address,
address: self.create_address(CreateScheme::Legacy { caller }),
});

if let Some(limit) = self.config.max_initcode_size {
Expand All @@ -620,7 +614,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
return emit_exit!(e.into(), Vec::new());
}

self.warm_addresses_and_storage(caller, address, access_list);
self.warm_addresses_and_storage(&[caller], access_list);

let create_inner_result = if self.config.has_eof && init_code.starts_with(EOF_MAGIC) {
self.create_eof_inner(caller, value, init_code, Some(gas_limit), false)
Expand Down Expand Up @@ -656,21 +650,19 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
gas_limit: u64,
access_list: Vec<(H160, Vec<H256>)>, // See EIP-2930
) -> (ExitReason, Vec<u8>) {
let address = self.create_address(CreateScheme::Fixed(address));

event!(TransactCreate {
caller,
value,
init_code: &init_code,
gas_limit,
address
address: self.create_address(CreateScheme::Fixed(address)),
});

if let Err(e) = self.record_create_transaction_cost(&init_code, &access_list) {
return emit_exit!(e.into(), Vec::new());
}

self.warm_addresses_and_storage(caller, address, access_list);
self.warm_addresses_and_storage(&[caller], access_list);

match self.create_inner(
caller,
Expand Down Expand Up @@ -701,33 +693,32 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
gas_limit: u64,
access_list: Vec<(H160, Vec<H256>)>, // See EIP-2930
) -> (ExitReason, Vec<u8>) {
if let Some(limit) = self.config.max_initcode_size {
if init_code.len() > limit {
self.state.metadata_mut().gasometer.fail();
return emit_exit!(ExitError::CreateContractLimit.into(), Vec::new());
}
}

let code_hash = H256::from_slice(Keccak256::digest(&init_code).as_slice());
let address = self.create_address(CreateScheme::Create2 {
caller,
code_hash,
salt,
});
event!(TransactCreate2 {
caller,
value,
init_code: &init_code,
salt,
gas_limit,
address,
address: self.create_address(CreateScheme::Create2 {
caller,
code_hash,
salt,
}),
});

if let Some(limit) = self.config.max_initcode_size {
if init_code.len() > limit {
self.state.metadata_mut().gasometer.fail();
return emit_exit!(ExitError::CreateContractLimit.into(), Vec::new());
}
}

if let Err(e) = self.record_create_transaction_cost(&init_code, &access_list) {
return emit_exit!(e.into(), Vec::new());
}

self.warm_addresses_and_storage(caller, address, access_list);
self.warm_addresses_and_storage(&[caller], access_list);

match self.create_inner(
caller,
Expand Down Expand Up @@ -791,7 +782,8 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
return (e.into(), Vec::new());
}

self.warm_addresses_and_storage(caller, address, access_list);
self.warm_addresses_and_storage(&[caller, address], access_list);

// EIP-7702. authorized accounts
// NOTE: it must be after `inc_nonce`
if let Err(e) = self.authorized_accounts(authorization_list) {
Expand Down Expand Up @@ -913,8 +905,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
/// - [EIP-3651: Warm COINBASE](https://eips.ethereum.org/EIPS/eip-3651)
fn warm_addresses_and_storage(
&mut self,
caller: H160,
address: H160,
addresses: &[H160],
access_list: Vec<(H160, Vec<H256>)>,
) {
if self.config.increase_state_access_gas {
Expand All @@ -923,11 +914,11 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
let coinbase = self.block_coinbase();
self.state
.metadata_mut()
.access_addresses([caller, address, coinbase].iter().copied());
.access_addresses(addresses.iter().copied().chain(Some(coinbase)));
} else {
self.state
.metadata_mut()
.access_addresses([caller, address].iter().copied());
.access_addresses(addresses.iter().copied());
};

self.warm_access_list(access_list);
Expand Down

0 comments on commit 7b21250

Please sign in to comment.