Skip to content

geolocation/sdk: bump compute budget for target-scan instructions#3596

Merged
ben-dz merged 2 commits intomainfrom
bdz/geolocation-sdk-cu-budget-for-target-scans
Apr 28, 2026
Merged

geolocation/sdk: bump compute budget for target-scan instructions#3596
ben-dz merged 2 commits intomainfrom
bdz/geolocation-sdk-cu-budget-for-target-scans

Conversation

@ben-dz
Copy link
Copy Markdown
Contributor

@ben-dz ben-dz commented Apr 27, 2026

Resolves: #3595

Summary of Changes

  • Rust and Go geolocation SDKs now prepend a SetComputeUnitLimit(1_400_000) instruction to AddTarget, RemoveTarget, and (Rust only) SetResultDestination transactions. 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's MAX_TARGETS=4096 ceiling. Consumers no longer need to think about compute budgets up to that bound.
  • Rust SDK uses an exhaustive match over GeolocationInstruction, so adding a new variant forces an explicit CU-budget decision rather than silently falling through to the default.
  • Go SDK renames Build{Add,Remove}TargetInstructionBuild{Add,Remove}TargetInstructions and changes the return type from solana.Instruction to []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 into executor.ExecuteTransactions.
  • The Go SDK currently has no SetResultDestination builder, so that handler is only bumped on the Rust side.

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 4 +182 / -22 +160
Tests 4 +129 / -68 +61

Mostly SDK plumbing with matching test updates; no scaffolding/config/docs.

Key files (click to expand)
  • smartcontract/sdk/rs/src/geolocation/client.rs — adds TARGET_SCAN_COMPUTE_UNIT_LIMIT, exhaustive-match compute_unit_limit_for(...) helper, and prepends the compute-budget instruction inside GeoClient::execute_transaction. Bucket-coverage unit tests for every variant.
  • sdk/geolocation/go/add_target.goBuildAddTargetInstructions returns []solana.Instruction with a compute-budget prefix.
  • sdk/geolocation/go/remove_target.go — same change for BuildRemoveTargetInstructions.
  • sdk/geolocation/go/constants.go — adds TargetMutationComputeUnitLimit.
  • 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

  • Reproduced the original failure mode (exceeded CUs meter at BPF instruction at ~743 targets) on software-devnet in CH7 prior to the fix; the stress run will now scale to MAX_TARGETS=4096.
  • New unit tests in both SDKs assert per-variant bucket assignment and that AddTarget/RemoveTarget (and SetResultDestination in Rust) carry the 1.4M-CU prefix; the Rust tests use exhaustive variant lists so a new instruction can't silently slip through.
  • Verified add_target_cu_benchmark.rs budget assumption (1.4M CU sufficient up to N=4095) is unchanged; this PR only flips the SDK to actually request that budget.

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
Comment thread sdk/geolocation/go/add_target_test.go Outdated
Comment thread sdk/geolocation/go/executor_test.go Outdated
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.
@ben-dz ben-dz enabled auto-merge (squash) April 28, 2026 18:34
@ben-dz ben-dz merged commit 1f7c932 into main Apr 28, 2026
43 of 44 checks passed
@ben-dz ben-dz deleted the bdz/geolocation-sdk-cu-budget-for-target-scans branch April 28, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Geolocation: Increase CU Budget for Instructions that need it

2 participants