-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for compute budget instructions #24086
Conversation
RequestUnits: { | ||
index: 0, | ||
layout: BufferLayout.struct<ComputeBudgetInstructionInputData['RequestUnits']>([ | ||
BufferLayout.u8('instruction'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think because the ComputeBudgetInstructions use borsh
rather than bincode
for serialization, the instruction buffer is only a u8
rather than a u32
compared to other instructions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's correct!
|
||
static requestUnits(params: RequestUnitsParams): TransactionInstruction { | ||
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits; | ||
const data = encodeData(type, params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR still uses the BufferLayout
to match the other programs in the sdk, but it is also possible to switch to using the borsh
style serialization/deserialization i.e. what PublicKey does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is fine
'ComputeBudget111111111111111111111111111111', | ||
); | ||
|
||
static requestUnits(params: RequestUnitsParams): TransactionInstruction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning a TransactionInstruction
here rather than a Transaction
, the StakeProgram
seemed to return primarily Transaction
, but think TransactionInstruction
is a bit more composable
web3.js/test/compute-budget.test.ts
Outdated
|
||
use(chaiAsPromised); | ||
|
||
describe.skip('ComputeBudget', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently skipping these tests since I don't think that the transaction wide compute cap is activated on most networks yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's enabled by default in new runs of the test validator
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Codecov Report
@@ Coverage Diff @@
## master #24086 +/- ##
===========================================
- Coverage 81.8% 70.0% -11.8%
===========================================
Files 581 37 -544
Lines 158312 2301 -156011
Branches 0 325 +325
===========================================
- Hits 129518 1613 -127905
+ Misses 28794 573 -28221
- Partials 0 115 +115 |
* Add ComputeBudgetInstruction to web3 sdk * Prettier fix * Rename to ComputeBudgetProgram and enable tests Co-authored-by: Justin Starry <[email protected]>
@philcchen FYI we will unfortunately be breaking the API for the changes you added in this new pending change: #25104 |
@jstarry No worries! thanks for the heads up :) |
* Add ComputeBudgetInstruction to web3 sdk * Prettier fix * Rename to ComputeBudgetProgram and enable tests Co-authored-by: Justin Starry <[email protected]>
* Add ComputeBudgetInstruction to web3 sdk * Prettier fix * Rename to ComputeBudgetProgram and enable tests Co-authored-by: Justin Starry <[email protected]>
Problem
Missing ComputeBudgetInstruction in web3 sdk
Summary of Changes
Adds ComputeBudgetInstruction to web3 sdk