Skip to content

Commit

Permalink
Use higher compute budget for helloworld sealevel (#2981)
Browse files Browse the repository at this point in the history
### 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 😛
  • Loading branch information
tkporter authored and daniel-savu committed Jun 5, 2024
1 parent 9c39d68 commit 7b8b6d8
Showing 1 changed file with 18 additions and 1 deletion.
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

0 comments on commit 7b8b6d8

Please sign in to comment.