Bounty
XE-0268 · Bounty

net/sync: client apply loop discards dependency-retryable blocks after 10 passes; fresh sync near-livelock under target map order

Triaging claimed Medium xe#245 filed 2026-11-02 22:48 UTC by Sektorial12

Report

net/sync: client apply loop discards dependency-retryable blocks after 10 passes; fresh sync near-livelock under target map order

Suggested tier: Medium. Availability only; no funds, finality, state, or supply effect.

Summary

The sync server walks accounts in Go map order, sends entire account chains for accounts the client does not know, and stops at 10,000 blocks. The client stops reading at 10,000 blocks, applies the batch in received order, and retries only 10 times. An opening receive cannot be applied until its source send is applied. The client records many blocks as retryable dependency errors (unopened account / source send not pending) and discards them when the 10-pass bound is exhausted.

The unmodified target is a near-livelock on the tested chain, not a proven permanent stall. r-009 (180 s) reached 62/12,001 blocks and 31/6,001 accounts; r-030 (600 s, same chain, no lab knobs) applied 25 net new blocks and reached 26/12,001 blocks, 13/6,001 accounts, with 11 capped rounds and 0–10 applied calls per round. The permanent 0-progress livelock is the in-process deterministic ORDER=chain_desc case (r-021) only.

Target

  • Pinned commit: 978785929bc17a2f4ab30c383e5fc9cf4d634512
  • Unmodified binary SHA-256: c3bbf2612ab282fd31ea9b78eec109e9554a260b4ca6e6aa6e01d9fb04ff1f34
  • Instrumented node SHA-256: 43f8e71f9d533821fe8f5da7d9fcbf4e6c0301ba08fd7f33b86b279286ba6d9a
  • In-process test build: source commit above; patch SHA-256 2a05069542446be7e47a5c9566d32c4bdd3ce1111dafb88b6285c6d07022496a; test binary SHA-256 dae46008c031ab9d84e5c3666b30e66639ce01c9a42fc86b82883f8f737c4488
  • Network: t104b-lab (custom local genesis)
  • Ledger genesis: be79a8c7fa04ebb76f2fba9d8e9d5311007544029876a3c3e3e534aeb2fa0d16
  • Statechain genesis: cdac6a19f67c2a8f38c426570992ed91fd82aceb4dbb4490fcc13452be3fc0fb
  • Activation state: tip 0, no active features, protocol 1.0.0
  • Store/topology: Badger; single-peer runs use one server and one fresh client; r-016 uses five servers; loopback API/metrics; --disable-mdns --no-discovery

Preconditions

An honest server, a valid chain with a dependency path (or a hub whose sends are outside the 10k window), and more than 10,000 blocks. The client's frontier map is below the 1 MiB request boundary described in the companion F-002 report. No invalid blocks, forged signatures, or attacker are required.

Invariant

A fresh node with one honest peer reaches the server tip in bounded rounds. The same valid chain must converge regardless of the server's account iteration order. Re-submitted retryable blocks must not be permanently discarded after a fixed number of passes.

Unmodified-target observations

  • r-009: default-PoW 6,001-account / 12,001-block chain, target map order, 180 s. Client end state 62/12,001 blocks, 31/6,001 accounts; 5 capped rounds. The r-009 artifact has no run-meta; the node reports xe/9787859 and the per-run hash is recorded in r-030.
  • r-030: same chain, 600 s, INSTRUMENTED=0, empty SERVER_ENV/CLIENT_ENV. Start 1/1; end 26/12,001 blocks, 13/6,001 accounts; 11 hit maxTotalBlocks cap rounds and 11 could not be added after retries rounds; applied calls per round 0,0,0,3,4,2,0,10,4,2,8 (the counter includes duplicate no-ops; the final round was in flight at the stop sample); samples plateau at 24→26 blocks in the last two minutes. This is a near-livelock within a 600 s bound, not a permanent-stall claim.
  • Exact unmodified-target command:
GOTOOLCHAIN="go$(cat target/xe/.go-version)" \
  go run ./lab/scenarios/t-104b/cmd/genchain \
  -out /tmp/t104b-default-6k -shape linear -accounts 6000 \
  -difficulty default -workers 4

INSTRUMENTED=0 \
SERVER_BIN=$PWD/target/xe/xe CLIENT_BIN=$PWD/target/xe/xe \
  lab/scenarios/t-104b/run-node.sh /tmp/t104b-default-6k r-repro-f003 600

Causal controls (instrumented/in-process; not unmodified target)

  • r-021 in-process deterministic descending order on a 12,001-block path: 8 rounds, 10,000 received each, 0 new blocks, client stays at 1 account. This is the permanent livelock case; it is in-process deterministic ORDER=chain_desc, not unmodified target map order.
  • r-023: same chain/order with caps raised to 20k/20k; 21, 22, 22 new blocks in three rounds, exactly 11 accounts/round (10 retry passes plus the final pass).
  • r-024b: committed 400-account chain, descending, 1,000 retries; 800/800 non-genesis blocks in one round, 401 passes (801/801 including genesis).
  • r-024c: same chain, 10 retries; after two rounds 43/800 non-genesis blocks applied, 22/401 accounts, i.e. 11 accounts/round.
  • r-025: target-like map order, 20,000 accounts, 10k/10k, 10 retries; ten rounds, 100,000 received, 15 new blocks, 8/20,001 accounts.
  • r-026: star control (5 hubs, 6,006 accounts, 12,011 blocks), map order; converged in 2 rounds. r-020 ascending 6k path converged in 2 rounds.
  • Instrumented node repeats: r-005 (20,001 accounts, map, one peer, 150 s; end 6/40,001 blocks, 3 accounts), r-010 (default-PoW 6k, map, 180 s; end 68/12,001 blocks, 34/6,001 accounts), r-011 (same chain ascending; converged in 2 rounds), r-016 (five peers; end 4/40,001 blocks, 2 accounts, 3 net new; per-round sum 15 is unreliable under concurrency), r-017 (star; converged to 12,011/6,006; use r-026 for the two-round claim).

Root cause

  • net/sync.go:682-688: server accounts come from for acc := range ourFrontiers.
  • net/sync.go:697-699: an account absent from the client's map sends its entire chain.
  • net/sync.go:689,724: the server stops at maxServerBlocks = 10000.
  • net/sync.go:577: the client stops reading at maxTotalBlocks = 10000.
  • net/sync.go:604-627: at most 10 retry passes; a pass with no progress breaks early; a final pass applies what it can.
  • core/ledger.go:1081-1091: validateAndAddReceive calls getPendingSendOverlay(b.Source) (line 1086) and returns source send not pending when the source is absent.
  • core/cascade_commit.go:110-122: getPendingSendOverlay reads the cascade overlay or store.GetPendingSend; an unapplied source send yields no pending entry.
  • core/ledger.go:1454-1458: an unopened account has no declared public key.
  • core/retryable.go:5-33: IsRetryableError matches unopened account and source send not pending, so the client keeps such blocks for the next pass.

The server's map order is randomized per request by Go. A fresh client's only applied root is genesis, so a random 10k window may not contain a complete ancestor closure for a deep account.

Impact

Fresh-node onboarding and post-loss recovery are slow or stalled on the tested dependency-shaped chain: 26/12,001 blocks and 13/6,001 accounts after 600 s with the unmodified target. A hostile peer serving the same valid blocks in a dependency-hostile order would be expected to produce the permanent instrumented-order case; this was not tested with a separate malicious peer. The unmodified target's map order already produces the near-livelock. No funds are lost, no invalid block is accepted, and finalized state does not diverge.

Duplicate cross-references

  • #219 / PR #223 cover the 10,000-block response cap's terminal/continuation ambiguity and a readiness false-green. PR #223 does not change the client's fixed 10-pass apply loop or the cross-account dependency retry path. This report is the apply-side mechanism; it does not re-claim #219's readiness/cap result.
  • If maintainers treat this as a duplicate of #219, I accept the dedupe and will not re-file. The F-003 evidence can be added as a comment on #219 only if the XE team requests it.
  • #59 (overlapping sync resource use), #60 (SIGTERM/shutdown), #44 (full-page allocation), and #57 (lease-family blocks) are separate reports. #196 is the statechain response byte cap; #8 finding 4 is nil-block/empty-page amplification.

Suggested fix

Make the client order-independent: apply batches in dependency rounds until no progress, not a fixed 10 passes; or topologically sort receives by source depth. On the server, send accounts in chain-creation order or include source sends before recipients. Mark the tracker dirty when a response was capped so the next round starts immediately rather than waiting for the 60 s full resync. The tracker item is the #219/PR #223 area; complementary, not part of this report's novel mechanism.

Payout

XE address: b50f71f5ad1743456550ad7bd7720e18ce3a271f1c73eb90c56a79915404521b

Thread

Nothing public yet.