Skip to content

Commit a4bcd75

Browse files
committed
cli: init/update LUT if needed (solana)
1 parent ef34757 commit a4bcd75

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

cli/src/index.ts

+40-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import "@wormhole-foundation/sdk-solana-ntt";
2222
import "@wormhole-foundation/sdk-definitions-ntt";
2323
import type { Ntt, NttTransceiver } from "@wormhole-foundation/sdk-definitions-ntt";
2424

25-
import { type SolanaChains } from "@wormhole-foundation/sdk-solana";
25+
import { type SolanaChains, SolanaAddress } from "@wormhole-foundation/sdk-solana";
2626

2727
import { colorizeDiff, diffObjects } from "./diff";
2828
import { forgeSignerArgs, getSigner, type SignerType } from "./getSigner";
@@ -693,6 +693,19 @@ yargs(hideBin(process.argv))
693693
console.error(e.logs);
694694
}
695695
}
696+
if (missingConfig.solanaUpdateLUT) {
697+
if (chainToPlatform(chain) !== "Solana") {
698+
console.error("Solana update LUT can only be set on Solana chains");
699+
continue;
700+
}
701+
const solanaNtt = ntt as SolanaNtt<Network, SolanaChains>;
702+
const tx = solanaNtt.initializeOrUpdateLUT({ payer: new SolanaAddress(signer.address.address).unwrap() })
703+
try {
704+
await signSendWait(ctx, tx, signer.signer)
705+
} catch (e: any) {
706+
console.error(e.logs);
707+
}
708+
}
696709
}
697710

698711
// pull deps again
@@ -750,7 +763,7 @@ yargs(hideBin(process.argv))
750763
}
751764
}
752765

753-
if (extraInfo) {
766+
if (Object.keys(extraInfo).length > 0) {
754767
console.log(chalk.yellow(JSON.stringify(extraInfo, null, 2)));
755768
}
756769

@@ -761,23 +774,26 @@ yargs(hideBin(process.argv))
761774
errors++;
762775
}
763776

764-
for (const [chain, peers] of Object.entries(missing)) {
765-
console.error(`Peer errors for ${chain}:`);
766-
for (const manager of peers.managerPeers) {
777+
for (const [chain, missingConfig] of Object.entries(missing)) {
778+
console.error(`${chain} status:`);
779+
for (const manager of missingConfig.managerPeers) {
767780
console.error(` Missing manager peer: ${manager.address.chain}`);
768781
}
769-
for (const transceiver of peers.transceiverPeers) {
782+
for (const transceiver of missingConfig.transceiverPeers) {
770783
console.error(` Missing transceiver peer: ${transceiver.chain}`);
771784
}
772-
for (const evmChain of peers.evmChains) {
773-
console.error(` Missing EVM chain: ${evmChain}`);
785+
for (const evmChain of missingConfig.evmChains) {
786+
console.error(` ${evmChain} needs to be configured as an EVM chain`);
774787
}
775-
for (const relaying of peers.standardRelaying) {
788+
for (const relaying of missingConfig.standardRelaying) {
776789
console.warn(` No standard relaying: ${relaying}`);
777790
}
778-
if (peers.solanaWormholeTransceiver) {
791+
if (missingConfig.solanaWormholeTransceiver) {
779792
console.error(" Missing Solana wormhole transceiver");
780793
}
794+
if (missingConfig.solanaUpdateLUT) {
795+
console.error(" Missing or outdated LUT");
796+
}
781797
}
782798

783799
if (errors > 0) {
@@ -838,6 +854,7 @@ type MissingImplicitConfig = {
838854
evmChains: Chain[];
839855
standardRelaying: Chain[];
840856
solanaWormholeTransceiver: boolean;
857+
solanaUpdateLUT: boolean;
841858
}
842859

843860
function createWorkTree(platform: Platform, version: string): string {
@@ -964,6 +981,7 @@ async function upgradeSolana<N extends Network, C extends SolanaChains>(
964981
}
965982
const mint = (await (ntt.getConfig())).mint;
966983
await deploySolana(pwd, version, await ntt.getMode(), ctx, mint.toBase58(), payer, false, programKeyPath, binaryPath);
984+
// TODO: call initializeOrUpdateLUT. currently it's done in the following 'ntt push' step.
967985
}
968986

969987
async function deploy<N extends Network, C extends Chain>(
@@ -1332,6 +1350,7 @@ async function missingConfigs(
13321350
evmChains: [],
13331351
standardRelaying: [],
13341352
solanaWormholeTransceiver: false,
1353+
solanaUpdateLUT: false,
13351354
};
13361355

13371356
if (chainToPlatform(fromChain) === "Solana") {
@@ -1342,6 +1361,17 @@ async function missingConfigs(
13421361
count++;
13431362
missing.solanaWormholeTransceiver = true;
13441363
}
1364+
1365+
// here we just check if the LUT update function returns an instruction.
1366+
// if it does, it means the LUT is missing or outdated. notice that
1367+
// we're not actually updating the LUT here, just checking if it's
1368+
// missing, so it's ok to use the 0 pubkey as the payer.
1369+
const updateLUT = solanaNtt.initializeOrUpdateLUT({ payer: new PublicKey(0) });
1370+
// check if async generator is non-empty
1371+
if (!(await updateLUT.next()).done) {
1372+
count++;
1373+
missing.solanaUpdateLUT = true;
1374+
}
13451375
}
13461376

13471377
for (const [toChain, to] of Object.entries(deps)) {

0 commit comments

Comments
 (0)