Skip to content

Commit

Permalink
network: refactor (deduplicate, remove unnecessary code) subnet-relat…
Browse files Browse the repository at this point in the history
…ed entities across records & commons sub-packages
  • Loading branch information
iurii-ssv committed Jan 30, 2025
1 parent b4ed4fc commit 14d4c71
Show file tree
Hide file tree
Showing 39 changed files with 427 additions and 510 deletions.
3 changes: 1 addition & 2 deletions cli/operator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"github.com/ssvlabs/ssv/network"
networkcommons "github.com/ssvlabs/ssv/network/commons"
p2pv1 "github.com/ssvlabs/ssv/network/p2p"
"github.com/ssvlabs/ssv/network/records"
"github.com/ssvlabs/ssv/networkconfig"
"github.com/ssvlabs/ssv/nodeprobe"
"github.com/ssvlabs/ssv/observability"
Expand Down Expand Up @@ -400,7 +399,7 @@ var StartNodeCmd = &cobra.Command{
)
start := time.Now()
myValidators := nodeStorage.ValidatorStore().OperatorValidators(operatorData.ID)
mySubnets := make(records.Subnets, networkcommons.SubnetsCount)
mySubnets := make(networkcommons.Subnets, networkcommons.SubnetsCount)

Check warning on line 402 in cli/operator/node.go

View check run for this annotation

Codecov / codecov/patch

cli/operator/node.go#L402

Added line #L402 was not covered by tests
myActiveSubnets := 0
for _, v := range myValidators {
subnet := networkcommons.CommitteeSubnet(v.CommitteeID())
Expand Down
2 changes: 0 additions & 2 deletions eth/executionclient/mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions logging/fields/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fields
import (
"encoding/hex"
"fmt"
"github.com/ssvlabs/ssv/network/commons"
"net"
"net/url"
"strconv"
Expand All @@ -22,7 +23,6 @@ import (

"github.com/ssvlabs/ssv/eth/contract"
"github.com/ssvlabs/ssv/logging/fields/stringer"
"github.com/ssvlabs/ssv/network/records"
"github.com/ssvlabs/ssv/protocol/v2/message"
protocolp2p "github.com/ssvlabs/ssv/protocol/v2/p2p"
"github.com/ssvlabs/ssv/utils/format"
Expand Down Expand Up @@ -160,7 +160,7 @@ func UpdatedENRLocalNode(val *enode.LocalNode) zapcore.Field {
return zap.Stringer(FieldUpdatedENRLocalNode, val.Node())
}

func Subnets(val records.Subnets) zapcore.Field {
func Subnets(val commons.Subnets) zapcore.Field {
return zap.Stringer(FieldSubnets, val)
}

Expand Down
7 changes: 7 additions & 0 deletions message/validation/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const (
encodingOverheadDivisor = 20 // Divisor for message size to get encoding overhead, e.g. 10 for 10%, 20 for 5%. Done this way to keep const int.
)

const (
signatureSize = 256
signatureOffset = 0
operatorIDOffset = signatureOffset + signatureSize
MessageOffset = operatorIDOffset + operatorIDSize
)

const (
qbftMsgTypeSize = 8 // uint64
heightSize = 8 // uint64
Expand Down
4 changes: 2 additions & 2 deletions message/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func Test_ValidateSSVMessage(t *testing.T) {
slot := netCfg.Beacon.FirstSlotAtEpoch(1)

topic := commons.GetTopicFullName(commons.CommitteeTopicID(committeeID)[0])
msgSize := maxSignedMsgSize*2 + commons.MessageOffset
msgSize := maxSignedMsgSize*2 + MessageOffset

pmsg := &pubsub.Message{
Message: &pspb.Message{
Expand All @@ -259,7 +259,7 @@ func Test_ValidateSSVMessage(t *testing.T) {
topic := commons.GetTopicFullName(commons.CommitteeTopicID(committeeID)[0])
pmsg := &pubsub.Message{
Message: &pspb.Message{
Data: bytes.Repeat([]byte{1}, 1+commons.MessageOffset),
Data: bytes.Repeat([]byte{1}, 1+MessageOffset),
Topic: &topic,
From: []byte("16Uiu2HAkyWQyCb6reWXGQeBUt9EXArk6h3aq3PsFMwLNq3pPGH1r"),
},
Expand Down
128 changes: 0 additions & 128 deletions network/commons/common.go

This file was deleted.

31 changes: 0 additions & 31 deletions network/commons/common_test.go

This file was deleted.

Loading

0 comments on commit 14d4c71

Please sign in to comment.