<!-- XE-0049 · Supply monitor under-counts lease-renewal escrow → false conserved:false with empty notes (XUSD discrepancy −32318) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0049>. The page is the record; this is the same page for reading.*

XE-0049 · Bounty

# Supply monitor under-counts lease-renewal escrow → false conserved:false with empty notes (XUSD discrepancy −32318)

Closed · duplicate
—claimed Medium
[xe#68](https://github.com/xeprotocol/xe/issues/68)
filed 2026-10-26 13:17 UTC
by naufal2002

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   Leasing / ledger

Duplicate of
:   [XE-0015](https://bounty.xe.network/XE-0015) fixing

Tracked
:   internally

Updated
:   2026-11-10 00:11 UTC

Told
:   2026-11-08 20:35 UTC

### Patches

- [xe#136](https://github.com/xeprotocol/xe/pull/136) open by arturbarszcz78
  fix(core,node): account for lease-renewal escrow in supply auditor

### History

- [45085](https://bounty.xe.network/log/45085) 2026-11-08 20:35 UTC reply.mirrored
- [45082](https://bounty.xe.network/log/45082) 2026-11-08 20:35 UTC reply.sent
- [45080](https://bounty.xe.network/log/45080) 2026-11-08 20:35 UTC proposal.adopted
- [4155](https://bounty.xe.network/log/4155) 2026-11-04 09:19 UTC proposal.created
- [893](https://bounty.xe.network/log/893) 2026-10-29 14:22 UTC github.state\_pushed
- [892](https://bounty.xe.network/log/892) 2026-10-29 14:22 UTC github.labels
- [751](https://bounty.xe.network/log/751) 2026-10-29 14:22 UTC note.added
- [750](https://bounty.xe.network/log/750) 2026-10-29 14:22 UTC ticket.status accepted → closed
- [749](https://bounty.xe.network/log/749) 2026-10-29 14:22 UTC ticket.facts area
- [596](https://bounty.xe.network/log/596) 2026-10-29 14:04 UTC github.labels
- [532](https://bounty.xe.network/log/532) 2026-10-29 14:04 UTC ticket.status triaging → accepted
- [531](https://bounty.xe.network/log/531) 2026-10-29 14:04 UTC ticket.status new → triaging

[Full history](https://bounty.xe.network/log?ref=XE-0049) · [JSON](https://bounty.xe.network/v1/tickets/XE-0049) · [markdown](https://bounty.xe.network/XE-0049.md)

### Report

# Supply conservation monitor under-counts lease-renewal escrow → permanent false `conserved:false` with empty `notes`

**Component:** `core/supply.go` (`SupplyAuditor`) — `GET /supply` conservation audit
**Version observed:** `xe/92d83d1` (`testnet-0005`), reproduced live on `ldn`, `ffm`, `nyc`
**Source commit inspected:** `978785929bc17a2f4ab30c383e5fc9cf4d634512`
**Suggested severity:** MEDIUM — "accounting mismatch · API inconsistency" per the published tier table (target 2,500 XE). Accounting-integrity defect in the audit layer; **no fund loss, no mint, no double-spend**, so not Critical/Severe and filed publicly per the rules.
**Phase 1 surface:** transactions \& running a node (the `/supply` invariant check)

---

## Summary

The node's own supply auditor reports XUSD as **not conserved** on a healthy network:

```
"XUSD": { ... "discrepancy": -32318, "conserved": false },
"conserved": false, "notes": [], "stable": true
```

This is a **false alarm**. The underlying ledger conserves XUSD to the exact micro-unit. The discrepancy is caused entirely by `SupplyAuditor` omitting `lease_renew` escrow top-ups from its `escrow_burned` term.

Two documented contracts of `GET /supply` are violated simultaneously (per `docs/api.md`):

1. *"`notes` — every reason the report is not clean … **Empty on a healthy network**."* → Here `conserved:false` is reported with **`notes: []`** — the monitor flags non-conservation but supplies **no reason**, so an operator cannot tell a false alarm from a real leak.
2. *"`conserved` … never reports `true` on incomplete data"* — the converse failure: it reports `false` on **complete, correct** ledger data because the auditor's own model is incomplete.

Impact: the protocol's documented integrity canary is permanently tripped once any lease is renewed, which **masks any future real XUSD leak** — the exact failure mode a conservation monitor exists to catch.

---

## Affected code

`core/supply.go`, `termsFromChain` (block classification) — the `switch b.Type` has cases for `BlockLease`, `BlockLeaseAccept`, `BlockLeaseSettle`, but **no case for `BlockLeaseRenew`**:

```
// core/supply.go  (termsFromChain, ~L88-103)
switch b.Type {
case BlockGenesis:     c.genesis[b.Asset] += b.Balance
case BlockMint:        c.minted[b.Asset]  += b.Amount
case BlockBurn:        c.burned[b.Asset]  += b.Amount
case BlockLease:       c.leaseCost[b.Hash]      = b.Amount   // base cost only
case BlockLeaseAccept: c.acceptStake[b.Source]  = b.Amount
case BlockLeaseSettle: c.settleEmission[b.Source] = b.Amount
default:                                                      // <-- lease_renew falls here, ignored
}
```

The escrow-burn term is then derived from `leaseCost` (base only):

```
// core/supply.go  walk(), ~L242-250
for h, em := range emissions {
    add(&get(AssetXE.Symbol).Emitted, em)
    if cost, ok := costs[h]; ok {
        add(&get(AssetXUSD.Symbol).EscrowBurned, cost)   // base lease cost ONLY
    } else { ... }
}
```

But the real ledger escrow grows on each renewal and is burned in full at settle:

- `core/lease_renew.go` L137-138 — renewal tops up the live escrow pending:

  ```
  commit.TopUpPendingID     = b.Source
  commit.TopUpPendingAmount = b.Amount
  ```
- `core/ledger.go` L2226 (`lease_settle`) — the **entire** escrow pending (base \+ all renewals) is removed:

  ```
  commit.DeletePendingID = b.Source
  ```

So at settle the ledger correctly removes `base + Σ renewals` from `in_flight`, but the auditor only adds `base` to `escrow_burned`. The missing `Σ renewals` makes `accounted < created` by exactly that sum → negative `discrepancy`.

---

## Reproduction (live, read-only)

```
# 1. The monitor reports non-conservation with an empty notes array:
curl -s https://ldn.core.test.network/supply \
  | jq '{conserved, stable, notes, XUSD: .assets.XUSD | {discrepancy, conserved, created, minted, balances, escrow_burned}}'
# => "discrepancy": -32318, "conserved": false, notes: [], stable: true
#    (identical on ffm and nyc)

# 2. Reconstruct the discrepancy from lease data — it equals the renewal escrow the auditor omits:
curl -s "https://ldn.core.test.network/leases?state=settled" > settled.json
jq '[.[].renewals[]?.cost] | add' settled.json     # => 32318   (== -discrepancy, exactly)
jq '[.[].cost] | add'          settled.json         # => 67738   (base; == auditor escrow_burned)
```

### Exact conservation proof (XUSD)

| Term | Value (micro-XUSD) | Source |
| --- | --- | --- |
| `created` (\= `minted`) | 213,000,000 | `/supply` |
| `balances` (live accounts) | 212,899,944 | `/supply` |
| `escrow_burned` reported | 67,738 | `/supply` (base cost of 98 settled leases) |
| renewal escrow **omitted** | 32,318 | Σ `renewals[].cost` over settled leases (46 segments) |

```
balances + escrow_burned(base) + renewals_omitted
  = 212,899,944 + 67,738 + 32,318
  = 213,000,000
  = created                         ✓ conserves exactly once the renewal term is included
```

`discrepancy = accounted − created = (212,899,944 + 67,738) − 213,000,000 = −32,318`, i.e. precisely the omitted renewal escrow. The XE asset is unaffected (`discrepancy: 0, conserved: true`), as expected since only XUSD funds lease escrow.

Deterministic and stable: observed identical (`−32318`, `stable:true`, `notes:[]`) on all three public nodes and across repeated reads during live block production.

---

## Why this is NOT a fund-safety issue

The real ledger conserves. Verified:

- Escrow top-up/reduce is a symmetric, underflow-guarded `int64` delta (`store.addToPendingAmountTxn`); settle burns the full pending via `DeletePendingID`; rollback pops renewals symmetrically (`priorLeasePopRenewal` \+ `ReducePendingAmount`).
- Independent full-state reconstruction balances to the exact micro-XUSD (table above).
- XE emission/supply is independently `conserved: true` and stable over time.

The defect is confined to the **audit model** in `supply.go`, not to any balance-mutating path. No XUSD is created, lost, or double-counted on-chain.

---

## Impact

- **Integrity canary disabled.** `GET /supply` is documented as *the* conservation authority (`docs/api.md`: "This endpoint is the authority"). Once any lease is renewed, it permanently reports `conserved:false`. A genuine future XUSD leak would be indistinguishable from this baseline false alarm.
- **Contract violation / operator confusion.** `conserved:false` with `notes:[]` contradicts the documented guarantee that `notes` carries "every reason the report is not clean" and is "empty on a healthy network." Monitoring/alerting built on `conserved` or `notes` will either alarm forever or (if operators learn to ignore it) ignore a real breach.

No external attacker interaction is required; it is a protocol self-report defect.

---

## Suggested fix

Account for renewal escrow in the auditor so the burned term matches what the ledger actually removes.

```
// core/supply.go — add a renewal-cost map to chainTerms
type chainTerms struct {
    // ...
    leaseCost      map[string]uint64
    leaseRenewCost map[string]uint64 // NEW: Source -> Σ renewal top-ups
    // ...
}

// in termsFromChain switch:
case BlockLeaseRenew:
    c.leaseRenewCost[b.Source] += b.Amount

// in walk(), fold renewal cost into EscrowBurned wherever the base escrow is burned
// (settle path, and the LeaseExpired loop), keyed consistently with how costs[h] is keyed.
```

Equivalent alternative: derive `escrow_burned` for a burned lease directly from the stored `Lease` (`Cost + Σ Renewals[].Cost`) rather than from the base lease block amount, so the auditor and the ledger use the same escrow total by construction.

After the fix, `GET /supply` should return `XUSD.discrepancy: 0, conserved: true, notes: []` on the current testnet state.

---

## Metadata

- **Reporter contact:** govrex5@gmail.com
- **XE payout address:** `0x05055eE6Bffc9467aa8aad5F8e8665871dC71060`
- **Suggested severity:** MEDIUM (accounting mismatch \+ API inconsistency). Final severity at XE core team discretion.
- **Channel:** public GitHub issue on `xeprotocol/xe` (not funds/network-risking, so not the private `security@xe.network` channel).
- **Affected files:** `core/supply.go` (primary); cross-referenced `core/lease_renew.go` L137-138, `core/ledger.go` L2226.
- **Reproducible:** yes, read-only `GET /supply` \+ `GET /leases?state=settled`, no state mutation, no special access.

### Thread

**Joseph Denne**team2026-11-08 20:35 UTCgithub

Thanks, this was well put together and the numbers were useful. It has the same root cause as finding 3 in #4 (lease-renewal escrow not counted by the supply auditor), which was filed first and is being fixed, so this one closes as a duplicate and your data points are folded into that ticket. If you believe it is a different bug, reply with what differs and we will look again.
