Skip to content

Commit

Permalink
Support multiple origins in PI deployments (#2816)
Browse files Browse the repository at this point in the history
### Description

- Support multiple origins in PI deployments
- Simplify ci test with single core deploy command
- Improve output format of chains list command

### Related issues

Fixes #2813 

### Testing

Tested locally and with e2e test
  • Loading branch information
jmrossy authored Oct 17, 2023
1 parent d8fdfe6 commit b230aa7
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 131 deletions.
18 changes: 3 additions & 15 deletions typescript/cli/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,13 @@ set -e

echo "{}" > /tmp/empty-artifacts.json

echo "Deploying contracts to anvil1"
echo "Deploying contracts to anvil1 and anvil2"
yarn workspace @hyperlane-xyz/cli run hyperlane deploy core \
--chains ./examples/anvil-chains.yaml \
--chain-configs ./examples/anvil-chains.yaml \
--chains anvil1,anvil2 \
--artifacts /tmp/empty-artifacts.json \
--out /tmp \
--ism ./examples/multisig-ism.yaml \
--origin anvil1 --remotes anvil2 \
--key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--yes

CORE_ARTIFACTS_PATH=`find /tmp/core-deployment* -type f -exec ls -t1 {} + | head -1`

echo "Deploying contracts to anvil2"
yarn workspace @hyperlane-xyz/cli run hyperlane deploy core \
--chains ./examples/anvil-chains.yaml \
--artifacts $CORE_ARTIFACTS_PATH \
--out /tmp \
--ism ./examples/multisig-ism.yaml \
--origin anvil2 --remotes anvil1 \
--key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--yes

Expand Down
1 change: 1 addition & 0 deletions typescript/cli/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ export const logGreen = (...args: any) => console.log(chalk.green(...args));
export const logRed = (...args: any) => console.log(chalk.red(...args));
export const errorRed = (...args: any) => console.error(chalk.red(...args));
export const log = (...args: any) => console.log(...args);
export const logTable = (...args: any) => console.table(...args);
18 changes: 13 additions & 5 deletions typescript/cli/src/commands/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
hyperlaneContractAddresses,
} from '@hyperlane-xyz/sdk';

import { log, logBlue, logGray } from '../../logger.js';
import { log, logBlue, logGray, logTable } from '../../logger.js';

/**
* Parent command
Expand All @@ -33,13 +33,21 @@ const listCommand: CommandModule = {
command: 'list',
describe: 'List all core chains included in the Hyperlane SDK',
handler: () => {
const serializer = (chains: string[]) =>
chains.reduce<any>((result, chain) => {
result[chain] = {
'Display Name': chainMetadata[chain].displayName,
'Chain Id': chainMetadata[chain].chainId,
};
return result;
}, {});

logBlue('Hyperlane core mainnet chains:');
logGray('------------------------------');
log(Mainnets.map((chain) => chainMetadata[chain].displayName).join(', '));
log('');
logBlue('Hyperlane core testnet chains:');
logTable(serializer(Mainnets));
logBlue('\nHyperlane core testnet chains:');
logGray('------------------------------');
log(Testnets.map((chain) => chainMetadata[chain].displayName).join(', '));
logTable(serializer(Testnets));
},
};

Expand Down
28 changes: 11 additions & 17 deletions typescript/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,40 @@ const coreCommand: CommandModule = {
builder: (yargs) =>
yargs.options({
key: keyCommandOption,
chains: chainsCommandOption,
'chain-configs': chainsCommandOption,
chains: {
type: 'string',
description:
'Comma separated list of chain names to which contracts will be deployed',
},
out: outDirCommandOption,
artifacts: coreArtifactsOption,
ism: {
type: 'string',
description:
'A path to a JSON or YAML file with ISM configs (e.g. Multisig)',
},
origin: {
type: 'string',
description: 'Name of chain to which contracts will be deployed',
},
remotes: {
type: 'string',
description:
'Comma separated list of chain names to which origin will be connected',
},
yes: skipConfirmationOption,
}),
handler: async (argv: any) => {
logGray('Hyperlane permissionless core deployment');
logGray('----------------------------------------');
const key: string = argv.key || process.env.HYP_KEY;
const chainConfigPath: string = argv.chains;
const chainConfigPath: string = argv['chain-configs'];
const outPath: string = argv.out;
const origin: string | undefined = argv.origin;
const remotes: string[] | undefined = argv.remotes
? argv.remotes.split(',').map((r: string) => r.trim())
: undefined;
const chains: string[] | undefined = argv.chains
?.split(',')
.map((r: string) => r.trim());
const artifactsPath: string = argv.artifacts;
const ismConfigPath: string = argv.ism;
const skipConfirmation: boolean = argv.yes;
await runCoreDeploy({
key,
chainConfigPath,
chains,
artifactsPath,
ismConfigPath,
outPath,
origin,
remotes,
skipConfirmation,
});
process.exit(0);
Expand Down
10 changes: 7 additions & 3 deletions typescript/cli/src/commands/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,47 @@ export const keyCommandOption: Options = {
type: 'string',
description:
'A hex private key or seed phrase for transaction signing. Or use the HYP_KEY env var',
alias: 'k',
};

export const chainsCommandOption: Options = {
type: 'string',
description: 'A path to a JSON or YAML file with chain configs',
default: './configs/chain-config.yaml',
alias: 'cc',
};

export const outDirCommandOption: Options = {
type: 'string',
description: 'A folder name output artifacts into',
default: './artifacts',
alias: 'o',
};

export const coreArtifactsOption: Options = {
type: 'string',
description: 'File path to core deployment output artifacts',
alias: 'ca',
};

export const fileFormatOption: Options = {
type: 'string',
alias: 'f',
description: 'Output file format',
choices: ['json', 'yaml'],
default: 'yaml',
alias: 'f',
};

export const outputFileOption = (defaultPath: string): Options => ({
type: 'string',
alias: 'o',
description: 'Output file path',
default: defaultPath,
alias: 'o',
});

export const skipConfirmationOption: Options = {
type: 'boolean',
alias: 'y',
description: 'Skip confirmation prompts',
default: false,
alias: 'y',
};
Loading

0 comments on commit b230aa7

Please sign in to comment.