<!-- XE-16727 · [Low] Reputation Revert never restores FirstActivityAt/LastActivityAt — stale timestamps after partial fork unwind · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16727>. The page is the record; this is the same page for reading.*

XE-16727 · Bounty

# \[Low\] Reputation Revert never restores FirstActivityAt/LastActivityAt — stale timestamps after partial fork unwind

Closed · duplicate
—
[xe#654](https://github.com/xeprotocol/xe/issues/654)
filed 2026-11-17 05:32 UTC
by kecedanzz77-bit

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-22 23:26 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770280](https://bounty.xe.network/log/770280) 2026-11-22 23:26 UTC reply.mirror\_failed
- [770091](https://bounty.xe.network/log/770091) 2026-11-22 23:26 UTC proposal.adopted
- [770090](https://bounty.xe.network/log/770090) 2026-11-22 23:26 UTC reply.sent
- [770089](https://bounty.xe.network/log/770089) 2026-11-22 23:26 UTC ticket.status new → closed
- [769309](https://bounty.xe.network/log/769309) 2026-11-22 23:26 UTC proposal.adopted
- [769308](https://bounty.xe.network/log/769308) 2026-11-22 23:26 UTC ticket.facts area
- [769307](https://bounty.xe.network/log/769307) 2026-11-22 23:26 UTC proposal.adopted
- [769306](https://bounty.xe.network/log/769306) 2026-11-22 23:26 UTC ticket.facts
- [769305](https://bounty.xe.network/log/769305) 2026-11-22 23:26 UTC proposal.adopted
- [769304](https://bounty.xe.network/log/769304) 2026-11-22 23:26 UTC ticket.facts
- [766127](https://bounty.xe.network/log/766127) 2026-11-22 23:17 UTC note.added
- [766122](https://bounty.xe.network/log/766122) 2026-11-22 23:17 UTC proposal.created

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

### Report

## Summary

`ApplyReputationDelta` maintains `FirstActivityAt` (min) and `LastActivityAt` (max) from each event's timestamp, but `RevertReputationDelta` never touches them \-- and the undo path doesn't even record the original event timestamp, so the information is unrecoverable at revert time. A partial revert leaves stale timestamps: live state then differs from `rebuildReputation()` (which recomputes from scratch), so `/reputation` output changes across restarts.

## Root Cause

- `ApplyReputationDelta` (`core/reputation.go:90-96`) updates First/Last from `ev.Timestamp`.
- `RevertReputationDelta` (`core/reputation.go:102-146`) decrements counters only.
- The undo path (`core/rollback.go:264-271`) builds `repRevert` events with `Kind`, `Provider`, `Consumer`, `DurationSecs` \-- but no `Timestamp` (zero value).
- The full-revert case is masked (`ReputationEngine.Revert` deletes the aggregate when counters hit zero, `core/reputation.go:203-229`), but a partial revert leaves stale timestamps.

## Impact

Informational only \-- `/reputation` is documented best-effort, no consensus impact. Example: provider accepts leases at T\=100 and T\=200, then a fork unwinds the T\=200 accept \-- counters revert to 1 but `LastActivityAt` stays 200 (should be 100). Live state differs from `rebuildReputation()` (`core/ledger.go:665-741`), so `/reputation` output changes across restarts.

## Verification (executed PoC)

After 2 accepts (T\=100, T\=200) and reverting the T\=200 event: `accepted=1 first=100 last=200` (last should be 100). Reverting the T\=100 event instead: `accepted=1 first=100 last=200` (first should be 200). Confirmed even when the revert event is handed the correct timestamp \-- the function ignores it. Audited at HEAD `8cc209d` (testnet-0006).

## Note on related reports

#226 (XE-0135, accepted) Vulnerability 3 is about `DurationSecs`/lease-hours dropped on renewed leases \-- a different field; it never mentions `FirstActivityAt`/`LastActivityAt`. Distinct.

## Suggested fix

Record the event timestamp in the undo record and recompute First/Last from remaining events on revert (or rebuild the affected aggregate from lease records, as `rebuildReputation` does).

### Thread

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

Thanks. This is the same finding as an earlier report that is not public, 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-16727 and says what differs; it is read like any other.
