Bounty
XE-0103 · Bounty

[Lease Economics] LeaseAccept locks emission terms from any of the last 4 epochs — provider-selected stale terms are paid out at settle

Triaging claimed Medium xe#175 filed 2026-10-29 08:05 UTC by zafrans

Report

Suggested severity: Medium (2,500 XE) Area: ledger / lease settlement economics Repo pin: 9787859 (testnet-0005)

Summary

When a provider accepts a lease, the emission terms locked into the lease (R, PayoutCap, TWAP) are validated against any of the last 4 epochs, not against the single epoch that was active at the attested start time. The provider authors the LeaseAccept block, so the provider chooses which of those epochs to lock. LeaseSettle later pays out at the locked terms with no revalidation. The moment emission parameters differ between epochs, any provider can lock the most favourable recent epoch and be paid at stale terms — repeatedly, on every lease.

I am reporting this as Medium with an honest caveat up front: on the live testnet today the per-epoch parameters have never diverged (measurement below), so the realised overpayment today is zero. The flaw is live in the validation logic and becomes a direct overpayment the first time R moves between epochs.

Where

  • core/ledger.go:223 — const EpochLockTolerance = 3
  • node/node.go (epochAtFn, ~L440-460) — returns epochs with StartNS <= ns, newest first, truncated to EpochLockTolerance+1 = 4 candidates
  • core/ledger.go:2090 — validateLockedEmissionAt accepts the block if its locked (R, PayoutCap, TWAP) matches any candidate epoch
  • core/ledger.go:1607 — validateAndAddLeaseAccept locks terms via the above; core/ledger.go:2117 — validateAndAddLeaseSettle pays at the locked terms

Proof of concept

Local harness against Ledger.AddBlock, repo untouched at the pinned commit. Two identical leases differing only in which epoch's terms the provider locks:

  • Lock terms from a stale in-window epoch, R=900 → LeaseAccept accepted; LeaseSettle pays 601 XE
  • Lock terms from the current epoch, R=100 → LeaseSettle pays 67 XE
  • Same lease, 9.0x payout, chosen by the provider

Negative controls (both rejected, confirming the bound is exactly the tolerance window):

  • Terms from the 5th epoch back (R=9999) → rejected
  • Terms from a non-existent epoch (R=12345) → rejected

Live-testnet measurement (2026-10-29)

GET https://ldn.core.test.network/statechain/kv?prefix=epoch. — 1,000 epochs sampled (range: epoch 0 to the current epoch 1898). In every sampled epoch: r_effective = 2000, payout_cap = 1527, twap_milli_usd = 250. Spread across the current last-4 window is therefore 1.0x today. The epoch schema already carries the machinery for R to move (phase, twap_trigger_met, volume_trigger_met, r_source); when it does, this selection window is immediately monetisable by any provider.

Why this is not just sync tolerance

A multi-epoch tolerance makes sense for a validator whose statechain view lags during sync — and the codebase already has that distinction: the sync path runs with skipSkew. The problem here is that the tolerance is exercisable by the block author on the live accept path, and the author is the party who gets paid at the locked terms. A lagging validator and a choosing provider are different trust positions; the second one should not inherit the first one's allowance.

Suggested fix

On the live accept/renew path, require locked terms to equal the epoch active at the attested time (candidates[0]). If multi-epoch tolerance is needed for statechain catch-up, keep it on the sync/replay path only (the skipSkew call sites), not on author-submitted blocks.

Reporter

XE payout address: 24b1be6a99de922902aceccce2456abc3769e4ab1cac463ea86fb23496b868b3 Discovered: 2026-10-29, against the public testnet implementation at the pinned commit. No mainnet exists yet; no other users' funds, keys or workloads were touched — reproduction was local, the live check above is a read-only API query.

Thread

Joseph Denneteam2026-11-08 20:19 UTCgithub

Thanks for the report. We have confirmed the behaviour you describe and it is being handled; we will update this ticket when there is more to share.

zafrans2026-11-11 04:48 UTCgithub

Payout address update

Hi team — a quick correction to the Reporter section of this report.

The XE payout address previously listed here (24b1be6a99de922902aceccce2456abc3769e4ab1cac463ea86fb23496b868b3) is no longer accessible to me — I no longer control the key for that wallet. Please disregard it.

My current XE payout address is:

5dc48847412ffe94e4f7097b81ee111b9e207b47c9c1f3bab988f08b63bcc7e3

Please use this address for any award for this report. I am posting the same update on my other reports (#175, #183, #184, #191). Thank you.

ahmad322026-11-11 13:14 UTCgithub

Related observation on the same root — flagging here rather than filing separately, since one fix closes both.

epochAtFn (node/node.go:440-460) includes any stored epoch with StartNS <= now and never checks EndNS, so an epoch whose window has already ended still counts as "active" and its terms (R, PayoutCap, TWAP) can be locked into a LeaseAccept. The last-4-epochs window in this ticket is one half of the staleness; the missing EndNS check is the other half.

Separately, validateEpochValue (statechain/kvstore.go:333) validates EndNS > StartNS, phase, payout cap, and the R fields, but never checks epoch ordering — a new epoch can be written with an Epoch number or window that overlaps or precedes existing epochs, with nothing rejecting it.

Both are the same root as this ticket (stale/unguarded epoch terms feeding LeaseAccept). A fix that validates epoch ordering at write time plus EndNS at read time would close both.

Verified by direct code reading (no Go toolchain run). Writing epochs still needs the trusted oracle key, so this is not a new privilege — same impact as XE-0103.