Skip to content

Commit

Permalink
deprecate uptime apis (#3226)
Browse files Browse the repository at this point in the history
Co-authored-by: Alberto Benegiamo <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]>
  • Loading branch information
3 people authored Aug 15, 2024
1 parent 50b8d65 commit 9e77ecc
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 32 deletions.
18 changes: 13 additions & 5 deletions api/info/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,23 @@ type UptimeResponse struct {
}

type UptimeRequest struct {
// if omitted, defaults to primary network
// Deprecated: SubnetID in UptimeRequest is deprecated.
// Uptime API will be available only for Primary Network Validators.
SubnetID ids.ID `json:"subnetID"`
}

func (i *Info) Uptime(_ *http.Request, args *UptimeRequest, reply *UptimeResponse) error {
i.log.Debug("API called",
zap.String("service", "info"),
zap.String("method", "uptime"),
)
if args.SubnetID != constants.PrimaryNetworkID {
i.log.Warn("Deprecated API called",
zap.String("service", "info"),
zap.String("method", "uptime"),
)
} else {
i.log.Debug("API called",
zap.String("service", "info"),
zap.String("method", "uptime"),
)
}

result, err := i.networking.NodeUptime(args.SubnetID)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/info/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ 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.
- `observedSubnetUptime` (Deprecated) is a map of Subnet IDs to this node's Subnet uptimes, observed by the peer.

**Example Call:**

Expand Down Expand Up @@ -632,7 +632,7 @@ info.uptime({
}
```

- `subnetID` is the Subnet to get the uptime of. If not provided, returns the uptime of the node on
- `subnetID` (Deprecated) 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
Expand Down
11 changes: 5 additions & 6 deletions network/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ type metrics struct {
numUselessPeerListBytes prometheus.Counter
nodeUptimeWeightedAverage prometheus.Gauge
nodeUptimeRewardingStake prometheus.Gauge
nodeSubnetUptimeWeightedAverage *prometheus.GaugeVec
nodeSubnetUptimeRewardingStake *prometheus.GaugeVec
nodeSubnetUptimeWeightedAverage *prometheus.GaugeVec // Deprecated
nodeSubnetUptimeRewardingStake *prometheus.GaugeVec // Deprecated
peerConnectedLifetimeAverage prometheus.Gauge

lock sync.RWMutex
peerConnectedStartTimes map[ids.NodeID]float64
peerConnectedStartTimesSum float64
lock sync.RWMutex
peerConnectedStartTimes map[ids.NodeID]float64
peerConnectedStartTimesSum float64
}

func newMetrics(
Expand Down
2 changes: 1 addition & 1 deletion network/peer/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Info struct {
LastSent time.Time `json:"lastSent"`
LastReceived time.Time `json:"lastReceived"`
ObservedUptime json.Uint32 `json:"observedUptime"`
ObservedSubnetUptimes map[ids.ID]json.Uint32 `json:"observedSubnetUptimes"`
ObservedSubnetUptimes map[ids.ID]json.Uint32 `json:"observedSubnetUptimes"` // Deprecated
TrackedSubnets set.Set[ids.ID] `json:"trackedSubnets"`
SupportedACPs set.Set[uint32] `json:"supportedACPs"`
ObjectedACPs set.Set[uint32] `json:"objectedACPs"`
Expand Down
2 changes: 1 addition & 1 deletion proto/p2p/p2p.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ message Message {
message Ping {
// Uptime percentage on the primary network [0, 100]
uint32 uptime = 1;
// Uptime percentage on subnets
// Deprecated
repeated SubnetUptime subnet_uptimes = 2;
}

Expand Down
2 changes: 1 addition & 1 deletion proto/pb/p2p/p2p.pb.go

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

22 changes: 13 additions & 9 deletions vms/platformvm/api/static_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,19 @@ type PermissionlessValidator struct {
ValidationRewardOwner *Owner `json:"validationRewardOwner,omitempty"`
// The owner of the rewards from delegations during the validation period,
// if applicable.
DelegationRewardOwner *Owner `json:"delegationRewardOwner,omitempty"`
PotentialReward *json.Uint64 `json:"potentialReward,omitempty"`
AccruedDelegateeReward *json.Uint64 `json:"accruedDelegateeReward,omitempty"`
DelegationFee json.Float32 `json:"delegationFee"`
ExactDelegationFee *json.Uint32 `json:"exactDelegationFee,omitempty"`
Uptime *json.Float32 `json:"uptime,omitempty"`
Connected bool `json:"connected"`
Staked []UTXO `json:"staked,omitempty"`
Signer *signer.ProofOfPossession `json:"signer,omitempty"`
DelegationRewardOwner *Owner `json:"delegationRewardOwner,omitempty"`
PotentialReward *json.Uint64 `json:"potentialReward,omitempty"`
AccruedDelegateeReward *json.Uint64 `json:"accruedDelegateeReward,omitempty"`
DelegationFee json.Float32 `json:"delegationFee"`
ExactDelegationFee *json.Uint32 `json:"exactDelegationFee,omitempty"`
// Uptime is deprecated for Subnet Validators.
// It will be available only for Primary Network Validators.
Uptime *json.Float32 `json:"uptime,omitempty"`
// Connected is deprecated for Subnet Validators.
// It will be available only for Primary Network Validators.
Connected bool `json:"connected"`
Staked []UTXO `json:"staked,omitempty"`
Signer *signer.ProofOfPossession `json:"signer,omitempty"`

// The delegators delegating to this validator
DelegatorCount *json.Uint64 `json:"delegatorCount,omitempty"`
Expand Down
10 changes: 7 additions & 3 deletions vms/platformvm/client_permissionless_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ type ClientPermissionlessValidator struct {
PotentialReward *uint64
AccruedDelegateeReward *uint64
DelegationFee float32
Uptime *float32
Connected *bool
Signer *signer.ProofOfPossession
// Uptime is deprecated for Subnet Validators.
// It will be available only for Primary Network Validators.
Uptime *float32
// Connected is deprecated for Subnet Validators.
// It will be available only for Primary Network Validators.
Connected *bool
Signer *signer.ProofOfPossession
// The delegators delegating to this validator
DelegatorCount *uint64
DelegatorWeight *uint64
Expand Down
8 changes: 4 additions & 4 deletions vms/platformvm/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ platform.getCurrentValidators({
- `delegationFeeRate` is the percent fee this validator charges when others delegate stake to
them. Omitted if `subnetID` is not a PoS Subnet.
- `uptime` is the % of time the queried node has reported the peer as online and validating the
Subnet. Omitted if `subnetID` is not a PoS Subnet.
- `connected` is if the node is connected and tracks the Subnet.
Subnet. Omitted if `subnetID` is not a PoS Subnet. (Deprecated: uptime is deprecated for Subnet Validators. It will be available only for Primary Network Validators.)
- `connected` is if the node is connected and tracks the Subnet. (Deprecated: connected is deprecated for Subnet Validators. It will be available only for Primary Network Validators.)
- `signer` is the node's BLS public key and proof of possession. Omitted if the validator doesn't
have a BLS public key.
- `delegatorCount` is the number of delegators on this validator.
Expand Down Expand Up @@ -1222,11 +1222,11 @@ platform.getSubnet({
```

- `subnetID` is the ID of the Subnet to get information about. If omitted, fails.
- `threshold` signatures from addresses in `controlKeys` are needed to make changes to
- `threshold` signatures from addresses in `controlKeys` are needed to make changes to
a permissioned subnet. If the Subnet is a PoS Subnet, then `threshold` will be `0` and `controlKeys`
will be empty.
- changes can not be made into the subnet until `locktime` is in the past.
- `subnetTransformationTxID` is the ID of the transaction that changed the subnet into a elastic one,
- `subnetTransformationTxID` is the ID of the transaction that changed the subnet into a elastic one,
for when this change was performed.

**Example Call:**
Expand Down

0 comments on commit 9e77ecc

Please sign in to comment.