PoC - move process_compute_budget_instructions()
into own crate and more
#2193
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.
Problem
solana-compute-budget
hasprocess_compute_budget_instructions()
;process_compute_budget_instructions()
needs to access builtin programs' default costs to correctly allocate compute budget for builtin instructions;solana-compute-budget
crate;So, there will be circular dependencies for
process_compute_budget_instructions()
to builtin default cost.Summary of Changes
Commit 1: refactor, move statically defined
BUILT_IN_INSTRUCTION_COSTS
out ofsolana-cost-model
into its own crate.solana-cost-model
and other cratesCommit 2: refactor, move
process_compute_budget_instructions()
out ofsolana-compute-budget
into its own crate.solana-compute-budget-processor
breaks circular dep,solana-compute-budget
becomes purely "type def", safer and easier to shareprocess_compute_budget_instructions()
to do One Thing: parse transaction for compute-budget-limits, its result must be consistent regardless of current working_bank. Secondary functions can regulate/validate results on call site usingworking_bank
.Commit 3: refactor, Added intermediate InstructionDetails struct to store raw information after instructions iteration; break
process_compute_budget_instructions()
into two steps: one iterate instructions to retrieveInstructionDetails
that's suitable for caching-n-reusing, then sanitize and convert toComputeBudgetLimits
.Commit 4: refactor: Instruction processor takes SVMMessage in place of CompiledInstruction, fixes process_compute_budget_instructions use non-owned
SVMInstruction
from svm-transaction #2112Commit 5: feat, feature gated, compute budget allocates default cost units for builtin instructions, including compute-budget instructions themselves; Error transaction early if compute-unit-limit is invalid.
This fixes Feature Gate: Fail transaction if requested cu-limit exceeds max limit #885, compute-budget allocates constantly defined default-cost for builtin instructions #2212
Fixes #