Skip to content

Three inconsistent time units across proto files cause silent arithmetic errors #12

@bibonix

Description

@bibonix

The protocol uses three different time units with no naming convention to distinguish them.

Auth.timestamp (auth.proto:20) is minutes since the project epoch 2024-01-01 UTC. Ping.timestamp (ping.proto:13), echoed back as Pong.timestamp (pong.proto:84), is milliseconds since the Unix epoch. Every other time field — Lease.ends, Property.ends, Property.metered, Property.expires, Peer.metered, Peer.expires, Pong.expires, and Pong.cutoff in pong.proto — is seconds since the Unix epoch.

A client computing the remaining free window as Pong.cutoff - Pong.timestamp gets a result in a meaningless mixed unit: seconds minus milliseconds. The error is silent in proto3 because both fields share the uint64 type and the comment is the only clue. The same trap applies to any comparison between the echoed round-trip timestamp and the cutoff or expires sentinel.

Rename the fields to embed their unit (e.g. timestamp_ms in Ping/Pong and timestamp_min in Auth) or normalise all time fields to a single unit and a single epoch. Either way, document the choice once in a top-level comment so implementors do not have to diff three files to find the unit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions