Skip to content

apollo_batcher: Add get_ts from mempool for echonet#12456

Closed
ron-starkware wants to merge 1 commit intoayelet/mempool/naive-mempool/rebase-over-14-1-get_tsfrom
ron/get-timestamp
Closed

apollo_batcher: Add get_ts from mempool for echonet#12456
ron-starkware wants to merge 1 commit intoayelet/mempool/naive-mempool/rebase-over-14-1-get_tsfrom
ron/get-timestamp

Conversation

@ron-starkware
Copy link
Contributor

@ron-starkware ron-starkware commented Feb 10, 2026

Note

Medium Risk
Touches consensus proposal timestamp selection and adds a new cross-component request/response variant; incorrect timestamps or integration mismatches could affect block info and downstream validation, though changes are scoped and include tests for the new FIFO behavior.

Overview
Adds a new batcher RPC/trait method get_ts (wired through BatcherRequest::GetTimestamp/BatcherResponse::GetTimestamp) that returns a mempool-sourced timestamp.

Updates consensus proposal building to optionally use this batcher-provided “original” timestamp in Echonet mode (renaming the flag to use_original_timestamp), falling back to local clock time on errors.

Adjusts Echonet FIFO mempool timestamp behavior so get_ts() returns the last returned timestamp when the queue is empty (instead of 0), adds TransactionQueueTrait::get_last_returned_timestamp, and includes a regression test for the empty-queue-after-drain case.

Written by Cursor Bugbot for commit 5ac1dd9. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Ok(ts) => return ts,
Err(err) => {
warn!("Failed to get timestamp from batcher, falling back to clock time: {err:?}");
}
Copy link

Choose a reason for hiding this comment

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

Zero timestamp used instead of clock fallback

Medium Severity

When the mempool queue is empty and no prior get_ts call was made, batcher.get_ts() returns Ok(0). The get_proposal_timestamp function treats this as a valid timestamp and returns 0 (Unix epoch) instead of falling back to clock.unix_now(). The old code using state sync would fall back to clock time when no data was available, since the if let Ok(Some(block_header)) pattern wouldn't match on Ok(None). The new code has no equivalent fallback because the mempool call always succeeds — the "no data" case is encoded as Ok(0) rather than as an error.

Additional Locations (1)

Fix in Cursor Fix in Web

@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants