This repository was archived by the owner on Mar 11, 2025. It is now read-only.
token-client: Use transaction simulation results for the compute unit limit #6500
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
As part of #6492, the token-cli doesn't support priority fees. Currently, the token-client allows for setting a compute unit price and limit, but that requires users to know the compute units used by their transaction.
Solution
Transaction simulation gives the compute units used by a transaction, so instead of asking users to provide a number, we can be a bit smarter and use simulation results to set the compute unit limit used by a transaction.
We also need to support offline signing, which cannot simulate transactions. In this PR, the token client fails to extract the compute units used by the transaction after the offline "simulation", and thus uses the default limit of 200k * num_top_level_instructions.
A user-provided value for
compute_unit_limit
always takes precedence, so offline signing can use a hardcoded number if a compute unit limit is desired.Note: the range proofs for confidential transfers are so close to the transaction size limit that we can't add any other instructions to the transaction, so those are created and sent without the helpers