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

RPC: Add minContextSlot param to ensure consistent responses #25161

Merged
merged 3 commits into from
May 17, 2022

Conversation

jstarry
Copy link
Member

@jstarry jstarry commented May 12, 2022

Problem

When making requests to an RPC tool, it can be challenging to get consistent responses because requests could be handled by nodes which are lagging behind the node for a previously handled request.

Summary of Changes

Added a minContextSlot parameter to many RPC API's in order to fail fast and notify the client that the connected RPC client isn't caught up to the slot that was expected. Clients can tell if this parameter was respected by the RPC node by checking the apiVersion response in the context of the response is >= 1.11.0

This PR only adds this feature to the RPC server, it doesn't implement the client changes to make use of this new parameter. That can come later in a separate PR

Fixes #15705

@jstarry jstarry requested review from CriesofCarrots and ryoqun May 13, 2022 09:29
@jstarry jstarry marked this pull request as ready for review May 13, 2022 09:29
@jstarry
Copy link
Member Author

jstarry commented May 13, 2022

Adding a new field is not exactly a breaking change IMO but I'm not opposed to using a new struct to address the downstream breakage

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. Just one question about changing deprecated/obsolete endpoints.
Can you update the jsonrpc docs, please?

I agree about adding a field not really being breaking, and I'd prefer not to add new duplicate structs for all for these configs...
I'm trying to think of a cute way to fix the downstream build error anyway. I suppose one way might be to add and release a RpcAccountInfoConfig ctor that we update anchor to before releasing this.

rpc/src/rpc.rs Outdated Show resolved Hide resolved
rpc/src/rpc.rs Outdated Show resolved Hide resolved
@jstarry
Copy link
Member Author

jstarry commented May 15, 2022

How about we annotate these config structs as non exhaustive so that clients need to explicitly fill remaining fields with ..Default::default()?

@jstarry
Copy link
Member Author

jstarry commented May 15, 2022

Never mind, can't fill remaining fields with default values when using non exhaustive structs. But I think my suggestion is a good path to unbreak anchor even without the type attribute.

https://internals.rust-lang.org/t/allow-fru-syntax-on-non-exhaustive-structs/12800

@jstarry
Copy link
Member Author

jstarry commented May 15, 2022

Downstream anchor fix PR is here: coral-xyz/anchor#1895

@jstarry
Copy link
Member Author

jstarry commented May 15, 2022

@CriesofCarrots this is ready for another pass, anchor has been fixed already.

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, lgtm!

@jstarry jstarry merged commit 4690956 into solana-labs:master May 17, 2022
@jstarry jstarry deleted the rpc/min-slot branch May 17, 2022 06:46
@jstarry jstarry added the v1.10 label May 18, 2022
mergify bot pushed a commit that referenced this pull request May 18, 2022
* RPC: Add minContextSlot param to ensure consistent responses

* revert changes to deprecated endpoints

* update docs

(cherry picked from commit 4690956)

# Conflicts:
#	docs/src/developing/clients/jsonrpc-api.md
jstarry added a commit that referenced this pull request May 18, 2022
…#25161) (#25313)

* RPC: Add minContextSlot param to ensure consistent responses (#25161)

* RPC: Add minContextSlot param to ensure consistent responses

* revert changes to deprecated endpoints

* update docs

(cherry picked from commit 4690956)

# Conflicts:
#	docs/src/developing/clients/jsonrpc-api.md

* fix conflicts

Co-authored-by: Justin Starry <[email protected]>
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jun 29, 2022
…labs#25161)

* RPC: Add minContextSlot param to ensure consistent responses

* revert changes to deprecated endpoints

* update docs
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jun 29, 2022
…labs#25161)

* RPC: Add minContextSlot param to ensure consistent responses

* revert changes to deprecated endpoints

* update docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too widespread read-consistency issue for JSON RPC with load balancers
2 participants