Repository navigation
feat(sdk-coin-sol): add explicit compute-unit-limit setter - #9910
Draft
MohammedRyaan786 wants to merge 1 commit into
Draft
MohammedRyaan786 wants to merge 1 commit into
MohammedRyaan786 wants to merge 1 commit into
Conversation
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
Contributor
Contributor
|
|
This branch has not been deployed
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.
This pull request adds comprehensive support for Solana compute-budget instructions—specifically,
SetComputeUnitLimitandSetPriorityFee—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
MAX_COMPUTE_UNIT_LIMITto define the maximum allowed compute units per transaction.isComputeBudgetInstructionandparseComputeBudgetInstructionto identify and parse compute-budget instructions. These are now used throughout all instruction parsing functions.Instruction Parsing Enhancements
SetComputeUnitLimitandSetPriorityFeeinstructions, 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
TransactionBuilderclass to support an explicit compute-unit limit via a new_computeUnitLimitproperty and asetComputeUnitLimitmethod, which validates the value and ensures the corresponding instruction is prepended to the transaction. [1] [2]SetComputeUnitLimitinstruction is added before all others (after any nonce), and the instruction is also recorded for explain and parsing purposes.SetComputeUnitLimitinstruction is present.Type and Import Updates
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