Skip to content

fix: paginate Helius stake account requests - #283

Merged
galvanizze merged 4 commits into
crypkit:masterfrom
zmaslerdev:fix/solana-program-accounts-v2
Sep 4, 2026
Merged

fix: paginate Helius stake account requests#283
galvanizze merged 4 commits into
crypkit:masterfrom
zmaslerdev:fix/solana-program-accounts-v2

Conversation

@zmaslerdev

Copy link
Copy Markdown
Contributor

📝 Summary

Use paginated Helius stake-account queries while preserving legacy getProgramAccounts behavior for non-Helius Solana RPC providers.

🔍 Review

Recommendation: 🟡 Focused review — the change is localized, but stake balances depend on complete cursor traversal.

⚠️ Review carefully:

  • blockapi/v2/api/solana.py:_fetch_staked_sol — continue through empty filtered pages until paginationKey is null and preserve the flat internal result contract.

🔗 Compatibility

Helius RPC hosts use getProgramAccountsV2; other Solana RPC providers retain getProgramAccounts. Existing parsers still receive result as a flat account list.

✅ Verification

Confidence: 🟢 Fully verified — focused and full unit suites pass, and both production Helius and the default Solana RPC paths were exercised live.

@zmaslerdev

Copy link
Copy Markdown
Contributor Author

Hi @galvanizze, could you please review this change? GitHub does not allow the PR author to submit a formal review request without upstream write permission.

Comment thread blockapi/v2/api/solana.py Outdated
params=[self.STAKE_PROGRAM_ID, config],
)

config['limit'] = self.api_options.max_items_per_page

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

recheck this setting for helius

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checked against the current Helius contract: limits from 1 to 10,000 are supported, with 1,000–5,000 recommended for most use cases. I changed this to a Helius-specific page size of 5,000. A live authority with 4,093 stake accounts returned the same accounts and aggregate balances with limits 1,000, 5,000, and 10,000. The 5,000 limit reduced traversal from five requests to one, while 10,000 provided no meaningful benefit.

@galvanizze galvanizze left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

test on some addresses, with lots of balances/nfts, to check whether paginating works ok

@zmaslerdev

Copy link
Copy Markdown
Contributor Author

Tested the complete balance flow with include_nfts=True on incident addresses. One returned 1,356 balances including 1,348 NFTs, another returned 1,112 balances including 499 NFTs, and a withdraw authority with 4,093 stake accounts produced the expected available, staked, and locked balances. The regression test also covers an empty filtered page with a non-null cursor and continues until paginationKey is null. If a later page still fails after retries, the whole request fails instead of returning partial stake balances.

@zmaslerdev
zmaslerdev force-pushed the fix/solana-program-accounts-v2 branch from 9c03905 to b1d5a22 Compare September 3, 2026 20:02
@zmaslerdev

Copy link
Copy Markdown
Contributor Author

Update after narrowing the hotfix scope: this branch no longer implements retries. If a later Helius V2 page fails, the whole fetch fails without returning partial data. Timeout/retry handling is deferred to a follow-up.

@galvanizze
galvanizze merged commit ac16ad2 into crypkit:master Sep 4, 2026
1 check 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