Commit ef958fe
authored
contributor-rewards, solana-cli, validator-debt: fix the hardcoded 400ms slot times (malbeclabs/doublezero-offchain#411)
## Summary of Changes
Five call sites divided wall clock by a hardcoded 400ms slot duration.
They get three independent fixes rather than one shared helper, because
they want different answers: the two accuracy-critical sites stop
depending on a slot-duration constant at all, and the two that keep one
now share a single value.
* **`contributor-rewards`** — `find_epoch_at_timestamp` verifies its
estimate against real block times. The old estimate drifted ~30k slots
per day of lookback and no fixed constant survives the SIMD-0525
rollout. That epoch picks the leader schedule rewards are computed
against, so the search errors rather than guessing.
* **`solana-cli`** — the duplicate constants in `shreds pay` and
`prepare-offchain-message` collapse into one 350ms
`NOMINAL_SLOT_DURATION`, deliberately cluster-independent: a `~`
prefixed estimate and a deadline slot the CLI and operator must both
compute want reproducibility over accuracy.
* **`validator-debt`** — deletes two dead timestamp-to-epoch paths and
both constants. `rpc.rs` already does this mapping correctly for
production; the deleted code had no callers and contained an unsigned
subtraction that panicked in debug and wrapped in release.
### Before merging
* **`--valid-for` windows lengthen.** `--valid-for 1h` is now 10,285
slots, not 9,000. Mainnet reaches 350ms at epoch 1020 (2026-08-21);
until then the flag grants ~68 minutes. Testnet runs at 200ms, so ~34
minutes. The help text states the conversion rate.
* **The demand path can now fail where it used to be wrong.**
`ingestor/demand.rs` propagates a leader-schedule error, so a backfill
older than the endpoint's ledger retention errors instead of silently
mis-estimating. The snapshot paths warn and continue, but `snapshot` now
validates before writing rather than leaving an unusable file behind.
* **350ms needs one more bump** when SIMD-0525 finishes stepping mainnet
to 200ms. Nothing enforces it; the constants' comments record the
schedule.
## Testing Verification
* Pure-function tests for the search's per-step decision (both bounds,
the unbounded current-epoch case, the unstarted-epoch case), the
absent-block classifier (each of the three shapes `getBlockTime` uses,
plus a pruned ledger failing closed), and the epoch-boundary skip budget
(exclusive edge, a history gap, and a short-epoch cluster). No RPC mock,
and no new dependency.
* CLI assertions recomputed by hand from the 350ms derivation, with the
arithmetic in each test comment. The deletions are checked by `clippy
-Dwarnings`, which catches every orphaned import and unused constant.1 parent 70a36ce commit ef958fe
12 files changed
Lines changed: 623 additions & 362 deletions
File tree
- offchain/crates
- contributor-rewards
- src
- cli
- ingestor
- solana-cli
- src/command/shreds
- publisher_rewards
- validator-debt
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
257 | 260 | | |
258 | 261 | | |
259 | | - | |
| 262 | + | |
260 | 263 | | |
261 | | - | |
| 264 | + | |
262 | 265 | | |
263 | 266 | | |
264 | 267 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
280 | 271 | | |
281 | 272 | | |
282 | 273 | | |
| |||
327 | 318 | | |
328 | 319 | | |
329 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
330 | 326 | | |
331 | 327 | | |
332 | 328 | | |
| |||
0 commit comments