geolocation/sdk: bump compute budget for target-scan instructions#3596
Merged
geolocation/sdk: bump compute budget for target-scan instructions#3596
Conversation
AddTarget, RemoveTarget, and SetResultDestination each walk every target on the GeolocationUser account onchain. The default 200K CU per-tx limit exhausts at ~743 targets, well below MAX_TARGETS=4096; consumers were hitting "exceeded CUs meter" failures without an obvious fix. Both SDKs now prepend a SetComputeUnitLimit(1_400_000) instruction for these calls, matching the budget validated by add_target_cu_benchmark.rs. The Rust SDK uses an exhaustive match on GeolocationInstruction so a new variant cannot silently fall through. The Go SDK renames Build*Instruction to Build*Instructions (returning []solana.Instruction) — the rename forces the breaking type change to surface as a compile error rather than a silent slice/single mismatch. Resolves: #3595
nikw9944
approved these changes
Apr 28, 2026
Drop unused ExecuteTransaction (singular) helper from the geolocation Go executor — the SDK only ever calls ExecuteTransactions. Rename the TestExecuteTransaction_* tests to plural to match. Fix a stale comment in add_target_test.go that referenced the helper's old name.
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.
Resolves: #3595
Summary of Changes
SetComputeUnitLimit(1_400_000)instruction toAddTarget,RemoveTarget, and (Rust only)SetResultDestinationtransactions. These handlers do an O(n) scan over every target onchain; the default 200K CU per-tx limit exhausted around 743 targets, far below the program'sMAX_TARGETS=4096ceiling. Consumers no longer need to think about compute budgets up to that bound.matchoverGeolocationInstruction, so adding a new variant forces an explicit CU-budget decision rather than silently falling through to the default.Build{Add,Remove}TargetInstruction→Build{Add,Remove}TargetInstructionsand changes the return type fromsolana.Instructionto[]solana.Instruction. The rename surfaces the breaking type change as a compile error rather than a silent slice/single mismatch; callers feed the returned slice intoexecutor.ExecuteTransactions.SetResultDestinationbuilder, so that handler is only bumped on the Rust side.Diff Breakdown
Mostly SDK plumbing with matching test updates; no scaffolding/config/docs.
Key files (click to expand)
smartcontract/sdk/rs/src/geolocation/client.rs— addsTARGET_SCAN_COMPUTE_UNIT_LIMIT, exhaustive-matchcompute_unit_limit_for(...)helper, and prepends the compute-budget instruction insideGeoClient::execute_transaction. Bucket-coverage unit tests for every variant.sdk/geolocation/go/add_target.go—BuildAddTargetInstructionsreturns[]solana.Instructionwith a compute-budget prefix.sdk/geolocation/go/remove_target.go— same change forBuildRemoveTargetInstructions.sdk/geolocation/go/constants.go— addsTargetMutationComputeUnitLimit.sdk/geolocation/go/{add_target,remove_target,instructions,executor}_test.go— updated for new names/return type, plus regression tests asserting the prefix is present and requests the right limit.Testing Verification
exceeded CUs meter at BPF instructionat ~743 targets) on software-devnet in CH7 prior to the fix; the stress run will now scale toMAX_TARGETS=4096.AddTarget/RemoveTarget(andSetResultDestinationin Rust) carry the 1.4M-CU prefix; the Rust tests use exhaustive variant lists so a new instruction can't silently slip through.add_target_cu_benchmark.rsbudget assumption (1.4M CU sufficient up to N=4095) is unchanged; this PR only flips the SDK to actually request that budget.