Skip to content

Commit

Permalink
Enforce network config not including PrimaryNetworkID in `trackedSu…
Browse files Browse the repository at this point in the history
…bnets` (#3336)
  • Loading branch information
iansuvak authored Aug 27, 2024
1 parent 1057132 commit f30febb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions network/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type Config struct {
BLSKey *bls.SecretKey `json:"-"`

// TrackedSubnets of the node.
// It must not include the primary network ID.
TrackedSubnets set.Set[ids.ID] `json:"-"`
Beacons validators.Manager `json:"-"`

Expand Down
13 changes: 9 additions & 4 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ const (
var (
_ Network = (*network)(nil)

errNotValidator = errors.New("node is not a validator")
errNotTracked = errors.New("subnet is not tracked")
errExpectedProxy = errors.New("expected proxy")
errExpectedTCPProtocol = errors.New("expected TCP protocol")
errNotValidator = errors.New("node is not a validator")
errNotTracked = errors.New("subnet is not tracked")
errExpectedProxy = errors.New("expected proxy")
errExpectedTCPProtocol = errors.New("expected TCP protocol")
errTrackingPrimaryNetwork = errors.New("cannot track primary network")
)

// Network defines the functionality of the networking library.
Expand Down Expand Up @@ -202,6 +203,10 @@ func NewNetwork(
}
}

if config.TrackedSubnets.Contains(constants.PrimaryNetworkID) {
return nil, errTrackingPrimaryNetwork
}

inboundMsgThrottler, err := throttling.NewInboundMsgThrottler(
log,
metricsRegisterer,
Expand Down

0 comments on commit f30febb

Please sign in to comment.