SIMD-0287: Message Headers with Compute Budget Metadata#287
SIMD-0287: Message Headers with Compute Budget Metadata#287cavemanloverboy wants to merge 1 commit into
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.
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.
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.
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.
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. |
|
superseded |

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
MessageHeaderis extended to include two new fields:compute_unit_price(u64)compute_unit_limit(u32)three
u8signature counters.v2: Fixed Fields for Compute Unit Limit & Price, Loaded Data & Heap Requests
MessageHeaderis extended to include four new fields:compute_unit_price(u64)compute_unit_limit(u32)loaded_accounts_data_limit(u32)requested_heap_bytes(u32)three
u8signature counters.v3: Dynamic Header
ComputeBudgetHeaderstruct at the front of themessage, containing:
flags: u8bitmask indicating which compute budget fields are present.Option<u32>orOption<u64>) for the parametersflagsbyte.flags, serialize the corresponding field in orderwithout additional tags.
MessageHeader(threeu8counters) 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