Skip to content

Commit

Permalink
aggregate commit for #1788
Browse files Browse the repository at this point in the history
  • Loading branch information
iurii-ssv committed Oct 25, 2024
1 parent 3de919b commit 5561ad3
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 23 deletions.
16 changes: 13 additions & 3 deletions operator/validator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
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"
Expand Down Expand Up @@ -59,6 +57,7 @@ import (
ssvtypes "github.com/ssvlabs/ssv/protocol/v2/types"
registrystorage "github.com/ssvlabs/ssv/registry/storage"
"github.com/ssvlabs/ssv/storage/basedb"
"go.uber.org/zap"
)

//go:generate mockgen -package=mocks -destination=./mocks/controller.go -source=./controller.go
Expand Down Expand Up @@ -199,6 +198,7 @@ type controller struct {
validatorsMap *validators.ValidatorsMap
validatorStartFunc func(validator *validators.ValidatorContainer) (bool, error)
committeeValidatorSetup chan struct{}
dutyGuard *validator.CommitteeDutyGuard

metadataUpdateInterval time.Duration

Expand Down Expand Up @@ -323,6 +323,7 @@ func NewController(logger *zap.Logger, options ControllerOptions) Controller {
indicesChange: make(chan struct{}),
validatorExitCh: make(chan duties.ExitDescriptor),
committeeValidatorSetup: make(chan struct{}, 1),
dutyGuard: validator.NewCommitteeDutyGuard(),

messageValidator: options.MessageValidator,
}
Expand Down Expand Up @@ -964,7 +965,16 @@ func (c *controller) onShareInit(share *ssvtypes.SSVShare) (*validators.Validato

committeeRunnerFunc := SetupCommitteeRunners(ctx, opts)

vc = validator.NewCommittee(ctx, cancel, logger, c.beacon.GetBeaconNetwork(), operator, committeeRunnerFunc, nil)
vc = validator.NewCommittee(
ctx,
cancel,
logger,
c.beacon.GetBeaconNetwork(),
operator,
committeeRunnerFunc,
nil,
c.dutyGuard,
)
vc.AddShare(&share.Share)
c.validatorsMap.PutCommittee(operator.CommitteeID, vc)

Expand Down
8 changes: 4 additions & 4 deletions protocol/v2/ssv/spectest/msg_processing_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import (
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/integration/qbft/tests"
"github.com/ssvlabs/ssv/logging"
"github.com/ssvlabs/ssv/networkconfig"
Expand All @@ -27,6 +24,8 @@ import (
ssvprotocoltesting "github.com/ssvlabs/ssv/protocol/v2/ssv/testing"
"github.com/ssvlabs/ssv/protocol/v2/ssv/validator"
protocoltesting "github.com/ssvlabs/ssv/protocol/v2/testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)

type MsgProcessingSpecTest struct {
Expand Down Expand Up @@ -248,7 +247,7 @@ var baseCommitteeWithRunnerSample = func(
logger *zap.Logger,
keySetMap map[phase0.ValidatorIndex]*spectestingutils.TestKeySet,
runnerSample *runner.CommitteeRunner,
committeeDutyGuard runner.CommitteeDutyGuard,
committeeDutyGuard *validator.CommitteeDutyGuard,
) *validator.Committee {

var keySetSample *spectestingutils.TestKeySet
Expand Down Expand Up @@ -292,6 +291,7 @@ var baseCommitteeWithRunnerSample = func(
spectestingutils.TestingCommitteeMember(keySetSample),
createRunnerF,
shareMap,
committeeDutyGuard,
)

return c
Expand Down
6 changes: 3 additions & 3 deletions protocol/v2/ssv/spectest/ssv_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,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"
Expand All @@ -35,6 +32,8 @@ import (
ssvtesting "github.com/ssvlabs/ssv/protocol/v2/ssv/testing"
"github.com/ssvlabs/ssv/protocol/v2/ssv/validator"
protocoltesting "github.com/ssvlabs/ssv/protocol/v2/testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)

func TestSSVMapping(t *testing.T) {
Expand Down Expand Up @@ -564,6 +563,7 @@ func fixCommitteeForRun(t *testing.T, ctx context.Context, logger *zap.Logger, c
return r.(*runner.CommitteeRunner), nil
},
specCommittee.Share,
validator.NewCommitteeDutyGuard(),
)
tmpSsvCommittee := &validator.Committee{}
require.NoError(t, json.Unmarshal(byts, tmpSsvCommittee))
Expand Down
18 changes: 9 additions & 9 deletions protocol/v2/ssv/testing/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import (
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"
"go.uber.org/zap"
)

var TestingHighestDecidedSlot = phase0.Slot(0)
Expand Down Expand Up @@ -117,6 +115,7 @@ var ConstructBaseRunner = func(

shareMap := make(map[phase0.ValidatorIndex]*spectypes.Share)
shareMap[share.ValidatorIndex] = share
dutyGuard := validator.NewCommitteeDutyGuard()

var r runner.Runner
var err error
Expand All @@ -132,7 +131,7 @@ var ConstructBaseRunner = func(
km,
opSigner,
valCheck,
validator.NewCommitteeDutyGuard(),
dutyGuard,
)
case spectypes.RoleAggregator:
r, err = runner.NewAggregatorRunner(
Expand Down Expand Up @@ -204,7 +203,7 @@ var ConstructBaseRunner = func(
km,
opSigner,
valCheck,
validator.NewCommitteeDutyGuard(),
dutyGuard,
)
r.(*runner.CommitteeRunner).BaseRunner.RunnerRoleType = spectestingutils.UnknownDutyType
default:
Expand Down Expand Up @@ -300,6 +299,7 @@ var ConstructBaseRunnerWithShareMap = func(
var contr *controller.Controller

km := spectestingutils.NewTestingKeyManager()
dutyGuard := validator.NewCommitteeDutyGuard()

if len(shareMap) > 0 {
var keySetInstance *spectestingutils.TestKeySet
Expand Down Expand Up @@ -382,7 +382,7 @@ var ConstructBaseRunnerWithShareMap = func(
km,
opSigner,
valCheck,
validator.NewCommitteeDutyGuard(),
dutyGuard,
)
case spectypes.RoleAggregator:
r, err = runner.NewAggregatorRunner(
Expand Down Expand Up @@ -454,7 +454,7 @@ var ConstructBaseRunnerWithShareMap = func(
km,
opSigner,
valCheck,
validator.NewCommitteeDutyGuard(),
dutyGuard,
)
if r != nil {
r.(*runner.CommitteeRunner).BaseRunner.RunnerRoleType = spectestingutils.UnknownDutyType
Expand Down
6 changes: 3 additions & 3 deletions protocol/v2/ssv/validator/committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import (
"github.com/pkg/errors"
"github.com/ssvlabs/ssv-spec/qbft"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/ibft/storage"
"github.com/ssvlabs/ssv/logging/fields"
"github.com/ssvlabs/ssv/protocol/v2/message"
"github.com/ssvlabs/ssv/protocol/v2/ssv/queue"
"github.com/ssvlabs/ssv/protocol/v2/ssv/runner"
"github.com/ssvlabs/ssv/protocol/v2/types"
"go.uber.org/zap"
)

var (
Expand Down Expand Up @@ -57,6 +56,7 @@ func NewCommittee(
committeeMember *spectypes.CommitteeMember,
createRunnerFn CommitteeRunnerFunc,
shares map[phase0.ValidatorIndex]*spectypes.Share,
dutyGuard *CommitteeDutyGuard,
) *Committee {
if shares == nil {
shares = make(map[phase0.ValidatorIndex]*spectypes.Share)
Expand All @@ -71,7 +71,7 @@ func NewCommittee(
Shares: shares,
CommitteeMember: committeeMember,
CreateRunnerFn: createRunnerFn,
dutyGuard: NewCommitteeDutyGuard(),
dutyGuard: dutyGuard,
}
}

Expand Down
5 changes: 5 additions & 0 deletions protocol/v2/ssv/validator/committee_guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func (a *CommitteeDutyGuard) StartDuty(role spectypes.BeaconRole, validator spec
if !ok {
return fmt.Errorf("unsupported role %d", role)
}
// If an older committee duty is still running for this validator we won't be interested in it
// anymore now that we have a fresher duty started. The older duty might or might not finish
// successfully, either outcome is fine but since it's always better to execute the freshest
// committee duty CommitteeDutyGuard will invalidate the older duty (potentially preventing it
// from execution so that we don't waste resources on it).
runningSlot, exists := duties[validator]
if exists && runningSlot >= slot {
return fmt.Errorf("duty already running at slot %d", runningSlot)
Expand Down
2 changes: 1 addition & 1 deletion scripts/spec-alignment/differ.config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ApprovedChanges: ["50e5bb7eda99594e", "870a3a66aeccd737","4e22a08543b079b","56ceb03cd44ff702","188adfe8914e04c1","2438f9c5b82b69a3","1a716ee3bdb3170","90b166f78390af18","68219b82a1d9d829","c4c4caa5d0938b85","dfe99ce1d27b6cb1","35f5dab1f128d193","9a3973b64d7e8932","f33f07301a770d03","3e9e0dddfad3b302","d4fef6512374c1f5","b49f54cb45787e4b","59b2375130aef5df","f094cd0460432170","8e51881e527dd603","a7d6d58d9fa06379","1d124224ca4d0fe3","39ea06bfd1477d2d","7e2550bab51f22b2","87ebd29bd49fc52f","ef39dd5223e0d080","fe14e7f0503ea188","6146023d4d5708a2","aebb8e4348b6d667","973a2e6704dbf3","fb4cac598a68c592","257c7eb81d6eb245","2a8e94fe037e13fd","5e7eb878de54eec6","960a9c64cd4ec93c","57dfd255520bd849","ec333ff8a708db69","1cc1ff39ad91ee69","5714652b88e2d44f","7a53b3b037c56325","8c02ef1964464c30","19a268910a20da3d","af6e01ed565029f3","318b5169ac4dabb6","372c6b332e8ba699","c0d8a364c0db855a","4287381be4fb1841","b1614afc1da7794f","c214975412f3fd7","8bbf7eba3fa0cf7e","8e4ec8debe331b36","7a671d8fcefc3793","e2b0e9c6454c1c08","6707ecfefa5fec21","d5a7389d730464f1","8dfae3b3223d2de0","a81c092c985de728","968df5082c727ed6","9e53c73ee60b1cc2","9d265e99dd31d4f5","a34619e078d2e42f","17e8cec4f0625d53","e913f373aa88f333","cfc1e05c372d88dc","e5de6901d78b8833","57c1885b43dd8d19","e8a49856a5edd893","22ea21d10a2f861c","954e4fce01631c4e","108b9575f7c1d4bc","1f8d076449068f64","5a7ad98296703f6","159536003eeddac8","8ca8f82e67ddd3dd","16ebe47404323cc1","48bfe5cf1e578b47","dd83182b693a7216","308d21d9830f7047","6dde03147e012b1a","730c3e5e59393b7d","5b44a4b425ecc397","df5debc50ec8babc","92a41554b2910bb8","c36c680554dde59f","447feaa5cdc1a010","fda90c61f44cb149","cdbb4930eced584c","274336ec1127e6c0","2a496f5b3ad542d2","6b395912dde33b0e","cac56ec14994216b","8850900b5d9bcc65","15e7706486c6359e","cc22f28953b787ea","3bad6ae11596a574","8f84422a240d889c","5b265432dfbbaac7","43794bf5953db193","7975821460ebe1e7","173c505e12aabb8f","47ee0d148148a56f","8cc38593ebe049b6","bda3aec7157b095a","248712911696a851","f4d9c910f1dbaef7","1a2146fcad37acb8","b0b146f9bdab64b6","edfd442b4d725fbb","122f053573538a32","d720d714a20833e1", "f9c984e71b685f9b","8c6b4fee5a4c13ce","c0a8d2019a2c30d5", "717bef26105c733f","2f70630c27062353","2f70337ba7566a69","dd607a44e1341e6b","5210501625ac3de5","f786bf475b5085aa","18a66ed6e613d9c1","e8943e7741f6843d","276a489bd5a00032","ba3bba59f10bf6b","3c50ce0c8089d871","89ee72f6c610ab84","c92b95a85da2cb11","927ea6aed3f98f20","9338904026a0ce37","9683cfa19dc544a3","4d3fa2b8dfcb5f5b", "f19e9a2b295bcfb3", "b10199b2de6f03b8", "1afc17e358f9ca79","4b58762c0b433442","d293ec1bc61bb707","3e88c3b49d093605","4890ff80c88cc41d","5227ff3a225dd20d","81a60407a3a0ba80","db2ad807eb66254a","d308bd7c553ccdcf","bdaf172971637cbe","6ade9202843071fe","2fe8e14083997744","19c9a5362d1e1d3a","5956f803d239f178","92c55a4548a8b760","9a95524213bccfff","2f51a7338b86c229","e96966a281d74505","3ee479b9cbbc3a1d","82b392ba39c6c594","b9d2404e5c570019","24f528d85fb021f2","fe9609a785305d81","b0934079dcd986cc","a9c520a19b26049","d19a9403fd732d94","74a928f5dcb2fdd9","cbbfdb5e68cdac80","10e39d2ceda91f34","f99a004cf6697875","8fa5e8ebf7d223ec","6c80c145ba705243","fbabbc90d0b4178a","ab0c7f24e551ca6","af38a11cb8682c75","b110cba51df9f8d2","c4ff2ed3d20dc419","9295a5bb10efcec7","ab56ea44a75f898a","ff51ef26ab53ba58","df3771e2589008f9","106e5689655bcfc6","f90e0fb6883bff93","667656095cec39ee","9a5597af260c748a"]
ApprovedChanges: ["50e5bb7eda99594e", "870a3a66aeccd737","4e22a08543b079b","56ceb03cd44ff702","188adfe8914e04c1","2438f9c5b82b69a3","1a716ee3bdb3170","90b166f78390af18","68219b82a1d9d829","c4c4caa5d0938b85","dfe99ce1d27b6cb1","35f5dab1f128d193","9a3973b64d7e8932","f33f07301a770d03","3e9e0dddfad3b302","d4fef6512374c1f5","b49f54cb45787e4b","59b2375130aef5df","f094cd0460432170","8e51881e527dd603","a7d6d58d9fa06379","1d124224ca4d0fe3","39ea06bfd1477d2d","7e2550bab51f22b2","87ebd29bd49fc52f","ef39dd5223e0d080","fe14e7f0503ea188","6146023d4d5708a2","aebb8e4348b6d667","973a2e6704dbf3","fb4cac598a68c592","257c7eb81d6eb245","2a8e94fe037e13fd","5e7eb878de54eec6","960a9c64cd4ec93c","57dfd255520bd849","ec333ff8a708db69","1cc1ff39ad91ee69","5714652b88e2d44f","7a53b3b037c56325","8c02ef1964464c30","19a268910a20da3d","af6e01ed565029f3","318b5169ac4dabb6","372c6b332e8ba699","c0d8a364c0db855a","4287381be4fb1841","b1614afc1da7794f","c214975412f3fd7","8bbf7eba3fa0cf7e","8e4ec8debe331b36","7a671d8fcefc3793","e2b0e9c6454c1c08","6707ecfefa5fec21","d5a7389d730464f1","8dfae3b3223d2de0","a81c092c985de728","968df5082c727ed6","9e53c73ee60b1cc2","9d265e99dd31d4f5","a34619e078d2e42f","17e8cec4f0625d53","e913f373aa88f333","cfc1e05c372d88dc","e5de6901d78b8833","57c1885b43dd8d19","e8a49856a5edd893","22ea21d10a2f861c","954e4fce01631c4e","108b9575f7c1d4bc","1f8d076449068f64","5a7ad98296703f6","159536003eeddac8","8ca8f82e67ddd3dd","16ebe47404323cc1","48bfe5cf1e578b47","dd83182b693a7216","308d21d9830f7047","6dde03147e012b1a","730c3e5e59393b7d","5b44a4b425ecc397","df5debc50ec8babc","92a41554b2910bb8","c36c680554dde59f","447feaa5cdc1a010","fda90c61f44cb149","cdbb4930eced584c","274336ec1127e6c0","2a496f5b3ad542d2","6b395912dde33b0e","cac56ec14994216b","8850900b5d9bcc65","15e7706486c6359e","cc22f28953b787ea","3bad6ae11596a574","8f84422a240d889c","5b265432dfbbaac7","43794bf5953db193","7975821460ebe1e7","173c505e12aabb8f","47ee0d148148a56f","8cc38593ebe049b6","bda3aec7157b095a","248712911696a851","f4d9c910f1dbaef7","1a2146fcad37acb8","b0b146f9bdab64b6","edfd442b4d725fbb","122f053573538a32","d720d714a20833e1", "f9c984e71b685f9b","8c6b4fee5a4c13ce","c0a8d2019a2c30d5", "717bef26105c733f","2f70630c27062353","2f70337ba7566a69","dd607a44e1341e6b","5210501625ac3de5","f786bf475b5085aa","18a66ed6e613d9c1","e8943e7741f6843d","276a489bd5a00032","ba3bba59f10bf6b","3c50ce0c8089d871","89ee72f6c610ab84","c92b95a85da2cb11","927ea6aed3f98f20","9338904026a0ce37","9683cfa19dc544a3","4d3fa2b8dfcb5f5b", "f19e9a2b295bcfb3", "b10199b2de6f03b8", "1afc17e358f9ca79","4b58762c0b433442","d293ec1bc61bb707","3e88c3b49d093605","4890ff80c88cc41d","5227ff3a225dd20d","81a60407a3a0ba80","db2ad807eb66254a","d308bd7c553ccdcf","bdaf172971637cbe","6ade9202843071fe","2fe8e14083997744","19c9a5362d1e1d3a","5956f803d239f178","92c55a4548a8b760","9a95524213bccfff","2f51a7338b86c229","e96966a281d74505","3ee479b9cbbc3a1d","82b392ba39c6c594","b9d2404e5c570019","24f528d85fb021f2","fe9609a785305d81","b0934079dcd986cc","a9c520a19b26049","d19a9403fd732d94","74a928f5dcb2fdd9","cbbfdb5e68cdac80","10e39d2ceda91f34","f99a004cf6697875","8fa5e8ebf7d223ec","6c80c145ba705243","fbabbc90d0b4178a","ab0c7f24e551ca6","af38a11cb8682c75","b110cba51df9f8d2","c4ff2ed3d20dc419","9295a5bb10efcec7","ab56ea44a75f898a","ff51ef26ab53ba58","df3771e2589008f9","106e5689655bcfc6","f90e0fb6883bff93","667656095cec39ee","9a5597af260c748a", "a347ee50e92f7334"]

IgnoredIdentifiers:
- logger
Expand Down

0 comments on commit 5561ad3

Please sign in to comment.