<!-- XE-16824 · [Low] SwapBlock unwinding a lease_cancel deletes the reputation aggregate via Revert, losing activity timestamps · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16824>. The page is the record; this is the same page for reading.*

XE-16824 · Bounty

# \[Low\] SwapBlock unwinding a lease\_cancel deletes the reputation aggregate via Revert, losing activity timestamps

Closed · duplicate
—claimed Minor
[xe#662](https://github.com/xeprotocol/xe/issues/662)
filed 2026-11-17 06:23 UTC
by kecedanzz77-bit

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Minor

Area
:   Node / API

Duplicate of
:   [XE-7716](https://bounty.xe.network/XE-7716) triaging

Tracked
:   —

Updated
:   2026-11-22 23:26 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770272](https://bounty.xe.network/log/770272) 2026-11-22 23:26 UTC reply.mirror\_failed
- [770035](https://bounty.xe.network/log/770035) 2026-11-22 23:26 UTC proposal.adopted
- [770034](https://bounty.xe.network/log/770034) 2026-11-22 23:26 UTC reply.sent
- [770033](https://bounty.xe.network/log/770033) 2026-11-22 23:26 UTC ticket.status new → closed
- [769196](https://bounty.xe.network/log/769196) 2026-11-22 23:25 UTC proposal.adopted
- [769195](https://bounty.xe.network/log/769195) 2026-11-22 23:25 UTC ticket.facts area
- [769194](https://bounty.xe.network/log/769194) 2026-11-22 23:25 UTC proposal.adopted
- [769193](https://bounty.xe.network/log/769193) 2026-11-22 23:25 UTC ticket.facts
- [769190](https://bounty.xe.network/log/769190) 2026-11-22 23:25 UTC proposal.adopted
- [769189](https://bounty.xe.network/log/769189) 2026-11-22 23:25 UTC ticket.facts
- [766266](https://bounty.xe.network/log/766266) 2026-11-22 23:17 UTC note.added
- [766250](https://bounty.xe.network/log/766250) 2026-11-22 23:17 UTC proposal.created

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

### Report

## Summary

`ReputationEngine.Revert` deletes the whole reputation aggregate when the counters hit zero — but the "no counters" check ignores `FirstActivityAt`/`LastActivityAt`, which the forward path recorded from other lease events. Swapping out a `lease_cancel` (the only counter event for the account) therefore deletes the record entirely, including timestamps recorded by other events. The post-swap ledger has NO reputation record for the account while replay-from-chains produces a zero-counter record: strict replay determinism is broken.

Counters are all zero in both states, so no counter data is lost — only the timestamps plus determinism. Severity Low.

## Root cause

`ReputationEngine.Revert` (`core/reputation.go:203-226`) deletes the aggregate (memory \+ store via `DeleteReputation`, `:215`) when `hasNoCounters()` (`core/reputation.go:149-159`) is true after reverting. `hasNoCounters` checks only the 9 counters and never looks at `FirstActivityAt`/`LastActivityAt`.

## Verification

Found by stateful fuzzing of `Ledger.AddBlock` (40 instances in this round). Minimized reproducer, 27 blocks: lease `45386c5e` → cancel `3a56ca37` (swapped out); fork send `bfcaca53`. Replay 27/27 into a fresh ledger, `SwapBlock` succeeds, replay-from-chains state differs: reputation record missing in the first ledger, zero-counter record (`accP=0 accC=0 setP=0 setC=0 hrsP=0 hrsC=0 canC=0 unfP=0 unfC=0`) in the second. Supply post-swap conserved.

## Note on related reports

Distinct from:

- #654 — `Revert` never *restores* `FirstActivityAt`/`LastActivityAt` (stale timestamps after a partial fork unwind). This report is about *deletion* of the record, not stale values.
- #226 v3 — renewal durations dropped from `LeaseHoursSettled` \+ fallback timestamp uses base duration; different mechanism and code path.

## Suggested fix

Preserve the record (and its timestamps) when `FirstActivityAt`/`LastActivityAt` are set, or include timestamp presence in the deletion condition.

### Thread

**Joseph Denne**team2026-11-22 23:26 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-7716, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-16824 and says what differs; it is read like any other.
