Skip to content

Commit

Permalink
core: add sync committee duties (#1198)
Browse files Browse the repository at this point in the history
Adds required sync committee duties.

category: feature
ticket: #1174
  • Loading branch information
dB2510 authored Sep 29, 2022
1 parent 77f3497 commit 8a0e938
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
48 changes: 27 additions & 21 deletions core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ type DutyType int
const (
// DutyType enums MUST not change, it will break backwards compatibility.

DutyUnknown DutyType = 0
DutyProposer DutyType = 1
DutyAttester DutyType = 2
DutySignature DutyType = 3
DutyExit DutyType = 4
DutyBuilderProposer DutyType = 5
DutyBuilderRegistration DutyType = 6
DutyRandao DutyType = 7
DutyPrepareAggregator DutyType = 8
DutyAggregator DutyType = 9
DutyUnknown DutyType = 0
DutyProposer DutyType = 1
DutyAttester DutyType = 2
DutySignature DutyType = 3
DutyExit DutyType = 4
DutyBuilderProposer DutyType = 5
DutyBuilderRegistration DutyType = 6
DutyRandao DutyType = 7
DutyPrepareAggregator DutyType = 8
DutyAggregator DutyType = 9
DutySyncMessage DutyType = 10
DutyPrepareSyncContribution DutyType = 11
DutySyncContribution DutyType = 12
// Only ever append new types here...

dutySentinel DutyType = 10 // Must always be last
dutySentinel DutyType = 13 // Must always be last
)

func (d DutyType) Valid() bool {
Expand All @@ -53,16 +56,19 @@ func (d DutyType) Valid() bool {

func (d DutyType) String() string {
return map[DutyType]string{
DutyUnknown: "unknown",
DutyProposer: "proposer",
DutyAttester: "attester",
DutySignature: "signature",
DutyExit: "exit",
DutyBuilderProposer: "builder_proposer",
DutyBuilderRegistration: "builder_registration",
DutyRandao: "randao",
DutyPrepareAggregator: "prepare_aggregator",
DutyAggregator: "aggregator",
DutyUnknown: "unknown",
DutyProposer: "proposer",
DutyAttester: "attester",
DutySignature: "signature",
DutyExit: "exit",
DutyBuilderProposer: "builder_proposer",
DutyBuilderRegistration: "builder_registration",
DutyRandao: "randao",
DutyPrepareAggregator: "prepare_aggregator",
DutyAggregator: "aggregator",
DutySyncMessage: "sync_message",
DutyPrepareSyncContribution: "prepare_sync_contribution",
DutySyncContribution: "sync_contribution",
}[d]
}

Expand Down
5 changes: 4 additions & 1 deletion core/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ func TestBackwardsCompatability(t *testing.T) {
require.EqualValues(t, 7, core.DutyRandao)
require.EqualValues(t, 8, core.DutyPrepareAggregator)
require.EqualValues(t, 9, core.DutyAggregator)
require.EqualValues(t, 10, core.DutySyncMessage)
require.EqualValues(t, 11, core.DutyPrepareSyncContribution)
require.EqualValues(t, 12, core.DutySyncContribution)
// Add more types here.

const sentinel = core.DutyType(10)
const sentinel = core.DutyType(13)
for i := core.DutyUnknown; i <= sentinel; i++ {
if i == core.DutyUnknown {
require.False(t, i.Valid())
Expand Down

0 comments on commit 8a0e938

Please sign in to comment.