Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: WarpModule with update() IsmConfig #3678

Merged
merged 102 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
eb2172a
Saving initial work
ltyu Apr 29, 2024
8ac752b
draft push
paulbalaji Apr 30, 2024
3686051
Add read to WarpCrud, change totalSupply to use zod schema type, some…
ltyu Apr 30, 2024
2c74413
Derive WarpConfig from TokenRouter address (#3671)
ltyu Apr 29, 2024
fc4a8a4
Saving initial work
ltyu Apr 29, 2024
4da8778
Add read to WarpCrud, change totalSupply to use zod schema type, some…
ltyu Apr 30, 2024
0ccaa38
Fix unit tests. Incorporate some of Paul's Abstract CrudModule changes
ltyu Apr 30, 2024
3632eb8
fix conflicts
ltyu Apr 30, 2024
2c524cc
Re-add a few more overwritten merge lines
ltyu Apr 30, 2024
186a185
Add EvmERC20WarpCrudModule.create()
ltyu May 1, 2024
635ccf3
Add deploy given an Ism Object
ltyu May 1, 2024
10bd6cb
draft push
paulbalaji Apr 30, 2024
0378f8c
split deploy/update in EvmIsmCreator
paulbalaji May 2, 2024
e140813
Add update logic for Hook and ISM. This commit excludes working logic…
ltyu May 2, 2024
9b0a464
Fix conflicts
ltyu May 2, 2024
707967e
Fix conflicts
ltyu May 2, 2024
d40417f
Derive WarpConfig from TokenRouter address (#3671)
ltyu Apr 29, 2024
f32e5fc
Saving initial work
ltyu Apr 29, 2024
cd2e1a6
Derive WarpConfig from TokenRouter address (#3671)
ltyu Apr 29, 2024
062a00b
Saving initial work
ltyu Apr 29, 2024
76eb931
Add read to WarpCrud, change totalSupply to use zod schema type, some…
ltyu Apr 30, 2024
4e30f18
Fix unit tests. Incorporate some of Paul's Abstract CrudModule changes
ltyu Apr 30, 2024
d4cb141
Add read to WarpCrud, change totalSupply to use zod schema type, some…
ltyu Apr 30, 2024
c3ae3bf
Re-add a few more overwritten merge lines
ltyu Apr 30, 2024
fdc41f4
Add EvmERC20WarpCrudModule.create()
ltyu May 1, 2024
1efd295
Add deploy given an Ism Object
ltyu May 1, 2024
3d27f80
Add update logic for Hook and ISM. This commit excludes working logic…
ltyu May 2, 2024
d435b76
Ensure owners are configured correctly (#3677)
yorhodes Apr 30, 2024
8fcc2bc
Migrate SDK consts to Registry and use new registry utilities (#3615)
jmrossy May 1, 2024
80cc359
Avoid sinon import in exported lib files (#3685)
jmrossy May 1, 2024
965f8cd
feat: Modular Tx Submission – Create Transformer + Submitter + Builde…
nbayindirli May 1, 2024
3d439b3
export tx provider from sdk & remove safe util from infra (#3694)
nbayindirli May 2, 2024
c820d15
do not exit if @safe-global/protocol-kit/**/Multi_send.ts dne (#3696)
nbayindirli May 2, 2024
886b2b9
add defaultDescription to yargs --key option (#3697)
nbayindirli May 2, 2024
9e4c0d2
Fix conflicts
ltyu May 2, 2024
2b65365
Fix conflicts... again
ltyu May 3, 2024
9ac51d3
Fix conflicts
ltyu May 3, 2024
7be39b7
Merge branch 'main' into warpCrudModule
ltyu May 3, 2024
43fac78
Implement deployIsm(), clean up duplicate unit tests, add ismFactoryA…
ltyu May 6, 2024
71849ce
Update to use type DerivedTokenRouterConfig instead of base TokenRout…
ltyu May 6, 2024
5a2a289
Add changeset
ltyu May 6, 2024
d5b615d
Fix test name add comments
ltyu May 6, 2024
119e2e5
Merge branch 'main' into warpCrudModule
ltyu May 6, 2024
9d17eec
Fix conflicts
ltyu May 9, 2024
fc37f4e
Fix conflicts - moved additional logic in reader.ts into new EvmERC20…
ltyu May 13, 2024
988151e
Update according to PR comments
ltyu May 13, 2024
3bffa94
Updates according to comments, IsmConfig to always be an object inste…
ltyu May 14, 2024
88f5a41
Remove Hyperlane from name
ltyu May 14, 2024
3c64619
Use Promise.all, reduce extra read() calls
ltyu May 14, 2024
3b1e502
Update updateHook()
ltyu May 14, 2024
497111d
Add logic to encode tx instead of populateTransaction()
ltyu May 15, 2024
b6c2ba3
Add test4
ltyu May 15, 2024
0f2c953
Update tests to use chain, param
ltyu May 15, 2024
ab25db8
Update ProxyFactoryFactoriesSchema vals to be strings
ltyu May 15, 2024
2921096
nan ism module for cherry-picking
paulbalaji May 16, 2024
1a66022
Remove 'crud' from name. Update unit test to accomedate test4. Update…
ltyu May 16, 2024
fa8024a
Update AddressIsmConfig to CustomIsmConfig
ltyu May 16, 2024
d095c35
Update IsmConfig to use custom instead of address
ltyu May 16, 2024
67ec6b0
Merge branch 'cli-2.0' into warpCrudModule
ltyu May 16, 2024
72de4c5
Add Custom Type to DeployedIsmType
ltyu May 16, 2024
40344ac
Merge branch 'warpCrudModule' of https://github.com/hyperlane-xyz/hyp…
ltyu May 16, 2024
dddd0cf
Merge branch 'cli-2.0' into warpCrudModule
ltyu May 21, 2024
50d5d80
Update to fix bug deriving native and synthetic
ltyu May 21, 2024
2e34aaf
Rip out update logic
ltyu May 22, 2024
bd31efe
Update according to PR comments
ltyu May 23, 2024
76bc11e
Fix changeset file
ltyu May 24, 2024
26fb6d8
Add new changeset file
ltyu May 24, 2024
95b1945
Update typescript/sdk/src/token/EvmERC20WarpModule.ts
ltyu May 24, 2024
33957ea
Update typescript/sdk/src/token/EvmERC20WarpModule.ts
ltyu May 24, 2024
e99f375
Split out WarpModule and Reader tests
ltyu May 24, 2024
d07bf75
Fix changeset file
ltyu May 24, 2024
49cb85b
Merge branch 'warpCrudModule' of https://github.com/hyperlane-xyz/hyp…
ltyu May 24, 2024
0447429
Update changeset to remove create()
ltyu May 24, 2024
314e39b
Revert "Rip out update logic"
ltyu May 24, 2024
a141786
Clean up deploy.hardhat-test.ts
ltyu May 24, 2024
4b54a3d
Fix changeset file
ltyu May 24, 2024
b0b2f41
Update changeset to remove create()
ltyu May 24, 2024
7ac6d60
Revert "Rip out update logic"
ltyu May 24, 2024
911da47
Clean up deploy.hardhat-test.ts
ltyu May 24, 2024
f88e2c6
Fix conflicts
ltyu May 24, 2024
d19e03f
Fix changeset file
ltyu May 24, 2024
e820cfd
Update changeset to remove create()
ltyu May 24, 2024
337bc25
Revert "Rip out update logic"
ltyu May 24, 2024
4232edf
fix conflicts
ltyu May 24, 2024
a6b3945
Fix conflicts
ltyu Jun 12, 2024
1387247
Add ismFactoryAddress. Update updateIsm logic, tests
ltyu Jun 12, 2024
bf8af0e
Add test for same Ism. Update to use configDeepEquals
ltyu Jun 12, 2024
83e6ce5
Update test
ltyu Jun 12, 2024
6a904cd
Remove promise all
ltyu Jun 12, 2024
fedfb02
Reorder actual and expected. add .parse
ltyu Jun 18, 2024
bee56ad
Update to remove promise.all
ltyu Jun 28, 2024
0aa48d3
Rename variables
ltyu Jun 28, 2024
5cf33a3
Update changeset
ltyu Jun 28, 2024
ffb6a55
Remove unused hook
ltyu Jun 28, 2024
1f73afc
Merge branch 'main' of https://github.com/hyperlane-xyz/hyperlane-mon…
ltyu Jul 1, 2024
a1f58f9
Remove unused prop
ltyu Jul 1, 2024
02738cb
Remove 'protected' from ismModule constructor. Add unit test
ltyu Jul 2, 2024
f5b0443
Add logic to WarpModule.update to use IsmModule.update
ltyu Jul 2, 2024
ef1d01a
Remove if statements
ltyu Jul 2, 2024
a5c3f58
Rename fn
ltyu Jul 2, 2024
2b5e96c
Update comment
ltyu Jul 2, 2024
724773f
Paul's PR comments
ltyu Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smart-dancers-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': minor
---

Add EvmWarpModule with update() for ISM
8 changes: 8 additions & 0 deletions typescript/sdk/src/deploy/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ export const OwnerSchema = z.string();
export const OwnableConfigSchema = z.object({
owner: OwnerSchema,
});

export const ProxyFactoryFactoriesSchema = z.object({
staticMerkleRootMultisigIsmFactory: z.string(),
staticMessageIdMultisigIsmFactory: z.string(),
staticAggregationIsmFactory: z.string(),
staticAggregationHookFactory: z.string(),
domainRoutingIsmFactory: z.string(),
});
28 changes: 28 additions & 0 deletions typescript/sdk/src/ism/EvmIsmModule.hardhat-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,34 @@ describe('EvmIsmModule', async () => {
expect(eqAddress(initialIsmAddress, ism.serialize().deployedIsm)).to.be
.true;
});

it(`update threshold in an existing ${type} with Module creating using constructor`, async () => {
// create a an initial ISM
const { initialIsmAddress } = await createIsm(exampleRoutingConfig);

// update the threshold for a domain
(
exampleRoutingConfig.domains[TestChainName.test2] as MultisigIsmConfig
).threshold = 2;

// create a new IsmModule using it's constructor. Set it's deployedIsm address to the initialIsmAddr
const ism = new EvmIsmModule(multiProvider, {
chain,
config: exampleRoutingConfig,
addresses: {
...factoryAddresses,
mailbox: mailboxAddress,
deployedIsm: initialIsmAddress,
},
});

// expect 1 tx to update threshold for test2 domain
await expectTxsAndUpdate(ism, exampleRoutingConfig, 1);

// expect the ISM address to be the same
expect(eqAddress(initialIsmAddress, ism.serialize().deployedIsm)).to.be
.true;
});
}

it(`redeploy same config if the mailbox address changes for defaultFallbackRoutingIsm`, async () => {
Expand Down
2 changes: 1 addition & 1 deletion typescript/sdk/src/ism/EvmIsmModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class EvmIsmModule extends HyperlaneModule<
// return a number, and EVM the domainId and chainId are the same.
public readonly domainId: Domain;

protected constructor(
constructor(
protected readonly multiProvider: MultiProvider,
params: HyperlaneModuleParams<
IsmConfig,
Expand Down
2 changes: 2 additions & 0 deletions typescript/sdk/src/router/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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';
Expand All @@ -9,6 +10,7 @@ export const MailboxClientConfigSchema = OwnableSchema.extend({
mailbox: ZHash,
hook: HookConfigSchema.optional(),
interchainSecurityModule: IsmConfigSchema.optional(),
ismFactoryAddresses: ProxyFactoryFactoriesSchema.optional(),
});

export const ForeignDeploymentConfigSchema = z.object({
Expand Down
163 changes: 163 additions & 0 deletions typescript/sdk/src/token/EvmERC20WarpModule.hardhat-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ import {
Mailbox__factory,
} from '@hyperlane-xyz/core';
import {
EvmIsmModule,
HyperlaneAddresses,
HyperlaneContractsMap,
IsmConfig,
IsmType,
RouterConfig,
TestChainName,
serializeContracts,
} from '@hyperlane-xyz/sdk';
import { normalizeConfig } from '@hyperlane-xyz/utils';

import { TestCoreApp } from '../core/TestCoreApp.js';
import { TestCoreDeployer } from '../core/TestCoreDeployer.js';
import { HyperlaneProxyFactoryDeployer } from '../deploy/HyperlaneProxyFactoryDeployer.js';
import { ProxyFactoryFactories } from '../deploy/contracts.js';
import { HyperlaneIsmFactory } from '../ism/HyperlaneIsmFactory.js';
import { MultiProvider } from '../providers/MultiProvider.js';
import { AnnotatedEV5Transaction } from '../providers/ProviderType.js';
import { randomAddress } from '../test/testUtils.js';
import { ChainMap } from '../types.js';

import { EvmERC20WarpModule } from './EvmERC20WarpModule.js';
Expand All @@ -39,8 +47,10 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
const chain = TestChainName.test4;
let mailbox: Mailbox;
let hookAddress: string;
let ismAddress: string;
let ismFactory: HyperlaneIsmFactory;
let factories: HyperlaneContractsMap<ProxyFactoryFactories>;
let ismFactoryAddresses: HyperlaneAddresses<ProxyFactoryFactories>;
let erc20Factory: ERC20Test__factory;
let token: ERC20Test;
let signer: SignerWithAddress;
Expand All @@ -58,13 +68,20 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
expect(await deployedToken.owner()).to.equal(signer.address);
}

async function sendTxs(txs: AnnotatedEV5Transaction[]) {
for (const tx of txs) {
await multiProvider.sendTransaction(chain, tx);
}
}
paulbalaji marked this conversation as resolved.
Show resolved Hide resolved

before(async () => {
[signer] = await hre.ethers.getSigners();
multiProvider = MultiProvider.createTestMultiProvider({ signer });
const ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider);
factories = await ismFactoryDeployer.deploy(
multiProvider.mapKnownChains(() => ({})),
);
ismFactoryAddresses = serializeContracts(factories[chain]);
ismFactory = new HyperlaneIsmFactory(factories, multiProvider);
coreApp = await new TestCoreDeployer(multiProvider, ismFactory).deployApp();
routerConfigMap = coreApp.getRouterConfig(signer.address);
Expand All @@ -81,6 +98,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => {

mailbox = Mailbox__factory.connect(baseConfig.mailbox, signer);
hookAddress = await mailbox.defaultHook();
ismAddress = await mailbox.defaultIsm();
});

it('should create with a collateral config', async () => {
Expand Down Expand Up @@ -209,4 +227,149 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
);
await validateCoreValues(nativeContract);
});

describe('Update Ism', async () => {
const ismConfigToUpdate: IsmConfig[] = [
{
type: IsmType.TRUSTED_RELAYER,
relayer: randomAddress(),
},
{
type: IsmType.FALLBACK_ROUTING,
owner: randomAddress(),
domains: {},
},
{
type: IsmType.PAUSABLE,
owner: randomAddress(),
paused: false,
},
];
it('should deploy and set a new Ism', async () => {
const config = {
...baseConfig,
type: TokenType.native,
hook: hookAddress,
interchainSecurityModule: ismAddress,
} as TokenRouterConfig;

// Deploy using WarpModule
const evmERC20WarpModule = await EvmERC20WarpModule.create({
chain,
config,
multiProvider,
});
const actualConfig = await evmERC20WarpModule.read();

for (const interchainSecurityModule of ismConfigToUpdate) {
const expectedConfig: TokenRouterConfig = {
...actualConfig,
ismFactoryAddresses,
interchainSecurityModule,
};
await sendTxs(await evmERC20WarpModule.update(expectedConfig));
const updatedConfig = normalizeConfig(
(await evmERC20WarpModule.read()).interchainSecurityModule,
);

expect(updatedConfig).to.deep.equal(interchainSecurityModule);
}
});

it('should not deploy and set a new Ism if the config is the same', async () => {
const config = {
...baseConfig,
type: TokenType.native,
hook: hookAddress,
interchainSecurityModule: ismAddress,
} as TokenRouterConfig;

// Deploy using WarpModule
const evmERC20WarpModule = await EvmERC20WarpModule.create({
chain,
config,
multiProvider,
});
const actualConfig = await evmERC20WarpModule.read();

const owner = randomAddress();
const interchainSecurityModule: IsmConfig = {
type: IsmType.PAUSABLE,
owner,
paused: false,
};
const expectedConfig: TokenRouterConfig = {
...actualConfig,
ismFactoryAddresses,
interchainSecurityModule,
};

await sendTxs(await evmERC20WarpModule.update(expectedConfig));

const updatedConfig = normalizeConfig(
(await evmERC20WarpModule.read()).interchainSecurityModule,
);

expect(updatedConfig).to.deep.equal(interchainSecurityModule);

// Deploy with the same config
const txs = await evmERC20WarpModule.update(expectedConfig);

expect(txs.length).to.equal(0);
});

it('should update a mutable Ism', async () => {
const ismConfig: IsmConfig = {
type: IsmType.ROUTING,
owner: signer.address,
domains: {
'1': ismAddress,
},
};
const ism = await EvmIsmModule.create({
chain,
multiProvider,
config: ismConfig,
proxyFactoryFactories: ismFactoryAddresses,
mailbox: mailbox.address,
});

const { deployedIsm } = ism.serialize();
// Deploy using WarpModule
const config = {
...baseConfig,
type: TokenType.native,
hook: hookAddress,
interchainSecurityModule: deployedIsm,
} as TokenRouterConfig;

const evmERC20WarpModule = await EvmERC20WarpModule.create({
chain,
config,
multiProvider,
});
const actualConfig = await evmERC20WarpModule.read();
const expectedConfig: TokenRouterConfig = {
...actualConfig,
ismFactoryAddresses,
interchainSecurityModule: {
type: IsmType.ROUTING,
owner: randomAddress(),
domains: {
'2': ismAddress,
},
},
};

await sendTxs(await evmERC20WarpModule.update(expectedConfig));

const updatedConfig = normalizeConfig(
(await evmERC20WarpModule.read()).interchainSecurityModule,
);

expect(updatedConfig).to.deep.equal(
expectedConfig.interchainSecurityModule,
);
});
});
});
Loading
Loading