fix(batch): use blockhash(block.number - 1) in _tryBlockAndAggregate#63
fix(batch): use blockhash(block.number - 1) in _tryBlockAndAggregate#63lau90eth wants to merge 1 commit into
Conversation
|
lau90eth Thanks for the contribution! We're intentionally replicating Multicall3's behavior here, see https://github.com/mds1/multicall3/blob/main/src/Multicall3.sol#L79-L83. We'd like to keep the bug preserved to match expectations from other chains where Multicall3 is deployed. |
|
Got it, thanks for the context! Didn't realize this was intentionally matching the upstream Multicall3 behavior. Closing this PR. |
|
Confirmed from dApp testing:
|
Summary
_tryBlockAndAggregatewas callingblockhash(block.number), whichalways returns
bytes32(0)on mainnet EVM — the current block's hashis not yet available during execution.
The correct value is
blockhash(block.number - 1), consistent withthe existing
getLastBlockHash()implementation in the same contract.Root Cause
blockhash(N)returns0whenN >= block.number. The existing testspassed only because Foundry's test environment populates block hashes
differently from production EVM.
Fix
Multicall3From._tryBlockAndAggregate:block.number→block.number - 1Testing
forge test --match-path contracts/test/batch/Multicall3From.t.sol
29 tests passed, 0 failed.