Skip to content

Commit

Permalink
adds flag for enabling eip-1153
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ committed May 13, 2024
1 parent c2a001a commit b8bfe59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/standard/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ pub struct Config {
pub has_base_fee: bool,
/// Has PUSH0 opcode. See [EIP-3855](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3855.md)
pub has_push0: bool,
/// Enables transient storage. See [EIP-1153](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1153.md)
pub eip_1153_enabled: bool,
}

impl Config {
Expand Down Expand Up @@ -150,6 +152,7 @@ impl Config {
has_ext_code_hash: false,
has_base_fee: false,
has_push0: false,
eip_1153_enabled: false,
}
}

Expand Down Expand Up @@ -203,6 +206,7 @@ impl Config {
has_ext_code_hash: true,
has_base_fee: false,
has_push0: false,
eip_1153_enabled: false,
}
}

Expand Down Expand Up @@ -237,6 +241,7 @@ impl Config {
disallow_executable_format,
warm_coinbase_address,
max_initcode_size,
eip_1153_enabled,
} = inputs;

// See https://eips.ethereum.org/EIPS/eip-2929
Expand Down Expand Up @@ -299,6 +304,7 @@ impl Config {
has_ext_code_hash: true,
has_base_fee,
has_push0,
eip_1153_enabled,
}
}
}
Expand All @@ -315,6 +321,7 @@ struct DerivedConfigInputs {
disallow_executable_format: bool,
warm_coinbase_address: bool,
max_initcode_size: Option<usize>,
eip_1153_enabled: bool,
}

impl DerivedConfigInputs {
Expand All @@ -329,6 +336,7 @@ impl DerivedConfigInputs {
disallow_executable_format: false,
warm_coinbase_address: false,
max_initcode_size: None,
eip_1153_enabled: false,
}
}

Expand All @@ -343,6 +351,7 @@ impl DerivedConfigInputs {
disallow_executable_format: true,
warm_coinbase_address: false,
max_initcode_size: None,
eip_1153_enabled: false,
}
}

Expand All @@ -357,6 +366,7 @@ impl DerivedConfigInputs {
disallow_executable_format: true,
warm_coinbase_address: false,
max_initcode_size: None,
eip_1153_enabled: false,
}
}

Expand All @@ -372,6 +382,7 @@ impl DerivedConfigInputs {
warm_coinbase_address: true,
// 2 * 24576 as per EIP-3860
max_initcode_size: Some(0xC000),
eip_1153_enabled: false,
}
}
}
4 changes: 2 additions & 2 deletions src/standard/gasometer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ fn dynamic_opcode_cost<H: RuntimeBackend>(
target_is_cold: handler.is_cold(address, Some(index)),
}
}
Opcode::TLOAD => GasCost::TLoad,
Opcode::TLOAD if config.eip_1153_enabled => GasCost::TLoad,

Opcode::DELEGATECALL if config.has_delegate_call => {
let target = stack.peek(1)?.into();
Expand Down Expand Up @@ -389,7 +389,7 @@ fn dynamic_opcode_cost<H: RuntimeBackend>(
target_is_cold: handler.is_cold(address, Some(index)),
}
}
Opcode::TSTORE if !is_static => GasCost::TStore,
Opcode::TSTORE if !is_static && config.eip_1153_enabled => GasCost::TStore,
Opcode::LOG0 if !is_static => GasCost::Log {
n: 0,
len: U256::from_big_endian(&stack.peek(1)?[..]),
Expand Down

0 comments on commit b8bfe59

Please sign in to comment.