diff --git a/cli/operator/node.go b/cli/operator/node.go index fa94d113b3..d297be4e66 100644 --- a/cli/operator/node.go +++ b/cli/operator/node.go @@ -16,10 +16,11 @@ import ( "github.com/ilyakaznacheev/cleanenv" "github.com/pkg/errors" "github.com/spf13/cobra" - genesisspectypes "github.com/ssvlabs/ssv-spec-pre-cc/types" - spectypes "github.com/ssvlabs/ssv-spec/types" "go.uber.org/zap" + genesisspectypes "github.com/ssvlabs/ssv-spec-pre-cc/types" + convert "github.com/ssvlabs/ssv-spec/types" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/api/handlers" apiserver "github.com/ssvlabs/ssv/api/server" "github.com/ssvlabs/ssv/beacon/goclient" @@ -33,7 +34,6 @@ import ( "github.com/ssvlabs/ssv/eth/localevents" exporterapi "github.com/ssvlabs/ssv/exporter/api" "github.com/ssvlabs/ssv/exporter/api/decided" - "github.com/ssvlabs/ssv/exporter/convert" genesisibftstorage "github.com/ssvlabs/ssv/ibft/genesisstorage" ibftstorage "github.com/ssvlabs/ssv/ibft/storage" ssv_identity "github.com/ssvlabs/ssv/identity" @@ -295,9 +295,7 @@ var StartNodeCmd = &cobra.Command{ storageRoles := []convert.RunnerRole{ convert.RoleCommittee, - convert.RoleAttester, convert.RoleProposer, - convert.RoleSyncCommittee, convert.RoleAggregator, convert.RoleSyncCommitteeContribution, convert.RoleValidatorRegistration, diff --git a/exporter/api/query_handlers_test.go b/exporter/api/query_handlers_test.go index 12816e2e14..01cf88db47 100644 --- a/exporter/api/query_handlers_test.go +++ b/exporter/api/query_handlers_test.go @@ -8,11 +8,11 @@ import ( "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/herumi/bls-eth-go-binary/bls" "github.com/pkg/errors" - specqbft "github.com/ssvlabs/ssv-spec/qbft" - spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/stretchr/testify/require" "go.uber.org/zap" + specqbft "github.com/ssvlabs/ssv-spec/qbft" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/exporter/convert" qbftstorage "github.com/ssvlabs/ssv/ibft/storage" "github.com/ssvlabs/ssv/logging" @@ -87,12 +87,11 @@ func TestHandleDecidedQuery(t *testing.T) { db, l, done := newDBAndLoggerForTest(logger) defer done() - roles := []convert.RunnerRole{ - convert.RoleAttester, - convert.RoleCommittee, - convert.RoleProposer, - convert.RoleAggregator, - convert.RoleSyncCommitteeContribution, + roles := []spectypes.RunnerRole{ + spectypes.RoleCommittee, + spectypes.RoleProposer, + spectypes.RoleAggregator, + spectypes.RoleSyncCommitteeContribution, // skipping spectypes.BNRoleSyncCommitteeContribution to test non-existing storage } _, ibftStorage := newStorageForTest(db, l, roles...) @@ -203,7 +202,7 @@ func newDBAndLoggerForTest(logger *zap.Logger) (basedb.Database, *zap.Logger, fu } } -func newStorageForTest(db basedb.Database, logger *zap.Logger, roles ...convert.RunnerRole) (storage.Storage, *qbftstorage.QBFTStores) { +func newStorageForTest(db basedb.Database, logger *zap.Logger, roles ...spectypes.RunnerRole) (storage.Storage, *qbftstorage.QBFTStores) { sExporter, err := storage.NewNodeStorage(logger, db) if err != nil { panic(err) diff --git a/exporter/convert/message.go b/exporter/convert/message.go index 38a4724e31..d6bfa88c91 100644 --- a/exporter/convert/message.go +++ b/exporter/convert/message.go @@ -28,7 +28,7 @@ func (msg MessageID) GetDutyExecutorID() []byte { return msg[dutyExecutorIDStartPos : dutyExecutorIDStartPos+dutyExecutorIDSize] } -func (msg MessageID) GetRoleType() RunnerRole { +func (msg MessageID) GetRoleType() spectypes.RunnerRole { roleByts := msg[roleTypeStartPos : roleTypeStartPos+roleTypeSize] roleValue := binary.LittleEndian.Uint32(roleByts) @@ -37,10 +37,10 @@ func (msg MessageID) GetRoleType() RunnerRole { return spectypes.RoleUnknown } - return RunnerRole(roleValue) + return spectypes.RunnerRole(roleValue) } -func NewMsgID(domain spectypes.DomainType, dutyExecutorID []byte, role RunnerRole) MessageID { +func NewMsgID(domain spectypes.DomainType, dutyExecutorID []byte, role spectypes.RunnerRole) MessageID { // Sanitize role. If bad role, return an empty MessageID roleValue := int32(role) if roleValue < 0 { diff --git a/exporter/convert/roles.go b/exporter/convert/roles.go deleted file mode 100644 index d854e1a936..0000000000 --- a/exporter/convert/roles.go +++ /dev/null @@ -1,61 +0,0 @@ -package convert - -type RunnerRole int32 - -const ( - RoleAttester RunnerRole = iota - RoleAggregator - RoleProposer - RoleSyncCommitteeContribution - RoleSyncCommittee - - RoleValidatorRegistration - RoleVoluntaryExit - RoleCommittee -) - -// String returns name of the runner role -func (r RunnerRole) String() string { - switch r { - case RoleAttester: - return "ATTESTER" - case RoleAggregator: - return "AGGREGATOR" - case RoleProposer: - return "PROPOSER" - case RoleSyncCommittee: - return "SYNC_COMMITTEE" - case RoleSyncCommitteeContribution: - return "SYNC_COMMITTEE_CONTRIBUTION" - case RoleValidatorRegistration: - return "VALIDATOR_REGISTRATION" - case RoleVoluntaryExit: - return "VOLUNTARY_EXIT" - case RoleCommittee: - return "COMMITTEE" - default: - return "UNDEFINED" - } -} - -// ToBeaconRole returns name of the beacon role -func (r RunnerRole) ToBeaconRole() string { - switch r { - case RoleAttester: - return "ATTESTER" - case RoleAggregator: - return "AGGREGATOR" - case RoleProposer: - return "PROPOSER" - case RoleSyncCommittee: - return "SYNC_COMMITTEE" - case RoleSyncCommitteeContribution: - return "SYNC_COMMITTEE_CONTRIBUTION" - case RoleValidatorRegistration: - return "VALIDATOR_REGISTRATION" - case RoleVoluntaryExit: - return "VOLUNTARY_EXIT" - default: - return "UNDEFINED" - } -} diff --git a/ibft/storage/stores.go b/ibft/storage/stores.go index f187ce0028..f75f63db88 100644 --- a/ibft/storage/stores.go +++ b/ibft/storage/stores.go @@ -1,25 +1,24 @@ package storage import ( - "github.com/ssvlabs/ssv/utils/hashmap" - - "github.com/ssvlabs/ssv/exporter/convert" + spectypes "github.com/ssvlabs/ssv-spec/types" qbftstorage "github.com/ssvlabs/ssv/protocol/v2/qbft/storage" "github.com/ssvlabs/ssv/storage/basedb" + "github.com/ssvlabs/ssv/utils/hashmap" ) // QBFTStores wraps sync map with cast functions to qbft store type QBFTStores struct { - m *hashmap.Map[convert.RunnerRole, qbftstorage.QBFTStore] + m *hashmap.Map[spectypes.RunnerRole, qbftstorage.QBFTStore] } func NewStores() *QBFTStores { return &QBFTStores{ - m: hashmap.New[convert.RunnerRole, qbftstorage.QBFTStore](), + m: hashmap.New[spectypes.RunnerRole, qbftstorage.QBFTStore](), } } -func NewStoresFromRoles(db basedb.Database, roles ...convert.RunnerRole) *QBFTStores { +func NewStoresFromRoles(db basedb.Database, roles ...spectypes.RunnerRole) *QBFTStores { stores := NewStores() for _, role := range roles { stores.Add(role, New(db, role.String())) @@ -28,7 +27,7 @@ func NewStoresFromRoles(db basedb.Database, roles ...convert.RunnerRole) *QBFTSt } // Get store from sync map by role type -func (qs *QBFTStores) Get(role convert.RunnerRole) qbftstorage.QBFTStore { +func (qs *QBFTStores) Get(role spectypes.RunnerRole) qbftstorage.QBFTStore { s, ok := qs.m.Get(role) if !ok { return nil @@ -37,14 +36,14 @@ func (qs *QBFTStores) Get(role convert.RunnerRole) qbftstorage.QBFTStore { } // Add store to sync map by role as a key -func (qs *QBFTStores) Add(role convert.RunnerRole, store qbftstorage.QBFTStore) { +func (qs *QBFTStores) Add(role spectypes.RunnerRole, store qbftstorage.QBFTStore) { qs.m.Set(role, store) } // Each iterates over all stores and calls the given function -func (qs *QBFTStores) Each(f func(role convert.RunnerRole, store qbftstorage.QBFTStore) error) error { +func (qs *QBFTStores) Each(f func(role spectypes.RunnerRole, store qbftstorage.QBFTStore) error) error { var err error - qs.m.Range(func(role convert.RunnerRole, store qbftstorage.QBFTStore) bool { + qs.m.Range(func(role spectypes.RunnerRole, store qbftstorage.QBFTStore) bool { err = f(role, store) return err == nil }) diff --git a/ibft/storage/stores_test.go b/ibft/storage/stores_test.go index 0fc9c640ee..0773e1059c 100644 --- a/ibft/storage/stores_test.go +++ b/ibft/storage/stores_test.go @@ -3,13 +3,14 @@ package storage import ( "testing" + "github.com/stretchr/testify/require" + specqbft "github.com/ssvlabs/ssv-spec/qbft" - "github.com/ssvlabs/ssv/exporter/convert" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/logging" qbftstorage "github.com/ssvlabs/ssv/protocol/v2/qbft/storage" "github.com/ssvlabs/ssv/storage/basedb" "github.com/ssvlabs/ssv/storage/kv" - "github.com/stretchr/testify/require" ) func TestQBFTStores(t *testing.T) { @@ -19,29 +20,29 @@ func TestQBFTStores(t *testing.T) { store, err := newTestIbftStorage(logger, "") require.NoError(t, err) - qbftMap.Add(convert.RoleCommittee, store) - qbftMap.Add(convert.RoleCommittee, store) + qbftMap.Add(spectypes.RoleCommittee, store) + qbftMap.Add(spectypes.RoleCommittee, store) - require.NotNil(t, qbftMap.Get(convert.RoleCommittee)) - require.NotNil(t, qbftMap.Get(convert.RoleCommittee)) + require.NotNil(t, qbftMap.Get(spectypes.RoleCommittee)) + require.NotNil(t, qbftMap.Get(spectypes.RoleCommittee)) db, err := kv.NewInMemory(logger.Named(logging.NameBadgerDBLog), basedb.Options{ Reporting: true, }) require.NoError(t, err) - qbftMap = NewStoresFromRoles(db, convert.RoleCommittee, convert.RoleProposer) + qbftMap = NewStoresFromRoles(db, spectypes.RoleCommittee, spectypes.RoleProposer) - require.NotNil(t, qbftMap.Get(convert.RoleCommittee)) - require.NotNil(t, qbftMap.Get(convert.RoleCommittee)) + require.NotNil(t, qbftMap.Get(spectypes.RoleCommittee)) + require.NotNil(t, qbftMap.Get(spectypes.RoleCommittee)) id := []byte{1, 2, 3} - err = qbftMap.Each(func(role convert.RunnerRole, store qbftstorage.QBFTStore) error { + err = qbftMap.Each(func(role spectypes.RunnerRole, store qbftstorage.QBFTStore) error { return store.SaveInstance(&qbftstorage.StoredInstance{State: &specqbft.State{Height: 1, ID: id}}) }) require.NoError(t, err) - instance, err := qbftMap.Get(convert.RoleCommittee).GetInstance(id, 1) + instance, err := qbftMap.Get(spectypes.RoleCommittee).GetInstance(id, 1) require.NoError(t, err) require.NotNil(t, instance) require.Equal(t, specqbft.Height(1), instance.State.Height) diff --git a/integration/qbft/tests/scenario_test.go b/integration/qbft/tests/scenario_test.go index c5eac5ad0d..24c522da01 100644 --- a/integration/qbft/tests/scenario_test.go +++ b/integration/qbft/tests/scenario_test.go @@ -7,12 +7,12 @@ import ( spec "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/ethereum/go-ethereum/common" - spectypes "github.com/ssvlabs/ssv-spec/types" - "github.com/ssvlabs/ssv-spec/types/testingutils" - spectestingutils "github.com/ssvlabs/ssv-spec/types/testingutils" "github.com/stretchr/testify/require" "go.uber.org/zap" + spectypes "github.com/ssvlabs/ssv-spec/types" + "github.com/ssvlabs/ssv-spec/types/testingutils" + spectestingutils "github.com/ssvlabs/ssv-spec/types/testingutils" "github.com/ssvlabs/ssv/exporter/convert" qbftstorage "github.com/ssvlabs/ssv/ibft/storage" "github.com/ssvlabs/ssv/logging" @@ -174,15 +174,13 @@ func newStores(logger *zap.Logger) *qbftstorage.QBFTStores { storageMap := qbftstorage.NewStores() - roles := []convert.RunnerRole{ - convert.RoleAttester, - convert.RoleAggregator, - convert.RoleProposer, - convert.RoleSyncCommitteeContribution, - convert.RoleSyncCommittee, - convert.RoleValidatorRegistration, - convert.RoleVoluntaryExit, - convert.RoleCommittee, + roles := []spectypes.RunnerRole{ + spectypes.RoleAggregator, + spectypes.RoleProposer, + spectypes.RoleSyncCommitteeContribution, + spectypes.RoleValidatorRegistration, + spectypes.RoleVoluntaryExit, + spectypes.RoleCommittee, } for _, role := range roles { storageMap.Add(role, qbftstorage.New(db, role.String())) diff --git a/logging/fields/fields.go b/logging/fields/fields.go index 61d53747b3..64494826c0 100644 --- a/logging/fields/fields.go +++ b/logging/fields/fields.go @@ -9,19 +9,17 @@ import ( "strings" "time" - "github.com/ssvlabs/ssv/exporter/convert" - "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/dgraph-io/ristretto" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/libp2p/go-libp2p/core/peer" - specqbft "github.com/ssvlabs/ssv-spec/qbft" - spectypes "github.com/ssvlabs/ssv-spec/types" "go.uber.org/zap" "go.uber.org/zap/zapcore" + specqbft "github.com/ssvlabs/ssv-spec/qbft" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/eth/contract" "github.com/ssvlabs/ssv/logging/fields/stringer" "github.com/ssvlabs/ssv/network/records" @@ -233,7 +231,7 @@ func BeaconRole(val spectypes.BeaconRole) zap.Field { func Role(val spectypes.RunnerRole) zap.Field { return zap.Stringer(FieldRole, val) } -func ExporterRole(val convert.RunnerRole) zap.Field { +func ExporterRole(val spectypes.RunnerRole) zap.Field { return zap.Stringer(FieldRole, val) } diff --git a/operator/validator/controller.go b/operator/validator/controller.go index de3e9dbd23..5444339429 100644 --- a/operator/validator/controller.go +++ b/operator/validator/controller.go @@ -14,13 +14,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/jellydator/ttlcache/v3" "github.com/pkg/errors" + "go.uber.org/zap" + genesisspecqbft "github.com/ssvlabs/ssv-spec-pre-cc/qbft" genesisspecssv "github.com/ssvlabs/ssv-spec-pre-cc/ssv" genesisspectypes "github.com/ssvlabs/ssv-spec-pre-cc/types" specqbft "github.com/ssvlabs/ssv-spec/qbft" spectypes "github.com/ssvlabs/ssv-spec/types" - "go.uber.org/zap" - "github.com/ssvlabs/ssv/exporter/convert" "github.com/ssvlabs/ssv/ibft/genesisstorage" "github.com/ssvlabs/ssv/ibft/storage" @@ -1239,7 +1239,7 @@ func SetupCommitteeRunners( leader := qbft.RoundRobinProposer(state, round) return leader }, - Storage: options.Storage.Get(convert.RunnerRole(role)), + Storage: options.Storage.Get(role), Network: options.Network, Timer: roundtimer.New(ctx, options.NetworkConfig.Beacon, role, nil), CutOffRound: roundtimer.CutOffRound, @@ -1303,7 +1303,7 @@ func SetupRunners( //logger.Debug("leader", zap.Int("operator_id", int(leader))) return leader }, - Storage: options.Storage.Get(convert.RunnerRole(role)), + Storage: options.Storage.Get(role), Network: options.Network, Timer: roundtimer.New(ctx, options.NetworkConfig.Beacon, role, nil), CutOffRound: roundtimer.CutOffRound, diff --git a/protocol/v2/qbft/spectest/controller_type.go b/protocol/v2/qbft/spectest/controller_type.go index 5cf150b850..788cdc31ea 100644 --- a/protocol/v2/qbft/spectest/controller_type.go +++ b/protocol/v2/qbft/spectest/controller_type.go @@ -10,16 +10,14 @@ import ( "reflect" "testing" - "github.com/ssvlabs/ssv/exporter/convert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" specqbft "github.com/ssvlabs/ssv-spec/qbft" spectests "github.com/ssvlabs/ssv-spec/qbft/spectest/tests" spectypes "github.com/ssvlabs/ssv-spec/types" spectestingutils "github.com/ssvlabs/ssv-spec/types/testingutils" typescomparable "github.com/ssvlabs/ssv-spec/types/testingutils/comparable" - "github.com/stretchr/testify/require" - "go.uber.org/zap" - "github.com/ssvlabs/ssv/logging" "github.com/ssvlabs/ssv/protocol/v2/qbft" "github.com/ssvlabs/ssv/protocol/v2/qbft/controller" @@ -60,7 +58,7 @@ func RunControllerSpecTest(t *testing.T, test *spectests.ControllerSpecTest) { func generateController(logger *zap.Logger) *controller.Controller { identifier := []byte{1, 2, 3, 4} - config := qbfttesting.TestingConfig(logger, spectestingutils.Testing4SharesSet(), convert.RoleCommittee) + config := qbfttesting.TestingConfig(logger, spectestingutils.Testing4SharesSet(), spectypes.RoleCommittee) return qbfttesting.NewTestingQBFTController( spectestingutils.Testing4SharesSet(), identifier[:], diff --git a/protocol/v2/qbft/spectest/msg_processing_type.go b/protocol/v2/qbft/spectest/msg_processing_type.go index c11d8ada11..34ad4cbee1 100644 --- a/protocol/v2/qbft/spectest/msg_processing_type.go +++ b/protocol/v2/qbft/spectest/msg_processing_type.go @@ -8,14 +8,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + specqbft "github.com/ssvlabs/ssv-spec/qbft" spectests "github.com/ssvlabs/ssv-spec/qbft/spectest/tests" spectypes "github.com/ssvlabs/ssv-spec/types" spectestingutils "github.com/ssvlabs/ssv-spec/types/testingutils" typescomparable "github.com/ssvlabs/ssv-spec/types/testingutils/comparable" - "github.com/stretchr/testify/require" - - "github.com/ssvlabs/ssv/exporter/convert" "github.com/ssvlabs/ssv/logging" "github.com/ssvlabs/ssv/protocol/v2/qbft" "github.com/ssvlabs/ssv/protocol/v2/qbft/instance" @@ -34,7 +33,7 @@ func RunMsgProcessing(t *testing.T, test *spectests.MsgProcessingSpecTest) { ks := spectestingutils.KeySetForCommitteeMember(test.Pre.State.CommitteeMember) signer := spectestingutils.NewOperatorSigner(ks, 1) pre := instance.NewInstance( - qbfttesting.TestingConfig(logger, ks, convert.RunnerRole(msgId.GetRoleType())), // #nosec G104 + qbfttesting.TestingConfig(logger, ks, msgId.GetRoleType()), // #nosec G104 test.Pre.State.CommitteeMember, test.Pre.State.ID, test.Pre.State.Height, diff --git a/protocol/v2/qbft/spectest/qbft_mapping_test.go b/protocol/v2/qbft/spectest/qbft_mapping_test.go index 53477b59e1..c63a850305 100644 --- a/protocol/v2/qbft/spectest/qbft_mapping_test.go +++ b/protocol/v2/qbft/spectest/qbft_mapping_test.go @@ -7,13 +7,12 @@ import ( "strings" "testing" - "github.com/ssvlabs/ssv/exporter/convert" + "github.com/stretchr/testify/require" spectests "github.com/ssvlabs/ssv-spec/qbft/spectest/tests" "github.com/ssvlabs/ssv-spec/qbft/spectest/tests/timeout" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv-spec/types/testingutils" - "github.com/stretchr/testify/require" - "github.com/ssvlabs/ssv/logging" "github.com/ssvlabs/ssv/protocol/v2/qbft/instance" testing2 "github.com/ssvlabs/ssv/protocol/v2/qbft/testing" @@ -102,7 +101,7 @@ func TestQBFTMapping(t *testing.T) { ks := testingutils.Testing4SharesSet() signer := testingutils.NewOperatorSigner(ks, 1) pre := instance.NewInstance( - testing2.TestingConfig(logger, testingutils.KeySetForCommitteeMember(typedTest.Pre.State.CommitteeMember), convert.RoleCommittee), + testing2.TestingConfig(logger, testingutils.KeySetForCommitteeMember(typedTest.Pre.State.CommitteeMember), spectypes.RoleCommittee), typedTest.Pre.State.CommitteeMember, typedTest.Pre.State.ID, typedTest.Pre.State.Height, diff --git a/protocol/v2/qbft/testing/storage.go b/protocol/v2/qbft/testing/storage.go index 8a289ecda7..5b7578246a 100644 --- a/protocol/v2/qbft/testing/storage.go +++ b/protocol/v2/qbft/testing/storage.go @@ -6,8 +6,7 @@ import ( "go.uber.org/zap" - "github.com/ssvlabs/ssv/exporter/convert" - + spectypes "github.com/ssvlabs/ssv-spec/types" qbftstorage "github.com/ssvlabs/ssv/ibft/storage" "github.com/ssvlabs/ssv/storage/basedb" "github.com/ssvlabs/ssv/storage/kv" @@ -29,15 +28,13 @@ func getDB(logger *zap.Logger) basedb.Database { return db } -var allRoles = []convert.RunnerRole{ - convert.RoleAttester, - convert.RoleAggregator, - convert.RoleProposer, - convert.RoleSyncCommitteeContribution, - convert.RoleSyncCommittee, - convert.RoleValidatorRegistration, - convert.RoleVoluntaryExit, - convert.RoleCommittee, +var allRoles = []spectypes.RunnerRole{ + spectypes.RoleAggregator, + spectypes.RoleProposer, + spectypes.RoleSyncCommitteeContribution, + spectypes.RoleValidatorRegistration, + spectypes.RoleVoluntaryExit, + spectypes.RoleCommittee, } func TestingStores(logger *zap.Logger) *qbftstorage.QBFTStores { diff --git a/protocol/v2/qbft/testing/utils.go b/protocol/v2/qbft/testing/utils.go index 66b49340d6..7b4bd3e082 100644 --- a/protocol/v2/qbft/testing/utils.go +++ b/protocol/v2/qbft/testing/utils.go @@ -6,18 +6,16 @@ import ( "github.com/pkg/errors" "go.uber.org/zap" - "github.com/ssvlabs/ssv/exporter/convert" - "github.com/ssvlabs/ssv/protocol/v2/qbft/roundtimer" - specqbft "github.com/ssvlabs/ssv-spec/qbft" "github.com/ssvlabs/ssv-spec/types" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv-spec/types/testingutils" - "github.com/ssvlabs/ssv/protocol/v2/qbft" "github.com/ssvlabs/ssv/protocol/v2/qbft/controller" + "github.com/ssvlabs/ssv/protocol/v2/qbft/roundtimer" ) -var TestingConfig = func(logger *zap.Logger, keySet *testingutils.TestKeySet, role convert.RunnerRole) *qbft.Config { +var TestingConfig = func(logger *zap.Logger, keySet *testingutils.TestKeySet, role spectypes.RunnerRole) *qbft.Config { return &qbft.Config{ BeaconSigner: testingutils.NewTestingKeyManager(), Domain: testingutils.TestingSSVDomainType, diff --git a/protocol/v2/ssv/spectest/ssv_mapping_test.go b/protocol/v2/ssv/spectest/ssv_mapping_test.go index 5e530ebef2..90c5cf6086 100644 --- a/protocol/v2/ssv/spectest/ssv_mapping_test.go +++ b/protocol/v2/ssv/spectest/ssv_mapping_test.go @@ -10,6 +10,9 @@ import ( "testing" "github.com/attestantio/go-eth2-client/spec/phase0" + "github.com/stretchr/testify/require" + "go.uber.org/zap" + specssv "github.com/ssvlabs/ssv-spec/ssv" "github.com/ssvlabs/ssv-spec/ssv/spectest/tests" "github.com/ssvlabs/ssv-spec/ssv/spectest/tests/committee" @@ -21,10 +24,6 @@ import ( spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv-spec/types/testingutils" spectestingutils "github.com/ssvlabs/ssv-spec/types/testingutils" - "github.com/stretchr/testify/require" - "go.uber.org/zap" - - "github.com/ssvlabs/ssv/exporter/convert" tests2 "github.com/ssvlabs/ssv/integration/qbft/tests" "github.com/ssvlabs/ssv/logging" "github.com/ssvlabs/ssv/networkconfig" @@ -392,7 +391,7 @@ func fixRunnerForRun(t *testing.T, runnerMap map[string]interface{}, ks *spectes } func fixControllerForRun(t *testing.T, logger *zap.Logger, runner runner.Runner, contr *controller.Controller, ks *spectestingutils.TestKeySet) *controller.Controller { - config := qbfttesting.TestingConfig(logger, ks, convert.RoleCommittee) + config := qbfttesting.TestingConfig(logger, ks, spectypes.RoleCommittee) config.ValueCheckF = runner.GetValCheckF() newContr := controller.NewController( contr.Identifier, diff --git a/protocol/v2/ssv/testing/runner.go b/protocol/v2/ssv/testing/runner.go index 35af231928..3879d2f361 100644 --- a/protocol/v2/ssv/testing/runner.go +++ b/protocol/v2/ssv/testing/runner.go @@ -5,18 +5,16 @@ import ( "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/pkg/errors" + "go.uber.org/zap" + specqbft "github.com/ssvlabs/ssv-spec/qbft" spectypes "github.com/ssvlabs/ssv-spec/types" spectestingutils "github.com/ssvlabs/ssv-spec/types/testingutils" - "go.uber.org/zap" - - "github.com/ssvlabs/ssv/protocol/v2/qbft/controller" - "github.com/ssvlabs/ssv/protocol/v2/ssv" - - "github.com/ssvlabs/ssv/exporter/convert" "github.com/ssvlabs/ssv/integration/qbft/tests" "github.com/ssvlabs/ssv/networkconfig" + "github.com/ssvlabs/ssv/protocol/v2/qbft/controller" "github.com/ssvlabs/ssv/protocol/v2/qbft/testing" + "github.com/ssvlabs/ssv/protocol/v2/ssv" "github.com/ssvlabs/ssv/protocol/v2/ssv/runner" "github.com/ssvlabs/ssv/protocol/v2/ssv/validator" ) @@ -98,14 +96,14 @@ var ConstructBaseRunner = func( valCheck = nil } - config := testing.TestingConfig(logger, keySet, convert.RunnerRole(identifier.GetRoleType())) + config := testing.TestingConfig(logger, keySet, identifier.GetRoleType()) config.ValueCheckF = valCheck config.ProposerF = func(state *specqbft.State, round specqbft.Round) spectypes.OperatorID { return 1 } config.Network = net config.BeaconSigner = km - config.Storage = testing.TestingStores(logger).Get(convert.RunnerRole(role)) + config.Storage = testing.TestingStores(logger).Get(role) contr := testing.NewTestingQBFTController( spectestingutils.Testing4SharesSet(), @@ -352,13 +350,13 @@ var ConstructBaseRunnerWithShareMap = func( valCheck = nil } - config := testing.TestingConfig(logger, keySetInstance, convert.RunnerRole(identifier.GetRoleType())) + config := testing.TestingConfig(logger, keySetInstance, identifier.GetRoleType()) config.ValueCheckF = valCheck config.ProposerF = func(state *specqbft.State, round specqbft.Round) spectypes.OperatorID { return 1 } config.Network = net - config.Storage = testing.TestingStores(logger).Get(convert.RunnerRole(role)) + config.Storage = testing.TestingStores(logger).Get(role) contr = testing.NewTestingQBFTController( spectestingutils.Testing4SharesSet(), diff --git a/protocol/v2/ssv/validator/non_committee_validator.go b/protocol/v2/ssv/validator/non_committee_validator.go index aa8879b0ec..2463472284 100644 --- a/protocol/v2/ssv/validator/non_committee_validator.go +++ b/protocol/v2/ssv/validator/non_committee_validator.go @@ -2,17 +2,16 @@ package validator import ( "fmt" - "github.com/ssvlabs/ssv/protocol/v2/qbft/roundtimer" "slices" "strconv" "strings" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/herumi/bls-eth-go-binary/bls" - specqbft "github.com/ssvlabs/ssv-spec/qbft" - spectypes "github.com/ssvlabs/ssv-spec/types" "go.uber.org/zap" + specqbft "github.com/ssvlabs/ssv-spec/qbft" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/exporter/convert" "github.com/ssvlabs/ssv/ibft/storage" "github.com/ssvlabs/ssv/logging/fields" @@ -20,6 +19,7 @@ import ( "github.com/ssvlabs/ssv/protocol/v2/qbft" qbftcontroller "github.com/ssvlabs/ssv/protocol/v2/qbft/controller" qbftctrl "github.com/ssvlabs/ssv/protocol/v2/qbft/controller" + "github.com/ssvlabs/ssv/protocol/v2/qbft/roundtimer" qbftstorage "github.com/ssvlabs/ssv/protocol/v2/qbft/storage" "github.com/ssvlabs/ssv/protocol/v2/ssv" "github.com/ssvlabs/ssv/protocol/v2/ssv/queue" @@ -120,7 +120,7 @@ func (ncv *CommitteeObserver) ProcessMessage(msg *queue.SSVMessage) error { operatorIDs = append(operatorIDs, strconv.FormatUint(share, 10)) } logger.Info("✅ saved participants", - zap.String("converted_role", role.ToBeaconRole()), + zap.String("converted_role", role.String()), zap.String("validator_index", strconv.FormatUint(uint64(key.ValidatorIndex), 10)), zap.String("signers", strings.Join(operatorIDs, ", ")), ) @@ -138,15 +138,8 @@ func (ncv *CommitteeObserver) ProcessMessage(msg *queue.SSVMessage) error { return nil } -func (ncv *CommitteeObserver) getRole(msg *queue.SSVMessage, root [32]byte) convert.RunnerRole { - if msg.MsgID.GetRoleType() == spectypes.RoleCommittee { - _, found := ncv.Roots[root] - if !found { - return convert.RoleAttester - } - return convert.RoleSyncCommittee - } - return convert.RunnerRole(msg.MsgID.GetRoleType()) +func (ncv *CommitteeObserver) getRole(msg *queue.SSVMessage, root [32]byte) spectypes.RunnerRole { + return msg.MsgID.GetRoleType() } // nonCommitteeInstanceContainerCapacity returns the capacity of InstanceContainer for non-committee validators diff --git a/utils/casts/casts.go b/utils/casts/casts.go index 38aa186519..fbe0333c7a 100644 --- a/utils/casts/casts.go +++ b/utils/casts/casts.go @@ -6,8 +6,6 @@ import ( "time" spectypes "github.com/ssvlabs/ssv-spec/types" - - "github.com/ssvlabs/ssv/exporter/convert" ) var ( @@ -23,8 +21,8 @@ func DurationFromUint64(t uint64) time.Duration { return time.Duration(t) // #nosec G115 } -func BeaconRoleToConvertRole(beaconRole spectypes.BeaconRole) convert.RunnerRole { - return convert.RunnerRole(beaconRole) // #nosec G115 +func BeaconRoleToConvertRole(beaconRole spectypes.BeaconRole) spectypes.RunnerRole { + return spectypes.RunnerRole(beaconRole) // #nosec G115 } func BeaconRoleToRunnerRole(beaconRole spectypes.BeaconRole) spectypes.RunnerRole {