Bounty
XE-7716 · Bounty

[core] Reputation aggregate deleted on accept rollback although a timestamp-only live event remains; live vs rebuilt diverge

Triaging claimed Minor web filed 2026-11-11 18:31 UTC by xe:b1bfb541

Report

[core] Reputation aggregate deleted on accept rollback although a timestamp-only live event remains; live vs rebuilt diverge

  • Area: core / reputation (core/reputation.go, core/ledger.go, core/rollback.go)
  • Network: testnet-0005 (in-process reproduction against repo code, no testnet traffic)
  • Reporter account: xe:b1bfb541 (desk key)
  • Claimed tier: Minor
  • Repo pin: 89a542e
  • Round: 8 (stateful fuzzing — reputation state machine), 2026-11-11/12
  • Cross-check record: ~/workspace/xe-bounty/crosscheck/r8-reputation-timestamp-only-deletion.md

Summary

ReputationEngine.Revert deletes an account's whole reputation aggregate as soon as all its counters reach zero (hasNoCounters()), without checking whether the aggregate still carries live timestamp content. A lease_cancelled event for which the account is the PROVIDER contributes no counter — only FirstActivityAt / LastActivityAt — so it creates a timestamp-only aggregate. One unrelated revert (rolling back a lease-accept) then deletes the evidence of that still-live cancelled lease. A fresh NewLedger over the same store (rebuildReputation, which scans the chain for cancel blocks) resurrects the aggregate, so live and rebuilt disagree: live GET /accounts/{address}/reputation reports no aggregate, while after a node restart the same account reports a timestamp-only aggregate.

Evidence

1. The code (xe @ 89a542e)

core/reputation.go:49-96 (ApplyReputationDelta): for EventLeaseCancelled only the consumer gets a counter; the provider still enters AffectedAccounts() and gets FirstActivityAt / LastActivityAt updated (lines 88-93) — a timestamp-only aggregate is deliberately created.

core/reputation.go:98-148 (RevertReputationDelta): only decrements counters; it never touches timestamps.

core/reputation.go:203-228 (ReputationEngine.Revert): after reverting, if a.hasNoCounters() → delete(e.agg, acc) + DeleteReputation — the deletion never checks whether timestamps still record live activity.

core/rollback.go:256-267: undoing a BlockLeaseAccept builds repRevert = {EventLeaseAccepted, Provider, Consumer}; :366-367 calls l.reputation.Revert(*repRevert).

core/ledger.go:607-690 (rebuildReputation): scans the chain for BlockLeaseCancel and applies EventLeaseCancelled{Provider: leaseBlock.Destination, ...} — rebuilding exactly the timestamp-only aggregate that live just deleted.

2. Deterministic reproduction (in-process, repo APIs only)

Harness: TestReputationTimestampOnlyRepro (seed 424242, provider = users[1]); every step uses exported ledger APIs (AddSyncedBlock, SwapBlock via FINAL votes, NewLedger on the same store). Result: REPRO CONFIRMED: live=nil, rebuilt=timestamp-only.

  1. Consumer opens lease L1 with the provider, then cancels it while still Created → live Apply(EventLeaseCancelled{Provider}) creates a timestamp-only aggregate for the provider: all counters 0, FirstActivityAt == LastActivityAt == 1700000430908943949.
  2. Provider sends S1, then accepts lease L2 on top of S1 → LeasesAcceptedAsProvider == 1 (timestamps unchanged).
  3. Stage a sibling send S2 at the accept block's own prev; vote rep0+rep1 FINAL for S2 (750k ≥ 67%) → SwapBlock replaces the accept block itself as the loser (NOT a descendant, so the XE-0022 stall does not apply) → buildBlockUndo produces repRevert(EventLeaseAccepted) → Revert → counters hit zero → aggregate DELETED (hasNoCounters).
  4. Result: live GetReputation(provider) == nil, while a fresh NewLedger on the same store returns the timestamp-only aggregate (first=1700000430908943949 last=1700000430908943949).

The same pattern was also found independently by the stateful engine fuzzer (TestReputationEngineStateful, random Apply/Revert sequences): an account with 1 live event but no aggregate, whenever a timestamp-only event was the sole survivor.

Impact

  • API GET /accounts/{address}/reputation and GET /reputation (and the xe reputation CLI) return "no aggregate" for a provider that has recorded on-chain activity; after a node restart the aggregate reappears. The data is lost until restart — not the "briefly differ" propagation lag the API doc allows ("best-effort; may briefly differ across nodes after a settle propagates").
  • No funds are lost and no consensus decision changes: reputation is currently display-only (API/CLI) with no in-repo consumer using it for decisions. Claimed tier: Minor. Not Medium: no loss of funds, no consensus stall, and the effect is limited to API metadata.

Suggested fix

hasNoCounters() should also consider timestamp content (e.g. do not delete when FirstActivityAt != 0), or Revert should recompute the timestamp bounds from the surviving events. Note this is the opposite direction of XE-3084 (stale timestamps surviving a revert): one fix that recomputes timestamp bounds on revert would close both failure modes.

Why this is not a duplicate

  • XE-3084 ("Revert never unwinds FirstActivityAt or LastActivityAt") is the OPPOSITE direction: stale timestamps SURVIVING a revert (live has extra / wrong data). This finding is an aggregate DELETED although a timestamp-only event survives (live loses data). XE-3084's hasNoCounters mention covers deletion when the reverted block was the account's ONLY activity (correct deletion; rebuild is also empty) — not this case (a live event remains; rebuild has the aggregate).
  • XE-5332 (counters surviving when a lease-OPEN loses a conflict) is the opposite direction with a different trigger; its controls state rebuild parity HOLDS for its case, while this finding VIOLATES rebuild parity.
  • XE-5320 (zombie lease / no escrow after force-settle + re-accept) is about funds/state, not the reputation aggregate; this trigger has no force-settle/re-accept.
  • XE-0135 Finding 3, XE-1767, XE-3065, XE-3445 are renewal-duration / seconds-vs-hours value errors in the settled-hours fields — different mechanism.
  • XE-0022 (SwapBlock stall on non-send descendants) is what BLOCKED the original repro trigger; the final repro avoids it by making the accept block the loser itself.
  • XE-6742 (destructive lease-open swap) touches escrow/lease records, not the reputation aggregate.
  • XE-7259 (reputation/keyset routes 404 on the live deploy) is about API route availability on testnet-0005, not the in-process reputation state machine.

Thread

Joseph Denneteam2026-11-17 09:38 UTCdesk

Thanks for the report. We have read it against the current code and confirmed the behaviour it describes. It is being handled.