feat: emit NominationRevoked when revokeDelegate clears a pending nomination - #21
Merged
Conversation
There was a problem hiding this comment.
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 emitNominationRevoked(pending)only when an unmatured pending nomination is actually dropped, followed byDelegateRevoked. - Document the new emission behavior for
revokeDelegate()inIDelegationContract. - 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
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
revokeDelegate()silently dropped a pending (not-yet-effective) nomination without emitting an event, whilerevokeNomination()emitsNominationRevokedfor the same reset. This PR makes the event stream consistent:revokeDelegate()now calls_settle()and emitsNominationRevoked(pending)when an unmatured pending nomination is dropped, before the existingDelegateRevoked.A matured pending nomination is folded into the current delegate by
_settle()and is reported viaDelegateRevokedonly — 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
How Has This Been Tested?
forge test: 82/82 passing, including fuzz and invariant suites. Coverage stays at 100% (lines/branches/functions). Three new tests:test_revokeDelegate_emitsNominationRevokedForPending— event orderNominationRevoked→DelegateRevokedfor an unmatured pending nominationtest_revokeDelegate_noNominationRevokedWhenNoPending— viavm.recordLogs(), proves onlyDelegateRevokedis emittedtest_revokeDelegate_noNominationRevokedWhenPendingMatured— matured pending goes intoDelegateRevokedonlyChecklist