Skip to content

Commit

Permalink
test: Neutron Mainnet contract migration (#131)
Browse files Browse the repository at this point in the history
* support cradle & signer per network

* temp fix error

* remove & ignore install-state

* deps

* it's combined endpoint

* wip

* forked context

* wip

* remove

* query state comparison

* detailed queries

* refactor

* add lodash

* snapshot and compare

* migrator

* add result

* rename dir

* add cradle example

* add README

* remove context

* Add state diff test to migration testing scripts (#134)

add state diff test to migration testing scripts

* fmt

* lint: include ./tests to prettier script

---------

Co-authored-by: Udit Gulati <[email protected]>
  • Loading branch information
byeongsu-hong and udit-gulati authored Jun 28, 2024
1 parent eb791b5 commit 5f60971
Show file tree
Hide file tree
Showing 48 changed files with 4,167 additions and 235 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ context/*.config.json
tmp/
dist/
node_modules/
wasm_codes.zip
wasm_codes.zip

.yarn/install-state.gz
Binary file removed .yarn/install-state.gz
Binary file not shown.
24 changes: 17 additions & 7 deletions config.example.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
networks:
- id: 'localwasmd'
hrp: 'uwasm'
signer: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
endpoint:
rpc: 'http://localhost:26657'
rest: 'http://localhost:1317'
Expand All @@ -12,6 +13,7 @@ networks:

- id: 'localosmosis'
hrp: 'osmo'
signer: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
endpoint:
rpc: 'http://localhost:26657'
rest: 'http://localhost:1317'
Expand All @@ -23,6 +25,7 @@ networks:

- id: 'localneutron'
hrp: 'neutron'
signer: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
endpoint:
rpc: 'http://localhost:26657'
rest: 'http://localhost:1317'
Expand All @@ -32,23 +35,30 @@ networks:
denom: 'untrn'
domain: 1302

- id: 'cradle-neutron-chain'
hrp: 'neutron'
signer: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
is_cradle: true
cradle_session_id: '{{cradle_session_id}}'
gas:
price: 0.025
denom: untrn
domain: 1853125230

# Networks that already have hyperlane deployments
# but might require new warp route connections
evm_networks:
- name: 'mantasepolia'
signer: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
chain_id: 3441006
rpc_endpoint: "http://localhost:8545"
rpc_endpoint: 'http://localhost:8545'
network: 'sepolia'
nativeCurrency:
name: 'Sepolia Ether'
symbol: 'ETH'
decimals: 18
mailbox_address: "0x123..."
multisig_ism_factory_address: "0x123..."



signer: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
mailbox_address: '0x123...'
multisig_ism_factory_address: '0x123...'

deploy:
ism:
Expand Down
12 changes: 6 additions & 6 deletions example/src/recipient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { expectNextContractAddr, logTx } from './utils';

export const recipientCmd = new Command('deploy-test-recipient')
.option('--validator-address <validator-address>', 'validator address to use')
.action(
deployTestRecipient,
);
.action(deployTestRecipient);

type DeployTestRecipientArgs = {
validatorAddress?: `0x{string}`
}
validatorAddress?: `0x{string}`;
};

async function deployTestRecipient({validatorAddress}: DeployTestRecipientArgs) {
async function deployTestRecipient({
validatorAddress,
}: DeployTestRecipientArgs) {
const {
account,
provider: { query, exec },
Expand Down
59 changes: 32 additions & 27 deletions example/src/warp.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
HypERC20__factory,
import {
HypERC20__factory,
StaticMessageIdMultisigIsmFactory__factory,
} from '@hyperlane-xyz/core';
import { Command, Option} from 'commander';
import { Command, Option } from 'commander';
import { isAddress } from 'viem';

import { HYP_MAILBOX, HYP_MULTSIG_ISM_FACTORY } from './constants';
Expand All @@ -15,28 +15,25 @@ import {

const warpCmd = new Command('warp');

warpCmd.command('deploy')
warpCmd
.command('deploy')
.option(
'--contract-name <contract-name>',
'--contract-name <contract-name>',
'Warp contract name e.g. Hyperlane Bridged TIA',
'Hyperlane Bridged Osmo'
)
.option(
'--asset-name <asset-name>',
'Warp route asset name e.g. TIA',
'TIA'
'Hyperlane Bridged Osmo',
)
.option('--asset-name <asset-name>', 'Warp route asset name e.g. TIA', 'TIA')
.option(
'--create-new-ism',
'--create-new-ism',
'Option to create a new ISM for the the warp route',
false
false,
)
.option(
'--warp-ism-address <warp-ism-address>',
'ISM to set on the warp route recipient'
'--warp-ism-address <warp-ism-address>',
'ISM to set on the warp route recipient',
)
.option(
'--ism-validator-address <ism-validator-address>',
'--ism-validator-address <ism-validator-address>',
'Validator address on the ism',
)
.action(deployWarpRoute);
Expand All @@ -58,11 +55,11 @@ warpCmd
export { warpCmd };

type DeployWarpRouteArgs = {
contractName: string,
assetName: string,
createNewIsm?: boolean,
warpIsmAddress?: `0x${string}`,
ismValidatorAddress?: `0x${string}`,
contractName: string;
assetName: string;
createNewIsm?: boolean;
warpIsmAddress?: `0x${string}`;
ismValidatorAddress?: `0x${string}`;
};

async function deployWarpRoute({
Expand All @@ -78,7 +75,9 @@ async function deployWarpRoute({
} = CONTAINER.get(Dependencies);

if (createNewIsm && warpIsmAddress !== undefined) {
throw new Error("invalid options: cannot create a new ISM and pass a custom ISM address at the same time")
throw new Error(
'invalid options: cannot create a new ISM and pass a custom ISM address at the same time',
);
}

// deploy hyp erc20 (implementation)
Expand All @@ -100,15 +99,21 @@ async function deployWarpRoute({
abi: HypERC20__factory.abi,
address: hypErc20Addr,
functionName: 'initialize',
args: [0n, contractName ? contractName : 'Hyperlane Bridged OSMO', assetName ? assetName : 'OSMO'],
args: [
0n,
contractName ? contractName : 'Hyperlane Bridged OSMO',
assetName ? assetName : 'OSMO',
],
});
logTx('Initialize HypERC20', tx);
await query.waitForTransactionReceipt({ hash: tx });
}

// If the option was specifed to create a new ISM, deploy the multisig ISM contract
if (createNewIsm) {
ismValidatorAddress = ismValidatorAddress ? ismValidatorAddress : account.address
ismValidatorAddress = ismValidatorAddress
? ismValidatorAddress
: account.address;

const multisigIsmAddr = await query.readContract({
abi: StaticMessageIdMultisigIsmFactory__factory.abi,
Expand All @@ -117,7 +122,7 @@ async function deployWarpRoute({
args: [[ismValidatorAddress], 1],
});
console.log(`Deploying multisigIsm at "${multisigIsmAddr.green}"...`);

{
const tx = await exec.writeContract({
abi: StaticMessageIdMultisigIsmFactory__factory.abi,
Expand All @@ -129,9 +134,9 @@ async function deployWarpRoute({
await query.waitForTransactionReceipt({ hash: tx });
}

warpIsmAddress = multisigIsmAddr
warpIsmAddress = multisigIsmAddr;
}

// If a custom ISM address was specified or if a new ISM was created,
// register that address in the warp contract
// Otherwise, the default ISM will be used
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"clean": "rm -rf dist",
"lint": "eslint . --ext ts",
"prettier": "prettier ./script ./example ./codegen.ts --write",
"prettier": "prettier ./script ./example ./tests ./codegen.ts --write",
"build": "yarn clean && esbuild ./script --bundle --outfile=./dist/index.js --platform=node",
"start": "yarn build && node ./dist/index.js",
"cw-hpl": "yarn start",
Expand All @@ -29,8 +29,10 @@
"axios": "^1.6.7",
"colors": "^1.4.0",
"commander": "^11.1.0",
"cosmjs-types": "^0.9.0",
"decompress": "^4.2.1",
"inversify": "^6.0.1",
"lodash": "^4.17.21",
"readline": "^1.3.0",
"reflect-metadata": "^0.1.13"
},
Expand All @@ -40,6 +42,7 @@
"@types/decompress": "^4.2.7",
"@types/eslint": "^8",
"@types/js-yaml": "^4.0.8",
"@types/lodash": "^4.17.4",
"@types/node": "^20.11.20",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
Expand Down
Loading

0 comments on commit 5f60971

Please sign in to comment.