-
Notifications
You must be signed in to change notification settings - Fork 71
Precise Block Timestamps #2021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: zkevm
Are you sure you want to change the base?
Precise Block Timestamps #2021
Conversation
…zDb. Add methods to write and read precise timestamps, update Block struct to include TimestampNano, and ensure timestamps are recorded during block finalization.
0e2144e to
b36f240
Compare
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.
Pull Request Overview
This PR implements precise timestamp handling for blocks in the zkEVM system. The main purpose is to capture and store sub-second (nanosecond) precision timestamps for blocks, which are recorded during block finalization and made available through the API.
Key Changes:
- Added
TimestampNanofield to Block structs in RPC types to expose nanosecond precision timestamps - Implemented database methods to read and write precise timestamps with corresponding test coverage
- Updated block finalization to record precise timestamps and API methods to populate them
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| zkevm/jsonrpc/types/types.go | Added TimestampNano field to Block struct |
| zk/rpcdaemon/types.go | Added TimestampNano field to Block struct |
| zk/hermez_db/db.go | Added database table constant, methods for reading/writing precise timestamps, and L1 info root lookup |
| zk/hermez_db/db_test.go | Added test coverage for precise timestamp read/write operations |
| zk/stages/stage_sequence_execute_blocks.go | Added timestamp recording during block finalization |
| turbo/jsonrpc/zkevm_api.go | Updated API to fetch and populate precise timestamps in block responses |
| zk/stages/stage_sequence_blob_recovery.go | Refactored blob recovery logic with control flow and formatting improvements |
| zk/da/blob_da.go | Removed InfoRootTracker and updated to fetch L1 info root directly from database |
| smt/pkg/utils/utils.go | Updated import alias for poseidongold package |
| zk/tx/tx.go | Removed unused constant |
| zk/stages/stages.go | Removed Disabled field setting and added duplicate parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add DeleteBlockPreciseTimestamps function to hermez_db - Call DeleteBlockPreciseTimestamps in UnwindBatchesStage - Ensures block_precise_timestamps table is properly cleaned up when unwinding to a previous batch This fixes the failing unwind test where the table contents differed after unwinding.
The block_precise_timestamps table stores timestamps captured at block execution time using time.Now().UnixNano(). When blocks are unwound and then re-executed during sync, the timestamps will naturally differ since they're recorded at different wall-clock times. This is expected behavior - the precise timestamps are meant to record when a block was executed, not to be deterministic across re-executions. - Add block_precise_timestamps.txt to different_files array in unwind test - This allows the test to pass while maintaining proper timestamp tracking
Implement precise timestamp handling for blocks in ZkEvmAPI and HermezDb. Add methods to write and read precise timestamps, update Block struct to include TimestampNano, and ensure timestamps are recorded during block finalization.