Bounty
XE-0102 · Bounty

node: after any lease renewal the shipped client can never force-settle — renter escrow is permanently locked and later burned

Triaging claimed High xe#155 filed 2026-10-29 01:19 UTC by memekomik

Report

Suggested tier: High (10,000 XE) — permanent loss of a renter's escrowed XUSD through the normal renewal flow. Falls back to Medium if this is read as a client-only defect.

Repo pin: 978785929bc17a2f4ab30c383e5fc9cf4d634512

Summary

lease_force_settle is the renter's only remedy when a provider does not settle. The ledger validates the refund against the whole pending escrow (base cost plus every renewal top-up), but the node's own block builder signs the block with the base lease.Cost only. After a single renewal every force-settle block the shipped client can produce is rejected with a balance mismatch, so the renter can never recover the escrow; it survives until LeaseEscrowExpiry (365 days) and is then deleted by archiveExpiredLease.

What the ledger requires

// core/ledger.go:1969-1976 (validateAndAddLeaseForceSettle)
oldBal := l.getAssetBalanceOverlay(b.Account, "XUSD")
expectedBal := oldBal + pending.Amount     // pending = escrow incl. renewal top-ups
if expectedBal < oldBal {
    return fmt.Errorf("lease_force_settle would overflow uint64 balance")
}
if b.Balance != expectedBal {
    return fmt.Errorf("balance mismatch: expected %d, got %d", expectedBal, b.Balance)
}

The escrow grows on renewal: core/lease_renew.go:137-138 sets commit.TopUpPendingID = b.Source / commit.TopUpPendingAmount = b.Amount, applied as pending.Amount += topUp (store/mem_store.go:338-345). lease.Cost is never updated by a renewal — core/lease_renew.go:140-151 only appends a LeaseSegment. So after one renewal:

pending.Amount = lease.Cost + sum(renewal.Cost)   <- what the validator wants
lease.Cost     = base segment only                <- what the client builds with

What the client builds

// node/node.go:1930-1940 (forceSettleLease)
oldXUSD := n.Ledger.GetAssetBalances(myAddr)["XUSD"]
b := &core.Block{
    Type:         core.BlockLeaseForceSettle,
    Account:      myAddr,
    Previous:     prev,
    Balance:      oldXUSD + lease.Cost,   // base only, escrow is larger
    Timestamp:    core.Now().UnixNano(),
    Asset:        "XUSD",
    Source:       lease.LeaseHash,
    Amount:       lease.Cost,             // same problem on the amount
    Attestations: attestations,
}

AddBlock returns balance mismatch: expected <escrow>, got <escrow - topUps>; the node logs "Failed to add lease_force_settle for <hash>" (node/node.go:1948-1952) and gives up. There is no retry path and no CLI flag that recomputes the refund.

Reproduction (local, deterministic, no network)

Harness: a core.Ledger over the Badger store with a timekeeper config, a certificate lookup, and R = 2000. Create a lease, accept it, renew it once, then run forceSettleLease.

Observed:

after renewal: base cost=160000 renewal cost=160000 escrow=320000 duration=7200
client force-settle block (Balance=old+lease.Cost=999840000): REJECTED:
    balance mismatch: expected 1000000000, got 999840000
control block (Balance=old+escrow=1000000000): accepted; renter refunded 1000000000,
    state=unfulfilled

The control block proves the ledger side is fine and the defect is the block the client builds: a force-settle carrying the whole pending escrow is accepted and refunds the renter in full.

Impact

  • Permanent, unrecoverable loss of the renter's escrowed XUSD after any renewal when the provider does not settle — precisely the case force-settle exists for.
  • Loss includes the renewal top-ups, so extending a lease increases the loss.
  • No attacker key is needed: the provider only has to not settle, and in this build not settling is free because provider stake is zero (LeaseStakeDivisor = uint64(0), core/ledger.go:116 — separately tracked in #20).
  • Affects every renter using the shipped client that ever renews; hand-crafting a block is the only escape.

Not a duplicate

  • #92 is the ledger-side lease_cancel path (validateAndAddLeaseCancel refunds oldBal + leaseBlock.Amount and deletes the whole escrow). Its fix PR #109 changes lease_cancel only.
  • This is the client-side lease_force_settle path in node/node.go: different block type, different code path, different failure mode (the block is rejected outright, funds stay escrowed rather than vanishing at cancel time).
  • #21 / #90 concern the provider settling without service; this concerns the renter's refundwhen the provider does not settle.
  • Checked against all 151 issues/PRs at the time of writing; none describes a force-settle balance computed from lease.Cost.

Suggested fix

  1. In node.forceSettleLease, read the pending escrow and use it for both fields: Balance: oldXUSD + pending.Amount, Amount: pending.Amount (fall back to lease.Cost + sum(renewals) if the store call is unavailable). The control block above is exactly this shape and is accepted.
  2. Add a regression test that renews once and force-settles, asserting the ledger accepts and the renter balance returns to its pre-lease value.
  3. Introduce a single accessor (lease.TotalEscrow() = cost + renewals) used by cancel, force-settle and the supply auditor, so the same class of bug cannot reappear (see #92).

Notes

Source-level only: no traffic to testnet-0005, no accounts, no live node. PoC is a local go test under nice/taskset. Full report and test files available on request.

================================================================================ APPENDIX A — RECORDED POC OUTPUT (go test, pinned commit, local only)

=== RUN   TestF3_ForceSettleAfterRenewalIsUnbuildable
2026/10/29 00:46:09 Genesis block applied: 42000000000000 XE to 378d0f5c2063...
    f3_f4_test.go:62: after renewal: base cost=160000 renewal cost=160000 escrow=320000 duration=7200
    f3_f4_test.go:92: client force-settle block (Balance=old+lease.Cost=999840000): REJECTED: balance mismatch: expected 1000000000, got 999840000
    f3_f4_test.go:115: control block (Balance=old+escrow=1000000000): accepted; renter refunded 1000000000, state=unfulfilled
    f3_f4_test.go:117: VULNERABLE: the shipped client can never produce the accepted form after a renewal — it under-refunds by 160000 uXUSD (the renewal top-up) and is rejected outright
--- PASS: TestF3_ForceSettleAfterRenewalIsUnbuildable (0.01s)

Reading it: the client's block (Balance = old + lease.Cost) is rejected because the ledger wants old + pending.Amount (escrow including the renewal top-up). The control block carrying the full escrow is accepted and refunds the renter in full — so the ledger is correct and the block the client builds is wrong.

================================================================================ APPENDIX B — POC SOURCE (Go tests, package auditpoc)

Reproduce with:

git clone https://github.com/xeprotocol/xe && cd xe
git checkout 978785929bc17a2f4ab30c383e5fc9cf4d634512
mkdir -p auditpoc && cp <the two files below> auditpoc/
nice -n 15 taskset -c 0-1 go test ./auditpoc/ -run TestF3 -v -count=1

TestF3 is this report. TestF4 in the same file is the stale-certificate renewal issue (already filed as #97) and is included only because both live in one file.

--- auditpoc/f3_f4_test.go -----------------------------------------------------

package auditpoc

// F3  node/node.go:1901-1956 (forceSettleLease) vs core/ledger.go:1969-1976
//     (validateAndAddLeaseForceSettle). The node refunds only lease.Cost while
//     the ledger requires the whole escrow (base + every renewal top-up), so
//     after one renewal the renter's force-settle block is rejected forever and
//     the escrow cannot be recovered from the client: it burns at escrow expiry.
//
// F4  core/lease_renew.go:79-90 — a renewal only checks that the certificate is
//     unexpired *at the renewal instant*; it never checks that the certificate
//     covers the extension it is paying for, and it accepts any old (still
//     valid) certificate of the provider. A renter can therefore pin a cheap
//     quote for the whole LeaseMaxDuration (1 year).

import (
	"testing"
	"time"

	"github.com/xeprotocol/xe/core"
	"github.com/xeprotocol/xe/perf"
)

func TestF3_ForceSettleAfterRenewalIsUnbuildable(t *testing.T) {
	consumer := seedKP(0xC1)
	provider := seedKP(0xD2)
	h := newHarness(t, 2, []*core.KeyPair{consumer, provider})
	h.setNow(time.Now().UnixNano())
	h.mint(consumer, 1_000_000_000)
	h.mint(provider, 1_000_000)

	cert := h.issueCert(provider, core.RFallback, h.nowNanos, h.nowNanos+int64(7*24*time.Hour))
	leaseHash, baseCost := h.createLease(consumer, provider, 2, 2048, 20, 3600, cert, hexRepeat("ab"))

	h.acceptLease(leaseHash, provider, cert)

	// --- one renewal -------------------------------------------------------
	renewDur := uint64(3600)
	rCost, err := core.LeaseCost(2, 2048, 20, renewDur, cert.PriceMultiplierMilli)
	if err != nil {
		t.Fatal(err)
	}
	cchain := h.ledger.GetChain(consumer.Address())
	bal := h.balance(consumer.Address(), "XUSD")
	renew := &core.Block{
		Type:            core.BlockLeaseRenew,
		Account:         consumer.Address(),
		Previous:        cchain[len(cchain)-1].Hash,
		Balance:         bal - rCost,
		Timestamp:       h.nowNanos,
		Asset:           "XUSD",
		Source:          leaseHash,
		Amount:          rCost,
		Duration:        renewDur,
		CertificateHash: cert.Hash,
		LockedR:         core.RFallback,
		Attestations:    h.attest(leaseHash, 2),
	}
	h.add(renew, consumer)

	l := h.lease(leaseHash)
	escrow := h.pendingAmount(leaseHash)
	t.Logf("after renewal: base cost=%d renewal cost=%d escrow=%d duration=%d",
		baseCost, rCost, escrow, l.EffectiveDurationSecs())
	if escrow != baseCost+rCost {
		t.Fatalf("escrow %d != %d+%d", escrow, baseCost, rCost)
	}

	// --- the provider goes dark; the renter tries to force-settle ----------
	h.setNow(l.EffectiveExpiry() + core.LeaseSettleGrace + core.LeaseForceSettleGap + int64(time.Minute))
	oldXUSD := h.balance(consumer.Address(), "XUSD")
	cchain = h.ledger.GetChain(consumer.Address())

	// exactly what node.forceSettleLease builds (node/node.go:1930-1940):
	b := &core.Block{
		Type:         core.BlockLeaseForceSettle,
		Account:      consumer.Address(),
		Previous:     cchain[len(cchain)-1].Hash,
		Balance:      oldXUSD + l.Cost, // <-- only the base segment
		Timestamp:    h.nowNanos,
		Asset:        "XUSD",
		Source:       leaseHash,
		Amount:       l.Cost,
		Attestations: h.attest(leaseHash, 2),
	}
	if err := core.SignBlock(b, consumer); err != nil {
		t.Fatal(err)
	}
	err = h.ledger.AddBlock(b)
	if err == nil {
		t.Fatalf("expected the client's force-settle block to be rejected")
	}
	t.Logf("client force-settle block (Balance=old+lease.Cost=%d): REJECTED: %v", oldXUSD+l.Cost, err)
	if h.lease(leaseHash).State != core.LeaseAccepted {
		t.Fatalf("lease state changed")
	}

	// control: the same block with the real escrow refunds correctly.
	b2 := &core.Block{
		Type:         core.BlockLeaseForceSettle,
		Account:      consumer.Address(),
		Previous:     cchain[len(cchain)-1].Hash,
		Balance:      oldXUSD + escrow,
		Timestamp:    h.nowNanos + 1,
		Asset:        "XUSD",
		Source:       leaseHash,
		Amount:       escrow,
		Attestations: h.attest(leaseHash, 2),
	}
	if err := core.SignBlock(b2, consumer); err != nil {
		t.Fatal(err)
	}
	if err := h.ledger.AddBlock(b2); err != nil {
		t.Fatalf("control force-settle should succeed: %v", err)
	}
	t.Logf("control block (Balance=old+escrow=%d): accepted; renter refunded %d, state=%s",
		oldXUSD+escrow, h.balance(consumer.Address(), "XUSD"), h.lease(leaseHash).State)
	t.Logf("VULNERABLE: the shipped client can never produce the accepted form after a renewal — "+
		"it under-refunds by %d uXUSD (the renewal top-up) and is rejected outright", escrow-l.Cost)
}

func TestF4_RenewalPinsStaleCertificatePriceForAYear(t *testing.T) {
	consumer := seedKP(0xE1)
	provider := seedKP(0xF2)
	h := newHarness(t, 2, []*core.KeyPair{consumer, provider})
	t0 := int64(1_800_000_000_000_000_000)
	h.setNow(t0)
	h.mint(consumer, 1_000_000_000)
	h.mint(provider, 1_000_000)

	// The provider's opening quote: 0.5x, valid for 7 days.
	cheap := h.issueCert(provider, perf.PriceMultiplierMin, t0, t0+int64(7*24*time.Hour))
	leaseHash, _ := h.createLease(consumer, provider, 4, 8192, 50, 30*86400, cheap, hexRepeat("ef"))
	h.acceptLease(leaseHash, provider, cheap)

	// Two days later the provider raises its price to the 10x ceiling.
	h.advance(48 * time.Hour)
	dear := h.issueCert(provider, perf.PriceMultiplierMax, h.nowNanos, h.nowNanos+int64(7*24*time.Hour))
	t.Logf("provider's current quote: multiplier=%d (hash %s)", dear.PriceMultiplierMilli, dear.Hash[:12])

	// The renter renews for the maximum the protocol allows, still citing the
	// 5-day-old 0.5x certificate.
	maxDur := uint64(core.LeaseMaxDuration) - 30*86400 // cumulative cap
	cost, err := core.LeaseCost(4, 8192, 50, maxDur, cheap.PriceMultiplierMilli)
	if err != nil {
		t.Fatal(err)
	}
	atCurrent, err := core.LeaseCost(4, 8192, 50, maxDur, dear.PriceMultiplierMilli)
	if err != nil {
		t.Fatal(err)
	}
	cchain := h.ledger.GetChain(consumer.Address())
	bal := h.balance(consumer.Address(), "XUSD")
	if cost > bal {
		t.Fatalf("harness balance %d < cost %d", bal, cost)
	}
	renew := &core.Block{
		Type:            core.BlockLeaseRenew,
		Account:         consumer.Address(),
		Previous:        cchain[len(cchain)-1].Hash,
		Balance:         bal - cost,
		Timestamp:       h.nowNanos,
		Asset:           "XUSD",
		Source:          leaseHash,
		Amount:          cost,
		Duration:        maxDur,
		CertificateHash: cheap.Hash, // 0.5x, issued 2 days ago, expires in 5 days
		LockedR:         core.RFallback,
		Attestations:    h.attest(leaseHash, 2),
	}
	h.add(renew, consumer)

	l := h.lease(leaseHash)
	t.Logf("renewal accepted: certificate=%s multiplier=%d extension=%ds (lease now %ds)",
		cheap.Hash[:12], cheap.PriceMultiplierMilli, maxDur, l.EffectiveDurationSecs())
	t.Logf("paid %d uXUSD at the stale 0.5x quote; the provider's live quote would be %d uXUSD (%.0fx)",
		cost, atCurrent, float64(atCurrent)/float64(cost))
	if l.EffectiveDurationSecs() != 30*86400+maxDur {
		t.Fatalf("duration %d", l.EffectiveDurationSecs())
	}
	t.Logf("VULNERABLE: a 7-day price quote priced a 1-year extension — the provider is bound "+
		"to serve 365 days at %.1f%% of its current rate", 100*float64(cheap.PriceMultiplierMilli)/float64(dear.PriceMultiplierMilli))
}

func hexRepeat(s string) string {
	out := make([]byte, 0, 64)
	for len(out) < 64 {
		out = append(out, s...)
	}
	return string(out[:64])
}

--- auditpoc/harness_test.go (required for TestF3 to compile) ------------------

// Package auditpoc contains local, offline proofs-of-concept for the XE
// compute-leasing / VM audit (FINDINGS-A). Nothing here talks to a network.
package auditpoc

import (
	"encoding/hex"
	"testing"
	"time"

	"github.com/xeprotocol/xe/core"
	"github.com/xeprotocol/xe/perf"
	"github.com/xeprotocol/xe/store"
)

// network id is bound into block hashes; any fixed value works for a local chain.
func init() { core.SetNetworkID("xe-audit-local") }

type harness struct {
	t        *testing.T
	ledger   *core.Ledger
	store    core.Store
	tks      []*core.KeyPair
	cfg      *core.TimekeeperConfig
	certs    map[string]*perf.Certificate
	nowNanos int64
}

func seedKP(b byte) *core.KeyPair {
	var seed [32]byte
	for i := range seed {
		seed[i] = b
	}
	seed[0] = b
	seed[31] = b ^ 0x5a
	return core.KeyPairFromSeed(seed[:])
}

// newHarness builds a ledger whose timekeepers are tks and whose certificate
// lookup only ever returns certificates that pass perf.VerifyCertificateContent
// (this mirrors node.ingestCertificate -> certSet.put on a real node).
func newHarness(t *testing.T, threshold int, minter []*core.KeyPair) *harness {
	t.Helper()
	ms := store.NewMemStore()
	tks := []*core.KeyPair{seedKP(0x11), seedKP(0x22), seedKP(0x33)}
	keys := make([]string, 0, len(tks))
	for _, k := range tks {
		keys = append(keys, k.PubKeyHex())
	}
	cfg := &core.TimekeeperConfig{Threshold: threshold, Keys: keys}
	h := &harness{t: t, tks: tks, cfg: cfg, certs: map[string]*perf.Certificate{}, nowNanos: time.Now().UnixNano()}

	var minterKeys []string
	for _, k := range minter {
		minterKeys = append(minterKeys, k.Address())
	}

	h.ledger = core.NewLedger(ms, core.LedgerConfig{
		Difficulty:          0, // no PoW in the harness
		TimestampWindow:     0, // tests drive core.Now explicitly
		TimekeeperConfigFn:  func() *core.TimekeeperConfig { return cfg },
		MinterConfigFn:      func() *core.MinterConfig { return &core.MinterConfig{Keys: minterKeys} },
		CertificateLookupFn: h.lookupCert,
	})
	h.store = ms
	return h
}

func (h *harness) lookupCert(hash string) *core.CertificateInfo {
	c := h.certs[hash]
	if c == nil {
		return nil
	}
	return &core.CertificateInfo{Provider: c.Provider, ExpiresAt: c.ExpiresAt, PriceMultiplierMilli: c.PriceMultiplierMilli}
}

// setNow pins core.Now (used for attestation skew and block timestamps).
func (h *harness) setNow(ns int64) {
	h.nowNanos = ns
	core.Now = func() time.Time { return time.Unix(0, ns) }
}

func (h *harness) advance(d time.Duration) { h.setNow(h.nowNanos + int64(d)) }

func (h *harness) add(b *core.Block, kp *core.KeyPair) {
	h.t.Helper()
	if err := core.SignBlock(b, kp); err != nil {
		h.t.Fatalf("sign %s: %v", b.Type, err)
	}
	if err := h.ledger.AddBlock(b); err != nil {
		h.t.Fatalf("add %s: %v", b.Type, err)
	}
}

// mint gives an account `amount` micro-XUSD. Open blocks (previous=0) are minted
// as the account's first block; later mints extend the chain.
func (h *harness) mint(kp *core.KeyPair, amount uint64) {
	h.t.Helper()
	acct := kp.Address()
	chain := h.ledger.GetChain(acct)
	prev := "0"
	bal := uint64(0)
	if len(chain) > 0 {
		prev = chain[len(chain)-1].Hash
		bal = h.ledger.GetAssetBalances(acct)["XUSD"]
	}
	b := &core.Block{
		Type:      core.BlockMint,
		Account:   acct,
		Previous:  prev,
		Balance:   bal + amount,
		Timestamp: h.nowNanos,
		Asset:     "XUSD",
		Amount:    amount,
	}
	h.add(b, kp)
}

func (h *harness) issueCert(provider *core.KeyPair, mult uint64, issuedAt, expiresAt int64) *perf.Certificate {
	h.t.Helper()
	c := &perf.Certificate{
		Provider:             provider.Address(),
		Seed:                 hex.EncodeToString(bytes32(0x77)),
		WorkloadVersion:      perf.WorkloadVersion,
		Puzzles:              perf.PoWPuzzles,
		WorkProof:            hex.EncodeToString(bytes32(0x01)),
		CPUHash:              hex.EncodeToString(bytes32(0x02)),
		Score:                1.0,
		StartAttestationRoot: hex.EncodeToString(bytes32(0x03)),
		EndAttestationRoot:   hex.EncodeToString(bytes32(0x04)),
		StartMedian:          issuedAt,
		EndMedian:            issuedAt + int64(time.Second),
		IssuedAt:             issuedAt,
		ExpiresAt:            expiresAt,
		PriceMultiplierMilli: mult,
	}
	if err := perf.SignCertificate(c, provider); err != nil {
		h.t.Fatalf("sign cert: %v", err)
	}
	if err := perf.VerifyCertificateContent(c); err != nil {
		h.t.Fatalf("cert must be acceptable to a real node: %v", err)
	}
	h.certs[c.Hash] = c
	return c
}

func bytes32(b byte) []byte {
	out := make([]byte, 32)
	for i := range out {
		out[i] = b
	}
	return out
}

// attest collects `n` timekeeper attestations for identifier at h.nowNanos.
func (h *harness) attest(identifier string, n int) []core.TimekeeperAttestation {
	h.t.Helper()
	out := make([]core.TimekeeperAttestation, 0, n)
	for i := 0; i < n; i++ {
		a, err := core.SignAttestation(identifier, h.nowNanos, h.tks[i])
		if err != nil {
			h.t.Fatalf("sign attestation: %v", err)
		}
		out = append(out, *a)
	}
	return out
}

// createLease writes the consumer's lease block and returns its hash.
func (h *harness) createLease(consumer, provider *core.KeyPair, vcpus, memMB, diskGB, dur uint64, cert *perf.Certificate, accessPubKey string) (string, uint64) {
	h.t.Helper()
	cost, err := core.LeaseCost(vcpus, memMB, diskGB, dur, cert.PriceMultiplierMilli)
	if err != nil {
		h.t.Fatalf("LeaseCost: %v", err)
	}
	chain := h.ledger.GetChain(consumer.Address())
	if len(chain) == 0 {
		h.t.Fatalf("consumer chain not open")
	}
	prev := chain[len(chain)-1].Hash
	bal := h.ledger.GetAssetBalances(consumer.Address())["XUSD"]
	if cost > bal {
		h.t.Fatalf("harness: consumer balance %d < cost %d", bal, cost)
	}
	b := &core.Block{
		Type:            core.BlockLease,
		Account:         consumer.Address(),
		Previous:        prev,
		Balance:         bal - cost,
		Timestamp:       h.nowNanos,
		Asset:           "XUSD",
		Destination:     provider.Address(),
		Amount:          cost,
		VCPUs:           vcpus,
		MemoryMB:        memMB,
		DiskGB:          diskGB,
		Duration:        dur,
		AccessPubKey:    accessPubKey,
		CertificateHash: cert.Hash,
	}
	h.add(b, consumer)
	return b.Hash, cost
}

func (h *harness) acceptLease(leaseHash string, provider *core.KeyPair, cert *perf.Certificate) *core.Block {
	h.t.Helper()
	chain := h.ledger.GetChain(provider.Address())
	if len(chain) == 0 {
		h.t.Fatalf("provider chain not open")
	}
	bal := h.ledger.GetAssetBalances(provider.Address())["XUSD"]
	b := &core.Block{
		Type:            core.BlockLeaseAccept,
		Account:         provider.Address(),
		Previous:        chain[len(chain)-1].Hash,
		Balance:         bal, // stake is 0 because core.LeaseStakeDivisor == 0
		Timestamp:       h.nowNanos,
		Asset:           "XUSD",
		Source:          leaseHash,
		Amount:          0,
		Attestations:    h.attest(leaseHash, 2),
		CertificateHash: cert.Hash,
		LockedR:         core.RFallback,
	}
	h.add(b, provider)
	return b
}

func (h *harness) lease(hash string) *core.Lease {
	h.t.Helper()
	ls, ok := h.store.(core.LeaseStore)
	if !ok {
		h.t.Fatalf("store is not a LeaseStore")
	}
	l, err := ls.GetLease(hash)
	if err != nil || l == nil {
		h.t.Fatalf("lease %s: %v", hash[:12], err)
	}
	return l
}

func (h *harness) balance(acct, asset string) uint64 {
	return h.ledger.GetAssetBalances(acct)[asset]
}

func (h *harness) pendingAmount(sendHash string) uint64 {
	h.t.Helper()
	p, err := h.store.GetPendingSend(sendHash)
	if err != nil || p == nil {
		h.t.Fatalf("pending %s: %v", sendHash[:12], err)
	}
	return p.Amount
}

================================================================================ APPENDIX C — NOTES FOR TRIAGE

  • Source-level only: no traffic to testnet-0005, no accounts, no node joined to the mesh. Everything runs offline against the pinned tree.
  • The escrow is not merely stuck forever in-process: node/node.go:1884-1902 (archiveExpiredLease) deletes the pending send and marks the lease expired at expiry + LeaseEscrowExpiry + LeaseArchiveGap (365 days), so the renter's XUSD is destroyed.
  • Nothing in this report depends on the zero-stake issue (#20); the zero stake only makes
  • If you would like it as a PR: the fix is two fields in node/node.go (Balance and Amount from the pending escrow) plus a regression test that renews once and force-settles.

Thread

fangjian-bit2026-10-29 06:17 UTCgithub

Submitted fix and regression test suite in #173.

Refactored force-settle block creation into BuildForceSettleBlock which queries pending.Amount (with lease.Cost + sum(renewals.Cost) fallback) to match ledger's expectedBal := oldBal + pending.Amount check. Verified end-to-end with unit tests confirming rejection of partial refunds and successful processing of full escrow refunds.

Joseph Denneteam2026-11-08 20:19 UTCgithub

Thanks for the detailed report. We have confirmed the behaviour and it is being handled; we will update this ticket when there is more to share.

Reyzz952026-11-10 10:30 UTCgithub

Still reproduces at HEAD 89a542e (testnet-0005, 2026-11-10).

Ledger side is correct — validateAndAddLeaseForceSettle (ledger.go:1968-1978) refunds the full pending.Amount and a correctly-built block is accepted. But the node client still builds the block wrong: forceSettleLease (node/node.go:1901-1955, line 1934) uses Balance: oldXUSD + lease.Cost (base cost only) and never sums lease.Renewals[].Cost.

After any renewal the node's own ledger rejects its own block: balance mismatch: expected 10000000, got 9998666.

Rizky7922026-11-12 05:50 UTCgithub

Executed end-to-end confirmation of the automatic-tick path for this issue — supporting evidence, not a new report.

HEAD 89a542e (xe-node), local only, no live net, no real funds. Setup: real in-process ledger + local statechain genesis with sys.timekeepers (threshold 1) + two real libp2p hosts (consumer node + separate timekeeper peer, attestations via the production gatherAttestations path) + real gossipsub. The force-settle block was built by the real forceSettleLease, triggered by the real settleLoop (10s tick). 3/3 full runs PASS.

Results, renewed lease (base 40,000 + renew 40,000, escrow 80,000, provider never settles, past expiry + 1h grace + 25m gap):

  • Every settleLoop tick: node-built force-settle REJECTED — 'Failed to add lease_force_settle: balance mismatch: expected 100000000, got 99960000'. 9 distinct rejections across the 3 runs, no backoff or already-tried marker. Pending escrow stayed 80,000 locked, consumer XUSD stayed 99,920,000, lease stayed Accepted.
  • Control, SDK-style full-escrow block for the same lease: ACCEPTED, lease unfulfilled, consumer XUSD back to 100,000,000 (full 80,000 refund).
  • Control, no renewal (base-only lease): node-built force-settle ACCEPTED via the real node path, full 40,000 refund. The defect is specific to renewed leases.
  • Archive executed (not inferred): advanced to expiry + 365 days + 1h and ran the real tryArchiveExpiredLeases — pending escrow deleted, lease Expired, consumer XUSD still 99,920,000. The 80,000 never came back. Note: the archive log line says 'burned 40000' (Cost+Stake) while the deleted pending was 80,000.

Why this adds to #155: this issue's PoC replicates the client-built block; this is the same defect executed through the automatic settleLoop path, including the attestation gate that a no-timekeeper repro never reaches (without a configured timekeeper the block fails attestation validation before the balance check).

Context, written honestly: bounty ticket XE-1869 (same automatic path, executed PoC) was closed as a duplicate of XE-0102, and XE-2901 (bounty desk, still NEW) describes the same mechanism with a static PoC only. I am not filing a new bounty ticket — this comment only adds executed proof of the automatic path to the open issue. The fix in #173 (compute the refund from the full pending escrow) is exactly what this confirms is needed: build the force-settle block from leaseSettleAmount(lease) / LeaseTotalEmission (base + renewals) for both Balance and Amount, as settleLease already does.