feat(rpc): forward MinContextSlot in getProgramAccounts and getTokenAccounts#431
Open
ozpool wants to merge 1 commit into
Open
feat(rpc): forward MinContextSlot in getProgramAccounts and getTokenAccounts#431ozpool wants to merge 1 commit into
ozpool wants to merge 1 commit into
Conversation
…ccounts Three Solana RPC methods accept an optional `minContextSlot` per the spec but the Go bindings dropped it on the floor: - getProgramAccounts (via GetProgramAccountsOpts) - getTokenAccountsByOwner (via GetTokenAccountsOpts) - getTokenAccountsByDelegate (via GetTokenAccountsOpts) Without `minContextSlot`, callers on lagging RPC nodes can read state from a slot older than what they have already observed, which breaks read-your-own-writes and slot-pinned pagination flows. Follow-up to solana-foundation#245, which added the same field to GetMultipleAccountsWithOpts. Pattern is identical: a new `MinContextSlot *uint64` on the existing opts struct, forwarded into the params object only when non-nil. Purely additive. Tests pin the wire shape for each of the three methods using the existing mockJSONRPC harness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #245.
Gap
The Solana RPC spec lists
minContextSlotas an optional param ongetProgramAccounts,getTokenAccountsByOwner, andgetTokenAccountsByDelegate, but the Go bindings drop it on the floor — there is no way to pin these reads to a minimum slot.Without it, callers on lagging RPC nodes can read state from a slot older than what they have already observed downstream, which breaks read-your-own-writes and slot-pinned pagination flows. The other account-reading methods (
getAccountInfo,getMultipleAccounts,getSignaturesForAddress,simulateTransaction) already accept the field — this PR closes the parity gap.Change
Purely additive — the pattern matches #245 (
GetMultipleAccountsWithOpts):GetProgramAccountsOpts.MinContextSlot *uint64(forwarded inbuildGetProgramAccountsParams)GetTokenAccountsOpts.MinContextSlot *uint64(forwarded in bothGetTokenAccountsByOwnerandGetTokenAccountsByDelegate)The opts structs are public and additive; no existing call sites need changes. When
MinContextSlotis nil, the wire shape is byte-identical to before.Tests
rpc/getMinContextSlot_test.go(new) — three tests using the in-treemockJSONRPCharness pin the exactparamswire shape for each method:TestClient_GetProgramAccountsWithOpts_MinContextSlotTestClient_GetTokenAccountsByOwner_MinContextSlotTestClient_GetTokenAccountsByDelegate_MinContextSlotDiff size