Skip to content
This repository was archived by the owner on Sep 8, 2026. It is now read-only.

contributor-rewards: fail the tick instead of saving a snapshot with no leader schedule - #413

Merged
nikw9944 merged 4 commits into
mainfrom
nikw9944/infra-2372
Aug 27, 2026
Merged

contributor-rewards: fail the tick instead of saving a snapshot with no leader schedule#413
nikw9944 merged 4 commits into
mainfrom
nikw9944/infra-2372

Conversation

@nikw9944

@nikw9944 nikw9944 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

  • The scheduler no longer writes a snapshot it cannot use: a failed leader-schedule fetch propagates instead of becoming leader_schedule: null, and create_epoch_snapshot validates before saving.
  • Confirms malbeclabs/infra#2372. A failed fetch was one warn!, then an unusable snapshot uploaded over the epoch's canonical S3 key; the tick then failed reading it back with Missing leader schedule, a symptom whose cause survived only in the log. contributor-rewards, solana-cli, validator-debt: fix the hardcoded 400ms slot times #411 fixed this for the snapshot CLI command but not for the scheduler, which is the path that runs in production.
  • Scheduler failures now log the full cause chain ({:#}). Plain {} prints only the outermost context, so the newly propagated reason would still have been dropped.
  • Security: EpochFinder printed reqwest's error verbatim, which includes the request URL, both in its retry logs and in the error it propagates. It reads the DZ ledger through a vaulted URL on mainnet-beta, and journald ships to Loki, so those credentials would reach Loki on any timeout or 429 — and the {:#} change above would have printed them on the failure path too. Every RPC error in the module is now stripped of its URL, with a test pinning it.
  • Behavior change: a --dry-run tick that previously marked the epoch processed with an unusable snapshot now fails and retries — nothing validated on that path, since calculate_rewards never ran. Both deployed environments run with dry-run off.
  • Companion: malbeclabs/infra#2381 (the alert and its runbook).

Fixes malbeclabs/infra#2372

Testing Verification

  • New tests/test_snapshot_validate.rs builds a CompleteSnapshot from the existing testnet_snapshot.json and leader-schedule-epoch-89.json fixtures: validate() is Ok on a complete snapshot, and names the right issue when the leader schedule is missing or empty.
  • cargo test --workspace: 483 pass, 0 fail. just clippy (-Dclippy::all) and just fmt-check clean.
  • Not verified here: an end-to-end scheduler run against an endpoint that refuses getLeaderSchedule, since this session has no network route to a DZ ledger or Solana RPC. Traced instead: validate() precedes storage.save on both storage backends, and process_rewards returns the error without calling mark_success, so the epoch retries on the next tick.

@nikw9944 nikw9944 self-assigned this Aug 26, 2026
@nikw9944
nikw9944 marked this pull request as ready for review August 26, 2026 21:01
Comment thread crates/contributor-rewards/src/ingestor/epoch.rs Outdated
…no leader schedule

The scheduler logged a failed leader-schedule fetch as a warning, threw the
error away, and uploaded the snapshot under the canonical key with a null
leader schedule. It then failed reading that same file back with
"Missing leader schedule", a symptom whose cause survived only in a log line.

Both snapshot producers now propagate the fetch error with the epoch in its
context, and the scheduler validates before saving, which also covers the
--dry-run path where no consumer validates at all.

Refs malbeclabs/infra#2372
… API key out of it

The propagated leader-schedule error was formatted with {}, which prints only the
outermost context, so the reason the fetch failed never reached the journal.
Both scheduler failure sites now use {:#}.

EpochFinder's retry hooks logged SolanaClientError with {:?}, and reqwest's Debug
prints the request URL. The mainnet-beta read endpoint carries an API key in that
URL and journald ships to Loki, so every timeout and 429 would have published it.

Replaces the validate() unit tests with an integration test over the existing
snapshot and leader-schedule fixtures, so the accepting case asserts is_ok()
on a genuinely complete snapshot rather than a substring of an error.

Refs malbeclabs/infra#2372
…is branch

Comments and prose only, no behavior change.
…rror too

Redacting only the retry logs left the leak open: when the retry gives up, the
client error travels up the chain, and the scheduler prints that chain with
{:#}, so the mainnet-beta read endpoint's API key still reached journald and
Loki. Every RPC call in EpochFinder now converts its error through redacted_error,
which drops the original as a source rather than wrapping it.

Test points a client at a closed local port and asserts the key is absent from
the propagated error while present in the raw one.

Refs malbeclabs/infra#2372
@nikw9944
nikw9944 force-pushed the nikw9944/infra-2372 branch from f04cf47 to a5e562a Compare August 26, 2026 22:13
@nikw9944

Copy link
Copy Markdown
Contributor Author

Addressed the review in a5e562a: the URL redaction now covers the propagated error, not only the retry logs.

The catch was correct and the leak was worse than the comment suggested — this PR also changed the scheduler to print the failure chain with {:#}, so the deepest cause, the reqwest error carrying the API key, went straight to journald and on to Loki. All six RPC calls in EpochFinder now convert through redacted_error, and a test pins the invariant.

Nothing else changed. Rebased onto main for #412's org repoint; cargo test --workspace is 483 passing, clippy and fmt clean.

@nikw9944
nikw9944 merged commit 8004775 into main Aug 27, 2026
6 checks passed
@nikw9944
nikw9944 deleted the nikw9944/infra-2372 branch August 27, 2026 14:55
bgm-malbeclabs pushed a commit to malbeclabs/doublezero that referenced this pull request Aug 28, 2026
…no leader schedule (malbeclabs/doublezero-offchain#413)

## Summary of Changes
* The scheduler no longer writes a snapshot it cannot use: a failed leader-schedule fetch propagates instead of becoming `leader_schedule: null`, and `create_epoch_snapshot` validates before saving.
* A failed fetch was one `warn!`, then an unusable snapshot uploaded over the epoch's canonical S3 key; the tick then failed reading it back with `Missing leader schedule`, a symptom whose cause survived only in the log. malbeclabs/doublezero-offchain#411 fixed this for the `snapshot` CLI command but not for the scheduler, which is the path that runs in production.
* Scheduler failures now log the full cause chain (`{:#}`). Plain `{}` prints only the outermost context, so the newly propagated reason would still have been dropped.
* **Security:** `EpochFinder`'s retry logs printed `reqwest`'s error verbatim, which includes the request URL. That URL carries the read endpoint's API key on mainnet-beta and journald ships to Loki, so those logs now strip it. This matters because the companion PR points mainnet-beta's reads at the keyed endpoint.
* **Behavior change:** a `--dry-run` tick that previously marked the epoch processed with an unusable snapshot now fails and retries — nothing validated on that path, since `calculate_rewards` never ran. Both deployed environments run with dry-run off.

## Testing Verification
* New `tests/test_snapshot_validate.rs` builds a `CompleteSnapshot` from the existing `testnet_snapshot.json` and `leader-schedule-epoch-89.json` fixtures: `validate()` is `Ok` on a complete snapshot, and names the right issue when the leader schedule is missing or empty.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants