Skip to content

Commit

Permalink
feat: add Cancun configuration (rust-ethereum#288)
Browse files Browse the repository at this point in the history
* feat: add Cancun configuration

* add missing fields to config

* add missing field
  • Loading branch information
RomarQ authored Jun 4, 2024
1 parent a388f69 commit fda8a40
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/standard/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ impl Config {
Self::config_with_derived_values(DerivedConfigInputs::shanghai())
}

/// Cancun hard fork configuration.
pub const fn cancun() -> Config {
Self::config_with_derived_values(DerivedConfigInputs::cancun())
}

const fn config_with_derived_values(inputs: DerivedConfigInputs) -> Config {
let DerivedConfigInputs {
gas_storage_read_warm,
Expand Down Expand Up @@ -324,8 +329,11 @@ impl Config {
/// Independent inputs that are used to derive other config values.
/// See `Config::config_with_derived_values` implementation for details.
struct DerivedConfigInputs {
/// `WARM_STORAGE_READ_COST` (see EIP-2929).
gas_storage_read_warm: u64,
/// `COLD_SLOAD_COST` (see EIP-2929).
gas_sload_cold: u64,
/// `ACCESS_LIST_STORAGE_KEY_COST` (see EIP-2930).
gas_access_list_storage_key: u64,
decrease_clears_refund: bool,
has_base_fee: bool,
Expand Down Expand Up @@ -407,4 +415,22 @@ impl DerivedConfigInputs {
eip_1559_enabled: true,
}
}

const fn cancun() -> Self {
Self {
gas_storage_read_warm: 100,
gas_sload_cold: 2100,
gas_access_list_storage_key: 1900,
decrease_clears_refund: true,
has_base_fee: true,
has_push0: true,
disallow_executable_format: true,
warm_coinbase_address: true,
// 2 * (MAX_CODE_SIZE = `24576`) = (0xC000 = 49152) as per EIP-3860
max_initcode_size: Some(0xC000),
eip_1153_enabled: true,
eip_5656_enabled: true,
eip_1559_enabled: true,
}
}
}

0 comments on commit fda8a40

Please sign in to comment.