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

Use higher compute budget for helloworld sealevel #2981

Merged
merged 1 commit into from
Nov 27, 2023
Merged
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
19 changes: 18 additions & 1 deletion typescript/helloworld/src/multiProtocolApp/sealevelAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AccountMeta,
ComputeBudgetProgram,
Keypair,
PublicKey,
SystemProgram,
Expand All @@ -26,6 +27,14 @@ import { Address, Domain } from '@hyperlane-xyz/utils';

import { IHelloWorldAdapter } from './types';

// The compute limit to set for the send hello world instruction.
// This is typically around ~160k, but can be higher depending on
// the index in the merkle tree, which can result in more moderately
// more expensive merkle tree insertion.
// Because a higher compute limit doesn't increase the fee for a transaction,
// we generously request 1M units.
const SEND_HELLO_WORLD_COMPUTE_LIMIT = 1_000_000;

export class SealevelHelloWorldAdapter
extends SealevelRouterAdapter
implements IHelloWorldAdapter
Expand Down Expand Up @@ -80,6 +89,12 @@ export class SealevelHelloWorldAdapter
data: Buffer.from(serializedData),
});

const setComputeLimitInstruction = ComputeBudgetProgram.setComputeUnitLimit(
{
units: SEND_HELLO_WORLD_COMPUTE_LIMIT,
},
);

const connection = this.getProvider();
const recentBlockhash = (await connection.getLatestBlockhash('finalized'))
.blockhash;
Expand All @@ -88,7 +103,9 @@ export class SealevelHelloWorldAdapter
feePayer: senderPubKey,
blockhash: recentBlockhash,
recentBlockhash,
}).add(txInstruction);
})
.add(setComputeLimitInstruction)
.add(txInstruction);
transaction.partialSign(randomWallet);

return { type: ProviderType.SolanaWeb3, transaction };
Expand Down
Loading