From a8e35bedbdfb30d7c9c323252b8abdf763e8c2f9 Mon Sep 17 00:00:00 2001 From: Yorke Rhodes Date: Thu, 27 Jul 2023 16:38:51 -0400 Subject: [PATCH] Migrate from config object to address map --- .../config/environments/mainnet2/core.ts | 31 ++++++++++++------- .../sdk/src/core/HyperlaneCoreDeployer.ts | 8 +++-- typescript/sdk/src/core/types.ts | 2 +- typescript/sdk/src/ism/HyperlaneIsmFactory.ts | 14 +++++++-- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/typescript/infra/config/environments/mainnet2/core.ts b/typescript/infra/config/environments/mainnet2/core.ts index f141f2546f..e545f90cb7 100644 --- a/typescript/infra/config/environments/mainnet2/core.ts +++ b/typescript/infra/config/environments/mainnet2/core.ts @@ -1,21 +1,30 @@ -import { - AggregationIsmConfig, - ChainMap, - CoreConfig, - objMap, -} from '@hyperlane-xyz/sdk'; +import { ChainMap, Chains, CoreConfig, objMap } from '@hyperlane-xyz/sdk'; import { aggregationIsm } from '../../aggregationIsm'; import { Contexts } from '../../contexts'; import { owners } from './owners'; +const aggregationIsmAddresses: Record = { + [Chains.arbitrum]: '0x7995D00bdDb146334d6568b627bcd2a7DdA3B005', + [Chains.avalanche]: '0xF6bF41939ebA2363A6e311E886Ed4a5ab3dc1F5D', + [Chains.bsc]: '0x294F19d5fe29646f8E2cA4A71b6B18b78db10F9f', + [Chains.celo]: '0x656bF500F0E2EE55F26dF3bc69b44c6eA84dd065', + [Chains.ethereum]: '0xe39eA548F36d1c3DA9b871Badd11345f836a290A', + [Chains.gnosis]: '0xD0Ec4de35069520CD17522281D36DD299525d85f', + [Chains.moonbeam]: '0x04100049AC8e279C85E895d48aab1E188152e939', + [Chains.optimism]: '0x99663d142576204284b91e96d39771db94eD5188', + [Chains.polygon]: '0x0673cc1cc5eb80816E0d0E2dA5FE10053Da97943', +}; + export const core: ChainMap = objMap(owners, (local, owner) => { - const defaultIsm: AggregationIsmConfig = aggregationIsm( - 'mainnet2', - local, - Contexts.Hyperlane, - ); + const defaultIsm = aggregationIsmAddresses[local]; + + // const defaultIsm: AggregationIsmConfig = aggregationIsm( + // 'mainnet2', + // local, + // Contexts.Hyperlane, + // ); if (local === 'arbitrum') { return { diff --git a/typescript/sdk/src/core/HyperlaneCoreDeployer.ts b/typescript/sdk/src/core/HyperlaneCoreDeployer.ts index 8caa437a37..b5e75ed2fe 100644 --- a/typescript/sdk/src/core/HyperlaneCoreDeployer.ts +++ b/typescript/sdk/src/core/HyperlaneCoreDeployer.ts @@ -37,7 +37,7 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer< async deployMailbox( chain: ChainName, - ismConfig: IsmConfig, + ismConfig: IsmConfig | types.Address, proxyAdmin: types.Address, owner: types.Address, ): Promise { @@ -53,7 +53,11 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer< return cachedMailbox; } - const defaultIsmAddress = await this.deployIsm(chain, ismConfig); + const defaultIsmAddress = + typeof ismConfig === 'string' + ? ismConfig + : await this.deployIsm(chain, ismConfig); + const domain = this.multiProvider.getDomainId(chain); return this.deployProxiedContract( chain, diff --git a/typescript/sdk/src/core/types.ts b/typescript/sdk/src/core/types.ts index 07c8618df6..0c7a90d1d7 100644 --- a/typescript/sdk/src/core/types.ts +++ b/typescript/sdk/src/core/types.ts @@ -7,7 +7,7 @@ import { IsmConfig } from '../ism/types'; import { ChainName } from '../types'; export type CoreConfig = { - defaultIsm: IsmConfig; + defaultIsm: IsmConfig | types.Address; owner: types.Address; remove?: boolean; upgrade?: UpgradeConfig; diff --git a/typescript/sdk/src/ism/HyperlaneIsmFactory.ts b/typescript/sdk/src/ism/HyperlaneIsmFactory.ts index 5a0d77befc..329a18d46e 100644 --- a/typescript/sdk/src/ism/HyperlaneIsmFactory.ts +++ b/typescript/sdk/src/ism/HyperlaneIsmFactory.ts @@ -356,11 +356,15 @@ export async function moduleCanCertainlyVerify( export async function moduleMatchesConfig( chain: ChainName, moduleAddress: types.Address, - config: IsmConfig, + config: IsmConfig | types.Address, multiProvider: MultiProvider, contracts: HyperlaneContracts, origin?: ChainName, ): Promise { + if (typeof config === 'string') { + return utils.eqAddress(moduleAddress, config); + } + const provider = multiProvider.getProvider(chain); const module = IInterchainSecurityModule__factory.connect( moduleAddress, @@ -483,8 +487,14 @@ export async function moduleMatchesConfig( export function collectValidators( origin: ChainName, - config: IsmConfig, + config: IsmConfig | types.Address, ): Set { + // TODO: support address configurations in collectValidators + if (typeof config === 'string') { + console.warn('Validators not fetched from address ISM config'); + return new Set([]); + } + let validators: string[] = []; if ( config.type === ModuleType.MERKLE_ROOT_MULTISIG ||