<!-- XE-8799 · Node block producers sign prev=0 blocks when a local chain read fails — Ledger.GetChain swallows store errors; Node.Receive/autoAcceptLease lack the len==0 abort · testnet -->
*Markdown view of <https://bounty.xe.network/XE-8799>. The page is the record; this is the same page for reading.*

XE-8799 · Bounty

# Node block producers sign prev\=0 blocks when a local chain read fails — Ledger.GetChain swallows store errors; Node.Receive/autoAcceptLease lack the len\=\=0 abort

Triaging
claimed Minor
web
filed 2026-11-12 00:58 UTC
by xe:8d50b3a1

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Minor

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:15 UTC

Told
:   2026-11-20 00:15 UTC

### Patches

None linked.

### History

- [546032](https://bounty.xe.network/log/546032) 2026-11-20 00:15 UTC proposal.adopted
- [546031](https://bounty.xe.network/log/546031) 2026-11-20 00:15 UTC ticket.award
- [545953](https://bounty.xe.network/log/545953) 2026-11-20 00:15 UTC proposal.adopted
- [545952](https://bounty.xe.network/log/545952) 2026-11-20 00:15 UTC reply.sent
- [545870](https://bounty.xe.network/log/545870) 2026-11-20 00:15 UTC proposal.adopted
- [545869](https://bounty.xe.network/log/545869) 2026-11-20 00:15 UTC ticket.status new → triaging
- [545663](https://bounty.xe.network/log/545663) 2026-11-20 00:15 UTC proposal.adopted
- [545662](https://bounty.xe.network/log/545662) 2026-11-20 00:15 UTC ticket.facts area
- [545661](https://bounty.xe.network/log/545661) 2026-11-20 00:15 UTC proposal.adopted
- [545660](https://bounty.xe.network/log/545660) 2026-11-20 00:15 UTC ticket.facts
- [545659](https://bounty.xe.network/log/545659) 2026-11-20 00:15 UTC proposal.adopted
- [545658](https://bounty.xe.network/log/545658) 2026-11-20 00:15 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-8799) · [JSON](https://bounty.xe.network/v1/tickets/XE-8799) · [markdown](https://bounty.xe.network/XE-8799.md)

### Report

# Node-side block producers sign prev\=0 blocks on a failed local chain read — `core.Ledger.GetChain` swallows store errors, and `Node.Receive` / `autoAcceptLease` are the only node producers with no len\=\=0 abort

- **Track:** Round 2 / B1 — chain-status blindness, sibling hunt beyond XE-0121 / XE-2706 / XE-6695
- **Repo / HEAD:** `github.com/xeprotocol/xe` @ `89a542ea51d38375299aee54c6c99102e9bfa666` (testnet-0005), static analysis only, nothing filed
- **Suggested tier: Minor (ceiling 650 XE)** — reasoning in §5. This is deliberately *not* claimed at the Medium tier of the CLI family; the trigger is narrower, for reasons stated honestly in §4.

## 1\. Summary

XE-0121 / XE-2706 / XE-6695 are all one root cause in one helper: the **HTTP** client
`client.Client.GetChain` (`client/client.go:35`) ignores HTTP status, and the five CLI commands
in `cmd/xe/main.go` discard its error (`chain, _ :=`) and fall back to `prev := "0"`.

There is a **second, independent chain-read helper** with the same defect shape, and fixing the
HTTP helper or any of the five CLI commands does not touch it:

`core.Ledger.GetChain` (`core/ledger.go:2374-2389`) **has no error return at all.** When the
underlying store read fails it logs and returns `nil`, indistinguishable from "this account has
no chain":

```
func (l *Ledger) GetChain(account string) []*Block {
	chain, err := l.store.GetAccountChain(account)
	if err != nil {
		storeReadErrors.Add(1)
		log.Printf("ERROR: GetChain: store read for %s failed: %v — surfacing as no chain, NOT a genuine miss", shortAddr(account), err)
		return nil
	}
	if chain == nil {
		return nil
	}
	...
}
```

(The log line itself concedes the value is wrong: "surfacing as no chain, **NOT** a genuine miss"
— but the function's signature makes that distinction unrepresentable to every caller.)

Every block producer in `node/` reads its `Previous` through this helper. Five of them fail
closed on an empty result — `Node.Send` (node.go:761, "account not open"), `Node.CreateLeaseBlock`
(node.go:2090), `Node.RenewLease` (node/lease\_renew.go:45), `settleLease` (node.go:1990) and
`forceSettleLease` (node.go:1923) all abort when `len(chain) == 0`. **Two do not:**

### Instance A — `Node.Receive` (node/node.go:803-818)

```
chain := n.Ledger.GetChain(myAddr)
prev := "0"
if len(chain) > 0 {
	prev = chain[len(chain)-1].Hash
}
...
assetBal := n.Ledger.GetAssetBalances(myAddr)[asset]
if len(chain) == 0 {
	assetBal = 0
}

b := &core.Block{
	Type:      core.BlockReceive,
	Account:   myAddr,
	Previous:  prev,                 // "0" on a failed read
	Balance:   assetBal + p.Amount,  // balance forcibly reset to 0 + amount on a failed read
	...
}
```

On a failed read of an **already-open** account this signs an *open* receive block
(`core.SignBlock`, core/crypto.go:100-104, treats `Previous == "0"` as an open block and fills
`PubKey`). The balance reset is the worst part: the signed `Balance` is exactly
`0 + pending.Amount`, which is precisely what staged-conflict validation at `prev=0` expects
(see §3), so the bad block is shaped to *pass* the fork-staging check, not merely to be signed.

### Instance B — `autoAcceptLease` (node/node.go:1573-1588) — remotely initiated, daemon-reachable

```
chain := n.Ledger.GetChain(myAddr)
prev := "0"
if len(chain) > 0 {
	prev = chain[len(chain)-1].Hash
}
xusdBal = n.Ledger.GetAssetBalances(myAddr)["XUSD"]
...
b := &core.Block{
	Type:     core.BlockLeaseAccept,
	Account:  myAddr,
	Previous: prev,   // "0" on a failed read, no len==0 abort anywhere in the function
	Balance:  xusdBal - stake,
	...
}
```

`autoAcceptLease` is not a local CLI action: it is triggered **by a remote consumer's lease
block** (`handleIncoming`, node.go:725, and the lease-watch loop, node.go:1695) on any provider
node. It also provisions the consumer's VM *before* this code runs, so even the failure modes
below burn a full VM boot first. At HEAD `LeaseStake()` returns 0 for every lease
(`LeaseStakeDivisor = 0`, core/ledger.go:44-48,116), so the earlier
`stake > GetAssetBalances(...)` guards pass trivially for an XUSD-unfunded provider.

### Instance C — the same swallowed error is served to remote clients as a clean 200

`node.Node.GetChain` (node.go:879-881) is a pass-through to the same helper, and
`api.Handler.handleGetChain` (api/handler.go:457-476) reports `Total: len(blocks)`. A store-read
failure on the *serving* node therefore leaves the node as HTTP **200 with `total=0`** — a
response no client-side status check (the XE-0121 fix) can distinguish from a genuinely
unopened account. The helper's error-swallowing thus re-creates the XE-0121 end state through a
200 response, on a path that family's fix does not cover.

## 2\. Trigger

- The store read behind the helper is `BadgerStore.GetAccountChain`
  (store/badger\_store.go:127-166). It returns a real error — not `nil, nil` — when the chain's
  hash list references a missing block body (`chain references missing block %s`), when a block
  body fails to unmarshal, or on DB/transaction failure. That Badger reads of exactly this kind
  do fail in the wild is already on the board (XE-7371: "GetAccountChain referencing a missing
  block errors on BadgerStore but succeeds on MemStore").
- Instance B needs no operator action at all: any consumer lease addressed to the provider
  starts the accept path. Instance A is an exported `Node` API (`Node.Receive`); it has no
  caller inside the shipped daemon binary, which is one reason for the Minor tier (§4).

## 3\. Why the bad block is not harmlessly rejected (staging arithmetic, verified in code)

`Ledger.AddBlock` (core/ledger.go:807-918) checks for a conflict sibling *before* per-type
validation: `detectConflictSibling` (core/conflict.go:40-50) matches **any** stored block with
the same `Previous`. A `prev="0"` block on an open account is therefore a sibling of the
account's first block and is **staged as a conflict and accepted (`AddBlock` returns nil)**,
provided `ValidateStagedBlock` passes. In the conflict branch the parent balance is forced to
0 for `prev="0"` blocks (ledger.go:832-833: the parent-balance walk runs only
`if chain != nil && b.Previous != "0"`), and staged validation (ledger.go:2757-2806) requires:

- receive: `Balance == 0 + pending.Amount` — Instance A's forced `assetBal = 0` makes its
  signed balance match **exactly, by construction**.
- lease\_accept: `Amount <= 0` and `Balance == 0 - Amount` — at HEAD `Amount = stake = 0`
  (divisor 0), so this matches for a provider whose XUSD balance is 0 (account open in XE
  only — e.g. faucet-funded — but never funded in XUSD).

A staged block conflict-locks the account ("account has unresolved conflict — block rejected
pending resolution" for subsequent blocks) until quorum resolves the position — the same end
state as XE-0121, reached through the node's own producers instead of the CLI.

## 4\. Honest limits (why this is Minor, not Medium)

- **The failure must be transient between build and admission.** `AddBlock` re-reads the same
  store (conflict detection, ledger.go:807). If the store error *persists*, that re-read errors
  too, `AddBlock` returns the error, and the op fails closed with no fork. The fork in §3 needs
  the read to fail at `GetChain` time and succeed milliseconds later at admission — a transient
  Badger error, not the persistent-corruption case. This is materially narrower than the CLI
  family, where the read node and the submit node are *different machines* and the failure is
  an ordinary 429/5xx.
- **Finalized first block \= safe.** If the sibling (the account's first block) is already
  finalized, the staged path rejects outright ("block conflicts with finalized block"),
  same window as XE-0121.
- **Instance B with a non-zero XUSD balance fails closed at staging** (`Balance != 0`), leaving
  only the wasted VM provisioning — a cost the board already knows from the
  provision-before-commit family (XE-4694, XE-0748).
- **Instance A harms only the operator's own account**, and only via the exported library
  surface; Instance B harms the provider's own account, triggered by a remote lease but with
  no third-party funds at risk. No funds are stolen in any variant; worst case is a
  conflict-locked account plus a wasted VM boot.

## 5\. Tier reasoning

Minor (ceiling 650 XE). Same *impact class* as a Medium family (false-signed open block,
staged fork, account conflict-lock), but: trigger requires a transient local store failure
rather than an ordinary HTTP condition; one of the two signing instances is not reachable from
the shipped daemon; the other needs a zero XUSD balance to pass staging at current parameters.
Claiming Medium would overstate it. The durable value of the report is the helper: as long as
`Ledger.GetChain` cannot return an error, every current and future node producer has to
remember to treat `nil` as "unknown" — and two already don't.

**Suggested fix:** give the helper an error-bearing sibling (`GetChainE` / change the
signature), abort in `Receive` and `autoAcceptLease` on `len(chain) == 0` for accounts that
have pending/lease state (mirroring the five sibling producers), and have `handleGetChain`
surface a store failure as 5xx instead of `200, total=0`.

## 6\. Dedupe evidence

Closest tickets, read in full on 2026-11-12 (plus a title sweep of the 890-ticket public
index snapshot of 2026-11-11 23:47 \+ targeted title searches for `prev`, `GetChain`,
`previous`, `stale`, `frontier`, `autoAccept`, `lease_accept`, `unopened`, `wallet.js`):

- **XE-0121** — `client.Client.GetChain` HTTP-status blindness \+ `cmdSend` only; its
  "same class in the web wallet" section is `web/assets/wallet.js`. Never names
  `core.Ledger.GetChain`, `node/`, or any node producer. Fixing it (status checks in the HTTP
  client) leaves Instances A/B/C fully intact.
- **XE-2706 / XE-6695** — the same HTTP root cause in CLI `receive`/`mint`/`burn`/`lease`
  (`cmd/xe/main.go:748/836/910/1057`). CLI commands only; `Node.Receive` (node.go:792) is a
  different function in a different package that never calls the HTTP client, and
  `autoAcceptLease` has no CLI counterpart at all.
- **XE-5418** — Go client pagination termination on server-reported `total` (200-response
  truncation, stale-but-non-zero previous, CLI consumers). Different helper behaviour,
  different trigger, CLI only.
- **XE-6928 / XE-6786 / XE-6654 / XE-7546 / XE-8572 / XE-0625 (per XE-5418's thread)** — HTTP
  client transport/pagination/read-getter status issues. None touches the core ledger helper
  or node producers.
- **XE-7821 / XE-7857** — web wallet prev\=0 / same-previous concurrency. Different client,
  already separated from the Go paths by XE-7821's own dedupe section.
- **XE-8012** — concurrent CLI processes signing the same previous (no inter-process lock).
  Concurrency, not a failed read; node producers hold `blockCreateMu` and are not its subject.
- **XE-0479** — TypeScript SDK `frontier()` on an unsynced node. Different repo/codebase.
- **XE-7371** — Badger-vs-Mem `GetAccountChain` divergence on a missing block (store-layer
  split in multisig validation). Cited here as evidence the store error is real; it does not
  follow the error into any signing path.
- **XE-4694 / XE-0748 / XE-8378** — auto-accept provisioning/retry-scheduler economics. They
  cover *when* accept retries or burns a boot, not a prev\=0 block signed on a failed chain
  read; none names `GetChain`, `Previous`, or the len\=\=0 asymmetry among node producers.

No title in the sweep names a node producer (`Node.Receive`, `Node.Send`, `autoAcceptLease`)
together with `prev`/`GetChain`/chain-status, and no full-text read above covers
`core/ledger.go:2374`. Residual risk, stated plainly: a triager may still group this under
XE-0121's "GetChain trusts the node" umbrella — but here there is no node/network in the loop
at all; the untrusted read is the node's own store, and the fix lives in `core`/`node`, not
`client`/`cmd`.

### Thread

**Joseph Denne**team2026-11-20 00:15 UTCdesk

Thanks for the report. We have read it against the code and confirmed the behaviour it describes. It is being handled; the assessment follows the fix.
