Skip to content

feat(levm): implement fork-specific SSTORE gas costs for pre-merge forks (#5)#5

Merged
lferrigno merged 1 commit into
mainfrom
continuous-claude/iteration-6/2026-01-18-7917b30a
Jan 18, 2026
Merged

feat(levm): implement fork-specific SSTORE gas costs for pre-merge forks (#5)#5
lferrigno merged 1 commit into
mainfrom
continuous-claude/iteration-6/2026-01-18-7917b30a

Conversation

@lferrigno

Copy link
Copy Markdown
Owner

pre-merge Ethereum forks. This completes the core gas cost implementation
for pre-merge fork support.

Changes to gas_cost.rs:

  • Add pre-Istanbul SSTORE constants: SSTORE_GAS_SET (20000 for zero to
    non-zero), SSTORE_GAS_RESET (5000 for other changes), and
    SSTORE_REFUND_CLEAR (15000 for clearing slots)
  • Modify sstore() to accept fork parameter and use simple gas model for
    pre-Istanbul forks (no net gas metering)
  • Apply EIP-2929 cold/warm access costs only for Berlin and later

Changes to stack_memory_storage_flow.rs:

  • Pass fork to gas_cost::sstore() function
  • Apply EIP-2200 stipend check only for Istanbul and later forks
  • Implement pre-Istanbul refund logic: 15000 gas refund for clearing
    storage (non-zero to zero)
  • Maintain EIP-2200 net gas metering refunds for Istanbul+ forks

Gas cost history for SSTORE:

  • Frontier through Spurious Dragon: 20000 (set), 5000 (reset), 15000 refund
  • Istanbul: EIP-2200 net gas metering
  • Berlin+: EIP-2929 cold/warm access costs added

…rks (#5)

Implement fork-specific gas cost handling for the SSTORE opcode across
pre-merge Ethereum forks. This completes the core gas cost implementation
for pre-merge fork support.

Changes to gas_cost.rs:
- Add pre-Istanbul SSTORE constants: SSTORE_GAS_SET (20000 for zero to
  non-zero), SSTORE_GAS_RESET (5000 for other changes), and
  SSTORE_REFUND_CLEAR (15000 for clearing slots)
- Modify sstore() to accept fork parameter and use simple gas model for
  pre-Istanbul forks (no net gas metering)
- Apply EIP-2929 cold/warm access costs only for Berlin and later

Changes to stack_memory_storage_flow.rs:
- Pass fork to gas_cost::sstore() function
- Apply EIP-2200 stipend check only for Istanbul and later forks
- Implement pre-Istanbul refund logic: 15000 gas refund for clearing
  storage (non-zero to zero)
- Maintain EIP-2200 net gas metering refunds for Istanbul+ forks

Gas cost history for SSTORE:
- Frontier through Spurious Dragon: 20000 (set), 5000 (reset), 15000 refund
- Istanbul: EIP-2200 net gas metering
- Berlin+: EIP-2929 cold/warm access costs added
@lferrigno lferrigno merged commit 7fcb2a7 into main Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant