Skip to content

feat(sdk-coin-sol): add explicit compute-unit-limit setter - #9910

Draft
MohammedRyaan786 wants to merge 1 commit into
masterfrom
mohammedryaan/chalo-1650-sdk-coin-sol-explicit-compute-unit-limit-setter-in
Draft

MohammedRyaan786 wants to merge 1 commit into
masterfrom
mohammedryaan/chalo-1650-sdk-coin-sol-explicit-compute-unit-limit-setter-in

Conversation

@MohammedRyaan786

@MohammedRyaan786 MohammedRyaan786 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

This pull request adds comprehensive support for Solana compute-budget instructions—specifically, SetComputeUnitLimit and SetPriorityFee—across all transaction parsing and building logic. This enables transactions to explicitly set their compute unit limits and priority fees, which is critical for optimizing transaction execution and fee calculation. The changes ensure these instructions are handled consistently in all relevant transaction types and expose a new API for setting the compute unit limit.

Key changes include:

Compute-Budget Instruction Support

  • Added a new constant MAX_COMPUTE_UNIT_LIMIT to define the maximum allowed compute units per transaction.
  • Implemented helper functions isComputeBudgetInstruction and parseComputeBudgetInstruction to identify and parse compute-budget instructions. These are now used throughout all instruction parsing functions.

Instruction Parsing Enhancements

  • Updated all instruction parsing functions (e.g., for wallet init, send, staking activate/delegate/deactivate/withdraw, ATA init/close) to recognize and correctly handle SetComputeUnitLimit and SetPriorityFee instructions, ensuring these are included in the parsed instruction data. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Transaction Builder Improvements

  • Extended the TransactionBuilder class to support an explicit compute-unit limit via a new _computeUnitLimit property and a setComputeUnitLimit method, which validates the value and ensures the corresponding instruction is prepended to the transaction. [1] [2]
  • During transaction building, if a compute-unit limit is set, a SetComputeUnitLimit instruction is added before all others (after any nonce), and the instruction is also recorded for explain and parsing purposes.
  • When parsing existing transactions, the builder restores the compute unit limit if a SetComputeUnitLimit instruction is present.

Type and Import Updates

  • Updated type signatures and imports throughout the codebase to include the new compute-budget instruction types.

These changes ensure robust and consistent handling of compute-budget instructions, which is essential for advanced transaction fee management and performance tuning on Solana.

What: add setComputeUnitLimit(units) to the Solana TransactionBuilder. It validates an integer between 1 and the on-chain maximum of 1,400,000. When set, buildLegacyTransaction() prepends a SetComputeUnitLimit instruction ahead of every entry of _instructionsData (after the durable-nonce AdvanceNonceAccount, before the optional SetComputeUnitPrice) and records it in _instructionsData the way memo is, so explain and parsing see it. initBuilder() restores the limit from a parsed transaction, so a signing-phase rebuild from raw is byte-identical, and with no limit set the built bytes are unchanged. The per-type instruction parsers (send, staking, ATA and wallet init) now accept compute-budget instructions through a shared helper, and
matchTransactionTypeByInstructionsOrder skips leading compute-budget instructions, so raw transactions that carry a limit still classify and round trip for every builder.

Why: the priority fee is charged on the requested compute-unit limit rather than the units actually consumed, so every sponsored transaction must set an explicit, intent-sized limit (SOL Gasless Fee Payer TDD section 4.1, invariant 8). The instruction type already existed but no builder emitted it, leaving sponsored transactions without a compute cap.

Ticket: CHALO-1650
Session-Id: 3662d15a-5b50-4187-a602-918f68e8ee2f
Task-Id: cc1ab97e-1b0c-42f2-8440-deaee2d552b3

What: add setComputeUnitLimit(units) to the Solana TransactionBuilder.
It validates an integer between 1 and the on-chain maximum of
1,400,000. When set, buildLegacyTransaction() prepends a
SetComputeUnitLimit instruction ahead of every entry of
_instructionsData (after the durable-nonce AdvanceNonceAccount,
before the optional SetComputeUnitPrice) and records it in
_instructionsData the way memo is, so explain and parsing see it.
initBuilder() restores the limit from a parsed transaction, so a
signing-phase rebuild from raw is byte-identical, and with no limit
set the built bytes are unchanged. The per-type instruction parsers
(send, staking, ATA and wallet init) now accept compute-budget
instructions through a shared helper, and
matchTransactionTypeByInstructionsOrder skips leading compute-budget
instructions, so raw transactions that carry a limit still classify
and round trip for every builder.

Why: the priority fee is charged on the requested compute-unit limit
rather than the units actually consumed, so every sponsored
transaction must set an explicit, intent-sized limit (SOL Gasless
Fee Payer TDD section 4.1, invariant 8). The instruction type already
existed but no builder emitted it, leaving sponsored transactions
without a compute cap.

Ticket: CHALO-1650
Session-Id: 3662d15a-5b50-4187-a602-918f68e8ee2f
Task-Id: cc1ab97e-1b0c-42f2-8440-deaee2d552b3
@linear-code

linear-code Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

CHALO-1650

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Unit tests are failing on Node 26.x (Current release line, non-blocking). This is not an LTS version yet, so it does not block merge, but it signals an incompatibility to fix before Node 26.x becomes LTS.

View run

This branch has not been deployed

No deployments
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