Skip to content

fix(batch): use blockhash(block.number - 1) in _tryBlockAndAggregate#63

Open
lau90eth wants to merge 1 commit into
circlefin:mainfrom
lau90eth:lau90eth/fix-blockhash-tryblockandaggregate
Open

fix(batch): use blockhash(block.number - 1) in _tryBlockAndAggregate#63
lau90eth wants to merge 1 commit into
circlefin:mainfrom
lau90eth:lau90eth/fix-blockhash-tryblockandaggregate

Conversation

@lau90eth
Copy link
Copy Markdown

Summary

_tryBlockAndAggregate was calling blockhash(block.number), which
always returns bytes32(0) on mainnet EVM — the current block's hash
is not yet available during execution.

The correct value is blockhash(block.number - 1), consistent with
the existing getLastBlockHash() implementation in the same contract.

Root Cause

blockhash(N) returns 0 when N >= block.number. The existing tests
passed only because Foundry's test environment populates block hashes
differently from production EVM.

Fix

  • Multicall3From._tryBlockAndAggregate: block.numberblock.number - 1
  • Updated tests to assert the correct value

Testing

forge test --match-path contracts/test/batch/Multicall3From.t.sol

29 tests passed, 0 failed.

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