Skip to content

Add ComputeBudget SetComputeUnitPrice and SetComputeUnitLimit instructions and composers - #25

Merged
sebscholl merged 4 commits into
mainfrom
feature/compute-budget-set-compute-unit-price
Jul 6, 2026
Merged

Add ComputeBudget SetComputeUnitPrice and SetComputeUnitLimit instructions and composers#25
sebscholl merged 4 commits into
mainfrom
feature/compute-budget-set-compute-unit-price

Conversation

@fulf

@fulf fulf commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Adds Compute Budget program support and bumps the gem to 0.1.7:

  • Instructions::ComputeBudget::SetComputeUnitPriceInstruction + composer — priority fee (u8 3 + le_u64 micro-lamports)
  • Instructions::ComputeBudget::SetComputeUnitLimitInstruction + composer — compute unit cap (u8 2 + le_u32 units)

Includes unit and validator-backed composer tests (one pins the exact on-chain fee implied by limit × price), plus a Compute Budget docs page and table/sidebar entries.

rake test: 345 runs, 0 failures · rubocop: clean

🤖 Generated with Claude Code

fulf and others added 2 commits July 3, 2026 12:04
Let any transaction composed with Solace attach a compute unit price —
the priority fee validators use to order transactions during
congestion. The instruction encodes the SetComputeUnitPrice directive
(1-byte index 3 + le_u64 micro-lamports) and takes no accounts — the
composer registers only the Compute Budget program and resolves its
index at compose time. Add unit and validator-backed integration tests,
a Compute Budget page to the docs site, rows to the bundled
builder/composer tables, and bump to 0.1.7.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Complete the ComputeBudget coverage started with SetComputeUnitPrice so
a transaction can also cap its compute units — and, paired with a
compute unit price, pin down the exact priority fee it pays. The
instruction encodes the SetComputeUnitLimit directive (1-byte index 2 +
le_u32 units) and takes no accounts. The composer test asserts the
exact on-chain fee implied by a 10k-unit limit at 1M micro-lamports per
unit. Extends the Compute Budget docs page, the bundled builder and
composer tables, and the 0.1.7 changelog entry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@fulf
fulf force-pushed the feature/compute-budget-set-compute-unit-price branch from cd3eb96 to 725b5de Compare July 3, 2026 09:04

@sebscholl sebscholl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good with the exception of the two tests that seem to not be validating the relevant subject.

The convention of the gem is to prove the relevant behavior in both a sponsored and non sponsored transaction. Please just update that accordingly, as I believe that both tests commented on simply tests a transfer worked as opposed to priority fees/computer budgets being appropriately applied.

The sponsored and non-sponsored cases asserted balances that would
pass even if the compute budget instruction never made it on-chain.
Each test now uses only its own composer: both files decode the
composed transaction and assert the instruction is present with the
exact payload, the sponsored and non-sponsored cases confirm the
transaction is valid, the price tests assert the priority fee is
deducted, and the limit tests add a case where the node rejects a
transaction that exceeds the requested limit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@fulf
fulf force-pushed the feature/compute-budget-set-compute-unit-price branch from 93893df to 2d13c2b Compare July 3, 2026 13:23
@fulf

fulf commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@sebscholl updated the tests to:

  • assert the inclusion of the relevant CU ix
  • assert the generated tx is valid

LMK if this is better 🙇

@fulf
fulf requested a review from sebscholl July 3, 2026 13:31
Use sequentially organized before blocks with instance variables
instead of let statements, matching the price composer test. Rename
describe blocks to the behavior actually under test, and merge the
sponsored/non-sponsored blocks — they asserted nothing payer-specific
and were the same test once named honestly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@fulf
fulf requested a review from sebscholl July 6, 2026 14:10
@sebscholl
sebscholl merged commit 6575f1b into main Jul 6, 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