Skip to content

fix(l2genesis): explicitly initialize WETH storage slots after vm.etch#372

Open
dev-khimesh wants to merge 2 commits into
base:mainfrom
dev-khimesh:fix/l2genesis-weth-storage-init
Open

fix(l2genesis): explicitly initialize WETH storage slots after vm.etch#372
dev-khimesh wants to merge 2 commits into
base:mainfrom
dev-khimesh:fix/l2genesis-weth-storage-init

Conversation

@dev-khimesh

Copy link
Copy Markdown

Description

The setWETH() function deploys the WETH predeploy via vm.etch, which skips constructor execution. While the WETH contract:

  • Has pure name()/symbol() reading from L1Block (no storage)
  • Has constant decimals (no storage slot)
  • Has _balanceOf (slot 0) and _allowance (slot 1) that correctly start empty

This change adds explicit vm.store calls to zero both storage slots for audit clarity and updates the NatSpec to document the safety invariant.

Changes

  1. Added vm.store calls for _balanceOf (slot 0) and _allowance (slot 1)
  2. Updated NatSpec comment with detailed storage layout documentation

Test Plan

  • Existing L2Genesis tests (L2Genesis.t.sol) already verify WETH bytecode is set: assertGt(Predeploys.WETH.code.length, 0)
  • Genesis WETH should return correct name() / symbol() via L1Block
  • Genesis WETH should return decimals = 18

Closes #357

Khimesh Dewangan added 2 commits July 11, 2026 22:14
…WithInitData()

Moves _finalizeGameCreation() before the external proxy.initialize()/initializeWithInitData() call in both create() and createWithInitData() functions to follow the Checks-Effects-Interactions (CEI) pattern. This prevents state-desynchronization where a dispute game could be initialized but not yet registered in the factory registry, which could cause integration failures and stale state reads for downstream components. Closes base#356.
The setWETH() function uses vm.etch to deploy WETH bytecode, which skips constructor execution. While the WETH contract has no constructor side effects (name/symbol are pure L1Block readers, decimals is constant, and mappings correctly start empty), this change makes the initialization explicit by:

1. Zeroing _balanceOf (slot 0) and _allowance (slot 1) via vm.store for clarity
2. Updating the NatSpec comment to document why each storage slot is correct

This addresses Lumi audit finding base#357 and makes the safety invariant auditable at a glance.

Closes base#357
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

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.

Lumi Security Audit: Security Feedback for L2Genesis.s.sol

2 participants