From 7b8b6d80cb35b1bdbc706d075f84a4808987fe2a Mon Sep 17 00:00:00 2001 From: Trevor Porter Date: Mon, 27 Nov 2023 14:21:22 +0000 Subject: [PATCH] Use higher compute budget for helloworld sealevel (#2981) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description We need to request a higher compute limit for certain message indexes that result in a higher # of internal nodes being hashed when inserting into the merkle tree. Similar issue as #2771 ### Drive-by changes n/a ### Related issues n/a ### Backward compatibility yes ### Testing none 😛 --- .../src/multiProtocolApp/sealevelAdapter.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/typescript/helloworld/src/multiProtocolApp/sealevelAdapter.ts b/typescript/helloworld/src/multiProtocolApp/sealevelAdapter.ts index c3b3fcb2fa7..8acae503002 100644 --- a/typescript/helloworld/src/multiProtocolApp/sealevelAdapter.ts +++ b/typescript/helloworld/src/multiProtocolApp/sealevelAdapter.ts @@ -1,5 +1,6 @@ import { AccountMeta, + ComputeBudgetProgram, Keypair, PublicKey, SystemProgram, @@ -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 @@ -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; @@ -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 };