Skip to content

Compute unit price improvement #1744

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions sdk/src/tx/txHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ import { DEFAULT_CONFIRMATION_OPTS } from '../config';
* When the whileValidTxSender waits for confirmation of a given transaction, it needs the last available blockheight and blockhash used in the signature to do so. For pre-signed transactions, these values aren't attached to the transaction object by default. For a "scrappy" workaround which doesn't break backwards compatibility, the SIGNATURE_BLOCK_AND_EXPIRY property is simply attached to the transaction objects as they are created or signed in this handler despite a mismatch in the typescript types. If the values are attached to the transaction when they reach the whileValidTxSender, it can opt-in to use these values.
*/

const DEV_TRY_FORCE_TX_TIMEOUTS =
process.env.DEV_TRY_FORCE_TX_TIMEOUTS === 'true' || false;

export const COMPUTE_UNITS_DEFAULT = 200_000;

const BLOCKHASH_FETCH_RETRY_COUNT = 3;
Expand Down Expand Up @@ -554,13 +551,11 @@ export class TxHandler {

const computeUnitsPrice = baseTxParams?.computeUnitsPrice;

if (DEV_TRY_FORCE_TX_TIMEOUTS) {
allIx.push(
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 0,
})
);
} else if (computeUnitsPrice > 0 && !hasSetComputeUnitPriceIx) {
if (
typeof computeUnitsPrice === 'number' &&
computeUnitsPrice != null &&
!hasSetComputeUnitPriceIx
) {
allIx.push(
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: computeUnitsPrice,
Expand Down Expand Up @@ -603,13 +598,7 @@ export class TxHandler {
);
}

if (DEV_TRY_FORCE_TX_TIMEOUTS) {
tx.add(
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 0,
})
);
} else if (computeUnitsPrice != 0) {
if (typeof computeUnitsPrice === 'number' && computeUnitsPrice != null) {
tx.add(
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: computeUnitsPrice,
Expand Down
Loading