Skip to content

Commit fda8a40

Browse files
authored
feat: add Cancun configuration (#288)
* feat: add Cancun configuration * add missing fields to config * add missing field
1 parent a388f69 commit fda8a40

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/standard/config.rs

+26
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ impl Config {
238238
Self::config_with_derived_values(DerivedConfigInputs::shanghai())
239239
}
240240

241+
/// Cancun hard fork configuration.
242+
pub const fn cancun() -> Config {
243+
Self::config_with_derived_values(DerivedConfigInputs::cancun())
244+
}
245+
241246
const fn config_with_derived_values(inputs: DerivedConfigInputs) -> Config {
242247
let DerivedConfigInputs {
243248
gas_storage_read_warm,
@@ -324,8 +329,11 @@ impl Config {
324329
/// Independent inputs that are used to derive other config values.
325330
/// See `Config::config_with_derived_values` implementation for details.
326331
struct DerivedConfigInputs {
332+
/// `WARM_STORAGE_READ_COST` (see EIP-2929).
327333
gas_storage_read_warm: u64,
334+
/// `COLD_SLOAD_COST` (see EIP-2929).
328335
gas_sload_cold: u64,
336+
/// `ACCESS_LIST_STORAGE_KEY_COST` (see EIP-2930).
329337
gas_access_list_storage_key: u64,
330338
decrease_clears_refund: bool,
331339
has_base_fee: bool,
@@ -407,4 +415,22 @@ impl DerivedConfigInputs {
407415
eip_1559_enabled: true,
408416
}
409417
}
418+
419+
const fn cancun() -> Self {
420+
Self {
421+
gas_storage_read_warm: 100,
422+
gas_sload_cold: 2100,
423+
gas_access_list_storage_key: 1900,
424+
decrease_clears_refund: true,
425+
has_base_fee: true,
426+
has_push0: true,
427+
disallow_executable_format: true,
428+
warm_coinbase_address: true,
429+
// 2 * (MAX_CODE_SIZE = `24576`) = (0xC000 = 49152) as per EIP-3860
430+
max_initcode_size: Some(0xC000),
431+
eip_1153_enabled: true,
432+
eip_5656_enabled: true,
433+
eip_1559_enabled: true,
434+
}
435+
}
410436
}

0 commit comments

Comments
 (0)