Bounty
XE-0748 · Bounty

[Medium] Provider lease-accept retry scheduler wired to only 2 of ~10 failure exits - one transient VM provision or capacity failure permanently strands the lease in created state (node.go:1465)

Triaging web filed 2026-11-05 15:21 UTC by xe:79bd7409

Report

[Medium] The provider's lease-accept retry scheduler is wired to only 2 of ~10 failure exits of autoAcceptLease — one transient VM-provision or capacity failure permanently strands the lease in created, and its escrow can only be recovered by an explicit consumer lease_cancel

Summary

A provider node is supposed to accept a consumer's lease_open automatically. The accept is driven by the 5-second lease-watch tick (node/node.go:1657-1699), and whether the tick re-drives a failed accept is decided by the provider's own retry scheduler, acceptSchedule (node/node.go:1708-1755). The scheduler's only input is a local boolean in autoAcceptLease:

// node/node.go:1460-1466
func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
	if !n.beginAccept(leaseBlock.Hash) {
		return
	}
	defer n.endAccept(leaseBlock.Hash)
	retry := false
	defer func() { n.acceptSched.record(leaseBlock.Hash, retry, time.Now()) }()

record(hash, retry=false) marks the lease done and the tick never looks at it again:

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

// node/node.go:1726-1745
func (s *acceptSchedule) record(leaseHash string, retry bool, now time.Time) {
	...
	if !retry {
		st.done = true
		return
	}
	...
}

retry is set to true at exactly two of the roughly ten failure exits of autoAcceptLease:

exit failure sets retry = true?
node/node.go:1471-1475 a VM for this lease already exists no
node/node.go:1477-1480 the accept policy rejected the lease no
node/node.go:1485-1488 not enough XUSD for the stake no
node/node.go:1490-1495 attestation gathering failed yes (:1493)
node/node.go:1503-1507 the pinned performance certificate is unusable no
node/node.go:1512-1516 the balance changed under the lock no
node/node.go:1533-1543 insufficient resources (capacity) no
node/node.go:1564-1569 the VM provision failed no
node/node.go:1579-1585 the balance changed during provisioning no
node/node.go:1604-1609 signing the lease_accept failed no
node/node.go:1612-1622 the ledger rejected the lease_accept yes, iff core.IsRetryableError(err) (:1617)

The two bolded "no" rows are the paradigm transient failures: the provider's capacity frees up when other leases expire, and a Lima boot can fail once and succeed on the next attempt. The node's own retry scheduler exists precisely to handle them — node/node.go:1633-1648 defines a backoff ladder (acceptRetryQuick 5s, acceptRetryBase 20s, doubling to acceptRetryMax 160s) — but it is never told about them. The deferred record treats the exit as terminal, the scheduler sets done = true, due() returns false forever, and the lease-watch tick never re-drives the accept.

The consequence is that the lease is stranded in state created permanently:

  • not settleable — core/ledger.go:2142-2147 requires state accepted (lease not yet accepted for settle (state created): retry after accept);
  • not force-settleable — core/ledger.go:1914-1920 requires state accepted (lease not yet accepted for force-settle (state created): retry after accept);
  • never archived or burned by the provider's expiry passes — trySettleExpiredLeases (node/node.go:1796-1823), tryForceSettleStaleLeases (:1836-1853) and tryArchiveExpiredLeases (:1863-1879) all skip any lease whose state is not accepted (:1809, :1829, :1856), so the escrow is never released or burned by the node either;
  • only recoverable by an explicit lease_cancel from the consumer — core/ledger.go:1792-1876 accepts a cancel of a lease in state created and refunds the escrow (:1866), and it is the only lease operation that does.

Until the consumer issues that cancel, the consumer's escrow is locked and the tenant never gets the compute it paid for. The provider earns nothing and does no work. All of this is reproduced deterministically on the production lease-watch and accept paths, on plain master, with no PR required.

Relation to XE-0668 (my own ticket) — the opposite direction on the same boolean

XE-0668 (reporter 210, mine, new, area node-api) reports that core.IsRetryableError's bare "not found" substring makes permanent lease rejections classify as retryable, so node/node.go:1617 sets retry = true and the provider re-drives the accept forever, destroying and re-creating the tenant VM on every cycle.

This report is the mirror image and the opposite failure: transient failures that never reach the classifier at all are treated as terminal, so the lease is abandoned after a single attempt. XE-0668 is "retry when it should not"; this report is "never retry when it should". They are two defects of the same retry boolean, in opposite directions, with opposite consequences (XE-0668: unbounded VM churn; this report: permanent strand and a locked escrow) and different fixes. Fixing one does not fix the other; fixing the boolean's wiring requires fixing both. Neither ticket's PoC nor claims cover the other's code path: XE-0668's PoC drives the AddBlock rejection at node/node.go:1612-1622; this report's PoC drives the exits at :1533-1543 and :1564-1569, which return before any ledger call and therefore never touch core.IsRetryableError.

Affected component and versions

  • xeprotocol/xe, master @ 02e9641 (Merge pull request #251 from xeprotocol/fix/dao-tool-timestamp). No PR is required.
  • Also verified unchanged on the two open PRs that touch this code (see the dedup section): PR #205's rewritten node/node.go still contains retry := false with exactly one retry = true, and PR #180's hunk on autoAcceptLease adds lease-cap fields without touching the flag.
  • Code paths: node/node.go (autoAcceptLease, leaseWatchLoop, leaseWatchTick, acceptSchedule.due/record/prune, acceptRetryDelay, trySettleExpiredLeases, tryForceSettleStaleLeases, tryArchiveExpiredLeases, exceedsCapacity), core/ledger.go (validateAndAddLeaseAccept, validateAndAddLeaseSettle, validateAndAddLeaseForceSettle, validateAndAddLeaseCancel), node/vm.go (provisionVM).

Root cause

1. The scheduler has one input, and 8 of ~10 exits never write it

autoAcceptLease (node/node.go:1460-1631) is a single function with a local retry boolean and a deferred record. The eight exits that leave retry == false are listed in the table above. Three are unambiguously transient:

  • node/node.go:1533-1543 — insufficient resources. The provider sums its live VMs plus its reservations and refuses the lease if it does not fit. This is a momentary condition: every lease the provider already holds eventually expires and frees its capacity. The path returns without retry = true, so a lease that arrived during a busy window is never accepted even when the window passes.
  • node/node.go:1564-1569 — the VM provision failed. provisionVM (node/vm.go:69-103) calls VMManager.Provision and the backends can fail for reasons that are gone a second later: a Lima boot timeout (vm/lima_manager.go returns limactl ... timed out after ...), a transient disk or image error, a host reboot mid-provision. The node logs VM provision failed, not accepting and returns — the tenant's VM is gone, the escrow is still locked, and the scheduler has been told the lease is finished.
  • node/node.go:1579-1585 — the balance changed during provisioning. A concurrent debit on the provider's account between the capacity check and the block build aborts the accept. The next tick would succeed, but there is no next tick.

2. The exits that DO set retry = true prove the mechanism is otherwise intact

node/node.go:1490-1495 (attestation gathering) sets retry = true, and the scheduler then does exactly what it was built to do: it backs off, re-drives, and records the failure count. node/node.go:1617 sets retry = core.IsRetryableError(err) for ledger rejections. The defect is therefore not in the scheduler — it is in the coverage of the flag.

3. Nothing else re-drives a stranded lease

leaseWatchTick (node/node.go:1670-1699) is the only driver, and its first test is acceptSched.due(...):

// node/node.go:1676
if !n.acceptSched.due(p.SendHash, now) || n.acceptRunning(p.SendHash) {
    continue
}

With st.done == true, due() is false forever (node/node.go:1719-1724), so the tick continues past the lease on every one of its 5-second fires. acceptSched.prune(live) (:1747-1755) only removes entries whose pending send is gone — a stranded lease's escrow is still pending, so its entry survives indefinitely, permanently inert.

4. No other path can rescue the lease

node-side pass filter reaches a created lease?
trySettleExpiredLeases (:1796-1823) lease.State != core.LeaseAccepted → skip (:1809) no
tryForceSettleStaleLeases (:1836-1853) lease.State != core.LeaseAccepted → skip (:1829) no
tryArchiveExpiredLeases (:1863-1879) lease.State != core.LeaseAccepted → skip (:1856) no
cleanupOrphanedVMs (:1773-1794) acts on VMs, and no VM exists here no
consumer's lease_force_settle core/ledger.go:1914-1920 state gate rejected
provider's lease_settle core/ledger.go:2142-2147 state gate rejected
consumer's lease_cancel core/ledger.go:1792-1876, expects state created (:1866) the only one that works

Reproduction

Deterministic PoC: node/accept_schedule_abandon_test.go — six tests that drive the production lease-watch tick, the production autoAcceptLease and the production acceptSchedule, with vm.MockManager behind the vm.Manager interface the node calls. No network, no wall-clock dependence (fake clock via core.Now, base time.Unix(1700000000,0)), fixed structure, real core.Ledger validation and store commits. Nothing stubs the accept path, the scheduler or the lease-watch tick.

go test ./node/ -run 'TestProviderAcceptSchedule|TestStrandedLease|TestConsumerCanCancelStranded|TestProviderAcceptLands' -v -count=1

Verbatim output (passing run; log timestamps and hashes differ between runs):

=== RUN   TestProviderAcceptScheduleAbandonsLeaseAfterTransientProvisionFailure
2026/11/05 21:44:52 Lease watch: found unaccepted lease 4f3cbb589e55..., auto-accepting
2026/11/05 21:44:52 VM provision failed for lease 4f3cbb589e55...: limactl start timed out after 5m0s
2026/11/05 21:44:52 Lease 4f3cbb589e55...: VM provision failed, not accepting
    accept_schedule_abandon_test.go:386: STEP 1: the first lease-watch tick drove the accept; the VM provision failed (a transient error)
    accept_schedule_abandon_test.go:397: STEP 2: acceptSchedule: done=true failures=0 - the transient provision failure was recorded as a TERMINAL outcome
    accept_schedule_abandon_test.go:404: STEP 3: acceptSched.due() is false forever - the lease-watch tick will never re-drive it
    accept_schedule_abandon_test.go:415: STEP 4: 20 further lease-watch ticks -> 1 VM provision attempt in total (the healthy VM plane was never asked again)
    accept_schedule_abandon_test.go:425: STEP 5: lease state="created", provider chain holds 0 lease_accept block(s) - the tenant never gets compute
    accept_schedule_abandon_test.go:436: STEP 6: the consumer's escrow is still pending: 667 XUSD from dfe702e49522... to 9eec1ac436d6...
ABANDONMENT CONFIRMED: one transient VM-provision failure permanently strands the lease - the provider never retries it
--- PASS: TestProviderAcceptScheduleAbandonsLeaseAfterTransientProvisionFailure (0.01s)
=== RUN   TestProviderAcceptScheduleRetriesTransientAttestationFailure
2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting
2026/11/05 21:44:52 Failed to gather attestations for lease_accept 366d5e627bf5...: timekeepers unreachable: dial tcp 10.0.0.7:9000: connect: connection refused
2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 5s
2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting
2026/11/05 21:44:52 Failed to gather attestations for lease_accept 366d5e627bf5...: timekeepers unreachable: dial tcp 10.0.0.7:9000: connect: connection refused
2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 20s
2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting
2026/11/05 21:44:52 Failed to gather attestations for lease_accept 366d5e627bf5...: timekeepers unreachable: dial tcp 10.0.0.7:9000: connect: connection refused
2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 40s
2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting
2026/11/05 21:44:52 Failed to gather attestations for lease_accept 366d5e627bf5...: timekeepers unreachable: dial tcp 10.0.0.7:9000: connect: connection refused
2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 1m20s
2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting
2026/11/05 21:44:52 Failed to gather attestations for lease_accept 366d5e627bf5...: timekeepers unreachable: dial tcp 10.0.0.7:9000: connect: connection refused
2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 2m40s
    accept_schedule_abandon_test.go:481: CONTROL: 5 ticks -> 5 accept attempts, acceptSchedule done=false failures=5 next-delay=2m40s (saturated at acceptRetryMax=2m40s)
    accept_schedule_abandon_test.go:483:         acceptSched.due() stays true: the scheduler re-drives the lease on every tick
CONTROL CONFIRMED: the same scheduler DOES retry a failure that sets retry=true - only the transient exits that do not set it are stranded
--- PASS: TestProviderAcceptScheduleRetriesTransientAttestationFailure (0.00s)
=== RUN   TestProviderAcceptScheduleAbandonsLeaseWhenCapacityIsTemporarilyExhausted
2026/11/05 21:44:52 Lease watch: found unaccepted lease 57cfc845564d..., auto-accepting
2026/11/05 21:44:52 Cannot auto-accept lease 57cfc845564d...: insufficient resources (used 0/0/0 + req 1/1024/10 > cap 0/8192/100)
    accept_schedule_abandon_test.go:509: STEP 1: capacity exhausted -> the accept was abandoned (done=true failures=0), no VM was ever provisioned
    accept_schedule_abandon_test.go:526: STEP 2: capacity restored -> 20 further ticks produced 0 provision attempts; lease state="created", 0 lease_accept blocks
CAPACITY STRAND CONFIRMED: a temporary capacity rejection strands the lease exactly like a provision failure
--- PASS: TestProviderAcceptScheduleAbandonsLeaseWhenCapacityIsTemporarilyExhausted (0.00s)
=== RUN   TestStrandedLeaseCannotBeSettledOrForceSettled
2026/11/05 21:44:52 Lease watch: found unaccepted lease 5f91a59a8698..., auto-accepting
2026/11/05 21:44:52 VM provision failed for lease 5f91a59a8698...: limactl start timed out after 5m0s
2026/11/05 21:44:52 Lease 5f91a59a8698...: VM provision failed, not accepting
    accept_schedule_abandon_test.go:559: STEP 1: consumer lease_force_settle -> lease not yet accepted for force-settle (state created): retry after accept
    accept_schedule_abandon_test.go:575: STEP 2: provider lease_settle -> lease not yet accepted for settle (state created): retry after accept
    accept_schedule_abandon_test.go:581: STEP 3: escrow still pending: 667 XUSD locked
STRANDED CONFIRMED: neither the consumer nor the provider can settle or force-settle the stranded lease
--- PASS: TestStrandedLeaseCannotBeSettledOrForceSettled (0.00s)
=== RUN   TestConsumerCanCancelStrandedLeaseAndRecoverEscrow
2026/11/05 21:44:52 Lease watch: found unaccepted lease e76d423718d5..., auto-accepting
2026/11/05 21:44:52 VM provision failed for lease e76d423718d5...: limactl start timed out after 5m0s
2026/11/05 21:44:52 Lease e76d423718d5...: VM provision failed, not accepting
    accept_schedule_abandon_test.go:601: STEP 1: stranded lease; the consumer's XUSD balance is 9999333 (the lease cost 667 is locked in escrow)
    accept_schedule_abandon_test.go:622: STEP 2: consumer lease_cancel -> balance restored to 10000000, escrow released
HONEST BOUND CONFIRMED: the consumer can cancel the stranded lease and recover the escrow - the loss is the tenant's compute window, not the funds
--- PASS: TestConsumerCanCancelStrandedLeaseAndRecoverEscrow (0.00s)
=== RUN   TestProviderAcceptLandsWhenNoTransientFailureOccurs
2026/11/05 21:44:52 VM provisioned for lease c3888e097f9d... (user=xe-8809c206)
2026/11/05 21:44:52 Could not find consumer peer for account 5863e5bd066a...
    accept_schedule_abandon_test.go:644: NOTE: the harness has no libp2p host; the gossip publish at node/node.go:1625 panicked after the accept was committed: runtime error: invalid memory address or nil pointer dereference
    accept_schedule_abandon_test.go:659: POSITIVE CONTROL: no transient failure -> the lease_accept lands, lease state="accepted"
POSITIVE CONTROL CONFIRMED: the accept path itself is healthy - the strand is caused by the missing retry=true on the transient exits
--- PASS: TestProviderAcceptLandsWhenNoTransientFailureOccurs (0.00s)
PASS
ok  	github.com/xeprotocol/xe/node	1.022s

(The gossip-publish panic in the positive control is a harness limitation, not the defect: the harness has no libp2p host, so n.Gossip is nil and net/gossip.go:105-112 dereferences g.topic. The lease_accept is committed to the ledger at node/node.go:1612 before the publish at :1625, and the test asserts the committed state. The test calls autoAcceptLease on its own goroutine and recovers there.)

What each test establishes

Test What it shows
AbandonsLeaseAfterTransientProvisionFailure One failed Provision → done=true, failures=0; 20 further production ticks (100 s of wall-clock time, more than the scheduler's 160 s maximum backoff) produce zero further attempts; lease stays created; 0 lease_accept blocks; escrow still pending.
RetriesTransientAttestationFailure (control) The same scheduler with a failure that sets retry = true: 5 ticks → 5 accept attempts, done=false, failures=5, backoff saturated at acceptRetryMax=2m40s. Proves the scheduler works and the defect is specifically the missing flag on the other exits.
AbandonsLeaseWhenCapacityIsTemporarilyExhausted providerVCPUs=0 → the capacity gate at node/node.go:1533 fires → done=true; capacity restored → 20 ticks produce zero attempts. The provider never even tries to provision.
StrandedLeaseCannotBeSettledOrForceSettled The consumer's lease_force_settle and the provider's lease_settle are both rejected with the exact production state-gate messages; the escrow stays locked.
ConsumerCanCancelStrandedLeaseAndRecoverEscrow The consumer's explicit lease_cancel is accepted and the escrow is refunded in full — the honest bound.
ProviderAcceptLandsWhenNoTransientFailureOccurs With nothing failing, the accept lands and the lease becomes accepted — the strand is specific to the exits that do not set retry = true.

Reproducibility matrix

run command result
1 -run 'TestProviderAcceptSchedule|TestStrandedLease|TestConsumerCanCancelStranded|TestProviderAcceptLands' -v -count=1 6/6 PASS
2 same, -count=3 PASS (ok github.com/xeprotocol/xe/node 0.293s)
3 go test ./node/ -count=1 (whole package, includes XE-0615's and XE-0668's PoCs) PASS (ok github.com/xeprotocol/xe/node 1.582s)
4 go vet ./node/ clean, exit 0

The PoC is deterministic: fixed keys, a fake clock, real ledger validation, no network, no sleeps.

Impact

  • The tenant never gets the compute it paid for. The consumer's escrow is debited at lease_open and the provider never accepts, so no VM is ever created. The provider's own scheduler was built to prevent exactly this and is not wired to the failure that causes it.
  • The consumer's escrow is locked indefinitely. The lease is not settleable, not force-settleable and not archivable in state created — the provider's expiry passes all skip it. The only release is an explicit lease_cancel from the consumer, which requires the consumer to notice the strand and act. The shipped SDK's rentLease does not reliably do this: XE-0078 (accepted, minor) reports that rentLease skips its cancel on a non-retryable wait error — the same strand this report produces is exactly the situation in which the SDK's own recovery is skipped.
  • A provider's capacity can be silently withheld from the market. In the capacity-exhaustion variant, the provider keeps its capacity (nothing is provisioned), but the lease it could have served is abandoned rather than deferred. A provider whose capacity is briefly full refuses leases forever instead of queueing them, with no log line, metric or API surface distinguishing "abandoned" from "retrying".
  • No operator-visible signal. The strand produces exactly one log line (VM provision failed, not accepting / Cannot auto-accept lease ...: insufficient resources) and no metric. acceptSched.due() silently returns false from then on. A provider operator has no way to tell that a lease was abandoned rather than deferred.

Honest bounds (what is not claimed)

  • No loss of funds is claimed. The escrow is not burned: the provider's expiry/archive passes all skip non-accepted leases (node/node.go:1809, :1829, :1856), and the consumer's lease_cancel refunds the escrow in full (proved in the PoC's ConsumerCanCancelStrandedLeaseAndRecoverEscrow). The loss is the tenant's compute window and the parties' time, not the XUSD.
  • No supply inflation, no double-accept, no stake-burn. Nothing is minted; the store's CAS rejects a second accept; LeaseStakeDivisor is const uint64(0) on master, so LeaseStake(cost) is 0 and there is no stake to burn or slash. (The XE-0668 PoC asserts the same bounds for the same reason.)
  • No resource leak is claimed. Unlike XE-0615, no VM is left running and no provider capacity is phantom-charged: in both reproduced variants the failure happens before or at provisioning, so nothing is ever created. The impact is availability and escrow lock, not leaked compute.
  • Not a consensus fork and no ledger divergence. Every balance, chain and frontier stays consistent; the strand is a node-side scheduling failure. The ledger's own state machine is behaving exactly as specified — it is the node's driver that never brings the lease to it.
  • Not a claim that the ledger should accept a created-state settle. The ledger's state gates at core/ledger.go:1914-1920 and :2142-2147 are correct; the defect is that the node never moves the lease out of created.
  • Not a claim about the exits that are genuinely permanent. :1477-1480 (policy rejection), :1485-1488/:1512-1516 (insufficient stake/balance) and :1503-1507 (certificate unusable) are plausibly intended as terminal. This report claims the two clearly transient exits — capacity (:1533-1543) and provision failure (:1564-1569) — plus the balance-changed-during-provisioning race (:1579-1585), and notes that the other exits deserve an explicit decision rather than the current implicit one.
  • Single-provider, single-lease scope. The PoC uses one consumer and one provider. Multi-lease capacity interactions were not simulated.
  • The 20-tick figure is a wall-clock argument, not a timing dependence. The production tick fires every 5 s (node/node.go:1657-1668); 20 ticks is 100 s, more than the scheduler's 160 s maximum backoff would need to re-drive the lease had it been marked retryable. The PoC itself uses a far-future now and has no sleeps.

Suggested fix direction

  1. Set retry = true on the transient exits. The two clear cases are the capacity rejection (node/node.go:1533-1543) and the provision failure (:1564-1569); the balance-changed-during-provisioning race (:1579-1585) belongs with them. The scheduler's backoff ladder (:1633-1648) already does the right thing once the flag is set — the control test proves it.
  2. Invert the default. The current default (retry := false) makes every new exit permanently terminal by default. Defaulting to retry = true and only clearing it on the explicitly permanent exits (policy rejection, already-accepted, unusable certificate) would make the scheduler's behaviour match its purpose and survive future edits to the function.
  3. Distinguish "terminal" from "transient" at the source. The same distinction core.IsRetryableError tries to make lexically (XE-0668's subject) is being made here by hand. Wrapping each exit in a typed error or an explicit acceptOutcome enum — rather than a boolean set in two places out of ten — removes both defects at once and makes the classifier unnecessary on this path.
  4. Surface the strand to the operator. Emit a distinct log line and a counter when a lease's schedule entry is marked done while the lease is still pending and unaccepted, and expose the stranded set in the API, so an operator can see "abandoned" versus "retrying".
  5. Consider a provider-side rescue for created leases. The provider cannot cancel a lease it does not hold (only the consumer can, core/ledger.go:1810-1811), so a stranded lease is invisible to every provider-side expiry pass. A periodic warning about pending-but-unaccepted leases older than some threshold would close the observability gap without changing ledger semantics.

Dedup

All 214 public desk tickets were listed and every ticket body was fetched from its detail endpoint (GET /v1/tickets returns metadata only) and swept in full, against a 15-claim characterisation of this report (the scheduler, the retry flag, done/due(), the transient exits, the created state, both settle gates, the escrow, the cancel-only release, and the tenant's compute). All 100 open PRs were fetched as diffs (https://github.com/xeprotocol/xe/pull/N.diff) and swept for acceptSched, retry = true/false, st.done, autoAcceptLease, leaseWatchTick, limactl and provision failed. All 245 open GitHub issues were fetched from the API and swept with the same vocabulary. The full sweep output is attached.

The only ticket that touches the core of this report (scheduler + done + due() + transient) is XE-0668 — my own ticket, and the opposite direction (see the relation section above). Seven tickets touch 3+ of the 15 claims; every one is distinct:

  • XE-0668 (mine) — permanent rejections classified retryable → unbounded retry and VM churn. Opposite direction on the same boolean.
  • XE-0615 (mine) — a VM whose lease record was deleted is never torn down. Its subject is a running VM with no lease; this report's subject is a lease with no VM. No overlap in mechanism.
  • XE-0675 (r=62) — the VM manager holds its lock across the whole multi-minute boot. A concurrency defect that delays accepts; this report is about the accepts that are never re-driven after a failure. (Notably, XE-0675's stall makes transient capacity rejections more likely, which makes this report's strand more likely — they compound, they do not overlap.)
  • XE-0102 (r=35) — after a renewal, force-settle's balance computation is wrong, so the escrow is locked and later burned. Different gate (the balance computation at core/ledger.go:1969-1976, reached only for accepted leases) versus this report's state gate (:1914-1920, for leases that never got there).
  • XE-0114 (r=36) — provider restart destroys VMs backing live accepted leases. Opposite direction again: accepted leases losing VMs, versus a created lease never gaining one.
  • XE-0078 (accepted, SDK) — rentLease skips its cancel on a non-retryable wait error. Cited as an amplifier, not a duplicate: it is the SDK's failure to clean up the exact strand this report creates.
  • XE-0583 (mine) — unwinding a consumer lease_open deletes the shared lease record. A consensus/unwind defect; this report needs no unwind, no fork and no deleted record.

Open PRs checked and confirmed not to fix this:

  • PR #205 rewrites node/node.go (resource dimensions) but its new autoAcceptLease still reads retry := false (:16741 of the diff) with exactly one retry = true at the attestation site (:16769); the capacity exit (:16826) and the provision-failure exit (:16868) are unchanged.
  • PR #180 adds lease-cap fields to the accept block inside autoAcceptLease and reworks cleanupOrphanedVMs; it does not touch the flag (one hunk header on autoAcceptLease, zero retry/acceptSched lines).
  • PR #28 only re-indents the n.autoAcceptLease(b) call site; PR #192 and PR #203 do not touch the accept path at all.

No ticket in the corpus reports a lease abandoned after a transient failure, a scheduler entry marked done on a non-terminal failure, or a created-state lease that cannot be settled or force-settled.

Artifacts

  • PoC: node/accept_schedule_abandon_test.go — six tests: TestProviderAcceptScheduleAbandonsLeaseAfterTransientProvisionFailure, TestProviderAcceptScheduleRetriesTransientAttestationFailure (control), TestProviderAcceptScheduleAbandonsLeaseWhenCapacityIsTemporarilyExhausted, TestStrandedLeaseCannotBeSettledOrForceSettled, TestConsumerCanCancelStrandedLeaseAndRecoverEscrow, TestProviderAcceptLandsWhenNoTransientFailureOccurs (positive control).
  • Run log: acceptsched_test.txt (verbatim -v -count=1 output above), acceptsched_test3.txt (-count=3), acceptsched_pkg.txt (whole node package), acceptsched_vet.txt (go vet, clean).
  • Dedup sweep: dedup_acceptsched.txt (all 214 ticket bodies from the detail endpoints, the 15-claim final sweep, the per-keyword hit lists, the 100 open PR diffs, and the 245 open GitHub issues).
  • Base commit: master @ 02e9641.

Thread

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

Fix implemented for the strand reported in this ticket (and, on the same path, the node-side surface of XE-0668). Patch and regression suite below; everything verified green on master 02e9641.

The fix (summary)

Three changes to node/node.go's autoAcceptLease, all on the production accept path:

  1. Typed outcomes at every exit (C). Each failure exit now wraps its error in terminalAcceptError (never retry) or transientAcceptError (retry on the acceptRetryDelay backoff). The deferred acceptSched.record classifies via errors.As, so the classification lives at the failure site instead of a boolean set in 2 of ~10 places.
  2. Inverted default (B). retry := true; only explicitly-terminal exits opt out. A wrongly-retried accept costs one cheap re-check per backoff interval; a wrongly-abandoned one strands the lease in created forever. Every exit added to this function in future now fails toward retry.
  3. State-driven classification at the AddBlock exit. core.IsRetryableError(err) is no longer consulted here at all. After the (unchanged) teardown, the exit is terminal iff the lease record is gone or already taken (n.GetLease), transient otherwise. This is what stops the node-side consequence of XE-0668: a permanent "not found" rejection (lease record unwound, pending send surviving) now stops after one attempt instead of destroying and re-creating the tenant VM on every retry — without touching the lexical classifier, which api/handler.go and core/quorum.go still use.

Two behavioral repairs ride along:

  • The "VM already exists" exit no longer strands + leaks. It previously returned silently: the lease stranded (this ticket) and the VM leaked (cleanupOrphanedVMs skips leases that are still pending — an XE-0615-flavored leak). It now finishes the accept: the VM serves the lease once the lease_accept lands, and the later balance gate still tears it down if the accept aborts.
  • The gossip-publish failure after commit is terminal, not a silent return — the ledger has committed and the lease is served; re-driving it would churn the VM.

Classification per exit:

exit classification
lease already accepted terminal
a VM for the lease already exists (finish the accept — see above)
accept policy rejected terminal
insufficient XUSD for stake (both sites) terminal
attestation gathering failed transient
pinned certificate unusable terminal
capacity exhausted transient
VM provision failed transient
balance changed during provisioning transient
sign failed transient
AddBlock rejected, lease record gone or taken terminal
AddBlock rejected, record still present and unaccepted transient
gossip publish failed after commit terminal

Patch — node/node.go

diff --git a/node/node.go b/node/node.go
index 2bbedc4..a0a44af 100644
--- a/node/node.go
+++ b/node/node.go
@@ -1457,25 +1457,70 @@ func shouldTeardownOnAcceptFailure(lease *core.Lease, myAddr string) bool {
 	return !leaseAlreadyAccepted(lease) || lease.Provider != myAddr
 }
 
+// terminalAcceptError marks an autoAcceptLease failure exit that can never
+// succeed on a retry; the deferred acceptSched.record marks the lease done.
+type terminalAcceptError struct{ err error }
+
+func (e terminalAcceptError) Error() string { return e.err.Error() }
+func (e terminalAcceptError) Unwrap() error { return e.err }
+
+// transientAcceptError marks an autoAcceptLease failure exit that is expected
+// to heal on its own (capacity frees up when other leases expire, a VM boot
+// can succeed on the next attempt, a balance race resolves); the deferred
+// record schedules a retry on the acceptRetryDelay backoff. It documents the
+// classification at the failure site: the inverted default already retries
+// every exit that is not explicitly terminal.
+type transientAcceptError struct{ err error }
+
+func (e transientAcceptError) Error() string { return e.err.Error() }
+func (e transientAcceptError) Unwrap() error { return e.err }
+
+var (
+	errLeaseAlreadyAccepted = errors.New("lease already accepted")
+	errAcceptStakeShortage  = errors.New("insufficient XUSD for the lease stake")
+	errAcceptNoCapacity     = errors.New("insufficient resources for the lease")
+	errAcceptBalanceChanged = errors.New("XUSD balance changed during provisioning")
+)
+
 func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	if !n.beginAccept(leaseBlock.Hash) {
 		return
 	}
 	defer n.endAccept(leaseBlock.Hash)
-	retry := false
-	defer func() { n.acceptSched.record(leaseBlock.Hash, retry, time.Now()) }()
+	// Every exit defaults to retrying: a wrongly retried accept costs one
+	// cheap re-check per backoff interval, while a wrongly abandoned accept
+	// strands the lease in state `created` forever, with its escrow only
+	// recoverable by an explicit consumer lease_cancel. Exits whose failure
+	// is permanent wrap their error in terminalAcceptError to opt out.
+	var acceptErr error
+	retry := true
+	defer func() {
+		var term terminalAcceptError
+		if acceptErr == nil || errors.As(acceptErr, &term) {
+			retry = false
+		}
+		n.acceptSched.record(leaseBlock.Hash, retry, time.Now())
+	}()
 	if leaseAlreadyAccepted(n.GetLease(leaseBlock.Hash)) {
+		acceptErr = terminalAcceptError{errLeaseAlreadyAccepted}
 		return
 	}
 
+	skipProvision := false
 	if n.VMManager != nil {
 		if _, err := n.VMManager.Get(leaseBlock.Hash); err == nil {
-			return
+			// A VM from an interrupted earlier attempt is still here. Finish
+			// the accept instead of abandoning it: returning silently leaked
+			// the VM (cleanupOrphanedVMs skips leases that are still pending)
+			// while stranding the lease, and tearing down + retrying churned
+			// it. The VM serves the lease only once the lease_accept lands.
+			skipProvision = true
 		}
 	}
 
 	if err := n.acceptPolicy.Allow(leaseBlock, n.activeLeaseCount()); err != nil {
 		log.Printf("Auto-accept policy rejected lease %s: %v", shortHash(leaseBlock.Hash), err)
+		acceptErr = terminalAcceptError{err}
 		return
 	}
 
@@ -1484,13 +1529,14 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 
 	if stake > n.Ledger.GetAssetBalances(myAddr)["XUSD"] {
 		log.Printf("Cannot auto-accept lease %s: insufficient XUSD for stake", shortHash(leaseBlock.Hash))
+		acceptErr = terminalAcceptError{errAcceptStakeShortage}
 		return
 	}
 
 	attestations, err := n.acceptAttestations(leaseBlock.Hash)
 	if err != nil {
 		log.Printf("Failed to gather attestations for lease_accept %s: %v", shortHash(leaseBlock.Hash), err)
-		retry = true
+		acceptErr = transientAcceptError{err}
 		return
 	}
 
@@ -1503,6 +1549,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	certHash, err := n.acceptCertificateHash(leaseBlock, startTime)
 	if err != nil {
 		log.Printf("Cannot auto-accept lease %s: %v", shortHash(leaseBlock.Hash), err)
+		acceptErr = terminalAcceptError{err}
 		return
 	}
 
@@ -1512,6 +1559,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	if stake > xusdBal {
 		n.blockCreateMu.Unlock()
 		log.Printf("Cannot auto-accept lease %s: insufficient XUSD for stake (have %d, need %d)", shortHash(leaseBlock.Hash), xusdBal, stake)
+		acceptErr = terminalAcceptError{errAcceptStakeShortage}
 		return
 	}
 
@@ -1539,6 +1587,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 				usedVCPUs, usedMemMB, usedDiskGB,
 				leaseBlock.VCPUs, leaseBlock.MemoryMB, leaseBlock.DiskGB,
 				n.providerVCPUs, n.providerMemoryMB, n.providerDiskGB)
+			acceptErr = transientAcceptError{errAcceptNoCapacity}
 			return
 		}
 
@@ -1551,7 +1600,9 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 
 	n.blockCreateMu.Unlock()
 
-	n.provisionVM(leaseBlock)
+	if !skipProvision {
+		n.provisionVM(leaseBlock)
+	}
 
 	if n.VMManager != nil {
 		n.reservedResMu.Lock()
@@ -1564,6 +1615,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	if n.VMManager != nil {
 		if _, err := n.VMManager.Get(leaseBlock.Hash); err != nil {
 			log.Printf("Lease %s: VM provision failed, not accepting", shortHash(leaseBlock.Hash))
+			acceptErr = transientAcceptError{err}
 			return
 		}
 	}
@@ -1581,6 +1633,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 		log.Printf("Lease %s: XUSD balance changed during provisioning (have %d, need %d), tearing down",
 			shortHash(leaseBlock.Hash), xusdBal, stake)
 		n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})
+		acceptErr = transientAcceptError{errAcceptBalanceChanged}
 		return
 	}
 
@@ -1605,6 +1658,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 		n.blockCreateMu.Unlock()
 		log.Printf("Failed to sign lease_accept: %v", err)
 		n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})
+		acceptErr = transientAcceptError{err}
 		return
 	}
 	n.solvePoW(b)
@@ -1612,11 +1666,23 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	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) {
+		lease := n.GetLease(leaseBlock.Hash)
+		if shouldTeardownOnAcceptFailure(lease, myAddr) {
 			n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})
-			retry = core.IsRetryableError(err)
+			// Classify from the ledger's state, not from the error text:
+			// core.IsRetryableError's bare "not found" match calls permanent
+			// rejections retryable, and its message list misses genuine
+			// state checks. A lease record that is gone (unwound) or already
+			// taken can never accept this block; anything else (a frontier
+			// or pending-send race, a consensus hiccup) can heal.
+			if lease == nil || leaseAlreadyAccepted(lease) {
+				acceptErr = terminalAcceptError{err}
+			} else {
+				acceptErr = transientAcceptError{err}
+			}
 		} else {
 			log.Printf("Lease %s: our accept already stands on-chain, keeping VM", shortHash(leaseBlock.Hash))
+			acceptErr = terminalAcceptError{err}
 		}
 		return
 	}
@@ -1624,6 +1690,9 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 
 	if err := n.Gossip.Publish(n.ctx, b); err != nil {
 		log.Printf("Failed to publish lease_accept: %v", err)
+		// The ledger has committed the accept; only the publish failed. The
+		// lease is served and sync catches the network up - do not re-drive.
+		acceptErr = terminalAcceptError{err}
 		return
 	}
 	n.syncTracker.MarkDirty()

Regression suite

Two test files, driving the production lease-watch tick, autoAcceptLease, acceptSchedule and core.Ledger (real validation and store commits), with vm.MockManager behind the vm.Manager interface:

  • node/accept_schedule_abandon_test.go (this ticket's PoC, reworked to assert the fixed behavior):
    • TestProviderAcceptScheduleRetriesAndAcceptsAfterTransientProvisionFailure — one provision failure → done=false failures=1, due() true after the backoff, retry lands the accept, lease accepted, escrow intact;
    • TestProviderAcceptScheduleRetriesTransientAttestationFailure — control: 5 ticks → 5 attempts, backoff saturating at acceptRetryMax;
    • TestProviderAcceptScheduleDefersLeaseWhenCapacityIsTemporarilyExhausted — capacity gate defers (failures=1), restored capacity → the accept lands;
    • TestStrandedLeaseCannotBeSettledOrForceSettled — a terminal exit (certificate not held) still strands, and the ledger's state gates behave as specified;
    • TestConsumerCanCancelStrandedLeaseAndRecoverEscrow — cancel still refunds in full;
    • TestProviderAcceptLandsWhenNoTransientFailureOccurs — positive control.
  • node/retryable_accept_loop_test.go (XE-0668's PoC, node-path assertions updated):
    • TestRetryableClassifierIsLexicalNotSemantic — the classifier itself is unchanged and still lexical (its other four consumers still use it);
    • TestProviderAcceptPermanentNotFoundStopsAfterOneAttempt — the lease-record-gone + pending-send state now yields exactly 1 provision and 1 teardown, done=true; the test also records that IsRetryableError still calls the same rejection "retryable", which is precisely why the accept path must not consult it;
    • TestProviderAcceptPermanentNonNotFoundStopsAfterOneAttempt — same outcome, one attempt;
    • TestLeaseOpenUnwindMakesProviderAcceptFailWithNotFound — the production unwind still produces the rejection; the node now terminates instead of looping.

Verification (master 02e9641)

go vet ./node/                     -> clean, exit 0
go build ./...                     -> exit 0
targeted suite -v -count=1         -> 10/10 PASS (0.851s)
same -count=3                      -> PASS (1.689s)
go test ./node/ -count=1           -> ok (2.171s)
go test ./... -count=1             -> ok (net, node, statechain)

Honest bounds

  • This retires core.IsRetryableError from the accept path only. Its other consumers (api/handler.go writeSubmitError, core/quorum.go x2, net/sync.go:609) still use it; the classifier's bare "not found" match remains broken for them (XE-0668).
  • The transient/terminal split is my judgment per exit. The genuinely contestable ones: insufficient stake and balance-under-lock are classified terminal (a funded provider would recover, but the condition is operator-fixable, not self-healing); a lease_accept that is permanently invalid for reasons other than the record being gone/taken (e.g. attestation or certificate rejection at the ledger) also retries — bounded by the existing acceptRetryMax backoff, but an operator-visible "permanent" signal there would be a worthwhile follow-up.
  • The deeper gaps remain as noted in this ticket's fix-direction section: deleting done entirely (always re-drive pending-unaccepted leases) and a provider-side lease_reject would make the whole family of strands unrepresentable; both are protocol-visible changes I have not attempted.

Full patch (includes both test files, 1,494 lines) and run logs available on request.

xe:79bd74092026-11-05 16:04 UTCweb

Addendum to the patch posted above: while re-auditing the reservation window for the review, one hardening improvement went in — the reservedRes release is now a defer inside the reservation block instead of an inline release after provisionVM.

Why: the reservation (node.go, capacity section of autoAcceptLease) is taken immediately before the VM provision and released right after it. The release was inline, so any unwind between the two — a panic inside VMManager.Provision or anywhere in the block-build — skipped it, leaving the lease's resources permanently phantom-charged against the provider's capacity (the reservation feeds both the accept capacity check and the advertised-capacity calculation) until process restart. Deferred, the release survives every exit path, and the reservation stays held through the block-build, which is also slightly more conservative against concurrent accepts.

Honest scope note: as the code stands today, nothing between the reserve and the old inline release recovers a panic — both autoAcceptLease call sites are bare goroutines, so a panic there kills the whole node process first (restart clears the reservation; the leak was latent). This is hardening, not a separately exploitable defect, and is folded into the same patch rather than a new ticket. (The no-recover-on-goroutine class is XE-0107's subject.)

Updated patch (node.go part only — the regression tests are unchanged from the message above):

diff --git a/node/node.go b/node/node.go
index 2bbedc4..6ec4a98 100644
--- a/node/node.go
+++ b/node/node.go
@@ -1457,25 +1457,70 @@ func shouldTeardownOnAcceptFailure(lease *core.Lease, myAddr string) bool {
 	return !leaseAlreadyAccepted(lease) || lease.Provider != myAddr
 }
 
+// terminalAcceptError marks an autoAcceptLease failure exit that can never
+// succeed on a retry; the deferred acceptSched.record marks the lease done.
+type terminalAcceptError struct{ err error }
+
+func (e terminalAcceptError) Error() string { return e.err.Error() }
+func (e terminalAcceptError) Unwrap() error { return e.err }
+
+// transientAcceptError marks an autoAcceptLease failure exit that is expected
+// to heal on its own (capacity frees up when other leases expire, a VM boot
+// can succeed on the next attempt, a balance race resolves); the deferred
+// record schedules a retry on the acceptRetryDelay backoff. It documents the
+// classification at the failure site: the inverted default already retries
+// every exit that is not explicitly terminal.
+type transientAcceptError struct{ err error }
+
+func (e transientAcceptError) Error() string { return e.err.Error() }
+func (e transientAcceptError) Unwrap() error { return e.err }
+
+var (
+	errLeaseAlreadyAccepted = errors.New("lease already accepted")
+	errAcceptStakeShortage  = errors.New("insufficient XUSD for the lease stake")
+	errAcceptNoCapacity     = errors.New("insufficient resources for the lease")
+	errAcceptBalanceChanged = errors.New("XUSD balance changed during provisioning")
+)
+
 func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	if !n.beginAccept(leaseBlock.Hash) {
 		return
 	}
 	defer n.endAccept(leaseBlock.Hash)
-	retry := false
-	defer func() { n.acceptSched.record(leaseBlock.Hash, retry, time.Now()) }()
+	// Every exit defaults to retrying: a wrongly retried accept costs one
+	// cheap re-check per backoff interval, while a wrongly abandoned accept
+	// strands the lease in state `created` forever, with its escrow only
+	// recoverable by an explicit consumer lease_cancel. Exits whose failure
+	// is permanent wrap their error in terminalAcceptError to opt out.
+	var acceptErr error
+	retry := true
+	defer func() {
+		var term terminalAcceptError
+		if acceptErr == nil || errors.As(acceptErr, &term) {
+			retry = false
+		}
+		n.acceptSched.record(leaseBlock.Hash, retry, time.Now())
+	}()
 	if leaseAlreadyAccepted(n.GetLease(leaseBlock.Hash)) {
+		acceptErr = terminalAcceptError{errLeaseAlreadyAccepted}
 		return
 	}
 
+	skipProvision := false
 	if n.VMManager != nil {
 		if _, err := n.VMManager.Get(leaseBlock.Hash); err == nil {
-			return
+			// A VM from an interrupted earlier attempt is still here. Finish
+			// the accept instead of abandoning it: returning silently leaked
+			// the VM (cleanupOrphanedVMs skips leases that are still pending)
+			// while stranding the lease, and tearing down + retrying churned
+			// it. The VM serves the lease only once the lease_accept lands.
+			skipProvision = true
 		}
 	}
 
 	if err := n.acceptPolicy.Allow(leaseBlock, n.activeLeaseCount()); err != nil {
 		log.Printf("Auto-accept policy rejected lease %s: %v", shortHash(leaseBlock.Hash), err)
+		acceptErr = terminalAcceptError{err}
 		return
 	}
 
@@ -1484,13 +1529,14 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 
 	if stake > n.Ledger.GetAssetBalances(myAddr)["XUSD"] {
 		log.Printf("Cannot auto-accept lease %s: insufficient XUSD for stake", shortHash(leaseBlock.Hash))
+		acceptErr = terminalAcceptError{errAcceptStakeShortage}
 		return
 	}
 
 	attestations, err := n.acceptAttestations(leaseBlock.Hash)
 	if err != nil {
 		log.Printf("Failed to gather attestations for lease_accept %s: %v", shortHash(leaseBlock.Hash), err)
-		retry = true
+		acceptErr = transientAcceptError{err}
 		return
 	}
 
@@ -1503,6 +1549,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	certHash, err := n.acceptCertificateHash(leaseBlock, startTime)
 	if err != nil {
 		log.Printf("Cannot auto-accept lease %s: %v", shortHash(leaseBlock.Hash), err)
+		acceptErr = terminalAcceptError{err}
 		return
 	}
 
@@ -1512,6 +1559,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	if stake > xusdBal {
 		n.blockCreateMu.Unlock()
 		log.Printf("Cannot auto-accept lease %s: insufficient XUSD for stake (have %d, need %d)", shortHash(leaseBlock.Hash), xusdBal, stake)
+		acceptErr = terminalAcceptError{errAcceptStakeShortage}
 		return
 	}
 
@@ -1539,6 +1587,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 				usedVCPUs, usedMemMB, usedDiskGB,
 				leaseBlock.VCPUs, leaseBlock.MemoryMB, leaseBlock.DiskGB,
 				n.providerVCPUs, n.providerMemoryMB, n.providerDiskGB)
+			acceptErr = transientAcceptError{errAcceptNoCapacity}
 			return
 		}
 
@@ -1547,23 +1596,29 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 		n.reservedRes.MemoryMB += leaseBlock.MemoryMB
 		n.reservedRes.DiskGB += leaseBlock.DiskGB
 		n.reservedResMu.Unlock()
+		// Release on every exit, including a panic inside provisionVM: an
+		// inline release after the provision call leaks the reservation (the
+		// provider's capacity stays phantom-charged until restart) whenever
+		// anything in between unwinds.
+		defer func() {
+			n.reservedResMu.Lock()
+			n.reservedRes.VCPUs -= leaseBlock.VCPUs
+			n.reservedRes.MemoryMB -= leaseBlock.MemoryMB
+			n.reservedRes.DiskGB -= leaseBlock.DiskGB
+			n.reservedResMu.Unlock()
+		}()
 	}
 
 	n.blockCreateMu.Unlock()
 
-	n.provisionVM(leaseBlock)
-
-	if n.VMManager != nil {
-		n.reservedResMu.Lock()
-		n.reservedRes.VCPUs -= leaseBlock.VCPUs
-		n.reservedRes.MemoryMB -= leaseBlock.MemoryMB
-		n.reservedRes.DiskGB -= leaseBlock.DiskGB
-		n.reservedResMu.Unlock()
+	if !skipProvision {
+		n.provisionVM(leaseBlock)
 	}
 
 	if n.VMManager != nil {
 		if _, err := n.VMManager.Get(leaseBlock.Hash); err != nil {
 			log.Printf("Lease %s: VM provision failed, not accepting", shortHash(leaseBlock.Hash))
+			acceptErr = transientAcceptError{err}
 			return
 		}
 	}
@@ -1581,6 +1636,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 		log.Printf("Lease %s: XUSD balance changed during provisioning (have %d, need %d), tearing down",
 			shortHash(leaseBlock.Hash), xusdBal, stake)
 		n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})
+		acceptErr = transientAcceptError{errAcceptBalanceChanged}
 		return
 	}
 
@@ -1605,6 +1661,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 		n.blockCreateMu.Unlock()
 		log.Printf("Failed to sign lease_accept: %v", err)
 		n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})
+		acceptErr = transientAcceptError{err}
 		return
 	}
 	n.solvePoW(b)
@@ -1612,11 +1669,23 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 	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) {
+		lease := n.GetLease(leaseBlock.Hash)
+		if shouldTeardownOnAcceptFailure(lease, myAddr) {
 			n.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})
-			retry = core.IsRetryableError(err)
+			// Classify from the ledger's state, not from the error text:
+			// core.IsRetryableError's bare "not found" match calls permanent
+			// rejections retryable, and its message list misses genuine
+			// state checks. A lease record that is gone (unwound) or already
+			// taken can never accept this block; anything else (a frontier
+			// or pending-send race, a consensus hiccup) can heal.
+			if lease == nil || leaseAlreadyAccepted(lease) {
+				acceptErr = terminalAcceptError{err}
+			} else {
+				acceptErr = transientAcceptError{err}
+			}
 		} else {
 			log.Printf("Lease %s: our accept already stands on-chain, keeping VM", shortHash(leaseBlock.Hash))
+			acceptErr = terminalAcceptError{err}
 		}
 		return
 	}
@@ -1624,6 +1693,9 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {
 
 	if err := n.Gossip.Publish(n.ctx, b); err != nil {
 		log.Printf("Failed to publish lease_accept: %v", err)
+		// The ledger has committed the accept; only the publish failed. The
+		// lease is served and sync catches the network up - do not re-drive.
+		acceptErr = terminalAcceptError{err}
 		return
 	}
 	n.syncTracker.MarkDirty()

Verification re-run after the change: go vet ./node/ clean, go build ./... exit 0, go test ./node/ -count=1 ok (2.302s).

Joseph Denneteam2026-11-06 21:34 UTCdesk

Thanks for the report. We have read it against the code and it is being handled. This ticket is updated when the fix lands, and the assessment and any award follow the fix. https://bounty.xe.network/XE-0748