Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Add boundary tests to lock in semantics and prevent regressions
Please add tests covering:
anchorBlockId == block.number - maxAnchorBlockIdOffset(passes) andanchorBlockId == block.number - maxAnchorBlockIdOffset - 1(revertsAnchorBlockTooOld()).maxAnchorBlockIdOffset > block.number(should not revert due to underflow; still fails later withBlockhashUnavailable()if out of 256-block window).anchorBlockId >= block.number(should revertBlockhashUnavailable()).maxAnchorBlockIdOffset(if allowed by config), to ensure no unexpected addition overflow behavior.You can quickly check for existing tests and anchor usages with:
I can draft Foundry/Hardhat tests for these cases if helpful.
🏁 Script executed:
Length of output: 14681
Add comprehensive boundary tests for
publishin TaikoInboxWe need to lock in the semantics of the
require(anchorBlockId + maxAnchorBlockIdOffset >= block.number, AnchorBlockTooOld())check and the subsequentBlockhashUnavailable()guard. No existing unit tests cover these edge cases, so please add tests (e.g. intest/InboxBoundary.t.sol) for:Exact lower boundary:
• anchorBlockId == block.number − maxAnchorBlockIdOffset → should succeed
• anchorBlockId == block.number − maxAnchorBlockIdOffset − 1 → should revert
AnchorBlockTooOld()Underflow “early‐chain” scenario (when
maxAnchorBlockIdOffset > block.number):• Ensure the underflowed sum still passes the first
require, but then revertsBlockhashUnavailable()if the block is out of the 256‐block hash window.Future and current block IDs:
• anchorBlockId ≥ block.number → should revert
BlockhashUnavailable()(becauseblockhash(anchorBlockId)returns 0)Large
maxAnchorBlockIdOffsetvalues:• If your config allows very large offsets, verify no overflow in
anchorBlockId + maxAnchorBlockIdOffsetand correct revert paths.Pinpoint locations:
src/protocol/taiko_alethia/TaikoInbox.sol, line 69 (theAnchorBlockTooOld()check)blockhashlookup and itsBlockhashUnavailable()requireFeel free to use Foundry’s
vm.roll(...)to manipulateblock.numberandvm.expectRevert(...)for these scenarios.🤖 Prompt for AI Agents