chore: Remove ismFactoryAddresses from warpConfig (#4888)

### Description
Remove `ismFactoryAddresses`, which was added to the WarpConfig to be
used in `WarpModule`, and passed into `IsmModule`.

This is tech debt that was added before passing in `addresses` via the
constructor as done here:
111e241532/typescript/sdk/src/ism/EvmIsmModule.ts (L65)


### Backward compatibility
Yes

### Testing
Unit Tests
main
Lee 16 hours ago committed by GitHub
parent 111e241532
commit 81ab4332ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      .changeset/empty-dodos-clap.md
  2. 16
      typescript/cli/src/deploy/warp.ts
  3. 2
      typescript/sdk/src/router/schemas.ts
  4. 19
      typescript/sdk/src/token/EvmERC20WarpModule.hardhat-test.ts
  5. 85
      typescript/sdk/src/token/EvmERC20WarpModule.ts

@ -0,0 +1,6 @@
---
'@hyperlane-xyz/cli': minor
'@hyperlane-xyz/sdk': minor
---
Remove ismFactoryAddresses from warpConfig

@ -534,7 +534,8 @@ async function updateExistingWarpRoute(
) {
logBlue('Updating deployed Warp Routes');
const { multiProvider, registry } = params.context;
const addresses = await registry.getAddresses();
const registryAddresses =
(await registry.getAddresses()) as ChainMap<ProxyFactoryFactoriesAddresses>;
const contractVerifier = new ContractVerifier(
multiProvider,
apiKeys,
@ -553,15 +554,13 @@ async function updateExistingWarpRoute(
`Missing artifacts for ${chain}. Probably new deployment. Skipping update...`,
);
config.ismFactoryAddresses = addresses[
chain
] as ProxyFactoryFactoriesAddresses;
const evmERC20WarpModule = new EvmERC20WarpModule(
multiProvider,
{
config,
chain,
addresses: {
...registryAddresses[chain],
deployedTokenRoute: deployedConfig.addressOrDenom!,
},
},
@ -646,7 +645,9 @@ async function enrollRemoteRouters(
deployedContractsMap: HyperlaneContractsMap<HypERC20Factories>,
): Promise<AnnotatedEV5Transaction[]> {
logBlue(`Enrolling deployed routers with each other...`);
const { multiProvider } = params.context;
const { multiProvider, registry } = params.context;
const registryAddresses =
(await registry.getAddresses()) as ChainMap<ProxyFactoryFactoriesAddresses>;
const deployedRoutersAddresses: ChainMap<Address> = objMap(
deployedContractsMap,
(_, contracts) => getRouter(contracts).address,
@ -674,7 +675,10 @@ async function enrollRemoteRouters(
const evmERC20WarpModule = new EvmERC20WarpModule(multiProvider, {
config: mutatedWarpRouteConfig,
chain,
addresses: { deployedTokenRoute: router.address },
addresses: {
...registryAddresses[chain],
deployedTokenRoute: router.address,
},
});
const otherChains = multiProvider

@ -1,6 +1,5 @@
import { z } from 'zod';
import { ProxyFactoryFactoriesSchema } from '../deploy/schemas.js';
import { HookConfigSchema } from '../hook/schemas.js';
import { IsmConfigSchema } from '../ism/schemas.js';
import { ZHash } from '../metadata/customZodTypes.js';
@ -10,7 +9,6 @@ export const MailboxClientConfigSchema = OwnableSchema.extend({
mailbox: ZHash,
hook: HookConfigSchema.optional(),
interchainSecurityModule: IsmConfigSchema.optional(),
ismFactoryAddresses: ProxyFactoryFactoriesSchema.optional(),
});
export const ForeignDeploymentConfigSchema = z.object({

@ -123,6 +123,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
// Let's derive it's onchain token type
@ -151,6 +152,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
// Let's derive it's onchain token type
@ -187,6 +189,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
// Let's derive it's onchain token type
@ -219,6 +222,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
// Let's derive it's onchain token type
@ -249,6 +253,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const { remoteRouters } = await evmERC20WarpModule.read();
expect(Object.keys(remoteRouters!).length).to.equal(numOfRouters);
@ -285,13 +290,14 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const actualConfig = await evmERC20WarpModule.read();
for (const interchainSecurityModule of ismConfigToUpdate) {
const expectedConfig: TokenRouterConfig = {
...actualConfig,
ismFactoryAddresses,
interchainSecurityModule,
};
await sendTxs(await evmERC20WarpModule.update(expectedConfig));
@ -316,6 +322,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const actualConfig = await evmERC20WarpModule.read();
@ -327,7 +334,6 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
};
const expectedConfig: TokenRouterConfig = {
...actualConfig,
ismFactoryAddresses,
interchainSecurityModule,
};
@ -374,11 +380,11 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
chain,
config,
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const actualConfig = await evmERC20WarpModule.read();
const expectedConfig: TokenRouterConfig = {
...actualConfig,
ismFactoryAddresses,
interchainSecurityModule: {
type: IsmType.ROUTING,
owner: randomAddress(),
@ -415,6 +421,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
interchainSecurityModule: ismAddress,
},
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const numOfRouters = Math.floor(Math.random() * 10);
await sendTxs(
@ -446,6 +453,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
interchainSecurityModule: ismAddress,
},
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const remoteRouters = randomRemoteRouters(1);
await sendTxs(
@ -498,6 +506,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
interchainSecurityModule: ismAddress,
},
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const currentConfig = await evmERC20WarpModule.read();
@ -527,7 +536,6 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
...baseConfig,
type: TokenType.native,
hook: hookAddress,
ismFactoryAddresses,
};
const owner = signer.address.toLowerCase();
@ -538,6 +546,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
interchainSecurityModule: ismAddress,
},
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
const currentConfig = await evmERC20WarpModule.read();
@ -571,7 +580,6 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
...baseConfig,
type: TokenType.native,
hook: hookAddress,
ismFactoryAddresses,
remoteRouters: {
[domain]: randomAddress(),
},
@ -584,6 +592,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
...config,
},
multiProvider,
proxyFactoryFactories: ismFactoryAddresses,
});
await sendTxs(
await evmERC20WarpModule.update({

@ -6,7 +6,11 @@ import {
TokenRouter__factory,
} from '@hyperlane-xyz/core';
import { buildArtifact as coreBuildArtifact } from '@hyperlane-xyz/core/buildArtifact.js';
import { ContractVerifier, ExplorerLicenseType } from '@hyperlane-xyz/sdk';
import {
ContractVerifier,
ExplorerLicenseType,
HyperlaneAddresses,
} from '@hyperlane-xyz/sdk';
import {
Address,
Domain,
@ -25,6 +29,7 @@ import {
HyperlaneModule,
HyperlaneModuleParams,
} from '../core/AbstractHyperlaneModule.js';
import { ProxyFactoryFactories } from '../deploy/contracts.js';
import { proxyAdminUpdateTxs } from '../deploy/proxy.js';
import { EvmIsmModule } from '../ism/EvmIsmModule.js';
import { DerivedIsmConfig } from '../ism/EvmIsmReader.js';
@ -40,7 +45,7 @@ import { TokenRouterConfig, TokenRouterConfigSchema } from './schemas.js';
export class EvmERC20WarpModule extends HyperlaneModule<
ProtocolType.Ethereum,
TokenRouterConfig,
{
HyperlaneAddresses<ProxyFactoryFactories> & {
deployedTokenRoute: Address;
}
> {
@ -56,7 +61,7 @@ export class EvmERC20WarpModule extends HyperlaneModule<
protected readonly multiProvider: MultiProvider,
args: HyperlaneModuleParams<
TokenRouterConfig,
{
HyperlaneAddresses<ProxyFactoryFactories> & {
deployedTokenRoute: Address;
}
>,
@ -242,36 +247,34 @@ export class EvmERC20WarpModule extends HyperlaneModule<
return [];
}
if (expectedConfig.ismFactoryAddresses) {
const actualDeployedIsm = (
actualConfig.interchainSecurityModule as DerivedIsmConfig
).address;
// Try to update (may also deploy) Ism with the expected config
const {
deployedIsm: expectedDeployedIsm,
updateTransactions: ismUpdateTransactions,
} = await this.deployOrUpdateIsm(actualConfig, expectedConfig);
// If an ISM is updated in-place, push the update txs
updateTransactions.push(...ismUpdateTransactions);
// If a new ISM is deployed, push the setInterchainSecurityModule tx
if (actualDeployedIsm !== expectedDeployedIsm) {
const contractToUpdate = MailboxClient__factory.connect(
this.args.addresses.deployedTokenRoute,
this.multiProvider.getProvider(this.domainId),
);
updateTransactions.push({
chainId: this.chainId,
annotation: `Setting ISM for Warp Route to ${expectedDeployedIsm}`,
to: contractToUpdate.address,
data: contractToUpdate.interface.encodeFunctionData(
'setInterchainSecurityModule',
[expectedDeployedIsm],
),
});
}
const actualDeployedIsm = (
actualConfig.interchainSecurityModule as DerivedIsmConfig
).address;
// Try to update (may also deploy) Ism with the expected config
const {
deployedIsm: expectedDeployedIsm,
updateTransactions: ismUpdateTransactions,
} = await this.deployOrUpdateIsm(actualConfig, expectedConfig);
// If an ISM is updated in-place, push the update txs
updateTransactions.push(...ismUpdateTransactions);
// If a new ISM is deployed, push the setInterchainSecurityModule tx
if (actualDeployedIsm !== expectedDeployedIsm) {
const contractToUpdate = MailboxClient__factory.connect(
this.args.addresses.deployedTokenRoute,
this.multiProvider.getProvider(this.domainId),
);
updateTransactions.push({
chainId: this.chainId,
annotation: `Setting ISM for Warp Route to ${expectedDeployedIsm}`,
to: contractToUpdate.address,
data: contractToUpdate.interface.encodeFunctionData(
'setInterchainSecurityModule',
[expectedDeployedIsm],
),
});
}
return updateTransactions;
@ -313,10 +316,6 @@ export class EvmERC20WarpModule extends HyperlaneModule<
expectedConfig.interchainSecurityModule,
'Ism not derived correctly',
);
assert(
expectedConfig.ismFactoryAddresses,
'Ism Factories addresses not provided',
);
const ismModule = new EvmIsmModule(
this.multiProvider,
@ -324,7 +323,7 @@ export class EvmERC20WarpModule extends HyperlaneModule<
chain: this.args.chain,
config: expectedConfig.interchainSecurityModule,
addresses: {
...expectedConfig.ismFactoryAddresses,
...this.args.addresses,
mailbox: expectedConfig.mailbox,
deployedIsm: (
actualConfig.interchainSecurityModule as DerivedIsmConfig
@ -357,8 +356,15 @@ export class EvmERC20WarpModule extends HyperlaneModule<
config: TokenRouterConfig;
multiProvider: MultiProvider;
contractVerifier?: ContractVerifier;
proxyFactoryFactories: HyperlaneAddresses<ProxyFactoryFactories>;
}): Promise<EvmERC20WarpModule> {
const { chain, config, multiProvider, contractVerifier } = params;
const {
chain,
config,
multiProvider,
contractVerifier,
proxyFactoryFactories,
} = params;
const chainName = multiProvider.getChainName(chain);
const deployer = new HypERC20Deployer(multiProvider);
const deployedContracts = await deployer.deployContracts(chainName, config);
@ -367,6 +373,7 @@ export class EvmERC20WarpModule extends HyperlaneModule<
multiProvider,
{
addresses: {
...proxyFactoryFactories,
deployedTokenRoute: deployedContracts[config.type].address,
},
chain,

Loading…
Cancel
Save