From 8a0e938932dfa5e17b860e850b5248593d061102 Mon Sep 17 00:00:00 2001 From: Dhruv Bodani Date: Thu, 29 Sep 2022 14:56:29 +0530 Subject: [PATCH] core: add sync committee duties (#1198) Adds required sync committee duties. category: feature ticket: #1174 --- core/types.go | 48 ++++++++++++++++++++++++++-------------------- core/types_test.go | 5 ++++- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/core/types.go b/core/types.go index 845024ca8..7f36be79d 100644 --- a/core/types.go +++ b/core/types.go @@ -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 { @@ -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] } diff --git a/core/types_test.go b/core/types_test.go index 66d50edb3..ed07c8b01 100644 --- a/core/types_test.go +++ b/core/types_test.go @@ -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())