From 427d1aca8e1f623c4753b03dc239965975767f19 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Wed, 24 Jul 2024 21:27:42 +0300 Subject: [PATCH 1/5] deprecate uptime apis --- api/info/client.go | 2 ++ api/info/service.go | 17 ++++++++++---- api/info/service.md | 4 ++-- network/metrics.go | 11 +++++----- network/network.go | 2 ++ network/peer/info.go | 2 +- proto/p2p/p2p.proto | 2 +- vms/platformvm/api/static_service.go | 22 +++++++++++-------- .../client_permissionless_validator.go | 10 ++++++--- vms/platformvm/service.md | 8 +++---- 10 files changed, 50 insertions(+), 30 deletions(-) diff --git a/api/info/client.go b/api/info/client.go index 15812cd5c213..e007ab5dd218 100644 --- a/api/info/client.go +++ b/api/info/client.go @@ -27,6 +27,8 @@ 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) + // Deprecated: Uptime is deprecated for Subnet Validators. + // It will be available only for Primary Network Validators. Uptime(context.Context, ids.ID, ...rpc.Option) (*UptimeResponse, error) GetVMs(context.Context, ...rpc.Option) (map[ids.ID][]string, error) } diff --git a/api/info/service.go b/api/info/service.go index fd0117c5a088..469d7bb07596 100644 --- a/api/info/service.go +++ b/api/info/service.go @@ -312,11 +312,20 @@ type UptimeRequest struct { SubnetID ids.ID `json:"subnetID"` } +// Deprecated: Uptime is deprecated for Subnet Validators. +// It will be available only for Primary Network Validators. 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 { diff --git a/api/info/service.md b/api/info/service.md index d7e70e269dff..49479802430b 100644 --- a/api/info/service.md +++ b/api/info/service.md @@ -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:** @@ -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 diff --git a/network/metrics.go b/network/metrics.go index 9702e821b246..a4b333e6daea 100644 --- a/network/metrics.go +++ b/network/metrics.go @@ -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( diff --git a/network/network.go b/network/network.go index 2aee13a910d9..a4142015859a 100644 --- a/network/network.go +++ b/network/network.go @@ -1098,6 +1098,8 @@ func (n *network) StartClose() { }) } +// Deprecated: NodeUptime is deprecated for Subnet Validators. +// It will be available only for Primary Network Validators. func (n *network) NodeUptime(subnetID ids.ID) (UptimeResult, error) { if subnetID != constants.PrimaryNetworkID && !n.config.TrackedSubnets.Contains(subnetID) { return UptimeResult{}, errNotTracked diff --git a/network/peer/info.go b/network/peer/info.go index 928c47ff26ee..843abc4c96fe 100644 --- a/network/peer/info.go +++ b/network/peer/info.go @@ -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"` diff --git a/proto/p2p/p2p.proto b/proto/p2p/p2p.proto index 53c0c84de303..79577eae0fe6 100644 --- a/proto/p2p/p2p.proto +++ b/proto/p2p/p2p.proto @@ -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; } diff --git a/vms/platformvm/api/static_service.go b/vms/platformvm/api/static_service.go index 418b447114c7..50c724cbf832 100644 --- a/vms/platformvm/api/static_service.go +++ b/vms/platformvm/api/static_service.go @@ -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"` + // Deprecated: Uptime is deprecated for Subnet Validators. + // It will be available only for Primary Network Validators. + Uptime *json.Float32 `json:"uptime,omitempty"` + // Deprecated: 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"` diff --git a/vms/platformvm/client_permissionless_validator.go b/vms/platformvm/client_permissionless_validator.go index 3974f770658d..85d7fde7aecb 100644 --- a/vms/platformvm/client_permissionless_validator.go +++ b/vms/platformvm/client_permissionless_validator.go @@ -44,9 +44,13 @@ type ClientPermissionlessValidator struct { PotentialReward *uint64 AccruedDelegateeReward *uint64 DelegationFee float32 - Uptime *float32 - Connected *bool - Signer *signer.ProofOfPossession + // Deprecated: Uptime is deprecated for Subnet Validators. + // It will be available only for Primary Network Validators. + Uptime *float32 + // Deprecated: 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 diff --git a/vms/platformvm/service.md b/vms/platformvm/service.md index caa040103533..f4cd28cd35f1 100644 --- a/vms/platformvm/service.md +++ b/vms/platformvm/service.md @@ -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. @@ -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:** From bd43e66e3c5e20f8296c4e097c22de9d3e2291f2 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Wed, 24 Jul 2024 21:30:44 +0300 Subject: [PATCH 2/5] indent using spaces --- vms/platformvm/api/static_service.go | 4 ++-- vms/platformvm/client_permissionless_validator.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vms/platformvm/api/static_service.go b/vms/platformvm/api/static_service.go index 50c724cbf832..49945730f60c 100644 --- a/vms/platformvm/api/static_service.go +++ b/vms/platformvm/api/static_service.go @@ -121,10 +121,10 @@ type PermissionlessValidator struct { DelegationFee json.Float32 `json:"delegationFee"` ExactDelegationFee *json.Uint32 `json:"exactDelegationFee,omitempty"` // Deprecated: Uptime is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // It will be available only for Primary Network Validators. Uptime *json.Float32 `json:"uptime,omitempty"` // Deprecated: Connected is deprecated for Subnet Validators. - // It will be available only for Primary Network 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"` diff --git a/vms/platformvm/client_permissionless_validator.go b/vms/platformvm/client_permissionless_validator.go index 85d7fde7aecb..81aee45ee727 100644 --- a/vms/platformvm/client_permissionless_validator.go +++ b/vms/platformvm/client_permissionless_validator.go @@ -45,10 +45,10 @@ type ClientPermissionlessValidator struct { AccruedDelegateeReward *uint64 DelegationFee float32 // Deprecated: Uptime is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // It will be available only for Primary Network Validators. Uptime *float32 // Deprecated: Connected is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // It will be available only for Primary Network Validators. Connected *bool Signer *signer.ProofOfPossession // The delegators delegating to this validator From c1dc525f94d02249528bb7c5c898b4886155a7d9 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Wed, 24 Jul 2024 21:48:18 +0300 Subject: [PATCH 3/5] generate protos --- proto/pb/p2p/p2p.pb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/pb/p2p/p2p.pb.go b/proto/pb/p2p/p2p.pb.go index bd55ad703546..87305d415db1 100644 --- a/proto/pb/p2p/p2p.pb.go +++ b/proto/pb/p2p/p2p.pb.go @@ -498,7 +498,7 @@ type Ping struct { // Uptime percentage on the primary network [0, 100] Uptime uint32 `protobuf:"varint,1,opt,name=uptime,proto3" json:"uptime,omitempty"` - // Uptime percentage on subnets + // Deprecated SubnetUptimes []*SubnetUptime `protobuf:"bytes,2,rep,name=subnet_uptimes,json=subnetUptimes,proto3" json:"subnet_uptimes,omitempty"` } From 108190a33224228aab0422c87e44fcdc83d90b6e Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Fri, 26 Jul 2024 23:47:54 +0300 Subject: [PATCH 4/5] update deprecate messages --- api/info/client.go | 2 -- api/info/service.go | 5 ++--- network/network.go | 2 -- vms/platformvm/client_permissionless_validator.go | 4 ++-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/api/info/client.go b/api/info/client.go index e007ab5dd218..15812cd5c213 100644 --- a/api/info/client.go +++ b/api/info/client.go @@ -27,8 +27,6 @@ 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) - // Deprecated: Uptime is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. Uptime(context.Context, ids.ID, ...rpc.Option) (*UptimeResponse, error) GetVMs(context.Context, ...rpc.Option) (map[ids.ID][]string, error) } diff --git a/api/info/service.go b/api/info/service.go index 469d7bb07596..459e46254e8b 100644 --- a/api/info/service.go +++ b/api/info/service.go @@ -308,12 +308,11 @@ 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"` } -// Deprecated: Uptime is deprecated for Subnet Validators. -// It will be available only for Primary Network Validators. func (i *Info) Uptime(_ *http.Request, args *UptimeRequest, reply *UptimeResponse) error { if args.SubnetID != constants.PrimaryNetworkID { i.log.Warn("Deprecated API called", diff --git a/network/network.go b/network/network.go index a4142015859a..2aee13a910d9 100644 --- a/network/network.go +++ b/network/network.go @@ -1098,8 +1098,6 @@ func (n *network) StartClose() { }) } -// Deprecated: NodeUptime is deprecated for Subnet Validators. -// It will be available only for Primary Network Validators. func (n *network) NodeUptime(subnetID ids.ID) (UptimeResult, error) { if subnetID != constants.PrimaryNetworkID && !n.config.TrackedSubnets.Contains(subnetID) { return UptimeResult{}, errNotTracked diff --git a/vms/platformvm/client_permissionless_validator.go b/vms/platformvm/client_permissionless_validator.go index 81aee45ee727..0ccd6f17d249 100644 --- a/vms/platformvm/client_permissionless_validator.go +++ b/vms/platformvm/client_permissionless_validator.go @@ -45,10 +45,10 @@ type ClientPermissionlessValidator struct { AccruedDelegateeReward *uint64 DelegationFee float32 // Deprecated: Uptime is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // It will be available only for Primary Network Validators. Uptime *float32 // Deprecated: Connected is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // It will be available only for Primary Network Validators. Connected *bool Signer *signer.ProofOfPossession // The delegators delegating to this validator From 14227a5d44924c43ba73a5f68281b65bfd255282 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 15 Aug 2024 14:02:20 +0300 Subject: [PATCH 5/5] remove deprecated annotations --- vms/platformvm/api/static_service.go | 8 ++++---- vms/platformvm/client_permissionless_validator.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/vms/platformvm/api/static_service.go b/vms/platformvm/api/static_service.go index 49945730f60c..46f02bd46ba9 100644 --- a/vms/platformvm/api/static_service.go +++ b/vms/platformvm/api/static_service.go @@ -120,11 +120,11 @@ type PermissionlessValidator struct { AccruedDelegateeReward *json.Uint64 `json:"accruedDelegateeReward,omitempty"` DelegationFee json.Float32 `json:"delegationFee"` ExactDelegationFee *json.Uint32 `json:"exactDelegationFee,omitempty"` - // Deprecated: Uptime is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // Uptime is deprecated for Subnet Validators. + // It will be available only for Primary Network Validators. Uptime *json.Float32 `json:"uptime,omitempty"` - // Deprecated: Connected is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // 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"` diff --git a/vms/platformvm/client_permissionless_validator.go b/vms/platformvm/client_permissionless_validator.go index 0ccd6f17d249..b2e48b0cce2a 100644 --- a/vms/platformvm/client_permissionless_validator.go +++ b/vms/platformvm/client_permissionless_validator.go @@ -44,11 +44,11 @@ type ClientPermissionlessValidator struct { PotentialReward *uint64 AccruedDelegateeReward *uint64 DelegationFee float32 - // Deprecated: Uptime is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // Uptime is deprecated for Subnet Validators. + // It will be available only for Primary Network Validators. Uptime *float32 - // Deprecated: Connected is deprecated for Subnet Validators. - // It will be available only for Primary Network Validators. + // 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