Skip to content

Commit

Permalink
fix: warp configure infinite loop (#3929)
Browse files Browse the repository at this point in the history
### Description
- Fixes `hyperlane warp configure` ism selection looping by configuring
a default Aggregation ISM with trusted relayer and fallback routing

### Related issues

- Fixes #3924 


### Backward compatibility
Yes

### Testing

Manual
  • Loading branch information
ltyu authored Jun 10, 2024
1 parent 3283eef commit 4040db7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-geckos-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': minor
---

Fix createDefaultWarpIsmConfig to default to trusted relayer and fallback routing without prompts
33 changes: 21 additions & 12 deletions typescript/cli/src/config/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
WarpRouteDeployConfig,
WarpRouteDeployConfigSchema,
} from '@hyperlane-xyz/sdk';
import { assert, objMap, promiseObjAll } from '@hyperlane-xyz/utils';
import { Address, assert, objMap, promiseObjAll } from '@hyperlane-xyz/utils';

import { CommandContext } from '../context/types.js';
import { errorRed, log, logBlue, logGreen } from '../logger.js';
Expand All @@ -26,11 +26,7 @@ import {
writeYamlOrJson,
} from '../utils/files.js';

import {
createAdvancedIsmConfig,
createRoutingConfig,
createTrustedRelayerConfig,
} from './ism.js';
import { createAdvancedIsmConfig } from './ism.js';

const TYPE_DESCRIPTIONS: Record<TokenType, string> = {
[TokenType.synthetic]: 'A new ERC20 with remote transfer functionality',
Expand Down Expand Up @@ -151,7 +147,7 @@ export async function createWarpRouteDeployConfig({

const interchainSecurityModule = advanced
? await createAdvancedIsmConfig(context)
: await createDefaultWarpIsmConfig(context);
: createDefaultWarpIsmConfig(owner);

switch (type) {
case TokenType.collateral:
Expand Down Expand Up @@ -205,14 +201,27 @@ export function readWarpRouteConfig(filePath: string): WarpCoreConfig {
return WarpCoreConfigSchema.parse(config);
}

async function createDefaultWarpIsmConfig(
context: CommandContext,
): Promise<IsmConfig> {
/**
* Creates a default configuration for an ISM with a TRUSTED_RELAYER and FALLBACK_ROUTING.
*
* 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.
*/
function createDefaultWarpIsmConfig(owner: Address): IsmConfig {
return {
type: IsmType.AGGREGATION,
modules: [
await createTrustedRelayerConfig(context),
await createRoutingConfig(context, IsmType.FALLBACK_ROUTING),
{
type: IsmType.TRUSTED_RELAYER,
relayer: owner,
},
{
type: IsmType.FALLBACK_ROUTING,
domains: {},
owner,
},
],
threshold: 1,
};
Expand Down

0 comments on commit 4040db7

Please sign in to comment.