From bae1979245fe52e0ca0c64852ee8599bd9900651 Mon Sep 17 00:00:00 2001 From: ljankovic-txfusion Date: Wed, 29 Jan 2025 15:17:15 +0100 Subject: [PATCH] feat: support ZKSync-specific ISM configuration --- typescript/cli/src/config/ism.ts | 10 +++--- typescript/cli/src/config/warp.ts | 57 +++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/typescript/cli/src/config/ism.ts b/typescript/cli/src/config/ism.ts index 81440e96eb..8a003950d1 100644 --- a/typescript/cli/src/config/ism.ts +++ b/typescript/cli/src/config/ism.ts @@ -10,6 +10,7 @@ import { MultisigIsmConfig, MultisigIsmConfigSchema, TrustedRelayerIsmConfig, + isStaticIsm, } from '@hyperlane-xyz/sdk'; import { CommandContext } from '../context/types.js'; @@ -87,6 +88,7 @@ const ISM_TYPE_DESCRIPTIONS: Record = { export async function createAdvancedIsmConfig( context: CommandContext, + excludeStaticIsms: boolean = false, ): Promise { logBlue('Creating a new advanced ISM config'); logBoldUnderlinedRed('WARNING: USE AT YOUR RISK.'); @@ -96,12 +98,12 @@ export async function createAdvancedIsmConfig( const moduleType = await select({ message: 'Select ISM type', - choices: Object.entries(ISM_TYPE_DESCRIPTIONS).map( - ([value, description]) => ({ + choices: Object.entries(ISM_TYPE_DESCRIPTIONS) + .filter(([value]) => !excludeStaticIsms || !isStaticIsm(value as IsmType)) + .map(([value, description]) => ({ value, description, - }), - ), + })), pageSize: 10, }); diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index f31069e091..f430748a13 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -3,6 +3,7 @@ import { stringify as yamlStringify } from 'yaml'; import { ChainMap, + ChainTechnicalStack, DeployedOwnableConfig, IsmConfig, IsmType, @@ -158,6 +159,10 @@ export async function createWarpRouteDeployConfig({ owner, ); + const excludeStaticIsms = + context.multiProvider.getChainMetadata(chain).technicalStack === + ChainTechnicalStack.ZkSync; + /** * The logic from the cli is as follows: * --advanced flag is provided: the user will have to build their own configuration using the available ISM types @@ -168,15 +173,24 @@ export async function createWarpRouteDeployConfig({ */ let interchainSecurityModule: IsmConfig; if (advanced) { - interchainSecurityModule = await createAdvancedIsmConfig(context); + interchainSecurityModule = await createAdvancedIsmConfig( + context, + excludeStaticIsms, + ); } else if (context.skipConfirmation) { - interchainSecurityModule = createDefaultWarpIsmConfig(owner); + interchainSecurityModule = createDefaultWarpIsmConfig( + owner, + excludeStaticIsms, + ); } else if ( await confirm({ message: 'Do you want to use a trusted ISM for warp route?', }) ) { - interchainSecurityModule = createDefaultWarpIsmConfig(owner); + interchainSecurityModule = createDefaultWarpIsmConfig( + owner, + excludeStaticIsms, + ); } else { interchainSecurityModule = createFallbackRoutingConfig(owner); } @@ -291,23 +305,36 @@ export function readWarpCoreConfig(filePath: string): WarpCoreConfig { } /** - * Creates a default configuration for an ISM with a TRUSTED_RELAYER and FALLBACK_ROUTING. + * Creates a default configuration for an ISM. * - * Properties relayer and owner are both set as input owner. + * When excludeStaticIsms is false (default): + * - Creates an AGGREGATION ISM with TRUSTED_RELAYER and FALLBACK_ROUTING modules + * - Properties relayer and owner are both set as input owner * - * @param owner - The address of the owner of the ISM. - * @returns The default Aggregation ISM configuration. + * When excludeStaticIsms is true: + * - Creates only a TRUSTED_RELAYER ISM (as static ISMs like AGGREGATION are not supported) + * - Properties relayer is set as input owner + * + * @param owner - The address of the owner of the ISM + * @param excludeStaticIsms - Whether to exclude static ISM types (default: false) + * @returns The ISM configuration */ -function createDefaultWarpIsmConfig(owner: Address): IsmConfig { +function createDefaultWarpIsmConfig( + owner: Address, + excludeStaticIsms: boolean = false, +): IsmConfig { + const trustedRelayerModule: IsmConfig = { + type: IsmType.TRUSTED_RELAYER, + relayer: owner, + }; + + if (excludeStaticIsms) { + return trustedRelayerModule; + } + return { type: IsmType.AGGREGATION, - modules: [ - { - type: IsmType.TRUSTED_RELAYER, - relayer: owner, - }, - createFallbackRoutingConfig(owner), - ], + modules: [trustedRelayerModule, createFallbackRoutingConfig(owner)], threshold: 1, }; }