Skip to content

Commit

Permalink
feat: add Cancun configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ committed May 8, 2024
1 parent 1e31869 commit 654fb20
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/standard/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,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 @@ -312,8 +317,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 @@ -385,4 +393,20 @@ impl DerivedConfigInputs {
eip_1559: 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_1559: true,
}
}
}

0 comments on commit 654fb20

Please sign in to comment.