Skip to content

L-05: add batchTimestamp <= lastL2BlockTimestamp check#2120

Open
valera-grinenko-ai wants to merge 2 commits intomatter-labs:draft-v31from
valera-grinenko-ai:pr/L-05-batch-timestamp-consistency
Open

L-05: add batchTimestamp <= lastL2BlockTimestamp check#2120
valera-grinenko-ai wants to merge 2 commits intomatter-labs:draft-v31from
valera-grinenko-ai:pr/L-05-batch-timestamp-consistency

Conversation

@valera-grinenko-ai
Copy link
Copy Markdown

@valera-grinenko-ai valera-grinenko-ai commented Apr 7, 2026

Summary

  • Adds explicit validation that batchTimestamp <= lastL2BlockTimestamp in Committer._verifyBatchTimestamp (old commit path)
  • Adds the same firstBlockTimestamp <= lastBlockTimestamp check in _commitOneBatchZKsyncOS (ZKsync OS commit path), which had the identical gap
  • Both paths already validate "not too old" and "not too big" independently, but never compared the two timestamps against each other

Test plan

  • Verify forge build passes
  • Confirm batches with batchTimestamp > lastL2BlockTimestamp are rejected (old path)
  • Confirm batches with firstBlockTimestamp > lastBlockTimestamp are rejected (ZKsync OS path)
  • Confirm valid batches still pass timestamp verification on both paths

🤖 Generated with Claude Code

The comment states all L2 blocks have timestamps in
[batchTimestamp, lastL2BlockTimestamp], implying batchTimestamp <=
lastL2BlockTimestamp. This invariant was not explicitly validated,
allowing malformed batches to pass. Add the missing consistency check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@StanislavBreadless StanislavBreadless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but maybe we should add the same check for zksync os if there is no other fix PR that does it:

                _newBatch.firstBlockTimestamp,
                _newBatch.lastBlockTimestamp,

The old commit path (_verifyBatchTimestamp) already checks
batchTimestamp <= lastL2BlockTimestamp. The ZKsync OS path
(_commitOneBatchZKsyncOS) validates firstBlockTimestamp not too old
and lastBlockTimestamp not too big, but never compares them against
each other. Add the same ordering check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants