Repository navigation
feat(sdk): add solana.FindAddress on sol_try_find_program_address - #28
Draft
paulbalaji wants to merge 6 commits into
Draft
paulbalaji wants to merge 6 commits into
paulbalaji wants to merge 6 commits into
Conversation
Programs that need a canonical bump loop over CreateAddress, paying the seed parsing and staging copy on every bump tried. FindAddress takes the same seed group without the bump and makes one sol_try_find_program_address syscall (fogo-v0 by name, solana-v3 hash 0x48504a38), writing the address and bump into a 33-byte output. The runtime charges 1,500 CU per bump, the same as CreateAddress. Malformed groups, more than 15 seeds and wrong lengths return 2007 before the syscall, which would otherwise abort or charge for all 255 bumps. Native contexts run the same search through DeriveAddress.
pda.Seeds.FindAddress looped over CreateAddress, paying the seed parsing and setup again for every bump. It now makes one solana.FindAddress call (sol_try_find_program_address), which tries the same bumps, 255 down to 1, at 1,500 CU each. Statuses are unchanged: 3001 with no room for the bump, 3004 when no bump works, and a missing native callback propagates. examples/find-address costs 630 to 960 CU less per search. The SDK-2 example snapshots of sdk/pda/pda.go are refreshed.
This was referenced Oct 19, 2026
paulbalaji
force-pushed
the
syscall-try-find-program-address
branch
from
October 19, 2026 17:19
4f9b430 to
26053c0
Compare
This was referenced Oct 19, 2026
paulbalaji
added a commit
to hyperlane-xyz/hyperlane-monorepo
that referenced
this pull request
Oct 19, 2026
hyperlane-integration-4 (3ddeff0) is upstream main 939b215, which merged our earlier PRs #9 to #24 in CrocSwap/goSVM#25, plus the open draft PRs: whole-word runtime loads, stores and key comparisons (CrocSwap/goSVM#27), solana.FindAddress on sol_try_find_program_address, also behind pda.Seeds.FindAddress (CrocSwap/goSVM#28), word-at-a-time == on byte arrays (CrocSwap/goSVM#29), the exact MinimumBalanceFor fast path at thresholds 2.0 and 1.0 (CrocSwap/goSVM#30), and word compares in front of hand-written byte compare loops (CrocSwap/goSVM#31). The SDK snapshot is copied from the new CLI.
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.
Problem
Programs that need a canonical bump loop over
CreateAddress, one syscall per bump, andpda.Seeds.FindAddress(#16, merged in #25) does the same. Every try parses the seed group again on top of the runtime's 1,500 CU, and the loop has its own setup. The runtime already hassol_try_find_program_address, which walks the bumps itself.Solution
solana.FindAddress(c, seeds, program, output) uint64makes onesol_try_find_program_addresssyscall (fogo-v0 by name, solana-v3 hash0x48504a38).seedsis the same encoded groupCreateAddresstakes, without the bump, so at most 15 seeds.outputis 33 bytes: the address, then the bump.The runtime charges 1,500 CU per bump tried, the same as one
CreateAddress, and tries 255 down to 1, asfind_program_addressdoes. Native contexts run the same search throughDeriveAddress.pda.Seeds.FindAddressnow makes onesolana.FindAddresscall. Same bumps and statuses: 3001 with no room for the bump, 3004 when no bump works, a missing native callback propagates.Benchmarks
TestFindAddressSBF, whole transaction against main939b215, same on both profiles:FindAddressCreateAddressloopprocess_authorityEach extra bump costs exactly 1,500 CU with
FindAddressand 1,625 with the loop for the Hyperlane seeds. 373 to 1,228 CU saved per search over 27 seed sets. Before #25 the gap looked bigger (up to 5,233 CU) because the test loop's one-timecopyof the group was a byte loop; #22 fixed that, not this PR.examples/find-address, which usespda.Seeds.FindAddress: 630 to 960 CU less per search (bump 255: 2,931 to 2,263; bump 250: 10,796 to 9,833).In the Hyperlane Go programs, measured before #25 on
hyperlane-integration-3, switching their PDA search from the loop toFindAddresscut total CU by 0.7% to 2.2% per program (584/584 tests pass).Tests
TestFindAddressSBFon fogo-v0 and solana-v3: 27 seed sets, each address and bump equal tofixture.FindProgramAddressand to aCreateAddressloop in the same program; four malformed groups return 2007.sdk/pda's 401solana-pubkeyvectors and status tests pass unchanged.examples/find-addresspassesgosvm test --svmon both profiles.TestCorpusMatchesPreCheckCompilerremoves only the new runtime lines and matches every recorded hash.solana/api.go,sdk/pda/pda.go) refreshed for all six examples, so existing SDK-2 projects need re-scaffolding, as with any snapshot change.make test: same failures asmain939b215on this machine (stdlib provenance/features tests with Go 1.23.2,TestFullSwapFactsunder/tmp).verify_rebuild.py+check_rebuild_reference.pypass locally: the reference ELFs are unchanged.Linked work
Closes #26, together with #27, #29, #30 and #31. If this merges first, #26 should stay open until the rest land.
Rebased onto
mainafter #25. Used by hyperlane-xyz/hyperlane-monorepo#9852 throughhyperlane-integration-4.