Skip to content

feat(rpc): impl getAccountInfo RPC for accounts_db v2#1217

Open
prestonsn wants to merge 8 commits intomainfrom
prestonsn/impl-get-account-info-for-db-two
Open

feat(rpc): impl getAccountInfo RPC for accounts_db v2#1217
prestonsn wants to merge 8 commits intomainfrom
prestonsn/impl-get-account-info-for-db-two

Conversation

@prestonsn
Copy link
Contributor

@prestonsn prestonsn commented Feb 7, 2026

Implements getAccountInfo RPC for accounts db two. The PR is a bit large mostly due to porting over agave's account-decoder crate to zig. This also includes porting over all related unit tests.

There's some quirkiness (specific to SPL token 22 metadata accounts) in the code due to us not having a borsh lib available. Instead of implementing one that we may not need all the functionality of, this PR hand-rolls deserialization for things like an array of strings. The number of cases we need to handle was pretty minimal, so it didn't make sense implementing something more complete/robust.

Testing done (against Agave testnet RPC @ v3.1.8):

Category What Was Tested
Encodings jsonParsed, base64, base64+zstd, base58, fallback format
Commitment Levels finalized, confirmed, processed
Parameters dataSlice (offset/length)
SPL Token Mint Fields: mintAuthority, supply, decimals, freezeAuthority, isInitialized
SPL Token Account Fields: owner, mint, tokenAmount, state, isNative, delegate, closeAuthority
Token-2022 Discriminator offset, extension parsing, program name, MintCloseAuthority, TransferFee, InterestBearingConfig
Vote Account Base fields + v4 SIMD-0185 fields (inflationRewardsCommissionBps, inflationRewardsCollector, blockRevenueCollector, blockRevenueCommissionBps, pendingDelegatorRewards, blsPubkeyCompressed)
Stake Account Initialized state, stake: null handling
Address Lookup Table Parsed data, kebab-case program name
BPF Upgradeable Loader ProgramData, authority: null handling
Sysvars Clock, EpochSchedule, EpochRewards, Rent, SlotHashes, StakeHistory, SlotHistory, LastRestartSlot
Response Structure context.slot, context.apiVersion

@github-project-automation github-project-automation bot moved this to 🏗 In progress in Sig Feb 7, 2026
@prestonsn prestonsn changed the base branch from main to adamw/implement-getSlot-in-rpc February 7, 2026 01:02
@prestonsn prestonsn marked this pull request as draft February 7, 2026 01:02
@prestonsn prestonsn self-assigned this Feb 7, 2026
@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 95.26196% with 104 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/rpc/account_codec/parse_token_extension.zig 94.65% 39 Missing ⚠️
src/rpc/account_codec/lib.zig 80.95% 32 Missing ⚠️
src/rpc/account_codec/parse_vote.zig 83.33% 14 Missing ⚠️
src/rpc/account_codec/parse_sysvar.zig 97.00% 7 Missing ⚠️
...rpc/account_codec/parse_bpf_upgradeable_loader.zig 95.72% 5 Missing ⚠️
src/rpc/account_codec/parse_config.zig 94.73% 5 Missing ⚠️
src/core/hash.zig 0.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/core/epoch_schedule.zig 98.96% <ø> (ø)
...c/rpc/account_codec/parse_account_lookup_table.zig 100.00% <100.00%> (ø)
src/rpc/account_codec/parse_nonce.zig 100.00% <100.00%> (ø)
src/rpc/account_codec/parse_stake.zig 100.00% <100.00%> (ø)
src/rpc/account_codec/parse_token.zig 100.00% <100.00%> (ø)
src/rpc/methods.zig 81.13% <ø> (+3.00%) ⬆️
src/rpc/request.zig 90.17% <100.00%> (ø)
src/rpc/test_serialize.zig 100.00% <100.00%> (ø)
src/runtime/program/vote/state.zig 96.10% <ø> (+0.10%) ⬆️
src/runtime/program/vote/state_v4.zig 94.22% <ø> (ø)
... and 9 more

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@prestonsn prestonsn force-pushed the adamw/implement-getSlot-in-rpc branch from 40fae04 to 72d8727 Compare February 9, 2026 17:58
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch 3 times, most recently from faf136b to ce30956 Compare February 10, 2026 21:27
@prestonsn prestonsn force-pushed the adamw/implement-getSlot-in-rpc branch from cf75dc5 to e7172e5 Compare February 11, 2026 16:22
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch from 40a15ee to 6afd364 Compare February 12, 2026 05:02
@prestonsn prestonsn force-pushed the adamw/implement-getSlot-in-rpc branch from e7172e5 to 0568f9e Compare February 12, 2026 22:08
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch 3 times, most recently from 6477dcb to d912ade Compare February 12, 2026 22:41
@ajw221 ajw221 force-pushed the adamw/implement-getSlot-in-rpc branch from 7d84370 to 8279fe0 Compare February 14, 2026 03:24
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch 6 times, most recently from 6945038 to 63d1d33 Compare February 17, 2026 04:08
Base automatically changed from adamw/implement-getSlot-in-rpc to main February 17, 2026 16:53
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch 3 times, most recently from 3cb9dd6 to 4c29a67 Compare February 17, 2026 18:16
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch 7 times, most recently from 8667355 to 1f15cea Compare February 19, 2026 00:08
@prestonsn prestonsn marked this pull request as ready for review February 19, 2026 00:57
Copy link
Contributor

@ajw221 ajw221 left a comment

Choose a reason for hiding this comment

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

initial review

@github-project-automation github-project-automation bot moved this from 🏗 In progress to 👀 In review in Sig Feb 20, 2026
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch from 1f15cea to e0f6005 Compare February 23, 2026 02:51
yewman
yewman previously approved these changes Feb 23, 2026
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch 2 times, most recently from 288c270 to b67e6b1 Compare February 23, 2026 23:51
Implement the getAccountInfo RPC method with full support for all Solana
account encodings: base58, base64, base64+zstd, and jsonParsed.
- Add AccountHookContext with getAccountInfo method for reading account data
- Support dataSlice parameter for partial account reads
- Implement streaming zstd compression for base64+zstd encoding
- Fall back to base64 encoding when no jsonParsed parser is available
- Agave v3.1.8 still supports it despite it being documented as
  deprected.
- Replace std.BoundedArray with inline buffer/len fields in JsonString and JsonArray
- Add WriterError helper in base64.zig to support both GenericWriter and *std.io.Writer
- Bridge base64+zstd path via adaptToNewApi for new Writer interface compatibility
- Update JSON serialization: writeStream → Stringify, jw.stream → jw.writer
- Change AccountData.jsonParsed from std.json.Value to []const u8 to avoid roundtrip parsing
@prestonsn prestonsn force-pushed the prestonsn/impl-get-account-info-for-db-two branch from b67e6b1 to a0a5842 Compare February 26, 2026 05:18
…ance

- Remove redundant arena allocator in encodeJsonParsed; caller already provides per-request arena
- Add errdefer for allocations in parse_vote.zig to prevent leaks with non-arena allocators
- Pass dataSlice to jsonParsed base64 fallback path, matching Agave behavior (SPL tokens excluded)
- Fix style violations: @this() in named structs, snake_case fn name, import ordering, container decl order
- Rename parse_account to parseAccount, fix SlotNotFound -> SlotNotAvailable, remove stale TODOs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

4 participants