From 4148bae7b8dffe267bb408cb02e3ea610e48df48 Mon Sep 17 00:00:00 2001 From: Csongor Kiss Date: Tue, 22 Oct 2024 19:52:13 +0100 Subject: [PATCH] cli: set up special relaying EVM->Solana (#529) --- cli/src/index.ts | 47 +++++++++++++++++++++++++++++++++-------------- evm/ts/src/ntt.ts | 11 +++++++++++ 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/cli/src/index.ts b/cli/src/index.ts index 46154759d..fe17844a7 100755 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -682,8 +682,12 @@ yargs(hideBin(process.argv)) const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver).setIsEvmChain(evmChain, true) await signSendWait(ctx, tx, signer.signer) } - for (const relaying of missingConfig.standardRelaying) { - const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver).setIsWormholeRelayingEnabled(relaying, true) + for (const relayingTarget of missingConfig.standardRelaying) { + const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver).setIsWormholeRelayingEnabled(relayingTarget, true) + await signSendWait(ctx, tx, signer.signer) + } + for (const relayingTarget of missingConfig.specialRelaying) { + const tx = (await ntt.getTransceiver(0) as EvmNttWormholeTranceiver).setIsSpecialRelayingEnabled(relayingTarget, true) await signSendWait(ctx, tx, signer.signer) } if (missingConfig.solanaWormholeTransceiver) { @@ -800,8 +804,11 @@ yargs(hideBin(process.argv)) for (const evmChain of missingConfig.evmChains) { console.error(` ${evmChain} needs to be configured as an EVM chain`); } - for (const relaying of missingConfig.standardRelaying) { - console.warn(` No standard relaying: ${relaying}`); + for (const relayingTarget of missingConfig.standardRelaying) { + console.warn(` No standard relaying to ${relayingTarget}`); + } + for (const relayingTarget of missingConfig.specialRelaying) { + console.warn(` No special relaying to ${relayingTarget}`); } if (missingConfig.solanaWormholeTransceiver) { console.error(" Missing Solana wormhole transceiver"); @@ -896,6 +903,7 @@ type MissingImplicitConfig = { transceiverPeers: ChainAddress[]; evmChains: Chain[]; standardRelaying: Chain[]; + specialRelaying: Chain[]; solanaWormholeTransceiver: boolean; solanaUpdateLUT: boolean; } @@ -1436,6 +1444,7 @@ async function missingConfigs( transceiverPeers: [], evmChains: [], standardRelaying: [], + specialRelaying: [], solanaWormholeTransceiver: false, solanaUpdateLUT: false, }; @@ -1490,17 +1499,27 @@ async function missingConfigs( if (chainToPlatform(fromChain) === "Evm") { const toIsEvm = chainToPlatform(toChain) === "Evm"; + const toIsSolana = chainToPlatform(toChain) === "Solana"; + const whTransceiver = await from.ntt.getTransceiver(0) as EvmNttWormholeTranceiver; + + if (toIsEvm) { + const remoteToEvm = await whTransceiver.isEvmChain(toChain); + if (!remoteToEvm) { + count++; + missing.evmChains.push(toChain); + } - const remoteToEvm = await (await from.ntt.getTransceiver(0) as EvmNttWormholeTranceiver).isEvmChain(toChain); - if (toIsEvm && !remoteToEvm) { - count++; - missing.evmChains.push(toChain); - } - - const standardRelaying = await (await from.ntt.getTransceiver(0) as EvmNttWormholeTranceiver).isWormholeRelayingEnabled(toChain); - if (toIsEvm && !standardRelaying) { - count++; - missing.standardRelaying.push(toChain); + const standardRelaying = await whTransceiver.isWormholeRelayingEnabled(toChain); + if (!standardRelaying) { + count++; + missing.standardRelaying.push(toChain); + } + } else if (toIsSolana) { + const specialRelaying = await whTransceiver.isSpecialRelayingEnabled(toChain); + if (!specialRelaying) { + count++; + missing.specialRelaying.push(toChain); + } } } diff --git a/evm/ts/src/ntt.ts b/evm/ts/src/ntt.ts index 47af29766..09fd4835d 100644 --- a/evm/ts/src/ntt.ts +++ b/evm/ts/src/ntt.ts @@ -137,6 +137,17 @@ export class EvmNttWormholeTranceiver toChainId(destChain) ); } + + async *setIsSpecialRelayingEnabled(destChain: Chain, enabled: boolean) { + const tx = await this.transceiver.setIsSpecialRelayingEnabled.populateTransaction( + toChainId(destChain), + enabled + ); + yield this.manager.createUnsignedTx( + tx, + "WormholeTransceiver.setSpecialRelayingEnabled" + ); + } } export class EvmNtt