From 730980717d4c56d232ca9922fe499b4efedadb49 Mon Sep 17 00:00:00 2001 From: Lior Rutenberg Date: Tue, 7 Nov 2023 15:23:53 +0100 Subject: [PATCH] Stage (#1199) * refactor: remove domain type discovery logs * spec align (#1197) * spec align 0.3.4 * bump ekm version --------- Co-authored-by: moshe-blox --- go.mod | 10 ++-------- go.sum | 8 ++++---- network/discovery/dv5_service.go | 9 ++------- protocol/v2/ssv/runner/runner.go | 19 ++++++++++++++++++- .../v2/ssv/runner/validator_registration.go | 2 +- protocol/v2/ssv/runner/voluntary_exit.go | 2 +- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index dd15d92b49..cb1cfef274 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.20 require ( github.com/aquasecurity/table v1.8.0 github.com/attestantio/go-eth2-client v0.16.3 - github.com/bloxapp/eth2-key-manager v1.3.1 - github.com/bloxapp/ssv-spec v0.3.3 + github.com/bloxapp/eth2-key-manager v1.3.2 + github.com/bloxapp/ssv-spec v0.3.4 github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/cespare/xxhash/v2 v2.2.0 github.com/cornelk/hashmap v1.0.8 @@ -222,9 +222,3 @@ require ( replace github.com/google/flatbuffers => github.com/google/flatbuffers v1.11.0 replace github.com/dgraph-io/ristretto => github.com/dgraph-io/ristretto v0.1.1-0.20211108053508-297c39e6640f - -// TODO: remove this replace when the following PR is merged https://github.com/bloxapp/eth2-key-manager/pull/100 -replace github.com/bloxapp/eth2-key-manager => github.com/bloxapp/eth2-key-manager v1.3.2-0.20231022162227-e2b8264a29a5 - -// TODO: remove this replace when the following PR is merged https://github.com/bloxapp/ssv-spec/pull -replace github.com/bloxapp/ssv-spec => github.com/moshe-blox/ssv-spec v0.0.0-20231105135956-a64e63f6e35a diff --git a/go.sum b/go.sum index 4aabd85bc6..cd46217e19 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bloxapp/eth2-key-manager v1.3.2-0.20231022162227-e2b8264a29a5 h1:vjrMmMH15Bo0QF+228CuEZvCI+OuPyJRco82Gj/WyTI= -github.com/bloxapp/eth2-key-manager v1.3.2-0.20231022162227-e2b8264a29a5/go.mod h1:cT+qAJfnAzNz9StFoHQ8xAkyU2eyEukd6xfxvcBWuZA= +github.com/bloxapp/eth2-key-manager v1.3.2 h1:xzxwYQZr8DoQrkCBkTnSdDWqqoPq/iy5VoKLxfPf4IY= +github.com/bloxapp/eth2-key-manager v1.3.2/go.mod h1:cT+qAJfnAzNz9StFoHQ8xAkyU2eyEukd6xfxvcBWuZA= +github.com/bloxapp/ssv-spec v0.3.4 h1:uu1pAP8FBucGf1FGORjzqz7if0vWGRY5w6ILLhA7IuM= +github.com/bloxapp/ssv-spec v0.3.4/go.mod h1:zPJR7YnG5iZ6I0h6EzfVly8bTBXaZwcx4TyJ8pzYVd8= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= @@ -519,8 +521,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= -github.com/moshe-blox/ssv-spec v0.0.0-20231105135956-a64e63f6e35a h1:I9d5JgkAFj3twwA3D7KkMxvp1wvMnkScmSGDvlf8J7o= -github.com/moshe-blox/ssv-spec v0.0.0-20231105135956-a64e63f6e35a/go.mod h1:zPJR7YnG5iZ6I0h6EzfVly8bTBXaZwcx4TyJ8pzYVd8= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= diff --git a/network/discovery/dv5_service.go b/network/discovery/dv5_service.go index 7c1c58150f..91ce4e340a 100644 --- a/network/discovery/dv5_service.go +++ b/network/discovery/dv5_service.go @@ -3,7 +3,6 @@ package discovery import ( "bytes" "context" - "encoding/hex" "fmt" "net" "sync/atomic" @@ -152,13 +151,9 @@ func (dvs *DiscV5Service) checkPeer(logger *zap.Logger, e PeerEvent) error { // TODO: uncomment errors once there are sufficient nodes with domain type. nodeDomainType, err := records.GetDomainTypeEntry(e.Node.Record()) if err != nil { - // return fmt.Errorf("could not read domain type: %w", err) - logger.Debug("could not read domain type entry", zap.Error(err)) + // TODO: skip missing domain type (likely old node). } else if nodeDomainType != dvs.domainType { - // return errors.New("different domain type") - logger.Debug("skipping different domain type entry", zap.String("domain_type", hex.EncodeToString(nodeDomainType[:]))) - } else { - logger.Debug("discovered node with matching domain type", zap.String("domain_type", hex.EncodeToString(nodeDomainType[:]))) + // TODO: skip different domain type. } // Get the peer's subnets, skipping if it has none. diff --git a/protocol/v2/ssv/runner/runner.go b/protocol/v2/ssv/runner/runner.go index 1a06df1e28..ff833d8c31 100644 --- a/protocol/v2/ssv/runner/runner.go +++ b/protocol/v2/ssv/runner/runner.go @@ -104,6 +104,15 @@ func (b *BaseRunner) baseStartNewDuty(logger *zap.Logger, runner Runner, duty *s return runner.executeDuty(logger, duty) } +// baseStartNewBeaconDuty is a base func that all runner implementation can call to start a non-beacon duty +func (b *BaseRunner) baseStartNewNonBeaconDuty(logger *zap.Logger, runner Runner, duty *spectypes.Duty) error { + if err := b.ShouldProcessNonBeaconDuty(duty); err != nil { + return errors.Wrap(err, "can't start non-beacon duty") + } + b.baseSetupForNewDuty(duty) + return runner.executeDuty(logger, duty) +} + // basePreConsensusMsgProcessing is a base func that all runner implementation can call for processing a pre-consensus msg func (b *BaseRunner) basePreConsensusMsgProcessing(runner Runner, signedMsg *spectypes.SignedPartialSignatureMessage) (bool, [][32]byte, error) { if err := b.ValidatePreConsensusMsg(runner, signedMsg); err != nil { @@ -271,9 +280,17 @@ func (b *BaseRunner) hasRunningDuty() bool { } func (b *BaseRunner) ShouldProcessDuty(duty *spectypes.Duty) error { + if b.QBFTController.Height >= specqbft.Height(duty.Slot) && b.QBFTController.Height != 0 { + return errors.Errorf("duty for slot %d already passed. Current height is %d", duty.Slot, + b.QBFTController.Height) + } + return nil +} + +func (b *BaseRunner) ShouldProcessNonBeaconDuty(duty *spectypes.Duty) error { // assume StartingDuty is not nil if state is not nil if b.State != nil && b.State.StartingDuty.Slot >= duty.Slot { - return errors.Errorf("duty for slot %d already passed. Current height is %d", duty.Slot, + return errors.Errorf("duty for slot %d already passed. Current slot is %d", duty.Slot, b.State.StartingDuty.Slot) } return nil diff --git a/protocol/v2/ssv/runner/validator_registration.go b/protocol/v2/ssv/runner/validator_registration.go index 3232fdff3e..f12dae2f08 100644 --- a/protocol/v2/ssv/runner/validator_registration.go +++ b/protocol/v2/ssv/runner/validator_registration.go @@ -54,7 +54,7 @@ func NewValidatorRegistrationRunner( } func (r *ValidatorRegistrationRunner) StartNewDuty(logger *zap.Logger, duty *spectypes.Duty) error { - return r.BaseRunner.baseStartNewDuty(logger, r, duty) + return r.BaseRunner.baseStartNewNonBeaconDuty(logger, r, duty) } // HasRunningDuty returns true if a duty is already running (StartNewDuty called and returned nil) diff --git a/protocol/v2/ssv/runner/voluntary_exit.go b/protocol/v2/ssv/runner/voluntary_exit.go index b569f853cc..147e5f1471 100644 --- a/protocol/v2/ssv/runner/voluntary_exit.go +++ b/protocol/v2/ssv/runner/voluntary_exit.go @@ -50,7 +50,7 @@ func NewVoluntaryExitRunner( } func (r *VoluntaryExitRunner) StartNewDuty(logger *zap.Logger, duty *spectypes.Duty) error { - return r.BaseRunner.baseStartNewDuty(logger, r, duty) + return r.BaseRunner.baseStartNewNonBeaconDuty(logger, r, duty) } // HasRunningDuty returns true if a duty is already running (StartNewDuty called and returned nil)