Skip to content

Conversation

@dnzdlklc
Copy link

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.

revitteth
revitteth previously approved these changes Oct 8, 2025
dnzdlklc and others added 3 commits October 15, 2025 12:27
…zDb. Add methods to write and read precise timestamps, update Block struct to include TimestampNano, and ensure timestamps are recorded during block finalization.
@dnzdlklc dnzdlklc force-pushed the precise-block-times branch from 0e2144e to b36f240 Compare October 15, 2025 11:31
Copilot AI review requested due to automatic review settings October 27, 2025 12:34
Copy link

Copilot AI left a 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 TimestampNano field 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.

dnzdlklc and others added 7 commits October 27, 2025 12:51
- 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
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.

3 participants