-
Notifications
You must be signed in to change notification settings - Fork 772
Add "proposed" optional flag to getValidatorsAt
#3531
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
Conversation
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.
-
Why was it necessary to propose a replacement for 3497 instead of evolving that PR?
-
I think it would be cleaner to add a new field instead of adding the complexity of a multi-type field. What suggested this approach?
tests/e2e/p/validator_sets.go
Outdated
@@ -102,6 +102,7 @@ var _ = e2e.DescribePChain("[Validator Sets]", func() { | |||
tc.DefaultContext(), | |||
constants.PrimaryNetworkID, | |||
height, | |||
false, |
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) When using a literal value that doesn't provide context as to what it represents, maybe add a comment (e.g. false, // isProposed
)?
The pivot to this approach was to re-use the already existing field and make it more easily cacheable on the backend and keep the number of externally exposed RPC methods limited if they are accomplishing similar things. Given the pivot in strategy we opted for a new PR.
I'm open to either solution. The reasoning behind accepting multi-type field was since it's already an established pattern in the industry, see eth_getBlockByNumber which accepts |
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.
generally LGTM, we probably need to update RELEASES.md
vms/platformvm/service.go
Outdated
@@ -1689,7 +1689,7 @@ func (s *Service) GetTimestamp(_ *http.Request, _ *struct{}, reply *GetTimestamp | |||
|
|||
// GetValidatorsAtArgs is the response from GetValidatorsAt | |||
type GetValidatorsAtArgs struct { | |||
Height avajson.Uint64 `json:"height"` | |||
Height avajson.Height `json:"height"` |
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.
I guess this is to prevent breaking change for that args. However I wonder if a separate bool flag or even using negative values would make this more straightforward.
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.
Yeah indeed, that + custom parsing is to allow either json field. The idea was that eth supports this kind of thing already in eth_getBlockByNumber
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.
But happy to hear the votes either way!
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.
It's probably better to have backwards compatibility, so I'm fine with this or using negative values. Should we also add latest
here?
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.
a new field would be optional regardless so I don't think it would impact backwards compatibility since the go client is already not backwards compatible in this implementation.
Re: latest
I do think it makes sense to add but would prefer to do it as a follow up to get this change in before etna rollout. I do think it's slightly odd that platform.getValidatorsAt({height: "latest"})
and platform.getCurrentValidators{}
would then return different types but I guess asking for them in the shorter return format that getValidatorsAt
uses is a valid usecase
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.
Couple small nits then lgtm
vms/platformvm/client.go
Outdated
// GetValidatorsAt returns the weights of the validator set of a provided | ||
// subnet at the specified height. | ||
// subnet at the specified height or at proposerVM height if [isProposed] is true. |
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.
I think this comment needs to be updated now.
Also - thoughts on changing height uint64
to height api.Height
? It feels like right now the MaxUint64
behavior might feel odd
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.
I made the change since I don't feel strongly one way or another. I agree that the behavior might be unintuitive but accepting height uint64
had the benefit of not changing the interface at all.
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: Ian Suvak <[email protected]>
Signed-off-by: Ian Suvak <[email protected]> Co-authored-by: Stephen Buttolph <[email protected]>
Why this should be merged
I'm not convinced that it should but opening this up for discussion.
Adding this interface was discussed together with adding
platform.GetProposedHeight
interface in #3530 This is a convenience method to allow for passing "proposed" instead of a numeric height literal toGetValidatorsAt
.The idea is to make it safer to publicly expose
GetValidatorsAt
interface. This by itself doesn't accomplish it but a different proxy service could use this same interface and callGetProposedHeight
and return the cached value if this was called with the same resolved height and subnet.How this works
Makes the GetValidatorsAt accept either numeric height or a "proposed" string literal that first calls
getMinimumHeight
and uses that instead of the numerical value. The service side is backward compatible but the client interface has changed.I'm also not sure if this solution is cleaner than just adding a new boolean flag field to the request. I don't think that the
platformVM
service uses this kind of type overloading anywhere else.How this was tested
Added a unit test.
Need to be documented in RELEASES.md?
Added a note to the
RELEASES.md
but this also introduces a breaking change to the client and not sure what's the best way to handle communication around that