Skip to content

fix(StdStorage): limit slot search to 256 reads#834

Closed
decofe wants to merge 1 commit intofoundry-rs:masterfrom
decofe:DaniPopes/limit-slot-reads
Closed

fix(StdStorage): limit slot search to 256 reads#834
decofe wants to merge 1 commit intofoundry-rs:masterfrom
decofe:DaniPopes/limit-slot-reads

Conversation

@decofe
Copy link
Contributor

@decofe decofe commented Mar 15, 2026

Follow-up to #833. Caps the number of storage slots checked in find() to 256 to prevent excessive RPC calls on contracts with complex storage access patterns (e.g. reflection tokens like BabyDoge).

#833 fixed the uint256 underflow infinite loop, but the loop still iterates through all recorded storage reads. For reflection tokens on a fork, balanceOf reads many slots, and checkSlotMutatesCall makes 2 calls per slot — each triggering dozens of eth_getStorageAt RPCs. This results in 1000+ RPC requests before eventually reverting.

Changes

  • Add MAX_SLOT_READS = 256 constant — only check the last 256 recorded slots (most likely to contain the target)
  • Add fork regression test with BabyDoge on BSC (0xc748...e8de)

Closes #740

Co-Authored-By: DaniPopes 57450786+DaniPopes@users.noreply.github.com

Prompted by: DaniPopes

Cap the number of storage slots checked in find() to 256 to prevent
excessive RPC calls on contracts with complex storage access patterns
(e.g. reflection tokens). Adds a fork regression test with BabyDoge on BSC.

Closes foundry-rs#740

Co-Authored-By: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
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.

bug(StdCheats): deal() hangs on reflection tokens

2 participants