-
Notifications
You must be signed in to change notification settings - Fork 743
add l1 support to getcurrentvalidators client response #3843
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
base: master
Are you sure you want to change the base?
Conversation
// [Endtime] is the Unix time repr. of when they are done staking | ||
// [NodeID] is the node ID of the staker | ||
// [Uptime] is the observed uptime of this staker | ||
// [Weight] is the validator weight (stake) when sampling validators | ||
type Staker struct { | ||
TxID ids.ID `json:"txID"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TxID and EndTime will have zero values for L1 validators. I did not want to break any client implementation. If we think it's weird to show these for L1 validators I can set them to pointers. We can even break Staker
into BaseStaker
and Staker
and move those fields there.
var minNonce uint64 | ||
if res.MinNonce != nil { | ||
minNonce = uint64(*res.MinNonce) | ||
} | ||
var balance uint64 | ||
if res.Balance != nil { | ||
balance = uint64(*res.Balance) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this wasn't also applied to the weight? I'm assuming you did this to check vars that are meant to change/be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to ensure they're not nil before de-referencing. Weight
is not a pointer here thus cannot be nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[no action required, just curious] why is weight stored as a non-pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weight is common in all validator types (stakers vs l1 validators), so they will always be present in json. By using a pointer we can mark it them as being "nilable" in json representations. Otherwise they will be always shown with their zero values.
afaict this pr does not change the response object for getCurrentValidators, lgtm |
This PR has become stale because it has been open for 30 days with no activity. Adding the |
Why this should be merged
L1 Validators are not supported in
client.GetCurrentValidators
response. This PR addsClientL1Validator
toClientPermissionlessValidator
so that it can show L1 validators fields in the response.How this works
This pull request includes several changes to the
vms/platformvm
package to enhance the representation and handling of L1 validators. The most important changes involve adding new types and refactoring existing ones to support the new L1 validator structure.Enhancements to L1 Validator Representation:
APIL1Validator
andBaseL1Validator
types to represent L1 validators with additional fields such asPublicKey
,RemainingBalanceOwner
,DeactivationOwner
,MinNonce
, andBalance
. (vms/platformvm/api/static_service.go
)ClientL1Validator
type to include fields forValidationID
,RemainingBalanceOwner
,DeactivationOwner
,MinNonce
, andBalance
. (vms/platformvm/client_permissionless_validator.go
)Refactoring and Code Simplification:
GetL1Validator
function to handle optional fields and convert them appropriately. (vms/platformvm/client.go
) [1] [2]RewardOwner
field fromPermissionlessValidator
and replaced it withValidationRewardOwner
andDelegationRewardOwner
. (vms/platformvm/api/static_service.go
)API and Service Updates:
convertL1ValidatorToAPI
function to use the newplatformapi.APIL1Validator
type and handle the conversion of nested fields. (vms/platformvm/service.go
)How this was tested
Existing tests should cover the service changes. We dont have any client UT, locally tested it.
Need to be documented in RELEASES.md?
Updated