Skip to content

fix(sync): use microseconds for MAX_TIMESTAMP_FUTURE_SHIFT#99

Merged
dignifiedquire merged 1 commit into
n0-computer:mainfrom
cbenhagen:fix/max-timestamp-future-shift-micros
May 8, 2026
Merged

fix(sync): use microseconds for MAX_TIMESTAMP_FUTURE_SHIFT#99
dignifiedquire merged 1 commit into
n0-computer:mainfrom
cbenhagen:fix/max-timestamp-future-shift-micros

Conversation

@cbenhagen
Copy link
Copy Markdown
Contributor

@cbenhagen cbenhagen commented May 6, 2026

Description

Fixes future timestamp validation so the allowed skew matches the documented ten-minute policy.

Entry timestamps and system_time_now() are Unix epoch microseconds. MAX_TIMESTAMP_FUTURE_SHIFT was derived using milliseconds, so the effective cap was about 600 ms instead of ten minutes. The constant now uses Duration::from_secs(1).as_micros() so it is expressed in the same unit as wall time.

Adds test_future_timestamp_accepts_one_second_skew, a regression test that would fail if the slack constant were still on millisecond scale: it inserts an entry one second in the future, then asserts the stored entry matches (round-trip), not only that insert succeeds.

Breaking Changes

None

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

Wall times are Unix epoch microseconds; deriving the cap from milliseconds
limited future slack to ~600ms instead of 10 minutes.

Add a regression test that inserts a 1s-ahead entry and asserts round-trip
from the store.
@n0bot n0bot Bot added this to iroh May 6, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh May 6, 2026
@dignifiedquire dignifiedquire merged commit 8e3f2ba into n0-computer:main May 8, 2026
25 of 26 checks passed
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

MAX_TIMESTAMP_FUTURE_SHIFT unit mismatch causes validate_entry to reject entries from peers with >600 ms wall-clock skew

2 participants