Standardize sentinel pattern (F-ssv-spec-027) - #620
Conversation
Greptile SummaryThis PR standardizes the sentinel pattern for
Confidence Score: 4/5Safe to merge — backward-compatible encoding, no protocol changes The wire encoding is unchanged for all previously valid values; the only behavioural change is that RoleUnknown (previously an implicit cast of -1 to uint32) is now explicit and correct. Minor style concerns (redundant guard, incomplete test coverage) do not affect correctness. types/runner_role.go — verify the redundant sentinel check is intentional Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Caller
participant M as messages.go
participant R as runner_role.go
Note over C,R: Encoding (NewMsgID)
C->>M: NewMsgID(domain, dutyExecutorID, role)
M->>R: role.WireUint32()
R-->>M: uint32 (MaxUint32 if role<0, else uint32(role))
M-->>C: MessageID bytes
Note over C,R: Decoding (GetRoleType)
C->>M: msgID.GetRoleType()
M->>M: binary.LittleEndian.Uint32(bytes)
M->>R: RunnerRoleFromWireUint32(v)
R-->>M: RunnerRole (RoleUnknown if v>MaxInt32)
M-->>C: RunnerRole
Reviews (1): Last reviewed commit: "Standardize sentinel pattern" | Re-trigger Greptile |
MatheusFranco99
left a comment
There was a problem hiding this comment.
Good change! Looks good to me! :)
However, I didn't get why the .json file tests got modified (since the edge case was already the same 0xff... , and some tests don't seem related to the issue)
Can you give me a help on that?
88ec2a8
d64176e to
88ec2a8
Compare
|
@MatheusFranco99 I had regenerated the fixtures after merge but you are right it wasn't necessary. I have cleaned up the git history and removed the unnecessary changes to allow for a clean merge on top of main |
|
Fixes https://github.com/ssvlabs/ssv-node-board/issues/866 |
|
This pull request has been marked as stale due to 60 days of inactivity. |
Fix for:
Inconsistent Enum Sentinel Values
ssv-spec · Inconsistency · Assigned: dev4 · Effort: —
BNRoleUnknown = math.MaxUint64(BeaconRole) vsRoleUnknown = -1(RunnerRole as int32). The RunnerRole sentinel-1can't be properly represented as uint32 (line 50-52 in messages.go converts to uint32), potentially matching corrupted data.Impact: Type confusion between sentinel values. Corrupted message data could match
RoleUnknownunintentionally.Recommendation: Standardize sentinel pattern across all enums.