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

Create new CLI package #2573

Merged
merged 96 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
559ae95
Create new CLI package
jmrossy Jul 26, 2023
a2aa1b5
Progress on deploy commands
jmrossy Jul 27, 2023
4aa2fb2
Finish implementation of core deploy command
jmrossy Jul 28, 2023
e382ecc
Implement cli warp deploy command
jmrossy Jul 29, 2023
7ec381c
Merge branch 'main' into rossy/cli
jmrossy Jul 29, 2023
e81eaf3
Update readme
jmrossy Jul 29, 2023
0cc2473
Create stubs for send commands
jmrossy Jul 29, 2023
951f189
Finish implementation of send commands
jmrossy Jul 29, 2023
4a4fa07
Run prettier
jmrossy Jul 29, 2023
369c71a
Update dockerfile for CLI package
jmrossy Jul 30, 2023
032986d
Improve send message logging
jmrossy Jul 30, 2023
b7bd7b8
Remove extra console.log line
jmrossy Jul 30, 2023
f0e7643
Merge branch 'main' into rossy/cli
jmrossy Jul 31, 2023
46a316a
Improve send commands
jmrossy Jul 31, 2023
1aafda3
Minor fix to warp deploy
jmrossy Aug 1, 2023
7ca03d1
Merge branch 'main' into rossy/cli
jmrossy Aug 1, 2023
9ff88de
Update CLI CI test
jmrossy Aug 1, 2023
91e4262
Merge branch 'main' into rossy/cli
jmrossy Aug 2, 2023
aff0499
Bump versions to 1.4.3-beta0
jmrossy Aug 2, 2023
f686eb2
Merge branch 'main' into rossy/cli
jmrossy Aug 6, 2023
ce5fbfc
Fix build errors from merge
jmrossy Aug 6, 2023
e914051
Address feedback from @yorhodes
jmrossy Aug 6, 2023
0bd1d09
Run prettier
jmrossy Aug 6, 2023
bfec96b
Merge branch 'main' into rossy/cli
jmrossy Aug 9, 2023
18f3d9f
Add new multisig config create command
jmrossy Aug 10, 2023
b5b8fab
Merge branch 'main' into rossy/cli
jmrossy Aug 11, 2023
1029299
Bump versions to 1.4.3-beta2
jmrossy Aug 11, 2023
fad0df8
Merge branch 'main' into rossy/cli
jmrossy Sep 22, 2023
8c2a620
Add create and validate commands for warp configs
jmrossy Sep 22, 2023
e0ecd6b
Bump versions for beta CLI publish
jmrossy Sep 22, 2023
6959b7f
Add alias for addresses command
jmrossy Sep 22, 2023
24162fe
Merge branch 'main' into rossy/cli
jmrossy Sep 28, 2023
13103da
Address feedback and reorganize cli config code
jmrossy Sep 28, 2023
7033a73
Remove stableVersion fields from package.json files
jmrossy Sep 28, 2023
f8f2105
Merge branch 'main' into rossy/cli
jmrossy Oct 3, 2023
4795ca5
Fix multisig casing and output file month number
jmrossy Oct 3, 2023
384652b
Upgrade packages to 1.5.3
jmrossy Oct 3, 2023
1908ae1
Merge branch 'main' into rossy/cli
jmrossy Oct 5, 2023
7ed8bc2
Add option to skip prompts for core deploy
jmrossy Oct 5, 2023
7b86a4a
Move CLI CI into node.yml
jmrossy Oct 5, 2023
eed11f5
Fix yarn command in ci-test
jmrossy Oct 6, 2023
b592245
Set artifacts path in deploy command
jmrossy Oct 6, 2023
8e44f62
Derp, fix artifact file path
jmrossy Oct 6, 2023
f9cffa3
Use example multisig config for ci test
jmrossy Oct 6, 2023
42de37c
Fix missing yes param
jmrossy Oct 6, 2023
ccad526
More fixes for ci-test
jmrossy Oct 7, 2023
7471530
Fix Ism cofigs and TestRecipient ISM
jmrossy Oct 7, 2023
528b554
Remove empty-artifacts file from git
jmrossy Oct 7, 2023
6692342
Attempt to use tmp for empty-artifacts
jmrossy Oct 7, 2023
3033188
Also use tmp for artifacts out
jmrossy Oct 7, 2023
1769053
Derp, path again
jmrossy Oct 7, 2023
1d9a994
Hack workaround for bigint console warn
jmrossy Oct 8, 2023
7f4fdea
Add filename select option for artifact and ism steps
jmrossy Oct 8, 2023
7fe4301
Bump versions ot 1.5.4-beta0
jmrossy Oct 9, 2023
ba8761d
Add CI test coverage for warp deploy
jmrossy Oct 9, 2023
84f13bf
Fix delivery check bug in HyperlaneCore
jmrossy Oct 9, 2023
4c9c04a
Add CI coverage for send commands
jmrossy Oct 10, 2023
0ed4d43
Merge branch 'main' into rossy/cli
jmrossy Oct 10, 2023
b044870
Increase timeout on some SDK unit tests
jmrossy Oct 10, 2023
287727c
Make SDK + CLI logging more consistent
jmrossy Oct 10, 2023
3d95734
Print tmp filenames to debug announcement
jmrossy Oct 10, 2023
31842f4
Install libssl3 before cli test
jmrossy Oct 10, 2023
5622d6d
Attempt to configure libssl
jmrossy Oct 10, 2023
4d98648
Attempt2
jmrossy Oct 10, 2023
b038479
Attempt to add libssl3 to agent dockerfile
jmrossy Oct 10, 2023
d6dabde
Update dockerfile again
jmrossy Oct 10, 2023
392e474
Revert dockerfile changes
jmrossy Oct 10, 2023
d467318
Merge branch 'main' into rossy/cli
jmrossy Oct 10, 2023
531c98f
Fix agent config file path
jmrossy Oct 10, 2023
e15ccdf
Increase validator startup sleep time
jmrossy Oct 11, 2023
cfc8a56
Add more logging
jmrossy Oct 11, 2023
688f61c
Try removing announce loop
jmrossy Oct 11, 2023
c57f986
Add more logging
jmrossy Oct 11, 2023
54180b6
Disable find cmd again
jmrossy Oct 11, 2023
7cb395b
Try to disable super noisy validator logs
jmrossy Oct 11, 2023
862f418
Skip announce tx entirely
jmrossy Oct 11, 2023
17c98a4
Try killing validator before running relayer
jmrossy Oct 11, 2023
ebad637
Fix missing quotation mark
jmrossy Oct 11, 2023
1d8add9
Attempt to silence noisy logs
jmrossy Oct 11, 2023
86a0743
Keep trying
jmrossy Oct 11, 2023
885ffda
Remove first docker kill command
jmrossy Oct 11, 2023
8593440
Extract message IDs
jmrossy Oct 11, 2023
e6b4262
Let validator be noisy?
jmrossy Oct 12, 2023
44fb1d7
Add message status command
jmrossy Oct 12, 2023
3b16d8e
Add delivery checking to ci test
jmrossy Oct 12, 2023
1780b6a
Attempt to reduce logging again
jmrossy Oct 12, 2023
b88f7fd
Fix message id check
jmrossy Oct 12, 2023
6ddb80e
Merge branch 'main' into rossy/cli
jmrossy Oct 12, 2023
d5b4a54
Print message id to confirm
jmrossy Oct 12, 2023
4e18c27
Deploy ISMs before core
jmrossy Oct 12, 2023
b39eaa0
Remove console log line
jmrossy Oct 12, 2023
b45c9e4
Run relayer properly
nambrot Oct 13, 2023
18586b6
Fix missing ISM domain for secondary PI chains
jmrossy Oct 13, 2023
5120610
Improvements and fixes to ci script
jmrossy Oct 14, 2023
8c6d6f0
Route validator and relayer logs to file
jmrossy Oct 14, 2023
80086bf
Add comments for things to address during v3 updates
jmrossy Oct 14, 2023
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
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@typescript-eslint/no-require-imports": ["warn"],
"@typescript-eslint/no-unused-vars": [
"error",
{
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
Expand All @@ -48,4 +48,4 @@
}
]
}
}
}
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ typescript/token @yorhodes @jmrossy @tkporter @aroralanuk
## Hello World
typescript/helloworld @yorhodes @nambrot

## CLI
typescript/cli @jmrossy @asaj
jmrossy marked this conversation as resolved.
Show resolved Hide resolved
jmrossy marked this conversation as resolved.
Show resolved Hide resolved

## Infra
typescript/infra @tkporter @nambrot @mattiecnvr
76 changes: 76 additions & 0 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CLI

on:
push:
branches: [main]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
DEBUG: 'hyperlane:*'

jobs:
yarn-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
.yarn/cache
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }}
- name: yarn-install
run: |
yarn install
CHANGES=$(git status -s --ignore-submodules)
if [[ ! -z $CHANGES ]]; then
echo "Changes found: $CHANGES"
git diff
exit 1
fi

yarn-build:
runs-on: ubuntu-latest
needs: [yarn-install]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version: 18
- name: yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
.yarn/cache
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }}
- name: build
run: yarn build

deploy:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
.yarn/cache
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }}
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly
- name: deploy
run: ./ci-test.sh
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ COPY typescript/utils/package.json ./typescript/utils/
COPY typescript/sdk/package.json ./typescript/sdk/
COPY typescript/helloworld/package.json ./typescript/helloworld/
COPY typescript/token/package.json ./typescript/token/
COPY typescript/cli/package.json ./typescript/cli/
COPY typescript/infra/package.json ./typescript/infra/
COPY solidity/package.json ./solidity/

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
[codecov-badge]: https://img.shields.io/codecov/c/github/hyperlane-xyz/hyperlane-monorepo
[foundry]: https://getfoundry.sh/
[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg
[license]: https://opensource.org/licenses/MIT
[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg
[license]: https://www.apache.org/licenses/LICENSE-2.0
[license-badge]: https://img.shields.io/badge/License-Apache-blue.svg

## Versioning

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"description": "A yarn workspace of core Hyperlane packages",
"version": "0.0.0",
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"husky": "^8.0.0",
"lint-staged": "^12.4.3",
"prettier": "^2.4.1"
"prettier": "^2.8.8"
},
"packageManager": "yarn@3.2.0",
"private": true,
Expand All @@ -37,6 +37,7 @@
"lodash": "^4.17.21",
"recursive-readdir": "^2.2.3",
"underscore": "^1.13",
"undici": "^5.11"
"undici": "^5.11",
"@trivago/prettier-plugin-sort-imports/@babel/parser": "^7.22.7"
}
}
6 changes: 3 additions & 3 deletions solidity/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@hyperlane-xyz/core",
"description": "Core solidity contracts for Hyperlane",
"version": "1.5.1",
"version": "1.5.2-beta0",
"dependencies": {
"@eth-optimism/contracts": "^0.6.0",
"@hyperlane-xyz/utils": "1.5.1",
"@hyperlane-xyz/utils": "1.5.2-beta0",
"@openzeppelin/contracts": "^4.8.0",
"@openzeppelin/contracts-upgradeable": "^4.8.0"
},
Expand All @@ -18,7 +18,7 @@
"ethers": "^5.7.2",
"hardhat": "^2.16.1",
"hardhat-gas-reporter": "^1.0.9",
"prettier": "^2.4.1",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.0.0-beta.5",
"solhint": "^3.3.2",
"solhint-plugin-prettier": "^0.0.5",
Expand Down
2 changes: 2 additions & 0 deletions typescript/cli/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
5 changes: 5 additions & 0 deletions typescript/cli/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": ["off"]
}
}
5 changes: 5 additions & 0 deletions typescript/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
/dist
/cache
/configs
/artifacts
57 changes: 57 additions & 0 deletions typescript/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Hyperlane CLI

The Hyperlane CLI is a command-line tool written in Typescript that facilitates common operations on Hyperlane, such as deploying the core contracts and/or warp routes to new chains.

## Hyperlane overview

Hyperlane is an interchain messaging protocol that allows applications to communicate between blockchains.

Developers can use Hyperlane to share state between blockchains, allowing them to build interchain applications that live natively across multiple chains.

To read more about interchain applications, how the protocol works, and how to integrate with Hyperlane, please see the [documentation](https://docs.hyperlane.xyz).

## Setup

Node 16 or newer is required.

**Option 1: Global install:**

```bash
# Install with NPM
npm install -g @hyperlane-xyz/cli
# Or uninstall old versions
npm uninstall -g @hyperlane-xyz/cli
```

**Option 2: Temp install:**

```bash
# Run via NPM's npx command
npx @hyperlane-xyz/cli
# Or via Yarn's dlx command
yarn dlx @hyperlane-xyz/cli
```

**Option 3: Run from source:**

```bash
git clone https://github.com/hyperlane-xyz/hyperlane-monorepo.git
cd hyperlane-monorepo
yarn install && yarn build
cd typescript/cli
yarn hyperlane
```

## Common commands

View help: `hyperlane --help`

Create a core deployment config: `hyperlane config create`

Run hyperlane core deployments: `hyperlane deploy core`

Run warp route deployments: `hyperlane deploy warp`

View SDK contract addresses: `hyperlane chains addresses`

Send test message: `hyperlane send message`
100 changes: 100 additions & 0 deletions typescript/cli/ci-test.sh
jmrossy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
for CHAIN in anvil1 anvil2
do
mkdir /tmp/$CHAIN \
/tmp/$CHAIN/state \
/tmp/$CHAIN/validator \
/tmp/$CHAIN/relayer && \
chmod 777 /tmp/$CHAIN -R
done

anvil --chain-id 31337 -p 8545 --state /tmp/anvil1/state > /dev/null &
ANVIL_1_PID=$!

anvil --chain-id 31338 -p 8555 --state /tmp/anvil2/state > /dev/null &
ANVIL_2_PID=$!

sleep 1

set -e

yarn build

for i in "anvil1 anvil2" "anvil2 anvil1"
do
set -- $i
echo "Deploying contracts to $1"
yarn hyperlane --local $1 --remotes $2 \
--chains ./examples/anvil-chains.yaml \
--key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 $3 \
done

echo "Deploying warp routes"
yarn hyperlane --local "anvil1" --remotes "anvil2" \
--chains ./examples/anvil-chains.yaml \
--key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

kill $ANVIL_1_PID
kill $ANVIL_2_PID

anvil --chain-id 31337 -p 8545 --block-time 1 --state /tmp/anvil1/state > /dev/null &
ANVIL_1_PID=$!

anvil --chain-id 31338 -p 8555 --block-time 1 --state /tmp/anvil2/state > /dev/null &
ANVIL_2_PID=$!

for i in "anvil1 8545 ANVIL1" "anvil2 8555 ANVIL2"
do
set -- $i
echo "Running validator on $1"
# Won't work on anything but linux due to -net=host
docker run --mount type=bind,source="$(pwd)/artifacts",target=/config \
--mount type=bind,source="/tmp",target=/data --net=host \
-e CONFIG_FILES=/config/agent_config.json -e HYP_VALIDATOR_ORIGINCHAINNAME=$1 \
-e HYP_VALIDATOR_REORGPERIOD=0 -e HYP_VALIDATOR_INTERVAL=1 \
-e HYP_BASE_CHAINS_${3}_CONNECTION_URL=http://127.0.0.1:${2} \
-e HYP_VALIDATOR_VALIDATOR_TYPE=hexKey \
-e HYP_VALIDATOR_VALIDATOR_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 \
-e HYP_VALIDATOR_CHECKPOINTSYNCER_TYPE=localStorage \
-e HYP_VALIDATOR_CHECKPOINTSYNCER_PATH=/data/${1}/validator \
-e HYP_BASE_TRACING_LEVEL=info -e HYP_BASE_TRACING_FMT=pretty \
gcr.io/abacus-labs-dev/hyperlane-agent:40cc4a6-20230420-080111 ./validator &
done

sleep 10

for i in "anvil1 8545" "anvil2 8555"
do
set -- $i
echo "Announcing validator on $1"
VALIDATOR_ANNOUNCE_ADDRESS=$(cat ./artifacts/addresses.json | jq -r ".$1.validatorAnnounce")
VALIDATOR=$(cat /tmp/$1/validator/announcement.json | jq -r '.value.validator')
STORAGE_LOCATION=$(cat /tmp/$1/validator/announcement.json | jq -r '.value.storage_location')
SIGNATURE=$(cat /tmp/$1/validator/announcement.json | jq -r '.serialized_signature')
cast send $VALIDATOR_ANNOUNCE_ADDRESS \
"announce(address, string calldata, bytes calldata)(bool)" \
$VALIDATOR $STORAGE_LOCATION $SIGNATURE --rpc-url http://127.0.0.1:$2 \
--private-key 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
done


for i in "anvil1 anvil2 ANVIL2" "anvil2 anvil1 ANVIL1"
do
set -- $i
echo "Running relayer on $1"
docker run --mount type=bind,source="$(pwd)/artifacts",target=/config \
--mount type=bind,source="/tmp",target=/data --net=host \
-e CONFIG_FILES=/config/agent_config.json \
-e HYP_BASE_CHAINS_ANVIL1_CONNECTION_URL=http://127.0.0.1:8545 \
-e HYP_BASE_CHAINS_ANVIL2_CONNECTION_URL=http://127.0.0.1:8555 \
-e HYP_BASE_TRACING_LEVEL=info -e HYP_BASE_TRACING_FMT=pretty \
-e HYP_RELAYER_ORIGINCHAINNAME=$1 -e HYP_RELAYER_DESTINATIONCHAINNAMES=$2 \
-e HYP_RELAYER_ALLOWLOCALCHECKPOINTSYNCERS=true -e HYP_RELAYER_DB=/data/$1/relayer \
-e HYP_RELAYER_GASPAYMENTENFORCEMENT='[{"type":"none"}]' \
-e HYP_BASE_CHAINS_${3}_SIGNER_TYPE=hexKey \
-e HYP_BASE_CHAINS_${3}_SIGNER_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 \
gcr.io/abacus-labs-dev/hyperlane-agent:40cc4a6-20230420-080111 ./relayer &
done

docker ps -aq | xargs docker stop | xargs docker rm
kill $ANVIL_1_PID
kill $ANVIL_2_PID
38 changes: 38 additions & 0 deletions typescript/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /usr/bin/env node
import chalk from 'chalk';
import yargs from 'yargs';

import { chainsCommand } from './src/commands/chains.js';
import { configCommand } from './src/commands/config.js';
import { deployCommand } from './src/commands/deploy.js';
import { sendCommand } from './src/commands/send.js';
import './src/logger.js';
import { errorRed } from './src/logger.js';
jmrossy marked this conversation as resolved.
Show resolved Hide resolved

const MISSING_PARAMS_ERROR = 'Not enough non-option arguments';

console.log(chalk.blue('Hyperlane'), chalk.magentaBright('CLI'));

try {
await yargs(process.argv.slice(2))
.scriptName('hyperlane')
// TODO get version num from package.json
.version(false)
.command(chainsCommand)
.command(configCommand)
.command(deployCommand)
.command(sendCommand)
.demandCommand()
.strict()
.help()
.fail((msg, err, yargs) => {
if (msg && !msg.includes(MISSING_PARAMS_ERROR)) errorRed('Error: ' + msg);
console.log('');
yargs.showHelp();
console.log('');
if (err) errorRed(err.toString());
process.exit(1);
}).argv;
} catch (error: any) {
errorRed('Error: ' + error.message);
}
Loading
Loading