Skip to content

feat(ws): support dataSlice in AccountSubscribe - #433

Merged
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
ozpool:feat/ws-accountsubscribe-dataslice
May 25, 2026
Merged

feat(ws): support dataSlice in AccountSubscribe#433
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
ozpool:feat/ws-accountsubscribe-dataslice

Conversation

@ozpool

@ozpool ozpool commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds AccountSubscribeOpts + AccountSubscribeWithConfig to mirror the optional configuration object the accountSubscribe RPC method accepts, including the missing dataSlice parameter.

dataSlice asks the validator to return only the requested {offset, length} slice of the account's data field. Useful for large accounts where the caller only needs a known-offset region (program account headers, discriminators, fixed header fields, etc.) — without it, every notification carries the full account data over the wire.

What changed

  • New AccountSubscribeOpts { Commitment, Encoding, DataSlice }.
  • New AccountSubscribeWithConfig(account, opts) carries the full opts object through to the request body.
  • The existing AccountSubscribeWithOpts(account, commitment, encoding) is preserved by delegating to the new opts form, and AccountSubscribe(account, commitment) is unchanged.

Test plan

  • go build ./...
  • go test ./...
  • New accountSubscribe_test.go asserts: defaults (encoding=base64, no commitment, no dataSlice), dataSlice JSON shape {\"offset\":N,\"length\":N}, and the encoding override path

Add AccountSubscribeOpts and AccountSubscribeWithConfig to mirror the
optional configuration object the accountSubscribe RPC method accepts,
including the missing dataSlice parameter. dataSlice asks the
validator to return only the requested slice of the account's data
field, which is useful for large accounts where the caller only needs
a known-offset region (program account headers, discriminators, fixed
header fields, etc.).

The existing AccountSubscribeWithOpts(account, commitment, encoding)
entry point delegates to the new opts form, so existing callers are
not affected.

Adds wire-shape tests covering: defaults, dataSlice JSON shape
({"offset": N, "length": N}), and the encoding override path.
@HealthyBuilder

Copy link
Copy Markdown
Collaborator

Same pattern as #432 approving

One non-blocking nit: ended up with AccountSubscribeWithOpts (old, 3-arg) + AccountSubscribeWithConfig (new, opts-struct) coexisting. We could clean this up later by deprecating the old one with a // Deprecated: comment pointing readers at the new entry point — happy to track that as a follow-up issue rather than block this PR.

@HealthyBuilder
HealthyBuilder merged commit fb31fb1 into solana-foundation:main May 25, 2026
12 checks passed
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.

2 participants