-
Notifications
You must be signed in to change notification settings - Fork 177
SIMD-0287: Message Headers with Compute Budget Metadata #287
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
base: main
Are you sure you want to change the base?
Conversation
|
||
- **Change**: Introduce a new `ComputeBudgetHeader` struct at the front of the | ||
message, containing: | ||
- `flags: u8` bitmask indicating which compute budget fields are present. |
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.
what're thoughts on the below? for future proof, is there a world where >8 compute-related operations take place?
#[repr(u8)]
enum ComputeBudgetOp {
ComputeUnitPrice(u64),
ComputeUnitLimit(u32),
...
}
ComputeBudgetHeader {
// perhaps Vec encoded with u8 length discriminator instead of u64
ops: Vec<ComputeBudgetOp>
}
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.
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.
in all seriousness, i think if we're worried about future proofing we can use a 16-bit flag
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 alternative repr is a bit wasteful bc every element comes with a discriminator, and you will need to check for dups. with the bitflag you get uniqueness for free and uniquely determines lenth + deserialization.
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.
edit: the optional fields confused me; thats for the API not for the serialization format. what you said makes sense to me
ComputeBudget program instructions are a huge waste, transaction settings should be in the header. +1 also a good excuse to increment the ungodly V1 transaction enum to V2 transaction and stop confusing everyone. |
It is possible to get access to Compute Budget instructions from a Solana Program
But MessageHeader isn't available on-chain. Solana Programs already have this possibilities and build some logic around it. |
yea this is kind of a pain... This is incredibly [REDACTED] but for backwards compatibility — similar to lookup tables — the instructions could be appended with equivalent compute budget instructions |
This is great! A solid method for future proofing without breaking V0 IXes. |
Summary
We introduce three new (candidate) versions for transaction format aiming at
reducing the transaction footprint for compute budget instructions.
Motivation
The use of compute budget instructions has become ubiquitous. These instructions
currently have a nontrivial serialized footprint and are presently wasteful in
their implementation. The information in these instructions can be compacted
significantly, enabling users to fit a bit more data in their transaction payload.
Detailed Design
v1: Fixed Fields for Compute Unit Limit & Price
MessageHeader
is extended to include two new fields:compute_unit_price
(u64)compute_unit_limit
(u32)three
u8
signature counters.v2: Fixed Fields for Compute Unit Limit & Price, Loaded Data & Heap Requests
MessageHeader
is extended to include four new fields:compute_unit_price
(u64)compute_unit_limit
(u32)loaded_accounts_data_limit
(u32)requested_heap_bytes
(u32)three
u8
signature counters.v3: Dynamic Header
ComputeBudgetHeader
struct at the front of themessage, containing:
flags: u8
bitmask indicating which compute budget fields are present.Option<u32>
orOption<u64>
) for the parametersflags
byte.flags
, serialize the corresponding field in orderwithout additional tags.
MessageHeader
(threeu8
counters) and therest of the message.
Importantly, this variant supports up to 8 compute budget ixs (reserved for future use).
Example
We consider v0 (existing), v1, v2, v3 message with noop (no instructions), cu limit + price, and all four existing compute budget instructions. These are the serialized footprints.
The code for this can be found here