feat(types): u64 entry point for Timestamp - #260
Open
poszu wants to merge 1 commit into
Open
Conversation
Timestamps are microseconds since the epoch, and every caller that stores or reads one holds it in a u64 — database rows, indexer state, node config. `from_micros` takes a u128, so all of them write `x as u128` at the call site purely to satisfy the signature. `from_micros_u64` removes that cast. µs in a u64 reach year 586524, so nothing representable is lost. Additive only: the inner representation stays u128, so the signed attestation digest (Hashable hashes the 16 big-endian bytes), the rmp persistence encoding, and every existing signature are untouched. A named constructor rather than `impl From<u64>`: `from_seconds` already takes a u64, so a bare From impl would make `x.into()` silently mean microseconds next to a seconds constructor of the same type, and a µs/s mixup is a 1e6 error in a timestamp. std draws the same line with Duration::from_micros / from_secs. Refs CORE-94
poszu
force-pushed
the
feat/timestamp-u64-entry-point
branch
from
July 31, 2026 10:09
2301765 to
3102ef5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Timestamps are microseconds since the epoch, and every caller that stores or reads one already holds it in a
u64— database rows, indexer state, node config.from_microstakes au128, so all of them writex as u128at the call site purely to satisfy the signature (in pod:r.timestamp_micros as u128,ts as u128,included_batch as u128, and more).from_micros_u64removes that cast. µs in au64reach year 586524, so nothing representable is lost.Additive only — the inner representation stays
u128. That matters becauseHashable for Timestamphashesas_micros().to_be_bytes(), the 16 big-endian bytes validators sign: narrowing the field would change every attestation digest and invalidate historical vote certificates. The rmp persistence encoding (au128is a 16-byteBin8, au64is auint, and they are not cross-readable) and the whole existing public API are likewise untouched. Nothing that exists today changes behaviour or representation; this only adds a constructor.A named constructor rather than
impl From<u64>is deliberate.from_secondsalready takes au64, so a bareFromimpl would makex.into()silently mean microseconds sitting beside a seconds constructor of the identical type — and a µs/s mixup is a 1e6 error in a timestamp. std draws the same line:Duration::from_micros/from_secs, noFrom<u64>.Note for pod: the pod repo pins
pod-typesto git revacd1565in three places in its rootCargo.toml, and the two fuzz workspaces pin13a2da8d, so this constructor is invisible to that build until those pins bump. Tracked in CORE-94 along with the call-site cleanup.🤖 Generated with Claude Code