Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove subnetIDs from uptime manager #3235

Merged
merged 31 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9c8835b
remove subnet IDs from uptime pkg
ceyonur Jul 24, 2024
733d5fd
remove subnet uptimes from platforvm
ceyonur Jul 25, 2024
10d8e86
remove subnet uptimes from p2p
ceyonur Jul 25, 2024
a2f69d0
remove subnet uptimes from api
ceyonur Jul 25, 2024
ee287c6
add tracked bool
ceyonur Jul 25, 2024
a42e48c
remove unnecessary err
ceyonur Jul 26, 2024
4c542af
remove connected subnet msg
ceyonur Jul 26, 2024
941f536
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Jul 26, 2024
9161864
fix linter
ceyonur Jul 26, 2024
dfded5e
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Jul 31, 2024
f275c15
rework on tests and reviews
ceyonur Jul 31, 2024
d9355cc
fix linter
ceyonur Jul 31, 2024
46501ad
Update proto/p2p/p2p.proto
ceyonur Aug 6, 2024
b7459bd
fix comment
ceyonur Aug 6, 2024
b81b737
Update vms/platformvm/service_test.go
ceyonur Aug 6, 2024
f6bb383
use disconnect in stop tracking
ceyonur Aug 6, 2024
7a6f7eb
remove todo comment
ceyonur Aug 6, 2024
64dec9c
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Aug 6, 2024
33eb562
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 8, 2024
cba7a50
remove unused err
ceyonur Sep 8, 2024
b4955d6
remove subnet connector mock
ceyonur Sep 8, 2024
3c9096e
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 10, 2024
4ce1977
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 11, 2024
863c92e
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 16, 2024
a441d62
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 19, 2024
0daacc6
uptime manager small refactor (#3346)
ceyonur Sep 23, 2024
f3261aa
use var block
ceyonur Sep 23, 2024
8f8285e
return err trackeds
ceyonur Sep 23, 2024
fb3cffa
Merge branch 'master' into remove-subnetid-uptime-manager
ceyonur Sep 23, 2024
23bc5f7
Simplify uptime tracking
StephenButtolph Sep 23, 2024
06fd4db
Merge branch 'master' into remove-subnetid-uptime-manager
StephenButtolph Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions api/info/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Client interface {
Peers(context.Context, ...rpc.Option) ([]Peer, error)
IsBootstrapped(context.Context, string, ...rpc.Option) (bool, error)
GetTxFee(context.Context, ...rpc.Option) (*GetTxFeeResponse, error)
Uptime(context.Context, ids.ID, ...rpc.Option) (*UptimeResponse, error)
Uptime(context.Context, ...rpc.Option) (*UptimeResponse, error)
GetVMs(context.Context, ...rpc.Option) (map[ids.ID][]string, error)
}

Expand Down Expand Up @@ -101,11 +101,9 @@ func (c *client) GetTxFee(ctx context.Context, options ...rpc.Option) (*GetTxFee
return res, err
}

func (c *client) Uptime(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (*UptimeResponse, error) {
func (c *client) Uptime(ctx context.Context, options ...rpc.Option) (*UptimeResponse, error) {
res := &UptimeResponse{}
err := c.requester.SendRequest(ctx, "info.uptime", &UptimeRequest{
SubnetID: subnetID,
}, res, options...)
err := c.requester.SendRequest(ctx, "info.uptime", struct{}{}, res, options...)
return res, err
}

Expand Down
9 changes: 2 additions & 7 deletions api/info/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,13 @@ type UptimeResponse struct {
WeightedAveragePercentage json.Float64 `json:"weightedAveragePercentage"`
}

type UptimeRequest struct {
// if omitted, defaults to primary network
SubnetID ids.ID `json:"subnetID"`
}

func (i *Info) Uptime(_ *http.Request, args *UptimeRequest, reply *UptimeResponse) error {
func (i *Info) Uptime(_ *http.Request, _ *struct{}, reply *UptimeResponse) error {
marun marked this conversation as resolved.
Show resolved Hide resolved
i.log.Debug("API called",
zap.String("service", "info"),
zap.String("method", "uptime"),
)

result, err := i.networking.NodeUptime(args.SubnetID)
result, err := i.networking.NodeUptime()
if err != nil {
return fmt.Errorf("couldn't get node uptime: %w", err)
}
Expand Down
14 changes: 1 addition & 13 deletions api/info/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ info.peers({
lastReceived: string,
benched: string[],
observedUptime: int,
observedSubnetUptime: map[string]int,
}
}
```
Expand All @@ -542,7 +541,6 @@ info.peers({
- `lastReceived` is the timestamp of last message received from the peer.
- `benched` shows chain IDs that the peer is being benched.
- `observedUptime` is this node's primary network uptime, observed by the peer.
- `observedSubnetUptime` is a map of Subnet IDs to this node's Subnet uptimes, observed by the peer.

**Example Call:**

Expand Down Expand Up @@ -575,7 +573,6 @@ curl -X POST --data '{
"lastReceived": "2020-06-01T15:22:57Z",
"benched": [],
"observedUptime": "99",
"observedSubnetUptimes": {},
"trackedSubnets": [],
"benched": []
},
Expand All @@ -588,9 +585,6 @@ curl -X POST --data '{
"lastReceived": "2020-06-01T15:22:34Z",
"benched": [],
"observedUptime": "75",
"observedSubnetUptimes": {
"29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL": "100"
},
"trackedSubnets": [
"29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL"
],
Expand All @@ -605,7 +599,6 @@ curl -X POST --data '{
"lastReceived": "2020-06-01T15:22:55Z",
"benched": [],
"observedUptime": "95",
"observedSubnetUptimes": {},
"trackedSubnets": [],
"benched": []
}
Expand All @@ -623,18 +616,13 @@ Other sources may be using data gathered with incomplete (limited) information.
**Signature:**

```sh
info.uptime({
subnetID: string // optional
}) ->
info.uptime() ->
{
rewardingStakePercentage: float64,
weightedAveragePercentage: float64
}
```

- `subnetID` is the Subnet to get the uptime of. If not provided, returns the uptime of the node on
the primary network.

- `rewardingStakePercentage` is the percent of stake which thinks this node is above the uptime
requirement.
- `weightedAveragePercentage` is the stake-weighted average of all observed uptimes for this node.
Expand Down
11 changes: 1 addition & 10 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,6 @@ func (m *manager) createAvalancheChain(
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
validators.UnhandledSubnetConnector, // avalanche chains don't use subnet connector
sb,
connectedValidators,
peerTracker,
Expand Down Expand Up @@ -1108,8 +1107,7 @@ func (m *manager) createSnowmanChain(
}

var (
bootstrapFunc func()
subnetConnector = validators.UnhandledSubnetConnector
bootstrapFunc func()
)
// If [m.validatorState] is nil then we are creating the P-Chain. Since the
// P-Chain is the first chain to be created, we can use it to initialize
Expand Down Expand Up @@ -1147,12 +1145,6 @@ func (m *manager) createSnowmanChain(
bootstrapFunc = func() {
close(m.unblockChainCreatorCh)
}

// Set up the subnet connector for the P-Chain
subnetConnector, ok = vm.(validators.SubnetConnector)
if !ok {
return nil, fmt.Errorf("expected validators.SubnetConnector but got %T", vm)
}
}

// Initialize the ProposerVM and the vm wrapped inside it
Expand Down Expand Up @@ -1295,7 +1287,6 @@ func (m *manager) createSnowmanChain(
m.FrontierPollFrequency,
m.ConsensusAppConcurrency,
m.ResourceTracker,
subnetConnector,
sb,
connectedValidators,
peerTracker,
Expand Down
26 changes: 0 additions & 26 deletions message/internal_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,32 +493,6 @@ func InternalConnected(nodeID ids.NodeID, nodeVersion *version.Application) Inbo
}
}

// ConnectedSubnet contains the subnet ID of the subnet that the node is
// connected to.
type ConnectedSubnet struct {
SubnetID ids.ID `json:"subnet_id,omitempty"`
}

func (m *ConnectedSubnet) String() string {
return fmt.Sprintf(
"SubnetID: %s",
m.SubnetID,
)
}

// InternalConnectedSubnet returns a message that indicates the node with [nodeID] is
// connected to the subnet with the given [subnetID].
func InternalConnectedSubnet(nodeID ids.NodeID, subnetID ids.ID) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: ConnectedSubnetOp,
message: &ConnectedSubnet{
SubnetID: subnetID,
},
expiration: mockable.MaxTime,
}
}

type Disconnected struct{}

func (Disconnected) String() string {
Expand Down
11 changes: 3 additions & 8 deletions message/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestMessage(t *testing.T) {
bytesSaved bool // if true, outbound message saved bytes must be non-zero
}{
{
desc: "ping message with no compression no subnet uptimes",
desc: "ping message with no compression no uptime",
op: PingOp,
msg: &p2p.Message{
Message: &p2p.Message_Ping{
Expand All @@ -78,17 +78,12 @@ func TestMessage(t *testing.T) {
bytesSaved: false,
},
{
desc: "ping message with no compression and subnet uptimes",
desc: "ping message with no compression and uptime",
op: PingOp,
msg: &p2p.Message{
Message: &p2p.Message_Ping{
Ping: &p2p.Ping{
SubnetUptimes: []*p2p.SubnetUptime{
{
SubnetId: testID[:],
Uptime: 100,
},
},
Uptime: 100,
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions message/mock_outbound_message_builder.go

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

5 changes: 0 additions & 5 deletions message/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const (
CrossChainAppResponseOp
// Internal:
ConnectedOp
ConnectedSubnetOp
DisconnectedOp
NotifyOp
GossipRequestOp
Expand Down Expand Up @@ -120,7 +119,6 @@ var (
CrossChainAppErrorOp,
CrossChainAppResponseOp,
ConnectedOp,
ConnectedSubnetOp,
darioush marked this conversation as resolved.
Show resolved Hide resolved
DisconnectedOp,
NotifyOp,
GossipRequestOp,
Expand Down Expand Up @@ -158,7 +156,6 @@ var (
ChitsOp,
// Internal
ConnectedOp,
ConnectedSubnetOp,
DisconnectedOp,
}

Expand Down Expand Up @@ -281,8 +278,6 @@ func (op Op) String() string {
// Internal
case ConnectedOp:
return "connected"
case ConnectedSubnetOp:
return "connected_subnet"
case DisconnectedOp:
return "disconnected"
case NotifyOp:
Expand Down
5 changes: 1 addition & 4 deletions message/outbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type OutboundMsgBuilder interface {

Ping(
primaryUptime uint32,
subnetUptimes []*p2p.SubnetUptime,
) (OutboundMessage, error)

Pong() (OutboundMessage, error)
Expand Down Expand Up @@ -198,14 +197,12 @@ func newOutboundBuilder(compressionType compression.Type, builder *msgBuilder) O

func (b *outMsgBuilder) Ping(
primaryUptime uint32,
subnetUptimes []*p2p.SubnetUptime,
) (OutboundMessage, error) {
return b.builder.createOutbound(
&p2p.Message{
Message: &p2p.Message_Ping{
Ping: &p2p.Ping{
Uptime: primaryUptime,
SubnetUptimes: subnetUptimes,
Uptime: primaryUptime,
},
},
},
Expand Down
52 changes: 16 additions & 36 deletions network/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,22 @@ type metrics struct {
// trackedSubnets does not include the primary network ID
trackedSubnets set.Set[ids.ID]

numTracked prometheus.Gauge
numPeers prometheus.Gauge
numSubnetPeers *prometheus.GaugeVec
timeSinceLastMsgSent prometheus.Gauge
timeSinceLastMsgReceived prometheus.Gauge
sendFailRate prometheus.Gauge
connected prometheus.Counter
disconnected prometheus.Counter
acceptFailed prometheus.Counter
inboundConnRateLimited prometheus.Counter
inboundConnAllowed prometheus.Counter
tlsConnRejected prometheus.Counter
numUselessPeerListBytes prometheus.Counter
nodeUptimeWeightedAverage prometheus.Gauge
nodeUptimeRewardingStake prometheus.Gauge
nodeSubnetUptimeWeightedAverage *prometheus.GaugeVec
nodeSubnetUptimeRewardingStake *prometheus.GaugeVec
peerConnectedLifetimeAverage prometheus.Gauge
numTracked prometheus.Gauge
numPeers prometheus.Gauge
numSubnetPeers *prometheus.GaugeVec
timeSinceLastMsgSent prometheus.Gauge
timeSinceLastMsgReceived prometheus.Gauge
sendFailRate prometheus.Gauge
connected prometheus.Counter
disconnected prometheus.Counter
acceptFailed prometheus.Counter
inboundConnRateLimited prometheus.Counter
inboundConnAllowed prometheus.Counter
tlsConnRejected prometheus.Counter
numUselessPeerListBytes prometheus.Counter
nodeUptimeWeightedAverage prometheus.Gauge
nodeUptimeRewardingStake prometheus.Gauge
peerConnectedLifetimeAverage prometheus.Gauge

lock sync.RWMutex
peerConnectedStartTimes map[ids.NodeID]float64
Expand Down Expand Up @@ -112,20 +110,6 @@ func newMetrics(
Name: "node_uptime_rewarding_stake",
Help: "The percentage of total stake which thinks this node is eligible for rewards",
}),
nodeSubnetUptimeWeightedAverage: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "node_subnet_uptime_weighted_average",
Help: "This node's subnet uptime averages weighted by observing subnet peer stakes",
},
[]string{"subnetID"},
),
nodeSubnetUptimeRewardingStake: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "node_subnet_uptime_rewarding_stake",
Help: "The percentage of subnet's total stake which thinks this node is eligible for subnet's rewards",
},
[]string{"subnetID"},
),
peerConnectedLifetimeAverage: prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "peer_connected_duration_average",
Expand All @@ -151,8 +135,6 @@ func newMetrics(
registerer.Register(m.inboundConnRateLimited),
registerer.Register(m.nodeUptimeWeightedAverage),
registerer.Register(m.nodeUptimeRewardingStake),
registerer.Register(m.nodeSubnetUptimeWeightedAverage),
registerer.Register(m.nodeSubnetUptimeRewardingStake),
registerer.Register(m.peerConnectedLifetimeAverage),
)

Expand All @@ -161,8 +143,6 @@ func newMetrics(
// initialize to 0
subnetIDStr := subnetID.String()
m.numSubnetPeers.WithLabelValues(subnetIDStr).Set(0)
m.nodeSubnetUptimeWeightedAverage.WithLabelValues(subnetIDStr).Set(0)
m.nodeSubnetUptimeRewardingStake.WithLabelValues(subnetIDStr).Set(0)
}

return m, err
Expand Down
Loading
Loading