Skip to content

Commit

Permalink
Stage (#1199)
Browse files Browse the repository at this point in the history
* refactor: remove domain type discovery logs

* spec align (#1197)

* spec align 0.3.4

* bump ekm version

---------

Co-authored-by: moshe-blox <[email protected]>
  • Loading branch information
Lior Rutenberg and moshe-blox authored Nov 7, 2023
1 parent d469dec commit 7309807
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
10 changes: 2 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
9 changes: 2 additions & 7 deletions network/discovery/dv5_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package discovery
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"net"
"sync/atomic"
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 18 additions & 1 deletion protocol/v2/ssv/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion protocol/v2/ssv/runner/validator_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion protocol/v2/ssv/runner/voluntary_exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7309807

Please sign in to comment.