Skip to content

tor-hsservice: Make offset_within_srv_period() work with timestamps from newer periods.

gabi-250 requested to merge gabi-250/arti:fix-wallclock-bug-again into main

This fixes a bug where offset_within_srv_period() returns None, instead of the offset of when from the start of the SRV of the previous time period:

2024-01-24T15:24:46Z ERROR tor_hsservice::svc::publish::reactor: descriptor upload failed for HS service
allium-cepa2 and time period TimePeriod { interval_num: 19745, length: IntegerMinutes { value: 1440 },
epoch_offset_in_sec: 43200 }: error: Programming error: internal error (bug) at
/../arti/crates/tor-hsservice/src/svc/publish/reactor.rs:218:13: current wallclock time not within
SRV range?! (now=SystemTime { tv_sec: 1706109886, tv_nsec: 246572852 },
SRV_start=SystemTime { tv_sec: 1705968000, tv_nsec: 0 })

We need to be able to calculate this offset even if now is not within the SRV range (because we upload the descriptor to the HsDirs of the previous time period too).

Note a similar bug exited in offset_within_period() (which no longer exists) too! That one was fixed in !1744 (merged):

Hidden services can have multiple "active" time periods for which they
generate descriptors. We need to be able to compute the offset of a
timestamp from the start of a given time period, even if that timestamp
falls within the "next" time period (for example, when publishing
descriptors for the "previous" time period, the `when` timestamp will
fall outside the `(start, end)` range of the "previous" time period).

Merge request reports

Loading