Skip to content

Commit

Permalink
sstore_cost return u64 instead of Option
Browse files Browse the repository at this point in the history
Signed-off-by: jsvisa <delweng@gmail.com>
  • Loading branch information
jsvisa committed Sep 23, 2024
1 parent f078452 commit b0a5536
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crates/interpreter/src/gas/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ pub const fn sload_cost(spec_id: SpecId, is_cold: bool) -> u64 {

/// `SSTORE` opcode cost calculation.
#[inline]
pub fn sstore_cost(spec_id: SpecId, vals: &SStoreResult, is_cold: bool) -> Option<u64> {
Some(if spec_id.is_enabled_in(SpecId::BERLIN) {
pub fn sstore_cost(spec_id: SpecId, vals: &SStoreResult, is_cold: bool) -> u64 {
if spec_id.is_enabled_in(SpecId::BERLIN) {
// Berlin specification logic
let mut gas_cost = istanbul_sstore_cost::<WARM_STORAGE_READ_COST, WARM_SSTORE_RESET>(vals);

Expand All @@ -200,7 +200,7 @@ pub fn sstore_cost(spec_id: SpecId, vals: &SStoreResult, is_cold: bool) -> Optio
} else {
// Frontier logic
frontier_sstore_cost(vals)
})
}
}

/// EIP-2200: Structured Definitions for Net Gas Metering
Expand Down
4 changes: 1 addition & 3 deletions crates/interpreter/src/instructions/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ pub fn sstore<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host:
interpreter.instruction_result = InstructionResult::ReentrancySentryOOG;
return;
}
gas_or_fail!(interpreter, {
gas::sstore_cost(SPEC::SPEC_ID, &state_load.data, state_load.is_cold)
});
gas::sstore_cost(SPEC::SPEC_ID, &state_load.data, state_load.is_cold);
refund!(
interpreter,
gas::sstore_refund(SPEC::SPEC_ID, &state_load.data)
Expand Down

0 comments on commit b0a5536

Please sign in to comment.