{"id":"XE-16994","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"705","source_url":"https://github.com/xeprotocol/xe/issues/705","reporter_id":2947,"title":"[Bug] /supply reports XCU as not conserved — SupplyAuditor never counts lease renewal burns (discrepancy −8789 micro-XCU)","area":null,"claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T08:13:52.241648+00:00","updated_at":"2026-11-18T08:56:07.953642+00:00","source_created_at":"2026-11-17T08:13:09+00:00","told_at":"2026-11-18T08:55:06+00:00","status_changed_at":"2026-11-18T08:39:45.795079+00:00","url":"https://bounty.xe.network/XE-16994","body":"**Suggested tier: Low** (below Medium — no user funds are lost or created; this is an accounting-data integrity issue. The bounty article lists Critical/Severe/High/Medium; final tier is at the core team's discretion.)\n\n## Summary\n`GET /supply` on public testnet nodes reports `\"conserved\": false` for XCU with `discrepancy: -8789` (micro-XCU = 0.008789 XCU). Root cause: the `SupplyAuditor` in `core/supply.go` counts only the INITIAL lease cost as `escrow_burned`, while `lease_renew` adds the renewal fee to the same escrow (`TopUpPendingAmount`, `core/lease_renew.go`) and `lease_settle` deletes the ENTIRE escrow (`DeletePendingID`, `core/ledger.go` `validateAndAddLeaseSettle`) — so renewal fees really are destroyed, but the auditor never counts them as destroyed. The ledger itself is consistent; the published supply report is what is wrong.\n\n## Reproduction (live, testnet-0006, 2026-11-17)\n`GET /supply` on THREE independent public nodes — IDENTICAL results:\n- https://ldn.core.test.network/supply\n- https://ffm.core.test.network/supply\n- https://nyc.core.test.network/supply\n\nEach: `\"conserved\": false, \"stable\": true, \"attempts\": 1`, and for XCU: `created=201000000, accounted=200991211, discrepancy=-8789, conserved=false, escrow_burned=15510, locked_stake=0, stake_forfeited=0, balances=200975701, in_flight=0`. XE on all three nodes: `discrepancy=0, conserved=true`.\n\n`GET /leases?limit=100` (ldn): 30 leases, ALL `settled`, each `cost=517`; 17 leases have 1 renewal @ `cost=517`.\n- 30 × 517 = 15,510 = the reported `escrow_burned` (initial costs only).\n- 17 × 517 = 8,789 = EXACTLY the `discrepancy` (−8,789).\n- Recompute: balances 200,975,701 + actual destroyed (15,510 + 8,789 = 24,299) = 201,000,000 = created. Conservation holds exactly once renewals are counted — proving the ledger is right and the auditor undercounts.\n\n## Code flow (source testnet-0006, commit 8cc209d)\n1. `core/supply.go` `fold()`: only `BlockLease` is recorded into `leaseCost`, only `BlockLeaseAccept` into `acceptStake`, only `BlockLeaseSettle` into `settleEmission`. `BlockLeaseRenew` is NEVER recorded.\n2. `core/supply.go` `walk()`: `EscrowBurned += costs[h]` only for settled (or `LeaseExpired`) leases. Renewal fees never enter `EscrowBurned`, `LockedStake`, or `StakeForfeited`.\n3. `core/lease_renew.go`: renewal debits the lessee by `b.Amount` and sets `commit.TopUpPendingID = b.Source` / `TopUpPendingAmount = b.Amount` — the pending escrow grows. Applied in `store/badger_store.go` and `store/mem_store.go`.\n4. `core/ledger.go` `validateAndAddLeaseSettle`: `commit.DeletePendingID = b.Source` — the whole escrow (initial cost + all renewal top-ups) is deleted; the provider receives only the XE emission + stake refund (`AssetCredit` XCU = `lease.Stake`). The renewal fee is destroyed without the auditor ever counting it.\n\n## Impact\n- `/supply` — the only published source of supply truth — permanently reports `conserved: false` on any network that has lease renewals. Every dashboard/integration reading this endpoint sees a phantom supply leak that grows with each renewal.\n- This is not inflation: no XCU is created from nothing; instead, legitimately destroyed XCU is not recorded as destroyed.\n- Scale: the gap grows linearly with renewals (here 17 × 517 micro-XCU). On a network with large/frequently renewed leases, the reported gap grows without bound.\n\n## Suggested fix\nIn `core/supply.go` `fold()`, also record `BlockLeaseRenew` (e.g. a `renewCost[leaseHash] += b.Amount` map), then in `walk()` add total renewals to `EscrowBurned` for settled leases (and to `LockedStake`/the appropriate classification for still-live leases). Alternative: compute `EscrowBurned` from the escrow amount actually deleted at settle, not from the initial lease cost alone.\n\n## Related observation (NOT part of this finding — not yet reproduced)\n`validateAndAddLeaseCancel` refunds only `leaseBlock.Amount` (the initial cost) while deleting the entire pending escrow — unlike `lease_force_settle`, which refunds the full `pending.Amount` (including renewal top-ups). Cancelling a renewed lease may therefore burn the consumer's renewal fees. The cancel window for accepted leases is narrow (accept must not be final) and there are currently NO cancelled leases on testnet, so there is no live reproduction yet — noted as a candidate for a future run, not as a finding.\n\n## Reward address (XE wallet 1)\na121fc8bc899fd12bb760fb1f0ecfc3ad0e6c9e572d9eedce29f43136c7b8d97","patch_refs":[],"thread":[{"id":11552,"source":"github","source_ref":"6973755751","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-16994.","created_at":"2026-11-18T08:55:06+00:00"}]}