Use invalid committee duty errors for malformed duties - F-ssv-spec-053#623
Use invalid committee duty errors for malformed duties - F-ssv-spec-053#623julienh-ssv wants to merge 1 commit into
Conversation
Greptile SummaryThis PR introduces Confidence Score: 5/5Safe to merge — focused error-code rename with no logic changes and good test coverage. The change is narrowly scoped: it adds a single error code constant at the tail of the iota (no value shifts), replaces three error-code references in validation, and adds matching tests. No logic is altered and existing numeric codes remain stable. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Committee.StartDuty] --> B{duty type?}
B -- "*CommitteeDuty" --> C{d == nil?}
C -- yes --> D[InvalidCommitteeDutyErrorCode\n'nil committee duty']
C -- no --> E[CommitteeDuty.Validate - called separately]
B -- "*AggregatorCommitteeDuty" --> F{d == nil?}
F -- yes --> G[InvalidAggregatorCommitteeDutyErrorCode]
F -- no --> H[continue StartDuty]
E --> I{cd == nil?}
I -- yes --> D2[InvalidCommitteeDutyErrorCode]
I -- no --> J{ValidatorDuties empty?}
J -- yes --> K[NoBeaconDutiesErrorCode]
J -- no --> L{nil vd?}
L -- yes --> D3[InvalidCommitteeDutyErrorCode]
L -- no --> M{slot mismatch?}
M -- yes --> D4[InvalidCommitteeDutyErrorCode]
M -- no --> N{invalid role?}
N -- yes --> O[WrongBeaconRoleTypeErrorCode]
N -- no --> P[ValidatorDuty.Validate]
Reviews (1): Last reviewed commit: "Use invalid committee duty errors for ma..." | Re-trigger Greptile |
momosh-ssv
left a comment
There was a problem hiding this comment.
Nice symmetry with the aggregator path. One coverage gap and one migration nit below — neither blocking.
| require.Error(t, err) | ||
| require.ErrorIs(t, err, &Error{}) | ||
| require.Equal(t, InvalidCommitteeDutyErrorCode, err.(*Error).Code) | ||
| }) |
There was a problem hiding this comment.
Worth adding a subcase for ValidatorDuties: [] so the NoBeaconDutiesErrorCode path is covered too. This new test is now the canonical suite for CommitteeDuty.Validate(), so leaving the empty-slice branch untested is an obvious gap.
| InvalidCommitteeMemberErrorCode | ||
| InvalidValidatorDutyErrorCode | ||
| BeaconVoteNilCheckpointErrorCode | ||
| InvalidCommitteeDutyErrorCode |
There was a problem hiding this comment.
Might be worth calling out in the PR body that consumers matching the raw code UnknownDutyRoleDataErrorCode for nil/malformed CommitteeDuty inputs need to migrate to InvalidCommitteeDutyErrorCode. This is the spec repo, so a migration note reduces friction for ssv-node maintainers picking up the change.
Ticket
F-ssv-spec-053
The ticket reported that
Committee.StartDutyreturnedUnknownDutyRoleDataErrorCodefor a nil*CommitteeDuty, while nil aggregator committee duties usedInvalidAggregatorCommitteeDutyErrorCode. This conflated malformed committee duties with unknown consensus duty roles.Changes
InvalidCommitteeDutyErrorCodewithout shifting existing error code values.Validation
go test ./typesgo test ./ssvmake fmtmake lintFixes - Fixes ssvlabs/ssv-node-board#1031