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

feat(Prague): Add EIP-7702 #1565

Merged
merged 14 commits into from
Jun 28, 2024
44 changes: 22 additions & 22 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ debug = true
[profile.ethtests]
inherits = "test"
opt-level = 3

# [patch.crates-io]
# alloy-eips = { git = "https://github.com/alloy-rs/alloy.git", rev = "41d4c7c" }
# alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "41d4c7c" }
# alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "41d4c7c" }
10 changes: 7 additions & 3 deletions crates/interpreter/src/gas/calc.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use revm_primitives::AccessListItem;

use super::constants::*;
use crate::{
num_words,
primitives::{SpecId, U256},
primitives::{AccessListItem, SpecId, U256},
SelfDestructResult,
};

Expand Down Expand Up @@ -359,6 +357,7 @@ pub fn validate_initial_tx_gas(
input: &[u8],
is_create: bool,
access_list: &[AccessListItem],
authorization_list_num: u64,
) -> u64 {
let mut initial_gas = 0;
let zero_data_len = input.iter().filter(|v| **v == 0).count() as u64;
Expand Down Expand Up @@ -399,5 +398,10 @@ pub fn validate_initial_tx_gas(
initial_gas += initcode_cost(input.len() as u64)
}

// EIP-7702
if spec_id.is_enabled_in(SpecId::PRAGUE) {
initial_gas += authorization_list_num * PER_CONTRACT_CODE_BASE_COST;
}

initial_gas
}
3 changes: 3 additions & 0 deletions crates/interpreter/src/gas/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub const COLD_ACCOUNT_ACCESS_COST: u64 = 2600;
pub const WARM_STORAGE_READ_COST: u64 = 100;
pub const WARM_SSTORE_RESET: u64 = SSTORE_RESET - COLD_SLOAD_COST;

/// EIP-7702
pub const PER_CONTRACT_CODE_BASE_COST: u64 = 2400;

/// EIP-3860 : Limit and meter initcode
pub const INITCODE_WORD_COST: u64 = 2;

Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instruction_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum InstructionResult {
EOFFunctionStackOverflow,
/// Aux data overflow, new aux data is larger tha u16 max size.
EofAuxDataOverflow,
/// Aud data is smaller then already present data size.
/// Aux data is smaller then already present data size.
EofAuxDataTooSmall,
/// EXT*CALL target address needs to be padded with 0s.
InvalidEXTCALLTarget,
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rust_2018_idioms = "deny"
all = "warn"

[dependencies]
alloy-eips = { version = "0.1", default-features = false }
alloy-eips = { version = "0.1", default-features = false, features = ["k256"]}
alloy-primitives = { version = "0.7.2", default-features = false, features = [
"rlp",
] }
Expand Down Expand Up @@ -104,4 +104,4 @@ optional_beneficiary_reward = []
rand = ["alloy-primitives/rand"]

# See comments in `revm-precompile`
c-kzg = ["dep:c-kzg", "dep:once_cell", "dep:derive_more"]
c-kzg = ["dep:c-kzg", "dep:once_cell", "dep:derive_more"]
Loading
Loading