{"id":"XE-0748","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":210,"title":"[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)","area":"node-api","claimed_tier":null,"assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-05T15:21:33.897732+00:00","updated_at":"2026-11-06T21:34:13.287529+00:00","source_created_at":null,"told_at":"2026-11-06T21:34:13.293415+00:00","status_changed_at":"2026-11-06T21:34:08.737422+00:00","url":"https://bounty.xe.network/XE-0748","body":"# [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`\r\n\r\n## Summary\r\n\r\nA 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`:\r\n\r\n```go\r\n// node/node.go:1460-1466\r\nfunc (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n\tif !n.beginAccept(leaseBlock.Hash) {\r\n\t\treturn\r\n\t}\r\n\tdefer n.endAccept(leaseBlock.Hash)\r\n\tretry := false\r\n\tdefer func() { n.acceptSched.record(leaseBlock.Hash, retry, time.Now()) }()\r\n```\r\n\r\n`record(hash, retry=false)` marks the lease **done** and the tick never looks at it again:\r\n\r\n```go\r\n// node/node.go:1719-1724\r\nfunc (s *acceptSchedule) due(leaseHash string, now time.Time) bool {\r\n\t...\r\n\treturn !ok || (!st.done && !now.Before(st.next))\r\n}\r\n\r\n// node/node.go:1726-1745\r\nfunc (s *acceptSchedule) record(leaseHash string, retry bool, now time.Time) {\r\n\t...\r\n\tif !retry {\r\n\t\tst.done = true\r\n\t\treturn\r\n\t}\r\n\t...\r\n}\r\n```\r\n\r\n`retry` is set to `true` at **exactly two** of the roughly ten failure exits of `autoAcceptLease`:\r\n\r\n| exit | failure | sets `retry = true`? |\r\n|---|---|---|\r\n| `node/node.go:1471-1475` | a VM for this lease already exists | no |\r\n| `node/node.go:1477-1480` | the accept policy rejected the lease | no |\r\n| `node/node.go:1485-1488` | not enough XUSD for the stake | no |\r\n| **`node/node.go:1490-1495`** | attestation gathering failed | **yes (`:1493`)** |\r\n| `node/node.go:1503-1507` | the pinned performance certificate is unusable | no |\r\n| `node/node.go:1512-1516` | the balance changed under the lock | no |\r\n| **`node/node.go:1533-1543`** | **insufficient resources (capacity)** | **no** |\r\n| **`node/node.go:1564-1569`** | **the VM provision failed** | **no** |\r\n| `node/node.go:1579-1585` | the balance changed during provisioning | no |\r\n| `node/node.go:1604-1609` | signing the `lease_accept` failed | no |\r\n| **`node/node.go:1612-1622`** | the ledger rejected the `lease_accept` | **yes, iff `core.IsRetryableError(err)` (`:1617`)** |\r\n\r\nThe 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.\r\n\r\nThe consequence is that the lease is stranded in state `created` permanently:\r\n\r\n- **not settleable** — `core/ledger.go:2142-2147` requires state `accepted` (`lease not yet accepted for settle (state created): retry after accept`);\r\n- **not force-settleable** — `core/ledger.go:1914-1920` requires state `accepted` (`lease not yet accepted for force-settle (state created): retry after accept`);\r\n- **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;\r\n- **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.\r\n\r\nUntil 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.\r\n\r\n## Relation to XE-0668 (my own ticket) — the opposite direction on the same boolean\r\n\r\n**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.\r\n\r\n**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`.\r\n\r\n## Affected component and versions\r\n\r\n- `xeprotocol/xe`, `master` @ `02e9641` (`Merge pull request #251 from xeprotocol/fix/dao-tool-timestamp`). **No PR is required.**\r\n- 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.\r\n- 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`).\r\n\r\n## Root cause\r\n\r\n### 1. The scheduler has one input, and 8 of ~10 exits never write it\r\n\r\n`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:\r\n\r\n- **`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.\r\n- **`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.\r\n- **`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.\r\n\r\n### 2. The exits that DO set `retry = true` prove the mechanism is otherwise intact\r\n\r\n`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.\r\n\r\n### 3. Nothing else re-drives a stranded lease\r\n\r\n`leaseWatchTick` (`node/node.go:1670-1699`) is the only driver, and its first test is `acceptSched.due(...)`:\r\n\r\n```go\r\n// node/node.go:1676\r\nif !n.acceptSched.due(p.SendHash, now) || n.acceptRunning(p.SendHash) {\r\n    continue\r\n}\r\n```\r\n\r\nWith `st.done == true`, `due()` is false forever (`node/node.go:1719-1724`), so the tick `continue`s 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.\r\n\r\n### 4. No other path can rescue the lease\r\n\r\n| node-side pass | filter | reaches a `created` lease? |\r\n|---|---|---|\r\n| `trySettleExpiredLeases` (`:1796-1823`) | `lease.State != core.LeaseAccepted` → skip (`:1809`) | no |\r\n| `tryForceSettleStaleLeases` (`:1836-1853`) | `lease.State != core.LeaseAccepted` → skip (`:1829`) | no |\r\n| `tryArchiveExpiredLeases` (`:1863-1879`) | `lease.State != core.LeaseAccepted` → skip (`:1856`) | no |\r\n| `cleanupOrphanedVMs` (`:1773-1794`) | acts on VMs, and no VM exists here | no |\r\n| consumer's `lease_force_settle` | `core/ledger.go:1914-1920` state gate | rejected |\r\n| provider's `lease_settle` | `core/ledger.go:2142-2147` state gate | rejected |\r\n| **consumer's `lease_cancel`** | `core/ledger.go:1792-1876`, expects state `created` (`:1866`) | **the only one that works** |\r\n\r\n## Reproduction\r\n\r\nDeterministic 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.\r\n\r\n```\r\ngo test ./node/ -run 'TestProviderAcceptSchedule|TestStrandedLease|TestConsumerCanCancelStranded|TestProviderAcceptLands' -v -count=1\r\n```\r\n\r\nVerbatim output (passing run; log timestamps and hashes differ between runs):\r\n\r\n```\r\n=== RUN   TestProviderAcceptScheduleAbandonsLeaseAfterTransientProvisionFailure\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 4f3cbb589e55..., auto-accepting\r\n2026/11/05 21:44:52 VM provision failed for lease 4f3cbb589e55...: limactl start timed out after 5m0s\r\n2026/11/05 21:44:52 Lease 4f3cbb589e55...: VM provision failed, not accepting\r\n    accept_schedule_abandon_test.go:386: STEP 1: the first lease-watch tick drove the accept; the VM provision failed (a transient error)\r\n    accept_schedule_abandon_test.go:397: STEP 2: acceptSchedule: done=true failures=0 - the transient provision failure was recorded as a TERMINAL outcome\r\n    accept_schedule_abandon_test.go:404: STEP 3: acceptSched.due() is false forever - the lease-watch tick will never re-drive it\r\n    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)\r\n    accept_schedule_abandon_test.go:425: STEP 5: lease state=\"created\", provider chain holds 0 lease_accept block(s) - the tenant never gets compute\r\n    accept_schedule_abandon_test.go:436: STEP 6: the consumer's escrow is still pending: 667 XUSD from dfe702e49522... to 9eec1ac436d6...\r\nABANDONMENT CONFIRMED: one transient VM-provision failure permanently strands the lease - the provider never retries it\r\n--- PASS: TestProviderAcceptScheduleAbandonsLeaseAfterTransientProvisionFailure (0.01s)\r\n=== RUN   TestProviderAcceptScheduleRetriesTransientAttestationFailure\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting\r\n2026/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\r\n2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 5s\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting\r\n2026/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\r\n2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 20s\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting\r\n2026/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\r\n2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 40s\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting\r\n2026/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\r\n2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 1m20s\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 366d5e627bf5..., auto-accepting\r\n2026/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\r\n2026/11/05 21:44:52 Lease 366d5e627bf5...: retrying accept in 2m40s\r\n    accept_schedule_abandon_test.go:481: CONTROL: 5 ticks -> 5 accept attempts, acceptSchedule done=false failures=5 next-delay=2m40s (saturated at acceptRetryMax=2m40s)\r\n    accept_schedule_abandon_test.go:483:         acceptSched.due() stays true: the scheduler re-drives the lease on every tick\r\nCONTROL CONFIRMED: the same scheduler DOES retry a failure that sets retry=true - only the transient exits that do not set it are stranded\r\n--- PASS: TestProviderAcceptScheduleRetriesTransientAttestationFailure (0.00s)\r\n=== RUN   TestProviderAcceptScheduleAbandonsLeaseWhenCapacityIsTemporarilyExhausted\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 57cfc845564d..., auto-accepting\r\n2026/11/05 21:44:52 Cannot auto-accept lease 57cfc845564d...: insufficient resources (used 0/0/0 + req 1/1024/10 > cap 0/8192/100)\r\n    accept_schedule_abandon_test.go:509: STEP 1: capacity exhausted -> the accept was abandoned (done=true failures=0), no VM was ever provisioned\r\n    accept_schedule_abandon_test.go:526: STEP 2: capacity restored -> 20 further ticks produced 0 provision attempts; lease state=\"created\", 0 lease_accept blocks\r\nCAPACITY STRAND CONFIRMED: a temporary capacity rejection strands the lease exactly like a provision failure\r\n--- PASS: TestProviderAcceptScheduleAbandonsLeaseWhenCapacityIsTemporarilyExhausted (0.00s)\r\n```\r\n\r\n```\r\n=== RUN   TestStrandedLeaseCannotBeSettledOrForceSettled\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease 5f91a59a8698..., auto-accepting\r\n2026/11/05 21:44:52 VM provision failed for lease 5f91a59a8698...: limactl start timed out after 5m0s\r\n2026/11/05 21:44:52 Lease 5f91a59a8698...: VM provision failed, not accepting\r\n    accept_schedule_abandon_test.go:559: STEP 1: consumer lease_force_settle -> lease not yet accepted for force-settle (state created): retry after accept\r\n    accept_schedule_abandon_test.go:575: STEP 2: provider lease_settle -> lease not yet accepted for settle (state created): retry after accept\r\n    accept_schedule_abandon_test.go:581: STEP 3: escrow still pending: 667 XUSD locked\r\nSTRANDED CONFIRMED: neither the consumer nor the provider can settle or force-settle the stranded lease\r\n--- PASS: TestStrandedLeaseCannotBeSettledOrForceSettled (0.00s)\r\n=== RUN   TestConsumerCanCancelStrandedLeaseAndRecoverEscrow\r\n2026/11/05 21:44:52 Lease watch: found unaccepted lease e76d423718d5..., auto-accepting\r\n2026/11/05 21:44:52 VM provision failed for lease e76d423718d5...: limactl start timed out after 5m0s\r\n2026/11/05 21:44:52 Lease e76d423718d5...: VM provision failed, not accepting\r\n    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)\r\n    accept_schedule_abandon_test.go:622: STEP 2: consumer lease_cancel -> balance restored to 10000000, escrow released\r\nHONEST BOUND CONFIRMED: the consumer can cancel the stranded lease and recover the escrow - the loss is the tenant's compute window, not the funds\r\n--- PASS: TestConsumerCanCancelStrandedLeaseAndRecoverEscrow (0.00s)\r\n=== RUN   TestProviderAcceptLandsWhenNoTransientFailureOccurs\r\n2026/11/05 21:44:52 VM provisioned for lease c3888e097f9d... (user=xe-8809c206)\r\n2026/11/05 21:44:52 Could not find consumer peer for account 5863e5bd066a...\r\n    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\r\n    accept_schedule_abandon_test.go:659: POSITIVE CONTROL: no transient failure -> the lease_accept lands, lease state=\"accepted\"\r\nPOSITIVE CONTROL CONFIRMED: the accept path itself is healthy - the strand is caused by the missing retry=true on the transient exits\r\n--- PASS: TestProviderAcceptLandsWhenNoTransientFailureOccurs (0.00s)\r\nPASS\r\nok  \tgithub.com/xeprotocol/xe/node\t1.022s\r\n```\r\n\r\n(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.)\r\n\r\n### What each test establishes\r\n\r\n| Test | What it shows |\r\n|---|---|\r\n| `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. |\r\n| `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. |\r\n| `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. |\r\n| `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. |\r\n| `ConsumerCanCancelStrandedLeaseAndRecoverEscrow` | The consumer's explicit `lease_cancel` is accepted and the escrow is refunded in full — the honest bound. |\r\n| `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`. |\r\n\r\n### Reproducibility matrix\r\n\r\n| run | command | result |\r\n|---|---|---|\r\n| 1 | `-run 'TestProviderAcceptSchedule\\|TestStrandedLease\\|TestConsumerCanCancelStranded\\|TestProviderAcceptLands' -v -count=1` | 6/6 PASS |\r\n| 2 | same, `-count=3` | PASS (`ok github.com/xeprotocol/xe/node 0.293s`) |\r\n| 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`) |\r\n| 4 | `go vet ./node/` | clean, exit 0 |\r\n\r\nThe PoC is deterministic: fixed keys, a fake clock, real ledger validation, no network, no sleeps.\r\n\r\n## Impact\r\n\r\n- **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.\r\n- **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.\r\n- **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\".\r\n- **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.\r\n\r\n## Honest bounds (what is *not* claimed)\r\n\r\n- **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.\r\n- **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.)\r\n- **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.\r\n- **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.\r\n- **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`.\r\n- **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.\r\n- **Single-provider, single-lease scope.** The PoC uses one consumer and one provider. Multi-lease capacity interactions were not simulated.\r\n- **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.\r\n\r\n## Suggested fix direction\r\n\r\n1. **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.\r\n2. **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.\r\n3. **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.\r\n4. **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\".\r\n5. **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.\r\n\r\n## Dedup\r\n\r\nAll **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.\r\n\r\n**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:\r\n\r\n- **XE-0668** (mine) — permanent rejections classified retryable → unbounded retry and VM churn. Opposite direction on the same boolean.\r\n- **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.\r\n- **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.)\r\n- **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).\r\n- **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.\r\n- **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.\r\n- **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.\r\n\r\nOpen PRs checked and confirmed **not** to fix this:\r\n\r\n- **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.\r\n- **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).\r\n- **PR #28** only re-indents the `n.autoAcceptLease(b)` call site; **PR #192** and **PR #203** do not touch the accept path at all.\r\n\r\nNo 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.\r\n\r\n## Artifacts\r\n\r\n- PoC: `node/accept_schedule_abandon_test.go` — six tests: `TestProviderAcceptScheduleAbandonsLeaseAfterTransientProvisionFailure`, `TestProviderAcceptScheduleRetriesTransientAttestationFailure` (control), `TestProviderAcceptScheduleAbandonsLeaseWhenCapacityIsTemporarilyExhausted`, `TestStrandedLeaseCannotBeSettledOrForceSettled`, `TestConsumerCanCancelStrandedLeaseAndRecoverEscrow`, `TestProviderAcceptLandsWhenNoTransientFailureOccurs` (positive control).\r\n- 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).\r\n- 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).\r\n- Base commit: `master` @ `02e9641`.","patch_refs":[],"thread":[{"id":291,"source":"web","source_ref":"reporter:210:0b3c725509146b06","author":"xe:79bd7409","team":false,"body":"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`.\n\n## The fix (summary)\n\nThree changes to `node/node.go`'s `autoAcceptLease`, all on the production accept path:\n\n1. **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.\n2. **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.\n3. **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.\n\nTwo behavioral repairs ride along:\n\n- **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.\n- **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.\n\nClassification per exit:\n\n| exit | classification |\n|---|---|\n| lease already accepted | terminal |\n| a VM for the lease already exists | *(finish the accept â€” see above)* |\n| accept policy rejected | terminal |\n| insufficient XUSD for stake (both sites) | terminal |\n| attestation gathering failed | transient |\n| pinned certificate unusable | terminal |\n| capacity exhausted | transient |\n| VM provision failed | transient |\n| balance changed during provisioning | transient |\n| sign failed | transient |\n| `AddBlock` rejected, lease record gone or taken | terminal |\n| `AddBlock` rejected, record still present and unaccepted | transient |\n| gossip publish failed after commit | terminal |\n\n## Patch â€” node/node.go\n\n```diff\ndiff --git a/node/node.go b/node/node.go\r\nindex 2bbedc4..a0a44af 100644\r\n--- a/node/node.go\r\n+++ b/node/node.go\r\n@@ -1457,25 +1457,70 @@ func shouldTeardownOnAcceptFailure(lease *core.Lease, myAddr string) bool {\r\n \treturn !leaseAlreadyAccepted(lease) || lease.Provider != myAddr\r\n }\r\n \r\n+// terminalAcceptError marks an autoAcceptLease failure exit that can never\r\n+// succeed on a retry; the deferred acceptSched.record marks the lease done.\r\n+type terminalAcceptError struct{ err error }\r\n+\r\n+func (e terminalAcceptError) Error() string { return e.err.Error() }\r\n+func (e terminalAcceptError) Unwrap() error { return e.err }\r\n+\r\n+// transientAcceptError marks an autoAcceptLease failure exit that is expected\r\n+// to heal on its own (capacity frees up when other leases expire, a VM boot\r\n+// can succeed on the next attempt, a balance race resolves); the deferred\r\n+// record schedules a retry on the acceptRetryDelay backoff. It documents the\r\n+// classification at the failure site: the inverted default already retries\r\n+// every exit that is not explicitly terminal.\r\n+type transientAcceptError struct{ err error }\r\n+\r\n+func (e transientAcceptError) Error() string { return e.err.Error() }\r\n+func (e transientAcceptError) Unwrap() error { return e.err }\r\n+\r\n+var (\r\n+\terrLeaseAlreadyAccepted = errors.New(\"lease already accepted\")\r\n+\terrAcceptStakeShortage  = errors.New(\"insufficient XUSD for the lease stake\")\r\n+\terrAcceptNoCapacity     = errors.New(\"insufficient resources for the lease\")\r\n+\terrAcceptBalanceChanged = errors.New(\"XUSD balance changed during provisioning\")\r\n+)\r\n+\r\n func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tif !n.beginAccept(leaseBlock.Hash) {\r\n \t\treturn\r\n \t}\r\n \tdefer n.endAccept(leaseBlock.Hash)\r\n-\tretry := false\r\n-\tdefer func() { n.acceptSched.record(leaseBlock.Hash, retry, time.Now()) }()\r\n+\t// Every exit defaults to retrying: a wrongly retried accept costs one\r\n+\t// cheap re-check per backoff interval, while a wrongly abandoned accept\r\n+\t// strands the lease in state `created` forever, with its escrow only\r\n+\t// recoverable by an explicit consumer lease_cancel. Exits whose failure\r\n+\t// is permanent wrap their error in terminalAcceptError to opt out.\r\n+\tvar acceptErr error\r\n+\tretry := true\r\n+\tdefer func() {\r\n+\t\tvar term terminalAcceptError\r\n+\t\tif acceptErr == nil || errors.As(acceptErr, &term) {\r\n+\t\t\tretry = false\r\n+\t\t}\r\n+\t\tn.acceptSched.record(leaseBlock.Hash, retry, time.Now())\r\n+\t}()\r\n \tif leaseAlreadyAccepted(n.GetLease(leaseBlock.Hash)) {\r\n+\t\tacceptErr = terminalAcceptError{errLeaseAlreadyAccepted}\r\n \t\treturn\r\n \t}\r\n \r\n+\tskipProvision := false\r\n \tif n.VMManager != nil {\r\n \t\tif _, err := n.VMManager.Get(leaseBlock.Hash); err == nil {\r\n-\t\t\treturn\r\n+\t\t\t// A VM from an interrupted earlier attempt is still here. Finish\r\n+\t\t\t// the accept instead of abandoning it: returning silently leaked\r\n+\t\t\t// the VM (cleanupOrphanedVMs skips leases that are still pending)\r\n+\t\t\t// while stranding the lease, and tearing down + retrying churned\r\n+\t\t\t// it. The VM serves the lease only once the lease_accept lands.\r\n+\t\t\tskipProvision = true\r\n \t\t}\r\n \t}\r\n \r\n \tif err := n.acceptPolicy.Allow(leaseBlock, n.activeLeaseCount()); err != nil {\r\n \t\tlog.Printf(\"Auto-accept policy rejected lease %s: %v\", shortHash(leaseBlock.Hash), err)\r\n+\t\tacceptErr = terminalAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1484,13 +1529,14 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \r\n \tif stake > n.Ledger.GetAssetBalances(myAddr)[\"XUSD\"] {\r\n \t\tlog.Printf(\"Cannot auto-accept lease %s: insufficient XUSD for stake\", shortHash(leaseBlock.Hash))\r\n+\t\tacceptErr = terminalAcceptError{errAcceptStakeShortage}\r\n \t\treturn\r\n \t}\r\n \r\n \tattestations, err := n.acceptAttestations(leaseBlock.Hash)\r\n \tif err != nil {\r\n \t\tlog.Printf(\"Failed to gather attestations for lease_accept %s: %v\", shortHash(leaseBlock.Hash), err)\r\n-\t\tretry = true\r\n+\t\tacceptErr = transientAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1503,6 +1549,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tcertHash, err := n.acceptCertificateHash(leaseBlock, startTime)\r\n \tif err != nil {\r\n \t\tlog.Printf(\"Cannot auto-accept lease %s: %v\", shortHash(leaseBlock.Hash), err)\r\n+\t\tacceptErr = terminalAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1512,6 +1559,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tif stake > xusdBal {\r\n \t\tn.blockCreateMu.Unlock()\r\n \t\tlog.Printf(\"Cannot auto-accept lease %s: insufficient XUSD for stake (have %d, need %d)\", shortHash(leaseBlock.Hash), xusdBal, stake)\r\n+\t\tacceptErr = terminalAcceptError{errAcceptStakeShortage}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1539,6 +1587,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \t\t\t\tusedVCPUs, usedMemMB, usedDiskGB,\r\n \t\t\t\tleaseBlock.VCPUs, leaseBlock.MemoryMB, leaseBlock.DiskGB,\r\n \t\t\t\tn.providerVCPUs, n.providerMemoryMB, n.providerDiskGB)\r\n+\t\t\tacceptErr = transientAcceptError{errAcceptNoCapacity}\r\n \t\t\treturn\r\n \t\t}\r\n \r\n@@ -1551,7 +1600,9 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \r\n \tn.blockCreateMu.Unlock()\r\n \r\n-\tn.provisionVM(leaseBlock)\r\n+\tif !skipProvision {\r\n+\t\tn.provisionVM(leaseBlock)\r\n+\t}\r\n \r\n \tif n.VMManager != nil {\r\n \t\tn.reservedResMu.Lock()\r\n@@ -1564,6 +1615,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tif n.VMManager != nil {\r\n \t\tif _, err := n.VMManager.Get(leaseBlock.Hash); err != nil {\r\n \t\t\tlog.Printf(\"Lease %s: VM provision failed, not accepting\", shortHash(leaseBlock.Hash))\r\n+\t\t\tacceptErr = transientAcceptError{err}\r\n \t\t\treturn\r\n \t\t}\r\n \t}\r\n@@ -1581,6 +1633,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \t\tlog.Printf(\"Lease %s: XUSD balance changed during provisioning (have %d, need %d), tearing down\",\r\n \t\t\tshortHash(leaseBlock.Hash), xusdBal, stake)\r\n \t\tn.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})\r\n+\t\tacceptErr = transientAcceptError{errAcceptBalanceChanged}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1605,6 +1658,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \t\tn.blockCreateMu.Unlock()\r\n \t\tlog.Printf(\"Failed to sign lease_accept: %v\", err)\r\n \t\tn.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})\r\n+\t\tacceptErr = transientAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \tn.solvePoW(b)\r\n@@ -1612,11 +1666,23 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tif err := n.Ledger.AddBlock(b); err != nil {\r\n \t\tn.blockCreateMu.Unlock()\r\n \t\tlog.Printf(\"Failed to add lease_accept: %v\", err)\r\n-\t\tif shouldTeardownOnAcceptFailure(n.GetLease(leaseBlock.Hash), myAddr) {\r\n+\t\tlease := n.GetLease(leaseBlock.Hash)\r\n+\t\tif shouldTeardownOnAcceptFailure(lease, myAddr) {\r\n \t\t\tn.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})\r\n-\t\t\tretry = core.IsRetryableError(err)\r\n+\t\t\t// Classify from the ledger's state, not from the error text:\r\n+\t\t\t// core.IsRetryableError's bare \"not found\" match calls permanent\r\n+\t\t\t// rejections retryable, and its message list misses genuine\r\n+\t\t\t// state checks. A lease record that is gone (unwound) or already\r\n+\t\t\t// taken can never accept this block; anything else (a frontier\r\n+\t\t\t// or pending-send race, a consensus hiccup) can heal.\r\n+\t\t\tif lease == nil || leaseAlreadyAccepted(lease) {\r\n+\t\t\t\tacceptErr = terminalAcceptError{err}\r\n+\t\t\t} else {\r\n+\t\t\t\tacceptErr = transientAcceptError{err}\r\n+\t\t\t}\r\n \t\t} else {\r\n \t\t\tlog.Printf(\"Lease %s: our accept already stands on-chain, keeping VM\", shortHash(leaseBlock.Hash))\r\n+\t\t\tacceptErr = terminalAcceptError{err}\r\n \t\t}\r\n \t\treturn\r\n \t}\r\n@@ -1624,6 +1690,9 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \r\n \tif err := n.Gossip.Publish(n.ctx, b); err != nil {\r\n \t\tlog.Printf(\"Failed to publish lease_accept: %v\", err)\r\n+\t\t// The ledger has committed the accept; only the publish failed. The\r\n+\t\t// lease is served and sync catches the network up - do not re-drive.\r\n+\t\tacceptErr = terminalAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \tn.syncTracker.MarkDirty()\n```\n\n## Regression suite\n\nTwo 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:\n\n- `node/accept_schedule_abandon_test.go` (this ticket's PoC, reworked to assert the fixed behavior):\n  - `TestProviderAcceptScheduleRetriesAndAcceptsAfterTransientProvisionFailure` â€” one provision failure â†’ `done=false failures=1`, `due()` true after the backoff, retry lands the accept, lease `accepted`, escrow intact;\n  - `TestProviderAcceptScheduleRetriesTransientAttestationFailure` â€” control: 5 ticks â†’ 5 attempts, backoff saturating at `acceptRetryMax`;\n  - `TestProviderAcceptScheduleDefersLeaseWhenCapacityIsTemporarilyExhausted` â€” capacity gate defers (`failures=1`), restored capacity â†’ the accept lands;\n  - `TestStrandedLeaseCannotBeSettledOrForceSettled` â€” a *terminal* exit (certificate not held) still strands, and the ledger's state gates behave as specified;\n  - `TestConsumerCanCancelStrandedLeaseAndRecoverEscrow` â€” cancel still refunds in full;\n  - `TestProviderAcceptLandsWhenNoTransientFailureOccurs` â€” positive control.\n- `node/retryable_accept_loop_test.go` (XE-0668's PoC, node-path assertions updated):\n  - `TestRetryableClassifierIsLexicalNotSemantic` â€” the classifier itself is unchanged and still lexical (its other four consumers still use it);\n  - `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;\n  - `TestProviderAcceptPermanentNonNotFoundStopsAfterOneAttempt` â€” same outcome, one attempt;\n  - `TestLeaseOpenUnwindMakesProviderAcceptFailWithNotFound` â€” the production unwind still produces the rejection; the node now terminates instead of looping.\n\n## Verification (master `02e9641`)\n\n```\ngo vet ./node/                     -> clean, exit 0\ngo build ./...                     -> exit 0\ntargeted suite -v -count=1         -> 10/10 PASS (0.851s)\nsame -count=3                      -> PASS (1.689s)\ngo test ./node/ -count=1           -> ok (2.171s)\ngo test ./... -count=1             -> ok (net, node, statechain)\n```\n\n## Honest bounds\n\n- 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).\n- 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.\n- 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.\n\nFull patch (includes both test files, 1,494 lines) and run logs available on request.","created_at":"2026-11-05T15:53:31.659950+00:00"},{"id":300,"source":"web","source_ref":"reporter:210:a7cc9c559bad9d34","author":"xe:79bd7409","team":false,"body":"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`.\n\n**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.\n\nHonest 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.)\n\nUpdated patch (node.go part only â€” the regression tests are unchanged from the message above):\n\n```diff\ndiff --git a/node/node.go b/node/node.go\r\nindex 2bbedc4..6ec4a98 100644\r\n--- a/node/node.go\r\n+++ b/node/node.go\r\n@@ -1457,25 +1457,70 @@ func shouldTeardownOnAcceptFailure(lease *core.Lease, myAddr string) bool {\r\n \treturn !leaseAlreadyAccepted(lease) || lease.Provider != myAddr\r\n }\r\n \r\n+// terminalAcceptError marks an autoAcceptLease failure exit that can never\r\n+// succeed on a retry; the deferred acceptSched.record marks the lease done.\r\n+type terminalAcceptError struct{ err error }\r\n+\r\n+func (e terminalAcceptError) Error() string { return e.err.Error() }\r\n+func (e terminalAcceptError) Unwrap() error { return e.err }\r\n+\r\n+// transientAcceptError marks an autoAcceptLease failure exit that is expected\r\n+// to heal on its own (capacity frees up when other leases expire, a VM boot\r\n+// can succeed on the next attempt, a balance race resolves); the deferred\r\n+// record schedules a retry on the acceptRetryDelay backoff. It documents the\r\n+// classification at the failure site: the inverted default already retries\r\n+// every exit that is not explicitly terminal.\r\n+type transientAcceptError struct{ err error }\r\n+\r\n+func (e transientAcceptError) Error() string { return e.err.Error() }\r\n+func (e transientAcceptError) Unwrap() error { return e.err }\r\n+\r\n+var (\r\n+\terrLeaseAlreadyAccepted = errors.New(\"lease already accepted\")\r\n+\terrAcceptStakeShortage  = errors.New(\"insufficient XUSD for the lease stake\")\r\n+\terrAcceptNoCapacity     = errors.New(\"insufficient resources for the lease\")\r\n+\terrAcceptBalanceChanged = errors.New(\"XUSD balance changed during provisioning\")\r\n+)\r\n+\r\n func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tif !n.beginAccept(leaseBlock.Hash) {\r\n \t\treturn\r\n \t}\r\n \tdefer n.endAccept(leaseBlock.Hash)\r\n-\tretry := false\r\n-\tdefer func() { n.acceptSched.record(leaseBlock.Hash, retry, time.Now()) }()\r\n+\t// Every exit defaults to retrying: a wrongly retried accept costs one\r\n+\t// cheap re-check per backoff interval, while a wrongly abandoned accept\r\n+\t// strands the lease in state `created` forever, with its escrow only\r\n+\t// recoverable by an explicit consumer lease_cancel. Exits whose failure\r\n+\t// is permanent wrap their error in terminalAcceptError to opt out.\r\n+\tvar acceptErr error\r\n+\tretry := true\r\n+\tdefer func() {\r\n+\t\tvar term terminalAcceptError\r\n+\t\tif acceptErr == nil || errors.As(acceptErr, &term) {\r\n+\t\t\tretry = false\r\n+\t\t}\r\n+\t\tn.acceptSched.record(leaseBlock.Hash, retry, time.Now())\r\n+\t}()\r\n \tif leaseAlreadyAccepted(n.GetLease(leaseBlock.Hash)) {\r\n+\t\tacceptErr = terminalAcceptError{errLeaseAlreadyAccepted}\r\n \t\treturn\r\n \t}\r\n \r\n+\tskipProvision := false\r\n \tif n.VMManager != nil {\r\n \t\tif _, err := n.VMManager.Get(leaseBlock.Hash); err == nil {\r\n-\t\t\treturn\r\n+\t\t\t// A VM from an interrupted earlier attempt is still here. Finish\r\n+\t\t\t// the accept instead of abandoning it: returning silently leaked\r\n+\t\t\t// the VM (cleanupOrphanedVMs skips leases that are still pending)\r\n+\t\t\t// while stranding the lease, and tearing down + retrying churned\r\n+\t\t\t// it. The VM serves the lease only once the lease_accept lands.\r\n+\t\t\tskipProvision = true\r\n \t\t}\r\n \t}\r\n \r\n \tif err := n.acceptPolicy.Allow(leaseBlock, n.activeLeaseCount()); err != nil {\r\n \t\tlog.Printf(\"Auto-accept policy rejected lease %s: %v\", shortHash(leaseBlock.Hash), err)\r\n+\t\tacceptErr = terminalAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1484,13 +1529,14 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \r\n \tif stake > n.Ledger.GetAssetBalances(myAddr)[\"XUSD\"] {\r\n \t\tlog.Printf(\"Cannot auto-accept lease %s: insufficient XUSD for stake\", shortHash(leaseBlock.Hash))\r\n+\t\tacceptErr = terminalAcceptError{errAcceptStakeShortage}\r\n \t\treturn\r\n \t}\r\n \r\n \tattestations, err := n.acceptAttestations(leaseBlock.Hash)\r\n \tif err != nil {\r\n \t\tlog.Printf(\"Failed to gather attestations for lease_accept %s: %v\", shortHash(leaseBlock.Hash), err)\r\n-\t\tretry = true\r\n+\t\tacceptErr = transientAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1503,6 +1549,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tcertHash, err := n.acceptCertificateHash(leaseBlock, startTime)\r\n \tif err != nil {\r\n \t\tlog.Printf(\"Cannot auto-accept lease %s: %v\", shortHash(leaseBlock.Hash), err)\r\n+\t\tacceptErr = terminalAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1512,6 +1559,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tif stake > xusdBal {\r\n \t\tn.blockCreateMu.Unlock()\r\n \t\tlog.Printf(\"Cannot auto-accept lease %s: insufficient XUSD for stake (have %d, need %d)\", shortHash(leaseBlock.Hash), xusdBal, stake)\r\n+\t\tacceptErr = terminalAcceptError{errAcceptStakeShortage}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1539,6 +1587,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \t\t\t\tusedVCPUs, usedMemMB, usedDiskGB,\r\n \t\t\t\tleaseBlock.VCPUs, leaseBlock.MemoryMB, leaseBlock.DiskGB,\r\n \t\t\t\tn.providerVCPUs, n.providerMemoryMB, n.providerDiskGB)\r\n+\t\t\tacceptErr = transientAcceptError{errAcceptNoCapacity}\r\n \t\t\treturn\r\n \t\t}\r\n \r\n@@ -1547,23 +1596,29 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \t\tn.reservedRes.MemoryMB += leaseBlock.MemoryMB\r\n \t\tn.reservedRes.DiskGB += leaseBlock.DiskGB\r\n \t\tn.reservedResMu.Unlock()\r\n+\t\t// Release on every exit, including a panic inside provisionVM: an\r\n+\t\t// inline release after the provision call leaks the reservation (the\r\n+\t\t// provider's capacity stays phantom-charged until restart) whenever\r\n+\t\t// anything in between unwinds.\r\n+\t\tdefer func() {\r\n+\t\t\tn.reservedResMu.Lock()\r\n+\t\t\tn.reservedRes.VCPUs -= leaseBlock.VCPUs\r\n+\t\t\tn.reservedRes.MemoryMB -= leaseBlock.MemoryMB\r\n+\t\t\tn.reservedRes.DiskGB -= leaseBlock.DiskGB\r\n+\t\t\tn.reservedResMu.Unlock()\r\n+\t\t}()\r\n \t}\r\n \r\n \tn.blockCreateMu.Unlock()\r\n \r\n-\tn.provisionVM(leaseBlock)\r\n-\r\n-\tif n.VMManager != nil {\r\n-\t\tn.reservedResMu.Lock()\r\n-\t\tn.reservedRes.VCPUs -= leaseBlock.VCPUs\r\n-\t\tn.reservedRes.MemoryMB -= leaseBlock.MemoryMB\r\n-\t\tn.reservedRes.DiskGB -= leaseBlock.DiskGB\r\n-\t\tn.reservedResMu.Unlock()\r\n+\tif !skipProvision {\r\n+\t\tn.provisionVM(leaseBlock)\r\n \t}\r\n \r\n \tif n.VMManager != nil {\r\n \t\tif _, err := n.VMManager.Get(leaseBlock.Hash); err != nil {\r\n \t\t\tlog.Printf(\"Lease %s: VM provision failed, not accepting\", shortHash(leaseBlock.Hash))\r\n+\t\t\tacceptErr = transientAcceptError{err}\r\n \t\t\treturn\r\n \t\t}\r\n \t}\r\n@@ -1581,6 +1636,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \t\tlog.Printf(\"Lease %s: XUSD balance changed during provisioning (have %d, need %d), tearing down\",\r\n \t\t\tshortHash(leaseBlock.Hash), xusdBal, stake)\r\n \t\tn.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})\r\n+\t\tacceptErr = transientAcceptError{errAcceptBalanceChanged}\r\n \t\treturn\r\n \t}\r\n \r\n@@ -1605,6 +1661,7 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \t\tn.blockCreateMu.Unlock()\r\n \t\tlog.Printf(\"Failed to sign lease_accept: %v\", err)\r\n \t\tn.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})\r\n+\t\tacceptErr = transientAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \tn.solvePoW(b)\r\n@@ -1612,11 +1669,23 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \tif err := n.Ledger.AddBlock(b); err != nil {\r\n \t\tn.blockCreateMu.Unlock()\r\n \t\tlog.Printf(\"Failed to add lease_accept: %v\", err)\r\n-\t\tif shouldTeardownOnAcceptFailure(n.GetLease(leaseBlock.Hash), myAddr) {\r\n+\t\tlease := n.GetLease(leaseBlock.Hash)\r\n+\t\tif shouldTeardownOnAcceptFailure(lease, myAddr) {\r\n \t\t\tn.teardownVM(&core.Lease{LeaseHash: leaseBlock.Hash})\r\n-\t\t\tretry = core.IsRetryableError(err)\r\n+\t\t\t// Classify from the ledger's state, not from the error text:\r\n+\t\t\t// core.IsRetryableError's bare \"not found\" match calls permanent\r\n+\t\t\t// rejections retryable, and its message list misses genuine\r\n+\t\t\t// state checks. A lease record that is gone (unwound) or already\r\n+\t\t\t// taken can never accept this block; anything else (a frontier\r\n+\t\t\t// or pending-send race, a consensus hiccup) can heal.\r\n+\t\t\tif lease == nil || leaseAlreadyAccepted(lease) {\r\n+\t\t\t\tacceptErr = terminalAcceptError{err}\r\n+\t\t\t} else {\r\n+\t\t\t\tacceptErr = transientAcceptError{err}\r\n+\t\t\t}\r\n \t\t} else {\r\n \t\t\tlog.Printf(\"Lease %s: our accept already stands on-chain, keeping VM\", shortHash(leaseBlock.Hash))\r\n+\t\t\tacceptErr = terminalAcceptError{err}\r\n \t\t}\r\n \t\treturn\r\n \t}\r\n@@ -1624,6 +1693,9 @@ func (n *Node) autoAcceptLease(leaseBlock *core.Block) {\r\n \r\n \tif err := n.Gossip.Publish(n.ctx, b); err != nil {\r\n \t\tlog.Printf(\"Failed to publish lease_accept: %v\", err)\r\n+\t\t// The ledger has committed the accept; only the publish failed. The\r\n+\t\t// lease is served and sync catches the network up - do not re-drive.\r\n+\t\tacceptErr = terminalAcceptError{err}\r\n \t\treturn\r\n \t}\r\n \tn.syncTracker.MarkDirty()\n```\n\nVerification re-run after the change: `go vet ./node/` clean, `go build ./...` exit 0, `go test ./node/ -count=1` ok (2.302s).","created_at":"2026-11-05T16:04:45.551541+00:00"},{"id":673,"source":"desk","source_ref":"reply:320","author":"Joseph Denne","team":true,"body":"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","created_at":"2026-11-06T21:34:13.287529+00:00"}]}