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: support transient storage opcodes (EIP-1153) #278

Merged
merged 7 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds flag for enabling eip-1153
  • Loading branch information
RomarQ committed May 13, 2024
commit b8bfe595de0c351c18a17546e6b9475d093fba99
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