Skip to content
Open
Changes from all commits
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
23 changes: 7 additions & 16 deletions crates/handler/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,22 +383,13 @@ pub trait Handler {
gas.record_refund(refunded);
}

// Reservoir handling at the top-level frame:
// - On success: use the frame's final reservoir as-is, state gas was consumed.
// - On revert/halt: restore state gas spent back to the reservoir,
// because state changes are rolled back so state gas should be refunded.
//
// Note: eth devnet3 does NOT do this — it ignores state_gas_spent and
// unconditionally sets gas.set_reservoir(reservoir) regardless of the
// instruction_result kind. This is a bug in the devnet3 spec.
if instruction_result.is_ok() {
gas.set_state_gas_spent(state_gas_spent);
gas.set_reservoir(reservoir);
} else {
// State changes rolled back, so no execution state gas was consumed.
gas.set_state_gas_spent(0);
gas.set_reservoir(reservoir + state_gas_spent);
}
// Always track state gas spent regardless of outcome.
gas.set_state_gas_spent(state_gas_spent);

// Reservoir handling at the top-level frame.
// Use the frame's final reservoir directly — it already reflects
// child frame restorations and any state gas consumed/spilled during execution.
gas.set_reservoir(reservoir);

Ok(())
}
Expand Down
Loading