Skip to content

feat: emit NominationRevoked when revokeDelegate clears a pending nomination - #21

Merged
F4ever merged 1 commit into
mainfrom
feat/add-event
Aug 7, 2026
Merged

feat: emit NominationRevoked when revokeDelegate clears a pending nomination#21
F4ever merged 1 commit into
mainfrom
feat/add-event

Conversation

@chasingrainbows

@chasingrainbows chasingrainbows commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

revokeDelegate() silently dropped a pending (not-yet-effective) nomination without emitting an event, while revokeNomination() emits NominationRevoked for the same reset. This PR makes the event stream consistent: revokeDelegate() now calls _settle() and emits NominationRevoked(pending) when an unmatured pending nomination is dropped, before the existing DelegateRevoked.

A matured pending nomination is folded into the current delegate by _settle() and is reported via DelegateRevoked only — no duplicate event. External state after the call is unchanged; only the event stream differs. terminate() is intentionally left untouched (end of contract life).

Related Issue/Task

  • Related task: N/A
  • Epic: N/A

How Has This Been Tested?

  • Local tests
  • Manual testing (describe steps)
  • Not tested (explain why)

forge test: 82/82 passing, including fuzz and invariant suites. Coverage stays at 100% (lines/branches/functions). Three new tests:

  • test_revokeDelegate_emitsNominationRevokedForPending — event order NominationRevokedDelegateRevoked for an unmatured pending nomination
  • test_revokeDelegate_noNominationRevokedWhenNoPending — via vm.recordLogs(), proves only DelegateRevoked is emitted
  • test_revokeDelegate_noNominationRevokedWhenPendingMatured — matured pending goes into DelegateRevoked only

Checklist

  • Documentation updated (if required)
  • New tests added (if applicable)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes revokeDelegate()’s event stream consistent with revokeNomination() by emitting NominationRevoked when revokeDelegate() clears a not-yet-effective pending nomination, while preserving the existing external state outcomes.

Changes:

  • Update revokeDelegate() to _settle() first, then emit NominationRevoked(pending) only when an unmatured pending nomination is actually dropped, followed by DelegateRevoked.
  • Document the new emission behavior for revokeDelegate() in IDelegationContract.
  • Add unit tests that assert the new event ordering/absence rules across pending/no-pending/matured-pending scenarios (using vm.recordLogs() where appropriate).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/DelegationContract.sol Calls _settle(), conditionally emits NominationRevoked for non-matured pending, then revokes the effective delegate and emits DelegateRevoked.
src/interfaces/IDelegationContract.sol Updates NatSpec for revokeDelegate() to describe the additional NominationRevoked emission when dropping a not-yet-effective nomination.
test/unit/DelegationContract.t.sol Adds tests covering (1) pending dropped emits NominationRevoked then DelegateRevoked, (2) no pending emits only DelegateRevoked, (3) matured pending results in only DelegateRevoked for the matured delegate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@F4ever
F4ever merged commit 3149356 into main Aug 7, 2026
7 checks passed
@F4ever
F4ever deleted the feat/add-event branch August 7, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants