Skip to content
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

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

joncinque
Copy link
Contributor

@joncinque joncinque commented Mar 26, 2024

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

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@joncinque joncinque merged commit 19c2dd7 into solana-labs:master Mar 27, 2024
@joncinque joncinque deleted the tkprio branch March 27, 2024 11:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants