Skip to content

Node orchestration - #5

Merged
azuchi merged 14 commits into
mainfrom
node-orchestration
Aug 17, 2026
Merged

azuchi merged 14 commits into
mainfrom
node-orchestration

Conversation

@Naviabheeman

Copy link
Copy Markdown
Contributor

Add node start stop, reindex, reindex-chainstate and reloadxfield triggers to level 2 core nodes while the network is live and actively building blocks. with this the intended test scenarios are covered

@azuchi azuchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the net-new commit (be15c8e) on top of the PR #4 branch. The supervisor design is genuinely well built: the in-container supervise-not-be-tapyrusd approach, the lock + process-identity check between deliberate restarts and crash recovery, the asyncio task-GC guard, the os._exit rationale in _shutdown, blocks-not-timer downtime, the nesting pause-file depth counter, and --no-deps throughout lib/compose.py are all the right calls, and the work-done.md write-up matches the code. The NODE_ORCHESTRATOR-must-persist-to-$GITHUB_ENV lesson (and documenting the drift you hit live) is exactly the compose-interpolation failure mode PR #4's review flagged — good to see it captured.

That said, the branch's own CI is red (run 30931367074), and there are two blockers plus two smaller items:

1. Docker creates runtime/ as root, and the job dies at "Assemble signer configs" — the pause file has the same problem waiting behind it

Every core-* service now bind-mounts ../runtime/orchestrator-control:/orchestrator-control. On the runner, runtime/ doesn't exist yet when verify_seeder.py first brings the cores up, so the Docker daemon (root) creates both runtime/ and runtime/orchestrator-control/ owned by root:root. Everything host-side that writes under runtime/ afterwards then fails as the non-root runner user — which is exactly how this run died:

PermissionError: [Errno 13] Permission denied: '.../runtime/signers'

Fixing the signers dir alone won't be enough: pause_node_orchestrators()'s PAUSE_FILE.touch() writes into the root-owned runtime/orchestrator-control/ itself, so generate_traffic.py would hit the identical PermissionError at its first pause (and PermissionError isn't in any script's except tuple, so it surfaces as a raw traceback).

Fix: create the directory host-side before the first docker compose up that mounts it — e.g. Path(...).mkdir(parents=True, exist_ok=True) at the top of verify_seeder.py's run() (it owns the first core bring-up), or a one-line workflow step before "Bring up tapyrus-seeder and verify it". Pre-existing host dirs are left alone by the daemon, so ownership stays with runner.

2. The reorg's confirmation phase runs with chaos resumed — the weekly full run will flake even though the smoke run passes

The pause bracket in simulate_reorg.py releases after _build_group_a_fork(), but the recipe's precision requirements don't end there: _reconnect_group_b() runs TopologyWaiter's exact getconnectioncount match (120s budget), and _confirm_tie_holds/_extend_group_b_by_two_blocks/_confirm_convergence assert precise getchaintips shapes on every node.

What protects those steps today is only the 360s startup grace of freshly-restarted orchestrators — and that only works at smoke scale. In the weekly run, REORG_LENGTH=30 makes group A's fork build alone ~900s, so core-1b/2b (restarted back at _restore_group_a) are long past their grace when the finally resumes chaos; their action loops are sitting in _wait_out_pause and fire within ~10s of the pause file disappearing. A restart (up to 90s down) or an invalidateblock landing during the exact-count wait or the tip assertions fails the step spuriously. The smoke run (REORG_LENGTH=5, ~150s build) stays inside the grace window, so CI green here won't predict the scheduled run.

Fix: extend the pause through _confirm_convergence() — i.e. bracket the whole of run() after _build_baseline(), not just the fork-building span. The recipe's own comment says "paused for the whole span where exactly one group is ever up", but the exact-count and tip assertions after reconnection are just as chaos-intolerant.

3. PRNG_SEED_BASE never actually reaches the containers

node_orchestrator.py reads PRNG_SEED_BASE from its own environment, but no core-* service passes it in environment: — so inside every container it falls back to "0", and every run seeds every node with 0:<node-name>. Chaos timing is per-node distinct but identical across runs, and the scripts.md/work-done.md claim ("seeded from github.run_id, deterministic and reproducible per run — its first real use") doesn't hold. Add PRNG_SEED_BASE: ${PRNG_SEED_BASE:-0} to each core-* service; it's a job-level workflow env var, so every later compose invocation resolves it identically and it introduces no recreate-drift.

4. "Runs continuously against background chaos" is overstated during traffic generation

generate_traffic.py pauses chaos for every _wait_for_next_block, and those waits are the overwhelming majority of the script's wall time — so during the traffic phases chaos is effectively suppressed except for actions already in flight, and most real churn happens between workflow steps. That may be a perfectly fine tradeoff, but the README/scripts.md currently sell it as continuous. Either soften the docs, or (better, later) relax _wait_for_next_block's all-7 requirement — e.g. require the 3 stable RPC targets and tolerate stragglers — so chaos genuinely overlaps traffic. Fine as a follow-up rather than in this PR.


Two notes rather than asks: (a) this PR stacks on the slack-report-seeder-check branch, so PR #4's open review items (in particular replacing the coinbase-rotation prediction with per-block detection) land here too — per-block detection would also let you delete CALIBRATION_MAX_ATTEMPTS and its retry loop outright; (b) recreate_fresh() is the one lib/compose.py helper without --no-deps — harmless for redis today, but worth adding for symmetry before someone uses it on a signer service.

Happy to approve once CI is green with 1–3 addressed (4 can be a documented tradeoff).

@Naviabheeman
Naviabheeman requested a review from azuchi August 6, 2026 13:25

@azuchi azuchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All four items from the previous review are properly addressed, and the follow-on work on top of them is genuinely impressive. CI is green twice at head (62fe00b).

Previous items, confirmed fixed:

  1. runtime/ root ownership (29d9f86): verify_seeder.py pre-creates runtime/orchestrator-control host-side at the top of run(), before any container can bind-mount it into existence as root. Right place — every path into the stack goes through that script first.
  2. Reorg pause scope (29d9f86): the bracket now extends through _confirm_convergence() with try/finally. I also checked the two steps left outside it — _verify_canary_transaction_survived targets CANARY_SENDER = core-1a, which is not a chaos node, so running it after resume is safe.
  3. PRNG_SEED_BASE (29d9f86): now in every core-* service's environment:. Reproducible chaos is real now.
  4. Docs honesty (29d9f86): README/scripts.md accurately describe chaos as mostly landing between steps during traffic generation, with the all-7-wait relaxation tracked as a real follow-up. Exactly the framing I hoped for.

Beyond those, this branch also lands the direct per-block coinbase observation (ba73078, _credit_coinbase_for_height + gap-crediting in _next_block_with_coinbase) — the preferred fix for PR #4's open item 2, with the calibration machinery deleted entirely. And the three live-debugging commits (6ba01bc, 7d89ab7, 62fe00b) each fix a real, evidenced bug: the PendingChange confirm-before-credit redesign with the monotonic max() guard, the pause-file release-barrier jitter (nice root-cause on the three-nodes-same-second invalidate), the topology-derived getchaintips expectation table (tightened, not just tolerated — the "second tip must be group A's fork specifically" check is better than the original), and setup getting the same two-attempt confirmation grace as the round loop. The _persist_env_for_rest_of_job self-containment and recreate_fresh gaining --no-deps close out my side notes from last time too.

Two small remaining items I'd like addressed — both quick:

  1. Doc drift in doc/scripts.md (~line 280): the start_node_orchestrator.py section still says the workflow step appends NODE_ORCHESTRATOR=1 to $GITHUB_ENV — but 29d9f86 moved that into the script itself (_persist_env_for_rest_of_job), and the workflow comment + work-done.md already describe the new arrangement. Please update the stale sentence.
  2. _last_credited_height initial value (generate_traffic.py run()): it's read via _current_height() after _seed_ledger_with_current_balances() releases its pause — a chaos invalidateblock landing in that instant could regress the min() below the height the balances were seeded at, and the first crediting pass would then re-credit a coinbase already included in the seeded balance. Narrow window, but the same double-credit failure mode 6ba01bc just fixed elsewhere, and free to close: initialize it from the seeding snapshot's own consistent heights (min of the after dict) inside the paused window instead.

One residual design note, not a request: a PendingChange dropped at settle (0 confirmations, still in the wallet) could in principle still confirm later and drift the ledger — the two-attempt grace makes this much rarer than the incident that motivated it, but it isn't structurally impossible. Worth a line in work-done.md someday if it's ever observed.

On merge sequencing: this branch stacks on slack-report-seeder-check and contains the fix for PR #4's one remaining open item (the calibration flakiness, fixed here by ba73078). As it stands, merging #4 alone would leave main flaky until #5 follows. Two clean options:

  • (a) Cherry-pick ba73078 back into PR #4 — #4 becomes approvable on its own merits, and this PR rebases to just the orchestrator work; or
  • (b) Merge #4 and #5 in quick succession, accepting that #4 is transiently flaky-by-design in between.

I'm fine with either — (a) is cleaner if the cherry-pick applies without conflicts; (b) is less churn if it doesn't. Happy to approve both once the two items above land and you've picked a sequencing.

@azuchi

azuchi commented Aug 11, 2026

Copy link
Copy Markdown
Member

@Naviabheeman please rebase with latest main branch.

Naviabheeman and others added 8 commits August 11, 2026 10:17
Restricts random stop/restart/reindex/invalidate chaos to the second- and
third-layer core nodes; core-1a/2a/3a (the signers' own RPC targets) get
crash-recovery supervision only, since live testing showed even a brief
disruption there could throw off generate_traffic.py's coinbase-rotation
tracking. Runs inside each core-* container via a Docker image layer +
entrypoint wrapper, coordinated with the other scenario scripts through a
shared pause file.

Also fixes several bugs found via live testing: a lingering seeder-test-node
connection breaking topology convergence, an unbounded downtime fallback
exceeding wait_for_topology.py's own budget, missing RPC-reachability
tolerance throughout generate_traffic.py's setup/verification calls, and
NODE_ORCHESTRATOR not persisting across workflow steps that recreate core
nodes via depends_on.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
_calibrate_coinbase_rotation predicted core-1a/2a/3a's coinbase earner from
a 3-height anchor observed once early in the run, assuming a clean repeating
3-cycle. Broke live under chaos: tapyrus-signer's round-master selection
rotates by ROUND, not by block, so a round that produces no block (e.g. a
signer briefly catching up from a chaos-triggered restart) silently shifts
the anchor, and every later height's predicted earner drifts from reality.
The predicted-vs-actual gap also meant a poll that observed two new blocks
at once silently skipped crediting the intermediate height.

_credit_coinbase_for_height reads each height's real coinbase transaction
and credits whichever of the 3 wallets actually has it -- no anchor to
drift, so a skipped round costs nothing. _next_block_with_coinbase credits
every height since the last one credited, not just the height a poll
happens to observe, closing the gap-skipping bug.

core-1a/2a/3a's chaos exclusion no longer needs the calibration-fragility
justification -- the signing-capacity/threshold reasoning alone still
covers it, noted in doc/work-done.md.

Verified live: 5 full rounds against a chaos-supervised stack, 70/70 round
actions succeeded, zero balance mismatches, coinbase income credited
correctly on all 3 earning nodes throughout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Four issues from review of the node orchestrator PR:

1. Docker created runtime/ as root on the first core-* bring-up (the bind
   mount source didn't exist yet), breaking every later host-side write
   under it as the non-root runner user -- "Assemble signer configs"
   (runtime/signers) and pause_node_orchestrators() (runtime/
   orchestrator-control/pause) both failed this way. Fixed: verify_seeder.py
   creates runtime/orchestrator-control host-side at the top of run(),
   before any container touches it.

2. simulate_reorg.py's chaos pause released right after the isolated fork
   building finished, but _reconnect_group_b's exact getconnectioncount
   wait and _confirm_tie_holds/_extend_group_b_by_two_blocks/
   _confirm_convergence's precise getchaintips assertions are just as
   chaos-intolerant. Only the 360s startup grace period protected these at
   smoke scale (REORG_LENGTH=5); the full weekly run (REORG_LENGTH=30,
   ~900s isolated builds) would flake once restarted orchestrators aged
   past their grace window and started firing mid-assertion. Fixed:
   extended the pause bracket through _confirm_convergence().

3. PRNG_SEED_BASE was set at job level but never passed into any core-*
   container's environment:, so node_orchestrator.py always fell back to
   "0" -- chaos timing wasn't actually reproducible per-run as documented.
   Fixed: added PRNG_SEED_BASE: ${PRNG_SEED_BASE:-0} to all 7 core-*
   services.

4. README/scripts.md oversold chaos as running continuously during traffic
   generation; in practice generate_traffic.py pauses chaos for every
   block wait, the overwhelming majority of its wall time. Softened the
   docs to describe this accurately, noting relaxing
   _wait_for_next_block's all-7 requirement as a real follow-up.

Also: start_node_orchestrator.py persisted NODE_ORCHESTRATOR via a
separate `echo >> $GITHUB_ENV` in the workflow step instead of
self-contained like verify_seeder.py's own env persistence -- the exact
fragile split that pattern was introduced to avoid. Moved persistence
into the script itself. And: every one of the 13 workflow-invoked
scripts now ends with a `done.` line naming what it handed off
(render_tapyrus_conf.py was the one missing it) -- a deliberate,
uniform, greppable marker for every handoff point in a job's log.

Verified live end-to-end against a fresh, chaos-supervised 7-node stack:
runtime/ stayed runner-owned through first bring-up, PRNG_SEED_BASE
reached containers directly, signers came up via --no-deps without
recreating any core node, generate_traffic.py settled cleanly (42/42
actions) under chaos, and simulate_reorg.py completed cleanly with
"node orchestrators resumed" now firing after _confirm_convergence as
intended -- topology reconnect, tie-check, extend, and all 7 nodes'
getchaintips shapes all passed under live chaos.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A real CI run reported 15 balance mismatches, permanent from the point
they first appeared. Traced through the container logs to two distinct
bugs, both triggered by the same incident: three chaos nodes (core-1b,
core-3b, core-7) independently invalidated their shared tip in the same
second.

1. _current_height() takes min() across all 7 nodes; the momentary
   height regression on the invalidating nodes could rewind
   _last_credited_height (a bare assignment), causing a later call to
   re-credit an already-credited coinbase height. Fixed with max() --
   monotonic regardless of when a regression lands.

2. generate_traffic.py credited its ledger the instant a send/issuance
   broadcast succeeded, with no on-chain confirmation check. One
   transaction broadcast right as the invalidate hit was relayed once
   and never confirmed again -- permanently draining the ledger's
   agreement with reality. Sends/issuances now return a PendingChange;
   _resolve_pending_changes only applies its ledger deltas once every
   one of its txids actually confirms (checked at the round's existing
   check/settle heights), dropping it -- not credited, not counted as a
   successful action -- if it never does. Removed the now-dead
   _apply_fee in favor of _extract_fee, reused by the resolver.
   Also fixed: the one-time setup (funding/issuance) confirmations were
   incrementing the same success counter as round-loop actions, letting
   it exceed its own denominator (caught live: "81/70 round actions
   succeeded") -- setup no longer counts toward it.

Also traced *why* three independent, differently-seeded nodes
invalidated the same block in the same second: not a seeding problem
(seeds are already per-node and uncorrelated) -- the shared pause file
acts as a release barrier. A node whose own randomized timer expires
during any of generate_traffic.py's frequent brief pauses queues at
_wait_out_pause() and fires the instant the file disappears, regardless
of how spread out its original timer was. Added a random 0-15s jitter
after a gated release to destagger this.

Verified live against a stack with chaos running continuously for 4+
hours: two separate 5-round generate_traffic.py runs, both settling
with zero balance mismatches, the second confirming the exact expected
70/70 round-action count.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A real CI run failed _confirm_convergence because core-3b showed a
second, valid-headers tip at group A's height -- the check only
tolerated this on core-7.

Re-derived every node's expected getchaintips shape from the actual
topology rather than patching the symptom: block propagation here has
two mechanisms, not just P2P adjacency -- each signer submits a block
it masters directly to its own RPC target (no core-to-core P2P needed),
and P2P relay along the static edges (core-1a<->1b, core-2a<->2b,
core-3a<->3b, core-7<->{1b,2b,3b}, with core-7 the only bridge between
the three otherwise-disconnected pairs). From this: group A's 4 nodes
each personally built their own fork (deterministic 2-tip residue after
reorging onto group B's longer chain); core-3a has no path to group A
within the reconnect window (3 hops: 1b/2b->7->3b->3a), so it stays
strict; core-3b and core-7 are both 1-2 hops from group A via core-7's
bridge, so both can legitimately pick up group A's fork as headers-only
knowledge without adopting it.

core-3b now gets the same tolerant check as core-7 -- tightened beyond
the original core-7-only version too: if either shows a second tip, it
must actually be group A's fork specifically, not just "any extra tip
is fine", so a genuinely unexpected chain wouldn't silently pass.

Documented as a table (code comment + doc/scripts.md) rather than
prose, so the expected shape per node is a lookup, not a re-derivation,
next time this needs touching.

Verified live: core-3b and core-7 both matched the new expectation
exactly (0 and 2 other known tips respectively, both correctly
resolving to group A's fork when present).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…raffic.py

A real CI run failed with 8 balance mismatches, all isolated to core-3a,
right after a federation change. Traced via the full script log: core-3a's
initial colored-coin issuance was flagged "never confirmed by height 73 --
dropped, not credited" only 33 seconds (one block) after broadcasting --
but the transaction was perfectly valid and confirmed shortly after (the
system was just busier than usual, with signer-b containers freshly
starting up). The dropped credit silently corrupted the ledger two ways at
once: the missed color credit drifted it negative over subsequent rounds
(getbalance itself is never negative -- confirmed the ledger's own tracked
value was the only thing that went below zero), and the fee deduction
bundled in the same PendingChange never applied either, leaving TPC
permanently too high relative to reality.

Root cause: _fund_unfunded_nodes()/_issue_colors() resolved with a single
final=True shot, unlike the round loop's own two-attempt check/settle
tolerance. Fixed by giving setup the same two-attempt pattern.

Also hardened _seed_ledger_with_current_balances() and _verify_round()
against a related but distinct risk: neither confirmed all 7 nodes were
read at the same height, so a block landing mid-read (the sequential
per-node loop in _verify_round is slow enough for this to matter) could
mix pre- and post-block state into one supposedly-consistent snapshot,
surfacing as a spurious mismatch with no real cause. Both now snapshot
every node's individual height before and after the read and retry (up to
5 attempts) if any node moved -- a precise per-node comparison, not
_current_height()'s aggregate min(), which could miss a non-minimum node
advancing without the aggregate changing at all.

Verified live: 4 full rounds against a live stack, 56/56 round actions
succeeded, zero balance mismatches.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
29d9f86 moved NODE_ORCHESTRATOR=1 persistence into start_node_orchestrator.py
itself (_persist_env_for_rest_of_job), but this doc section still described
the workflow step as the one appending it to $GITHUB_ENV.
…sion

_last_credited_height was set from _current_height() after
_seed_ledger_with_current_balances() already released its chaos pause. A
chaos invalidateblock landing in that instant could regress the observed
height below the one the balances were actually seeded at, and the first
crediting pass would then re-credit a coinbase already folded into the
seeded balance -- the same double-credit failure mode 6ba01bc fixed
elsewhere.

_seed_ledger_with_current_balances now returns the height its own
consistent snapshot was taken at, still inside the paused window, and run()
seeds _last_credited_height from that instead of re-reading the height
after chaos resumes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Naviabheeman and others added 2 commits August 11, 2026 22:20
…2b's mempool

A real CI run showed permanent, unchanging real-vs-ledger offsets (e.g. core-2b's
own color balance a fixed +3 above what the ledger tracked, from the height it
first appeared onward) -- the signature of a PendingChange wrongly dropped despite
its transaction actually confirming on-chain. Root cause: a chaos node's own
restart wipes its in-memory mempool, so a not-yet-confirmed transaction that node
itself broadcast can vanish from its own gettransaction view even though it was
already relayed and got mined via another node's mempool copy -- and that node's
restart downtime (DOWNTIME_MIN/MAX_BLOCKS=2-4 blocks) can easily outlast the
normal two-attempt check/settle window on its own.

Fixed two ways, one per root cause:
- verify_seeder.py's CONNECT_MODE_ARGS sets -persistmempool=1 on core-2b
  specifically (the node implicated in the live failure), so a clean chaos
  restart flushes its mempool to disk first instead of losing it.
- generate_traffic.py's new _give_chaos_senders_grace gives a still-pending
  change up to CHAOS_SENDER_EXTRA_RESOLVE_ATTEMPTS (3) more blocks before the
  final settle check, but only if its sender is in CHAOS_SENDER_GRACE_NODES --
  deliberately CHAOS_NODES minus core-2b, since core-2b no longer needs it.
  Wired into both the setup phase (funding/issuance) and every round.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comments in generate_traffic.py described the fixed-attempt-count design the
previous commit replaced (CHAOS_SENDER_EXTRA_RESOLVE_ATTEMPTS) and narrated
specific past incidents in-line, rather than just describing current
behavior. Trimmed to current-implementation-only; the incident history now
lives in doc/work-done.md (including a new short entry for the setup
single-shot-drop incident, which previously had no doc/work-done.md record
at all -- only the code comment). doc/scripts.md's two touched bullets are
now short step descriptions pointing to work-done.md for rationale, not
inline history.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Naviabheeman and others added 2 commits August 12, 2026 18:45
A real CI run hit the same permanent-offset signature 0057532 was meant to
close, on core-1b (sender) and core-2a (round-robin target), even though
core-1b is in CHAOS_SENDER_GRACE_NODES and its sync-wait ran and passed.

Root cause: _give_chaos_senders_grace made its "authoritative" confirmation
check immediately after _wait_for_sender_sync returned, at whatever height
was current -- still check_height, one full block earlier than the
settle_height every other pending change is judged at. When the sender
wasn't actually behind (sync-wait returns near-instantly), that gave it
less room than a non-chaos change, not more: a perfectly valid transaction
that simply needed one more block -- the same class of bug f14db84 already
fixed for setup -- got dropped a block early.

Fixed by moving the sync-wait-then-check to run at settle_height instead:
every call site (funding setup, issuance setup, round loop) now advances to
settle_height first and passes it in, so a CHAOS_SENDER_GRACE_NODES change
gets the identical one-block cushion as every other change, with the
sync-wait layered on top as insurance against the mempool-wipe case right
before that same final check.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… ones

A third real CI run hit the identical permanent-offset signature on core-2a
(never chaos-restarted at all) and core-2b (chaos, but excluded from
CHAOS_SENDER_GRACE_NODES specifically because persistmempool was assumed to
make this unnecessary for it). Traced through both container logs and
generate_traffic.py's own output to two separate incidents in one run: a
setup-phase core-2a -> core-2b FUNDING_PAIRS send dropped at the very first
settle (persisted unchanged for the rest of the run), and a round's own
core-2a/core-2b sends dropped with zero chaos activity anywhere nearby
(confirmed against docker logs core-2a/core-2b: both broadcasts relayed
normally, and the block that should have confirmed them contained no other
transactions at all).

Root cause: the grace mechanism was still gated on CHAOS_SENDER_GRACE_NODES
membership, so core-2a and core-2b never got the extra block at all -- they
always had exactly two attempts (check, settle), same as before any of this
was fixed. "Needs a third attempt" was never actually a chaos-specific
problem; the earlier fixes just patched the one subset that had been
directly observed failing.

Fixed by making settle-height's own resolve non-final and unconditionally
giving whatever's still pending afterward one more block (_give_final_grace,
replacing _give_chaos_senders_grace) before the true final drop, for every
sender -- CHAOS_SENDER_GRACE_NODES membership now only adds the
_wait_for_sender_sync safeguard on top of that same universal extra block,
it no longer gates whether the extra block happens at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@azuchi azuchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both items from my last review are addressed, and the three-incident debugging arc since then (0057532 → 9b2c250 → e7f9ff2) is documented in work-done.md with a candor that makes it genuinely useful reading — including the honest conclusion that "needs a third attempt" was never chaos-specific and the earlier fixes had just patched the observed subset. The final design is the right shape: a universal extra grace block for every still-pending change (_give_final_grace), with _wait_for_sender_sync's height-AND-blockhash convergence check layered on top only where a chaos restart can hide a self-broadcast transaction. CI is green twice at head (31675086075 / 31675082744), and the branch's own run history (one-green-one-red at each intermediate head, clean at this one) tells the story of the fix chain converging.

Previous items, confirmed fixed:

  1. scripts.md doc drift (1721b67): the start_node_orchestrator.py section now correctly attributes the $GITHUB_ENV persistence to the script's own _persist_env_for_rest_of_job.
  2. _last_credited_height seeding (c08d330): initialized from the snapshot's own heights inside the paused window, exactly as discussed — which brings me to the one new item, and an apology to go with it.

One new item — min(reachable) double-credits when any node is stably behind at snapshot time; it should be max. This one is on me: my last review explicitly suggested "min of the after dict", you implemented exactly what I asked for, and what I asked for was wrong. I'm sorry for the bad steer — here's the correction, hopefully before it costs you a CI run:

The consistent-read loop deliberately tolerates mixed heights across nodes (only per-node stability between before and after is required — correct, since chaos nodes legitimately diverge). But that means the accepted snapshot can be e.g. {core-1a: 10, ..., core-1b: 8} with core-1b sitting stably invalidated below the tip — an invalidateblock action in flight when the pause landed keeps it there for the whole snapshot, reachable and consistent. min(reachable) then returns 8, while core-1a/2a/3a's seeded balances were read at height 10 and already include heights 9–10's coinbase. The first _next_block_with_coinbase after core-1b reconsiders credits range(9, actual+1) — re-crediting 9 and 10 into balances that already contain them, and the run fails on a permanent positive offset. Same double-credit failure mode as the two you've already fixed, arriving through a third door — this time one I pointed you toward.

max(reachable) is correct, and there's a clean invariant behind it: a block is submitted to its earner's own RPC node first, and core-1a/2a/3a are never chaos-restarted or invalidated — so earner(h)'s height is always ≥ h, meaning every height ≤ the snapshot's max is already folded into its earner's seeded balance, and no height above it is. No double-credit, no under-credit (a block landing mid-snapshot bumps after ≠ before and retries). One-word fix plus the comment.

One non-blocking suggestion, author's call: -persistmempool=1 only dumps the mempool on a clean shutdown — _restart's fallback path (stop RPC fails → self._process.kill()) and _supervise_crashes' relaunch-after-crash both skip the dump, so core-2b isn't fully covered by the flag alone. Adding core-2b to CHAOS_SENDER_GRACE_NODES would close that residual hole for the cost of a near-instant sync check in the common case. Given this exact failure signature has now bitten three separate CI runs from three different directions, the cheap insurance seems worth it — but the universal grace block already covers the likeliest case, so I won't insist.

Happy to approve once the min → max fix lands.

Naviabheeman and others added 2 commits August 14, 2026 10:33
…max()

Review feedback: the consistent-read loop only requires each node's own
height to be stable (before == after), not that every node agrees -- a
chaos node can sit stably behind the tip for the whole snapshot (e.g. mid
invalidateblock when the pause landed) and still pass, so `reachable` can
legitimately span multiple heights. min(reachable) then anchors the seeded
balances to a lagging node's height instead of the tip they were actually
read at, and the first crediting pass re-credits heights already folded
into them -- the same double-credit failure mode fixed twice already
elsewhere in this file, this time reached through height selection rather
than a dropped PendingChange or a bare _last_credited_height assignment.

Fixed with max(): a block is always submitted to its earner's own RPC node
first, and core-1a/2a/3a (the only earners) are never chaos-restarted or
invalidated, so earner(h)'s own height is always >= h -- every height <=
the snapshot's max is already folded into that earner's just-seeded
balance, and no height above it is. No under-credit either: a block
landing mid-snapshot changes `after` and the loop retries.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Non-blocking review suggestion, taken: -persistmempool=1 only dumps the
mempool on a clean shutdown. node_orchestrator.py's _restart has a fallback
path (RPC stop fails -> self._process.kill()) and _supervise_crashes
relaunches after an unexpected exit -- both skip that dump, so the flag
alone never fully covered core-2b. The universal grace block (every sender
gets one extra block before the final drop) already covers the likeliest
case; the sync-wait this adds is cheap additional insurance -- near-instant
when core-2b is already caught up, the common case -- given this exact
failure signature has now surfaced through three separate mechanisms.

Also trimmed _give_final_grace's docstring, which narrated the specific
incident that motivated the universal grace block (now stale -- it said
core-2b was "excluded" from this set, no longer true) back down to
current-design-only; the incident history lives in doc/work-done.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@azuchi
azuchi merged commit e638abd into main Aug 17, 2026
2 checks passed
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.

2 participants