Skip to content

3.x.x: mine each clock-jump phase on settled work, so a held block's landing cannot race the phase's first share (#656) - #659

Merged
RobertClarke merged 3 commits into
3.x.xfrom
RobertClarke/656-clock-jump-settled-work
Oct 5, 2026
Merged

RobertClarke merged 3 commits into
3.x.xfrom
RobertClarke/656-clock-jump-settled-work

Conversation

@RobertClarke

@RobertClarke RobertClarke commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Closes #656. Refs #632, #640, #581, #646, #657.

Test-only: no server code changes.

Cause

The 10-04 nightly failed phase 3 of the wall-clock jump test. Server 0 answered the phase's first share ledger-confirmation-failed and logged payout revision changed before share commit in the same second the node took the held block.

held_landing returns as soon as the held block is the node's tip, and the phase mines at once. Its work predates two payout-revision moves: the held block's landing, and the servers' observation of the new tip. The share passes its submit check, then meets the moved revision at the append's fence. This is #632's race.

Since #581 (#646), the holder lands its held block itself as soon as it is released, so phase 3 now has phase 4's shape. Phase 4's refusals were the same race (10-02 and 10-05 nightlies). The test allowed them as REFUSED_AFTER_STEP_BACK and blamed the clock stepping back. Full diagnosis on #656.

Change

  • live_regtest.rs: adds Fixture::settled(index). It is 3.x.x: pause the session load's shares around scenario 2's own blocks, and start each replayed transcript after earlier blocks land (#631, #632) #640's wait from the transcript replay's current(), now shared. It waits until no candidate is unfinished and the server's /healthz shows the node's tip with payout_state_generation equal to qbit_prism_cluster.payout_revision.
  • live_transcript_replay.rs: current() calls it, with the same conditions and the same 30 s as before.
  • live_clock_jump.rs: Run::mine (every phase where a server must serve) and held_landing wait on it first. REFUSED_AFTER_STEP_BACK and the refusable parameter are removed, so phases 3 and 4 must accept every share like every other phase. The module doc explains why.
  • Second commit: the wait counts against each phase's WORK_SECONDS. Run::mine and held_landing set one deadline, settle within it, and give work_on what remains. A corrected server still has 30 s in all to serve again, as the test documents, rather than 30 s to settle plus 30 s for work. Fixture::settled takes its time limit, and the replay passes its 30 s.

Evidence

Local run: private PostgreSQL 16.15, pinned qbit 1.0.0, libfaketime 0.9.10, debug build.

  • Unchanged test: failed 3 of 3 with the nightly's exact error. Each time, server 0 logged payout revision changed before share commit in the second the node took the held block at height 12.
  • Fixed test: passed 10 runs: 6 on the first commit, 2 on the second, and 2 under the mutant below. Two of the first-commit passes ran while the host was heavily loaded. Every run had 98 acknowledged, refused {}, 18 blocks landed once each, and no persistence failure or stale-job cause on either server. In every run, both held blocks were offer_reserved at the jump, made exactly 1 submitblock call while held, and were answered accepted.
  • Host-caused failures: two other runs failed because of the host, not the test. One lost its log when the host's shared /tmp quota filled. The other timed out in the settle wait while every database lock wait on the host hit its 5 s lock timeout during a concurrent build: server 1 could not take its refresh's advisory lock. The old test would have failed there too, with no work in 30 s.
  • Mutant: a scratch server patch, not committed, sleeps 1.5 s between a submit's revision check and its append, as 3.x.x: pause the session load's shares around scenario 2's own blocks, and start each replayed transcript after earlier blocks land (#631, #632) #640 did for 3.x.x: transcript replay fails when a payout-revision change refuses a share mid-commit (ledger-confirmation-failed) #632.
    • Unchanged test: in one of 2 runs, server 0's first mine after phase 4's held landing was refused twice: once ledger-confirmation-failed at the fence, once stale-job with cause payout_revision. REFUSED_AFTER_STEP_BACK let both through, which shows the step-back refusals are this race.
    • Fixed test: 2 of 2 passed with refused {}.
  • Lint: cargo fmt --all --check and cargo clippy -p qbit-prism-server --all-targets -- -D warnings are clean.

The clock-jump test is nightly-only (#[ignore]). In this PR's CI, the shared helper is exercised only through the transcript replay; the first nightly after merge covers the rest.

No test was added or renamed, so test/prism-gated-tests.txt and test/prism-nightly-gated-tests.txt are unchanged.

Not in this PR

The third commit is empty. It re-runs CI after shard 2 failed authorization_rpc's authorization_fallback_requires_a_definitive_address_result with a database statement timeout. That test is outside this change, and the shard passed on the first commit.

#657 is a product bug on the same fence: a block-bearing proof whose revision moves between its check and its fence loses its block.

🤖 Generated with Claude Code

…landing cannot race the phase's first share (#656)

The 10-04 nightly failed phase 3 of the wall-clock jump test. Server 0
refused the phase's first share as ledger-confirmation-failed and logged
"payout revision changed before share commit" in the same second the
node took the held block. held_landing returned as soon as the held
block was the node's tip, and the phase mined at once, on work from
before two payout-revision moves: the landing's and the servers'
observation of the new tip. The share passed its submit check and met
the moved revision at the append's fence (#632).

Since #581 the holder lands its held block itself as soon as it is
released, so phase 3 now has phase 4's shape. Phase 4's refusals were
the same race (10-02 and 10-05 nightlies). The test allowed them as
REFUSED_AFTER_STEP_BACK and blamed the clock stepping back.

Fixture::settled is #640's wait from the transcript replay's current(),
now shared. It waits until no candidate is unfinished and the server's
/healthz shows the node's tip with payout_state_generation at
qbit_prism_cluster.payout_revision. The replay calls it with the same
conditions as before. The clock-jump test waits on it before every
serving mine and before each held block, and REFUSED_AFTER_STEP_BACK is
removed: phases 3 and 4 must accept every share, like every other phase.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T19:12:44.580312Z e3ca2ad New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

RobertClarke and others added 2 commits October 5, 2026 14:28
…so waiting for settled work does not double a server's serving budget (#656)

The settle wait added before each mine had its own 30 s, ahead of the
30 s work_on still gave a miner. A corrected server therefore had up to
60 s to serve again, where the test's WORK_SECONDS documents 30 s. Run::mine
and held_landing now set one WORK_SECONDS deadline, settle within it and
give work_on what remains. The ahead phase's no-work check keeps its own
WORK_SECONDS. Fixture::settled takes its time limit, and the transcript
replay passes its 30 s as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…meout failure (#656)

Shard 2 failed authorization_rpc's
authorization_fallback_requires_a_definitive_address_result with
"canceling statement due to statement timeout". That test is outside
this change, and the same shard passed on 26a866f. The token cannot
rerun a job, so this empty commit runs CI again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant