Bounty
XE-0668 · Bounty

[Medium] core.IsRetryableError matches bare "not found", so permanent lease rejections are classified retryable - the provider destroys and re-creates the tenant VM on every attempt (node.go:1617)

Closed · duplicate — web filed 2026-11-05 11:06 UTC by xe:79bd7409

Report

[Medium] core.IsRetryableError matches the bare substring "not found", so permanent lease rejections are classified retryable — the provider then destroys and re-creates the tenant's VM on every attempt (node/node.go:1617)

Summary

core.IsRetryableError (core/retryable.go) decides whether a failed operation should be retried by looking for substrings in the error text. Its pattern list contains the bare three-word string "not found" (core/retryable.go:13):

// core/retryable.go:5-35
func IsRetryableError(err error) bool {
	if err == nil {
		return false
	}
	msg := err.Error()
	retryablePatterns := []string{
		"previous block not found",
		"source send not pending",
		"not found",              // <-- line 13: matches ANY error whose text contains these words
		"frontier mismatch",
		"previous mismatch",
		"GetAccountChain",
		"GetBlock",
		"unresolved conflict",
		"Transaction Conflict",
		"lease not yet accepted",
		"epoch not yet available",
		"retry after statechain syncs",
		"retry after sync",
		"unopened account",

		"unknown block type",
		"not yet activated",
	}
	for _, p := range retryablePatterns {
		if strings.Contains(msg, p) {
			return true
		}
	}
	return false
}

The matcher is lexical, not semantic: it cannot tell "the block I depend on has not arrived yet" (genuinely transient) from "the lease record this operation requires does not exist and never will" (permanent, deterministic). On master @ 02e9641 14 permanent, deterministic error messages produced by the ledger and the stores are therefore classified retryable purely because of how they are worded — including two messages emitted by the same production guard, one after the other, with opposite verdicts.

core.IsRetryableError has exactly five consumers:

consumer what the verdict controls
api/handler.go:413 (writeSubmitError) HTTP 503 retryable:true vs 400 retryable:false — the documented API contract
core/quorum.go:328 (confirmConflict) whether a failed promotion is quarantined or retried
core/quorum.go:387 (appendStagedWinner) whether the error is swallowed and the winner silently dropped
net/sync.go:609 (requestSync) whether a dependency-rejected block is retried or discarded
node/node.go:1617 (autoAcceptLease) whether the provider keeps re-attempting the tenant's lease_accept — after destroying the tenant's VM

The last one is the only consumer whose misclassification is destructive. In autoAcceptLease the provider provisions the tenant's VM first (node/node.go:1554) and only then submits the lease_accept (node/node.go:1612). If the accept is rejected, the node tears the VM down and then asks the classifier whether to try again:

// node/node.go:1612-1621
if err := n.Ledger.AddBlock(b); err != nil {
	n.blockCreateMu.Unlock()
	log.Printf("Failed to add lease_accept: %v", err)
	if shouldTeardownOnAcceptFailure(n.GetLease(leaseBlock.Hash), myAddr) {
		n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})   // 1616: destroy the tenant's VM
		retry = core.IsRetryableError(err)                      // 1617: the classifier decides the future
	} else {
		log.Printf("Lease %s: our accept already stands on-chain, keeping VM", shortHash(leaseBlock.Hash))
	}
	return
}

A retryable verdict therefore means: destroy the tenant's VM, then build a brand-new one on the next attempt, forever. The accept-retry scheduler has no attempt cap and its backoff saturates at 160 s; the 5-second lease-watch re-drives the lease for as long as it is pending:

// node/node.go:1633-1648
var (
	acceptRetryQuick = 5 * time.Second
	acceptRetryBase  = AttestationRateLimit + 5*time.Second   // 15s + 5s = 20s
	acceptRetryMax   = 160 * time.Second
)

func acceptRetryDelay(failures int) time.Duration {
	if failures == 0 {
		return acceptRetryQuick
	}
	delay := acceptRetryBase
	for i := 1; i < failures && delay < acceptRetryMax; i++ {
		delay *= 2
	}
	return min(delay, acceptRetryMax)
}

// node/node.go:1726-1745 — record(): no attempt cap, no permanent-failure exit
func (s *acceptSchedule) record(leaseHash string, retry bool, now time.Time) {
	...
	if !retry {
		st.done = true
		return
	}
	delay := acceptRetryDelay(st.failures)
	st.failures++
	st.next = now.Add(delay)
	log.Printf("Lease %s: retrying accept in %v", shortHash(leaseHash), delay)
}

The only ways the loop ends are (a) the classifier returning false, or (b) the lease ceasing to be pending (n.acceptSched.prune(live), node/node.go:1698). There is no maximum attempt count and no "this can never succeed" detection anywhere on this path.

This report demonstrates, with a deterministic PoC against the production code paths:

  1. the classifier is lexical — 22 production error strings, 22 documented expectations, and the decisive pair emitted by one production guard with opposite verdicts;
  2. with a permanent "not found" rejection of the provider's accept, the provider destroys and re-creates the tenant's VM on every attempt, without bound (5 attempts → 5 provisions → 5 teardowns, retry delay saturated at 160 s, done=false, and the lease_accept never lands);
  3. with the same node-visible state and the same accept path, a rejection whose text does not contain "not found" produces exactly one attempt (1 provision → 1 teardown → done=true);
  4. the production unwind path (Ledger.SwapBlock) really does produce the "not found" rejection that the classifier calls retryable.

Affected component and versions

  • xeprotocol/xe, master @ 02e9641 (Merge pull request #251 from xeprotocol/fix/dao-tool-timestamp). No PR is required.
  • Code paths: core/retryable.go (the matcher), node/node.go (autoAcceptLease, leaseWatchTick, leaseWatchLoop, acceptSchedule, acceptRetryDelay, shouldTeardownOnAcceptFailure, leaseAlreadyAccepted), node/vm.go (provisionVM, teardownVM), core/ledger.go (validateAndAddLeaseAccept, validateAndAddLease), store/mem_store.go + store/badger_store.go (the lease-state CAS guard), core/rollback.go (buildBlockUndo).
  • No network measurement was performed and no live node was contacted: the PoC is a deterministic local unit test (fake clock via core.Now, fixed keys, no wall-clock dependence). The only substitution is vm.MockManager for the QEMU/Lima backends — the node calls the same vm.Manager interface either way, and the backend is not where the defect is.

Root cause

1. The classifier is a substring matcher, and one of its patterns is "not found"

core.IsRetryableError is called with errors that come from many different subsystems, and it has no type information to work with — strings.Contains(msg, p) is the whole decision. The bare "not found" pattern then matches every error whose text happens to contain those three words, regardless of what the words mean.

Permanent, deterministic errors on master that are classified retryable because of it:

# message (verbatim from the source) source permanent because
1 source lease block not found: <hash> core/ledger.go:1620 the referenced lease_open block is not in this node's store; the accept can never validate against it
2 lease_accept: certificate not found: <hash> core/ledger.go:1692 the pinned certificate is not held; the accept can never validate
3 certificate <hash> not found core/ledger.go:1537 the pinned certificate is not held
4 source lease block not found: <hash> core/ledger.go:1805 (lease_cancel) the referenced lease_open is not in this node's store
5 source lease block not found: <hash> core/ledger.go:1892 (lease_settle) same
6 lease not found: <hash> core/ledger.go:1909 (lease_renew) the lease record does not exist
7 lease not found: <hash> core/ledger.go:2133 (lease_force_settle) the lease record does not exist
8 multisig_update: account not found core/ledger.go:1326 the account does not exist
9 SwapBlock: account <addr> not found core/ledger.go:2895 the account does not exist
10 SwapBlock: block <hash> not found in chain core/ledger.go:2908 the block is not in the chain
11 GetBlockHeight: account <addr> not found core/ledger.go:3048 the account does not exist
12 GetBlockHeight: block <hash> not found in account <addr> core/ledger.go:3055 the block is not in the chain
13 CommitBlock: lease state conflict: lease <hash> not found store/mem_store.go:293, store/badger_store.go the lease record the accept's CAS requires does not exist
14 undo: lease <hash> not found while reversing lease_accept core/rollback.go:253 the lease record needed to reverse the accept does not exist

The decisive detail is that two of these come from the same production guard, one line apart, and the only difference between them is the wording:

// store/mem_store.go:288-304 — the lease CAS the provider's accept goes through
func (m *MemStore) applyCommitLocked(c *core.BlockCommit) error {
	if c.ExpectLeaseHash != "" {
		lease, ok := m.leases[c.ExpectLeaseHash]
		if !ok {
			return fmt.Errorf("CommitBlock: %w: lease %s not found", core.ErrLeaseStateConflict, c.ExpectLeaseHash[:12])        // 293 -> retryable = TRUE
		}
		if lease.State != c.ExpectLeaseState {
			return fmt.Errorf("CommitBlock: %w: lease %s is %s, want %s",
				core.ErrLeaseStateConflict, c.ExpectLeaseHash[:12], lease.State, c.ExpectLeaseState)                           // 296 -> retryable = FALSE
		}
		...

Both are the same permanent class of failure — core.ErrLeaseStateConflict, the lease record does not satisfy the accept's expectation — and both are deterministic: retrying cannot change the outcome. Yet one is "retryable" and the other is not, purely because one sentence contains the word "not".

2. The provider's accept path consumes that verdict destructively

node/node.go:1460-1631 (autoAcceptLease) is the provider side of a lease. The relevant sequence is:

// node/node.go:1460-1469
func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
	...
	retry := false
	defer func() { n.acceptSched.record(leaseBlock.Hash, retry, time.Now()) }()
	if leaseAlreadyAccepted(n.GetLease(leaseBlock.Hash)) {
		return
	}
	...
// node/node.go:1554 — the VM is created BEFORE the accept is attempted
	n.provisionVM(leaseBlock)
	...
// node/node.go:1612-1621 — the accept is attempted, and on failure the VM is destroyed
	if err := n.Ledger.AddBlock(b); err != nil {
		n.blockCreateMu.Unlock()
		log.Printf("Failed to add lease_accept: %v", err)
		if shouldTeardownOnAcceptFailure(n.GetLease(leaseBlock.Hash), myAddr) {
			n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})   // 1616
			retry = core.IsRetryableError(err)                      // 1617
		} else {
			log.Printf("Lease %s: our accept already stands on-chain, keeping VM", shortHash(leaseBlock.Hash))
		}
		return
	}

and the re-drive that makes it a loop rather than a single retry:

// node/node.go:1657-1668 — every 5 seconds
func (n *Node) leaseWatchLoop() {
	ticker := time.NewTicker(5 * time.Second)
	...
	case now := <-ticker.C:
		n.leaseWatchTick(now, &n.wg)
	...
}

// node/node.go:1670-1699
func (n *Node) leaseWatchTick(now time.Time, wg *sync.WaitGroup) {
	myAddr := n.KeyPair.Address()
	pending := n.Ledger.GetPendingForAccount(myAddr)
	live := make(map[string]bool, len(pending))
	for _, p := range pending {
		live[p.SendHash] = true
		if !n.acceptSched.due(p.SendHash, now) || n.acceptRunning(p.SendHash) {
			continue
		}
		leaseBlock := n.Ledger.GetBlock(p.SendHash)
		if leaseBlock == nil || leaseBlock.Type != core.BlockLease {
			continue
		}
		...
		if leaseAlreadyAccepted(n.GetLease(leaseBlock.Hash)) {
			n.acceptSched.record(leaseBlock.Hash, false, now)
			continue
		}
		log.Printf("Lease watch: found unaccepted lease %s, auto-accepting", shortHash(leaseBlock.Hash))
		wg.Add(1)
		go func() {
			defer wg.Done()
			n.autoAcceptLease(leaseBlock)
		}()
	}
	n.acceptSched.prune(live)
}

acceptSchedule.due() returns true forever once the lease is pending and the entry is not done:

// node/node.go:1719-1724
func (s *acceptSchedule) due(leaseHash string, now time.Time) bool {
	s.mu.Lock()
	defer s.mu.Unlock()
	st, ok := s.leases[leaseHash]
	return !ok || (!st.done && !now.Before(st.next))
}

So the whole lifetime of the loop is decided by one boolean: core.IsRetryableError(err).

3. What each cycle costs the provider and the tenant

Each cycle is a full VM lifecycle, not a no-op:

  • provisionVM (node/vm.go:69-103) creates a brand-new instance through the backend. The Lima backend runs limactl create + limactl start (vm/lima_manager.go:118-131) — a new VM, a new disk, a new boot; the QEMU backend does the equivalent. The tenant's SSH key is re-installed, so the tenant can still log in, but the machine is a different instance and everything on it is gone.
  • provisionVM also announces the VM to the consumer before the accept is even attempted (node/vm.go:89-102: n.Msg.Request(ctx, consumerPeer, "vm_credentials", info)). On a rejected accept the provider then deletes that very instance (node/node.go:1616), so the consumer is told about a machine that is already being destroyed, and is told again — about a different instance — on the next attempt. (This path is read from the source; the PoC harness has no network and does not exercise the credential delivery.)
  • teardownVM (node/vm.go:105-114) deletes the instance. The provider pays full instance-creation cost per cycle: image boot, disk provisioning, SSH-port wait (waitForSSHPort, up to 2 minutes on Lima) — for a lease that will never be accepted.
  • The lease_accept never lands, so the lease is never served: the provider is doing all of this work for a lease that stays in state created forever.

4. Why the same rejection, worded differently, is not a loop

shouldTeardownOnAcceptFailure decides whether the VM is destroyed; the classifier decides whether the attempt is repeated. They are independent:

// node/node.go:1436-1438, 1456-1458
func leaseAlreadyAccepted(lease *core.Lease) bool {
	return lease != nil && lease.State != core.LeaseCreated
}

func shouldTeardownOnAcceptFailure(lease *core.Lease, myAddr string) bool {
	return !leaseAlreadyAccepted(lease) || lease.Provider != myAddr
}

So for a lease whose record is missing or still in state created (the normal pre-accept state), every failed accept destroys the VM, and whether the attempt is repeated depends only on the text of the error. The PoC demonstrates the pair directly:

  • rejection text CommitBlock: lease state conflict: lease <hash> not found → IsRetryableError = true → destroy + re-create, forever;
  • rejection text lease_accept attestation: only 0 valid attestations from trusted timekeepers, need 1 → IsRetryableError = false → destroy once, stop.

Both are permanent. Only one of them contains the word "not".

Reproduction

Deterministic PoC: node/retryable_accept_loop_test.go — four tests, no network, no wall-clock dependence (fake clock via core.Now, base time.Unix(1700000000,0)), fixed keys, vm.MockManager behind the production vm.Manager interface. Nothing is stubbed: core.IsRetryableError, autoAcceptLease, leaseWatchTick, acceptSchedule, core.Ledger, store.MemStore and Ledger.SwapBlock are all the production implementations.

go test ./node/ -run "TestRetryableClassifierIsLexicalNotSemantic|TestProviderAcceptPermanentNotFoundEntersUnboundedRetryLoop|TestProviderAcceptPermanentNonNotFoundStopsAfterOneAttempt|TestLeaseOpenUnwindMakesProviderAcceptFailWithNotFound" -v -count=1

Verbatim output:

=== RUN   TestRetryableClassifierIsLexicalNotSemantic
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:1620 lease_accept             :: source lease block not found: 4f3a2b1c9d8e
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:1692 lease_accept             :: lease_accept: certificate not found: 4f3a2b1c9d8e
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:1537 lease_open               :: certificate 4f3a2b1c9d8e not found
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:1805 lease_cancel             :: source lease block not found: 4f3a2b1c9d8e
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:1892 lease_settle             :: source lease block not found: 4f3a2b1c9d8e
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:1909 lease_renew              :: lease not found: 4f3a2b1c9d8e
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:2133 lease_force_settle       :: lease not found: 4f3a2b1c9d8e
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:1326                          :: multisig_update: account not found
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:2895                          :: SwapBlock: account 4f3a2b1c not found
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:2908                          :: SwapBlock: block 4f3a2b1c not found in chain
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:3048                          :: GetBlockHeight: account 4f3a2b1c not found
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/ledger.go:3055                          :: GetBlockHeight: block 4f3a2b1c not found in account 4f3a2b1c
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent store/mem_store.go:293                       :: CommitBlock: lease state conflict: lease 4f3a2b1c not found
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=permanent core/rollback.go:253                         :: undo: lease 4f3a2b1c not found while reversing lease_accept
    retryable_accept_loop_test.go:344: [ok] retryable=false want=false kind=permanent core/ledger.go:1634 lease_accept             :: lease already accepted
    retryable_accept_loop_test.go:344: [ok] retryable=false want=false kind=permanent core/ledger.go:1640                          :: lease_accept stake mismatch: expected 667, got 1
    retryable_accept_loop_test.go:344: [ok] retryable=false want=false kind=permanent core/ledger.go:1662                          :: insufficient XUSD balance for stake: have 0, need 667
    retryable_accept_loop_test.go:344: [ok] retryable=false want=false kind=permanent core/ledger.go:1626                          :: lease_accept: provider account mismatch
    retryable_accept_loop_test.go:344: [ok] retryable=false want=false kind=permanent core/ledger.go:1318                          :: multisig_update: account is not multisig
    retryable_accept_loop_test.go:344: [ok] retryable=false want=false kind=permanent store/mem_store.go:296                       :: CommitBlock: lease state conflict: lease 4f3a2b1c is accepted, want created
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=transient core/retryable.go:11                         :: previous block not found
    retryable_accept_loop_test.go:344: [ok] retryable=true  want=true  kind=transient core/retryable.go:12                         :: source send not pending: 4f3a2b1c
    retryable_accept_loop_test.go:364: SIBLING MESSAGES: same store guard, same permanent condition, different wording:
    retryable_accept_loop_test.go:365:   retryable=true   :: CommitBlock: lease state conflict: lease 4f3a2b1c not found
    retryable_accept_loop_test.go:366:   retryable=false  :: CommitBlock: lease state conflict: lease 4f3a2b1c is accepted, want created
CLASSIFIER CONFIRMED: permanent lease failures are retryable iff the message contains "not found"
--- PASS: TestRetryableClassifierIsLexicalNotSemantic (0.00s)
=== RUN   TestProviderAcceptPermanentNotFoundEntersUnboundedRetryLoop
2026/11/05 16:55:13 Genesis block applied: 42000000000000 XE to 378d0f5c2063...
    retryable_accept_loop_test.go:391: STEP 1: lease record absent, pending send present - the provider keeps re-driving the accept
2026/11/05 16:55:13 Lease watch: found unaccepted lease e7b68ecd1240..., auto-accepting
2026/11/05 16:55:13 VM provisioned for lease e7b68ecd1240... (user=xe-9e41c71e)
2026/11/05 16:55:13 Could not find consumer peer for account 974cdb8ab595...
2026/11/05 16:55:13 Failed to add lease_accept: CommitBlock: CommitBlock: lease state conflict: lease e7b68ecd1240 not found
2026/11/05 16:55:13 VM torn down for lease e7b68ecd1240...
2026/11/05 16:55:13 Lease e7b68ecd1240...: retrying accept in 5s
2026/11/05 16:55:13 Lease watch: found unaccepted lease e7b68ecd1240..., auto-accepting
2026/11/05 16:55:13 VM provisioned for lease e7b68ecd1240... (user=xe-e6d794f7)
2026/11/05 16:55:13 Could not find consumer peer for account 974cdb8ab595...
2026/11/05 16:55:13 Failed to add lease_accept: CommitBlock: CommitBlock: lease state conflict: lease e7b68ecd1240 not found
2026/11/05 16:55:13 VM torn down for lease e7b68ecd1240...
2026/11/05 16:55:13 Lease e7b68ecd1240...: retrying accept in 20s
2026/11/05 16:55:13 Lease watch: found unaccepted lease e7b68ecd1240..., auto-accepting
2026/11/05 16:55:13 VM provisioned for lease e7b68ecd1240... (user=xe-90d2c7d7)
2026/11/05 16:55:13 Could not find consumer peer for account 974cdb8ab595...
2026/11/05 16:55:13 Failed to add lease_accept: CommitBlock: CommitBlock: lease state conflict: lease e7b68ecd1240 not found
2026/11/05 16:55:13 VM torn down for lease e7b68ecd1240...
2026/11/05 16:55:13 Lease e7b68ecd1240...: retrying accept in 40s
2026/11/05 16:55:13 Lease watch: found unaccepted lease e7b68ecd1240..., auto-accepting
2026/11/05 16:55:13 VM provisioned for lease e7b68ecd1240... (user=xe-99a844da)
2026/11/05 16:55:13 Could not find consumer peer for account 974cdb8ab595...
2026/11/05 16:55:13 Failed to add lease_accept: CommitBlock: CommitBlock: lease state conflict: lease e7b68ecd1240 not found
2026/11/05 16:55:13 VM torn down for lease e7b68ecd1240...
2026/11/05 16:55:13 Lease e7b68ecd1240...: retrying accept in 1m20s
2026/11/05 16:55:13 Lease watch: found unaccepted lease e7b68ecd1240..., auto-accepting
2026/11/05 16:55:13 VM provisioned for lease e7b68ecd1240... (user=xe-ec08425d)
2026/11/05 16:55:13 Could not find consumer peer for account 974cdb8ab595...
2026/11/05 16:55:13 Failed to add lease_accept: CommitBlock: CommitBlock: lease state conflict: lease e7b68ecd1240 not found
2026/11/05 16:55:13 VM torn down for lease e7b68ecd1240...
2026/11/05 16:55:13 Lease e7b68ecd1240...: retrying accept in 2m40s
    retryable_accept_loop_test.go:404: STEP 2: 5 retries -> 5 VM provisions and 5 VM teardowns (the tenant VM is destroyed and re-created every cycle)
    retryable_accept_loop_test.go:421: STEP 3: acceptSchedule: done=false failures=5 next-delay=2m40s (saturated at acceptRetryMax=2m40s)
    retryable_accept_loop_test.go:423:         acceptSchedule.due() stays true forever: the scheduler has no termination condition other than the lease ceasing to be pending
    retryable_accept_loop_test.go:430: STEP 4: the provider's chain holds no lease_accept - the accept never lands, so the lease is never served
PROVIDER LOOP CONFIRMED: a permanent "not found" rejection destroys and re-creates the tenant VM on every retry, without bound
--- PASS: TestProviderAcceptPermanentNotFoundEntersUnboundedRetryLoop (0.01s)
=== RUN   TestProviderAcceptPermanentNonNotFoundStopsAfterOneAttempt
2026/11/05 16:55:13 Genesis block applied: 42000000000000 XE to 378d0f5c2063...
    retryable_accept_loop_test.go:453: STEP 1: same state as the unbounded-loop case - lease record absent, pending send present
    retryable_accept_loop_test.go:485: STEP 2: production rejection: lease_accept attestation: only 0 valid attestations from trusted timekeepers, need 1
    retryable_accept_loop_test.go:486:         core.IsRetryableError(err) = false (no "not found" in the text)
2026/11/05 16:55:13 Lease watch: found unaccepted lease 73d3eb675256..., auto-accepting
2026/11/05 16:55:13 VM provisioned for lease 73d3eb675256... (user=xe-8fb40172)
2026/11/05 16:55:13 Could not find consumer peer for account d0369e97f6fb...
2026/11/05 16:55:13 Failed to add lease_accept: lease_accept attestation: only 0 valid attestations from trusted timekeepers, need 1
2026/11/05 16:55:13 VM torn down for lease 73d3eb675256...
    retryable_accept_loop_test.go:499: STEP 3: 5 lease-watch ticks -> 1 VM provision, 1 VM teardown (the scheduler gave up after the first attempt)
    retryable_accept_loop_test.go:509: STEP 4: acceptSchedule: done=true failures=0 - the lease is never retried
CONTRAST CONFIRMED: the same node state and the same accept path, with a rejection that does not contain "not found", is retried exactly once
--- PASS: TestProviderAcceptPermanentNonNotFoundStopsAfterOneAttempt (0.00s)
=== RUN   TestLeaseOpenUnwindMakesProviderAcceptFailWithNotFound
2026/11/05 16:55:13 Genesis block applied: 42000000000000 XE to 378d0f5c2063...
    retryable_accept_loop_test.go:529: STEP 1: provider holds the lease record (state=accepted) and its lease_accept is on its own chain
    retryable_accept_loop_test.go:548: STEP 2: production unwind DELETED the shared lease record
    retryable_accept_loop_test.go:562: STEP 3: production rejection: CommitBlock: CommitBlock: lease state conflict: lease 043b36f82fc8 not found
    retryable_accept_loop_test.go:563:         core.IsRetryableError(err) = true  (the bare "not found" substring at core/retryable.go:13)
2026/11/05 16:55:13 VM provisioned for lease 043b36f82fc8... (user=xe-be94d3a5)
2026/11/05 16:55:13 Could not find consumer peer for account 5d5347f45b1b...
2026/11/05 16:55:13 Failed to add lease_accept: CommitBlock: CommitBlock: lease state conflict: lease 043b36f82fc8 not found
2026/11/05 16:55:13 VM torn down for lease 043b36f82fc8...
2026/11/05 16:55:13 Lease 043b36f82fc8...: retrying accept in 5s
    retryable_accept_loop_test.go:581: STEP 4: the provider provisioned a VM and then TORE IT DOWN; acceptSchedule done=false failures=1
    retryable_accept_loop_test.go:589: NOTE: the same unwind also removed the lease's pending send (core/rollback.go:222), so on THIS node the lease-watch tick stops re-driving the lease
    retryable_accept_loop_test.go:590:       the unbounded cycle needs the lease to stay pending while its record is gone
PRODUCTION PATH CONFIRMED: the lease_open unwind makes the provider's accept fail with "not found", which the classifier calls retryable
--- PASS: TestLeaseOpenUnwindMakesProviderAcceptFailWithNotFound (0.00s)
PASS
ok  	github.com/xeprotocol/xe/node	0.299s

What each test establishes

test what it shows
TestRetryableClassifierIsLexicalNotSemantic 22 production error strings, 22 documented expectations, all holding. 14 permanent messages are classified retryable because they contain "not found"; 6 permanent messages without it are correctly non-retryable; the 2 genuinely transient ones are retryable. The decisive pair comes from one production guard (store/mem_store.go:290-303): ... lease <hash> not found → retryable, ... lease <hash> is accepted, want created → not retryable.
TestProviderAcceptPermanentNotFoundEntersUnboundedRetryLoop The provider's production loop with the lease record absent and the pending send present: 5 lease-watch ticks → 5 VM provisions and 5 VM teardowns, acceptSchedule.done=false, failures=5, the retry delay saturated at acceptRetryMax (2m40s), and no lease_accept on the provider's chain — the accept never lands.
TestProviderAcceptPermanentNonNotFoundStopsAfterOneAttempt The same node-visible state (lease record absent, pending send present) and the same accept path, with a rejection whose text does not contain "not found": 5 lease-watch ticks → 1 VM provision, 1 VM teardown, acceptSchedule.done=true — the lease is never retried. The only difference between the two runs is the wording of the rejection, which is the only thing core.IsRetryableError looks at.
TestLeaseOpenUnwindMakesProviderAcceptFailWithNotFound The production unwind really produces the rejection: Ledger.SwapBlock over a lease_open deletes the shared lease record; the provider's accept is then rejected with CommitBlock: CommitBlock: lease state conflict: lease 571b9fce8262 not found; core.IsRetryableError(err) = true; the node provisions a VM and then tears it down, done=false failures=1 — i.e. the first cycle of the unbounded loop. The test also prints the honest bound: the same unwind removed the lease's pending send (core/rollback.go:222), so on that node the lease-watch stops re-driving the lease.

Reproducibility matrix

The same PoC was run unchanged on three trees, all green:

tree result
master @ 02e9641 PASS (-count=1 and -count=3)
master + PR #147 diff (xe-pr147-master) PASS (repo packages build; go test ./node/ green)
PR #147 head (xe-pr147) PASS (repo packages build; go test ./node/ green)

go vet ./node/ is clean. The full go test ./node/ package suite passes on master with the PoC present.

Reachability, and the honest bound on it

The loop demonstrated above requires two things at the same time: the lease's pending send outlives the lease record (so the 5-second lease-watch keeps re-driving the accept) and the rejection's text contains "not found" (so the classifier says "retry again").

What the code does today. The lease record and the pending send are created in one atomic commit — core/ledger.go:1584-1604 sets commit.PutLease and commit.AddPending together, so a node never has one without the other. The only code in the tree that deletes a lease record is the unwind of a lease_open:

// core/rollback.go:220-223
case BlockLease:
	deletePendingID = b.Hash      // 222: the lease's pending send
	deleteLeaseHash = b.Hash      // 223: the lease record

and both are applied in the same store transaction (store/mem_store.go:219-230 and :256-258; store/badger_store.go:1101-1105). So on current master a single node does not reach "record gone, payment still pending" by itself — the one deletion that removes the record removes the pending send with it.

Therefore: the PoC injects that combination at the store boundary, using the store's own test-only helper MemStore.DropLeaseForTesting (store/mem_store.go:704-708), and lets the production code react to it. It is the only artificial step in the harness: autoAcceptLease, leaseWatchTick, acceptSchedule, acceptRetryDelay, core.Ledger, store.MemStore and core.IsRetryableError are all the production implementations, and nothing about the reaction is simulated.

What is live on master today, without any injection:

  1. The classification defect itself, for all five consumers. 14 permanent errors are classified retryable, on the API contract (api/handler.go:413), the quorum promotion path (core/quorum.go:328), the quorum winner append (core/quorum.go:387), the sync apply loop (net/sync.go:609) and the provider accept path (node/node.go:1617). Those other consumers are already reported elsewhere (see the dedup section); this report's subject is the fifth one, the only consumer whose misclassification destroys a machine.
  2. The provider's destroy-then-retry handler is unconditional. node/node.go:1615-1617 destroys the tenant's VM for any failed accept and then asks the classifier whether to try again. It does not look at why the accept failed.
  3. The scheduler is unbounded. acceptSchedule.record has no attempt cap and no permanent-failure exit (node/node.go:1726-1745), so any retryable verdict — from any cause — becomes an endless destroy/re-create cycle with a 160-second saturated backoff.
  4. A reachable route to a "not found" rejection of the accept exists, although on its own it is bounded. The provider's own certificate check is at node/node.go:1503; the ledger's is at core/ledger.go:1690. The window between them contains the entire VM provisioning (node/node.go:1554 → node/vm.go:118-142, which waits up to two minutes for the SSH port on Lima) and the PoW solve. If the pinned certificate is evicted from the provider's certificate cache in that window (node/certset.go:25-53 keeps 256 certificates per provider and evicts the oldest), the ledger rejects with lease_accept: certificate not found: <hash> — retryable → destroy + retry. On the next attempt the node's own check fails first ("pinned certificate <hash> not held", node/perf.go:428-430), the node gives up and the lease is marked done, so this route produces a bounded one- or two-cycle churn rather than an endless loop. I state that explicitly rather than overclaiming it.

Summary of the bound: the unbounded cycle is demonstrated, and it is the direct consequence of the production code's reaction to a misclassified rejection; but on current master the specific state it needs (record gone, payment pending) is not produced by a single-node transition. The defect is one store-level divergence away from live, and the node has no defence against it: no attempt cap, no permanent-failure detection, and a handler that destroys the tenant's machine before asking whether the failure was permanent.

Impact

  • The tenant's lease is never served. The lease_accept never lands, so the lease stays in state created and the provider never serves it. This is not a "free VM for the tenant": the machine is destroyed on every attempt.
  • The provider pays for a full VM lifecycle per attempt, forever. With the backoff saturated at 160 s, a stuck lease costs roughly 540 VM create/delete cycles per day, each of which is a fresh instance boot (Lima waits up to 2 minutes for the SSH port) plus a teardown, for a lease that can never be accepted.
  • The tenant's machine is repeatedly destroyed and replaced. Every cycle deletes the instance the provider just built (and may have just announced to the tenant, node/vm.go:89-102) and builds a new one. Anything the tenant had on the machine is lost, and the machine the tenant finally gets is not the machine it was last told about.
  • The provider's advertised capacity is charged during the window. activeLeaseCount is len(n.VMManager.List()) (node/node.go:1429-1434), so the transiently-provisioned VM is counted against the provider's capacity and can make autoAcceptLease refuse other, legitimate leases with insufficient resources (node/node.go:1533-1543).
  • The provider's node is stuck in a hot loop (a full VM lifecycle every 160 s per stuck lease) with no operator-visible signal beyond a log line, and no cap on how many leases can be in that state.
  • The trigger is inside the node's own control. The provider does not choose to destroy the machine; a substring match in core/retryable.go does.

Honest bounds (what is not claimed)

  • No fund loss, no escrow loss, no stake burn. The accept never lands in any of these scenarios, so no stake is locked and no escrow is consumed. (LeaseStakeDivisor is const uint64(0) on master, so LeaseStake(cost) is 0 anyway — there is no stake to burn.)
  • No double-accept. The store's CAS rejects a second accept for the same lease (store/mem_store.go:290-303), and autoAcceptLease returns early when the lease is already accepted (node/node.go:1467).
  • Not a consensus fork and not a ledger divergence. The provider's chain is unchanged by the loop; no block is committed, no balance moves, no vote is cast. This is a node-level resource/availability failure, not a disagreement about ledger state.
  • The unbounded cycle needs the injected store-level divergence. See "Reachability, and the honest bound on it": on current master the only lease-record deletion also removes the lease's pending send, so a single node does not produce that state by itself. I claim the reaction, the unbounded scheduler and the classifier defect; I do not claim that a specific single-node transition on current master triggers the endless cycle unaided.
  • The tenant-notification consequence is a source reading, not a PoC result. The harness has no network, so the vm_credentials delivery (node/vm.go:89-102) is not exercised; the destruction/re-creation counts are.
  • The certificate-eviction route is bounded. It produces a one- or two-cycle churn, not an endless loop, because the node's own certificate check fails on the following attempt.
  • Not the API contract. The writeSubmitError consumer's wrong 503-vs-400 is XE-0014 (accepted, Medium); this report does not re-argue it.
  • Not the sync storm. The net/sync.go:609 consumer's "lease not found" retry storm is XE-0035 (accepted, minor).
  • Not the quorum consumers. The quarantine bypass at core/quorum.go:328 is XE-0583 (T9). The swallow-and-drop at core/quorum.go:387 is not claimed here — it is noted as an unexplored adjacent consumer.
  • Not XE-0615 (mine). XE-0615 is the opposite failure: the node never tears down a VM whose lease record was deleted. This report is about the node tearing the VM down and rebuilding it in a loop.
  • Not profitable, not remotely triggerable. The state requires the lease's own consumer and provider; a third party cannot force it. No DoS-amplification claim is made.
  • Scope of the PoC. One consumer, one provider, one lease, store.MemStore, vm.MockManager. Multi-lease and multi-provider interactions were not simulated, and the Badger store was not exercised for this finding.

Suggested fix direction

  1. Classify on error identity, not on error text. The tree already has sentinels (core.ErrLeaseStateConflict, ErrWinnerFullValidation, ErrInvalidPoW, ErrGap). The permanent failures should carry a typed error and the five consumers should branch on errors.Is. At minimum: remove the bare "not found" from core/retryable.go:13 and replace it with the specific transient messages it was standing in for — previous block not found, cancel-wins: provider accept not found locally: retry after sync (already matched by the explicit retry after sync pattern at core/retryable.go:23), and the renew-wins: / settle-wins: variants that the open PR #185 adds — and put the permanent lease messages on a non-retryable list. This is the direction the open PR #36 started; it currently adds exactly one entry (multisig_update: account not found) and leaves the bare pattern in place. The distinction that matters is "the block I depend on has not arrived yet" (transient) versus "the lease record this operation requires does not exist and never will" (permanent) — both are worded with "not found" today.
  2. Bound the provider's accept loop independently of the classification. Give acceptSchedule a maximum attempt count and an explicit terminal state for a permanent failure, so that no classification mistake can turn one rejection into an endless destroy/re-create loop. node/node.go:1726-1745 currently has neither.
  3. Do not destroy the tenant's machine for a failure that will be retried. The teardown at node/node.go:1616 happens before the retry decision at :1617. For a retryable rejection the provider should re-attempt the accept against the machine it already built; the machine should only be torn down when the lease is dead or the failure is terminal. This also removes the tenant-visible churn (a machine destroyed and rebuilt every 20-160 s).
  4. Do not announce the VM before the accept lands. provisionVM (node/vm.go:69-103) sends vm_credentials to the consumer, but it runs at node/node.go:1554, before the accept is submitted at :1612. Announcing a machine the provider may immediately destroy is what converts a retry into a tenant-visible outage. The announcement belongs after the accept is committed.
  5. Treat a missing lease record as an explicit permanent condition on the provider's accept path, rather than letting the wording of the store's error decide whether the provider loops.

Relation to other existing reports (dedup)

All 231 public desk tickets were listed and every ticket body was fetched from its detail endpoint (GET /v1/tickets returns metadata only; bodies are not in the list payload) and swept in full. All 100 open PRs were fetched as diffs (https://github.com/xeprotocol/xe/pull/N.diff) and swept for IsRetryableError, retryable.go, autoAcceptLease, acceptRetry, acceptSched, teardownVM, not found, ExpectLease* and lease state conflict.

No ticket in the corpus reports this. The claim-level sweep found:

  • 0 tickets that mention both the classifier (IsRetryableError / core/retryable.go) and the provider accept path (autoAcceptLease / acceptSchedule);
  • 0 tickets that mention both the classifier and a VM teardown / re-provision;
  • 8 tickets that mention the classifier at all (XE-0021, XE-0040, XE-0098, XE-0105, XE-0268, XE-0464, XE-0481, XE-0583), and 1 ticket that mentions the bare "not found" substring (XE-0583, mine);
  • 5 tickets that mention the provider accept path (XE-0076, XE-0104, XE-0114, XE-0119, XE-0615), none of which mentions the classifier.

Adjacent reports, checked and distinct:

  • XE-0014 (reporter 10, accepted, Medium, node-api) — Structurally impossible blocks are rejected with 503 {retryable:true} instead of 400 {retryable:false}. This is the API consumer (api/handler.go:413). Its fix PR #36 adds a 14-entry nonRetryablePatterns allowlist that contains exactly one "not found" string (multisig_update: account not found) and does not remove the bare "not found" pattern. It makes no claim about the provider's accept path, the VM lifecycle, or the retry scheduler.
  • XE-0035 (reporter 14, accepted, minor, ops-testnet) — the sync consumer (net/sync.go:609): "lease not found" blocks retried every cycle. Same root cause, different consumer, no VM impact.
  • XE-0098 (reporter 32) — sync quarantine poisoning (core/quorum.go:328's sibling path, net/sync.go). XE-0268 (reporter 121, triaging) — the sync 10-pass discard. Both bodies contain zero mentions of node.go, autoAcceptLease, acceptSched, teardownVM or provisionVM.
  • XE-0583 (reporter 210, mine, new, consensus) — its T9 is the core/quorum.go:328 consumer of the same classifier defect, and its T10 shows the provider's re-accept of an orphaned lease failing with lease state conflict: lease <hash> not found. XE-0583 contains no mention of node.go:1617, autoAcceptLease, acceptSched, teardownVM, provisionVM, or of the provider's VM destroy/re-create behaviour — its subject is the consensus-level consequences of the shared lease record being deleted by a consumer-side unwind. This report's subject is the node-side consequence of the classifier verdict: the destroy/re-create loop, the unbounded scheduler, and the tenant-visible churn. The root cause (core/retryable.go:13) is shared; the consumer, the code path and the impact are not.
  • XE-0615 (reporter 210, mine, new, node-api) — the opposite failure mode: the node never tears down a VM whose lease record was deleted, so the guest runs forever and its capacity is permanently charged. This report is about the node tearing the VM down and rebuilding it in a loop.
  • XE-0114 (reporter 36) — provider restart destroys VMs backing live leases. XE-0259 (reporter 39) — Teardown reports success while the VM lives. XE-0119 (reporter 39) — resource clamping vs capacity accounting. All three are about VM lifecycle at startup, teardown reporting, or accounting — none is about the accept retry decision or the classifier.

Open PRs checked and confirmed not to fix this:

  • PR #36 — adds a nonRetryablePatterns allowlist with one entry; the bare "not found" stays.
  • PR #185 — adds eight more retryable substrings to core/retryable.go (renew-wins: … retry after sync and friends), widening the same matcher.
  • PR #114 — sanitises the API error text (cleanBlockError) for writeSubmitError; it does not change core.IsRetryableError's semantics, the store's "lease %s not found" message, or the provider's accept path.
  • PR #205 — touches autoAcceptLease / acceptSched / teardownVM only as unchanged context lines; the retry decision and the scheduler are byte-for-byte unchanged.
  • PR #179, PR #211, PR #227/#232, PR #210 — sync nil-guards, vote re-weighting, cascade overlays and pending-index work; none touches the provider's accept retry decision.

Artifacts

  • PoC: node/retryable_accept_loop_test.go — TestRetryableClassifierIsLexicalNotSemantic, TestProviderAcceptPermanentNotFoundEntersUnboundedRetryLoop, TestProviderAcceptPermanentNonNotFoundStopsAfterOneAttempt, TestLeaseOpenUnwindMakesProviderAcceptFailWithNotFound.
  • Run log: acceptloop_test.txt (the verbatim output above), acceptloop_test_count3.txt (-count=3), acceptloop_vet.txt (go vet ./node/, clean), acceptloop_fullpkg.txt (full go test ./node/ package, green).
  • Dedup sweep: dedup_acceptloop.txt (all 231 ticket bodies fetched from the detail endpoints, the claim-level co-occurrence sweep, the raw keyword sweep, the 100 open-PR diff sweep and the verbatim check of every ticket cited above).
  • Base commit: master @ 02e9641.

Thread

xe:79bd74092026-11-05 15:54 UTCweb

Cross-reference: the node-side surface of this ticket is fixed by the patch posted on XE-0748 (message there, verified green on master 02e9641).

Specifically, the accept path in node/node.go's autoAcceptLease no longer consults core.IsRetryableError at all. It now classifies the AddBlock rejection from the ledger's state: after the (unchanged) teardown, the exit is terminal iff the lease record is gone or already taken (n.GetLease), transient otherwise. The permanent "not found" rejection this ticket demonstrates (lease record unwound while the pending send survives) now yields one provision and one teardown, done=true — the destroy/re-create churn is gone, without touching the classifier itself.

Regression coverage in the patch on XE-0748:

  • node/retryable_accept_loop_test.go, TestProviderAcceptPermanentNotFoundStopsAfterOneAttempt — asserts the fixed behavior, and also records that core.IsRetryableError still classifies the same rejection as retryable, which is precisely why the accept path must not consult it;
  • node/accept_schedule_abandon_test.go — the transient-strand side (XE-0748), same patch.

Still open for this ticket: the classifier itself is unchanged. Its other consumers — api/handler.go writeSubmitError (503 vs 400), core/quorum.go (x2), net/sync.go:609 — retain the bare "not found" misclassification, and T1 (TestRetryableClassifierIsLexicalNotSemantic, 21 cases) still documents it case by case.

Joseph Denneteam2026-11-05 22:26 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0417, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, reply with what differs and we will look again.