Skip to content

Commit

Permalink
Add option to skip prompts for core deploy
Browse files Browse the repository at this point in the history
Update CLI CI test
Rename local to origin throughout CLI
  • Loading branch information
jmrossy committed Oct 5, 2023
1 parent 1908ae1 commit 7ed8bc2
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 181 deletions.
35 changes: 16 additions & 19 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ jobs:
- 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
Expand All @@ -36,7 +38,7 @@ jobs:
exit 1
fi
yarn-build:
build-and-test:
runs-on: ubuntu-latest
needs: [yarn-install]
steps:
Expand All @@ -46,31 +48,26 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1

- 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
- name: build-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
path: ./*
key: ${{ github.sha }}

- name: build
run: yarn build

- name: test
run: ./typescript/cli/ci-test.sh
150 changes: 75 additions & 75 deletions typescript/cli/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,84 +17,84 @@ 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 &
yarn hyperlane deploy core \
--chains ./examples/anvil-chains.yaml \
--origin $1 --remotes $2 \
--key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
--yes
done

docker ps -aq | xargs docker stop | xargs docker rm
kill $ANVIL_1_PID
kill $ANVIL_2_PID
# 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
35 changes: 34 additions & 1 deletion typescript/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
coreArtifactsOption,
keyCommandOption,
outDirCommandOption,
skipConfirmationOption,
} from './options.js';

/**
Expand Down Expand Up @@ -37,14 +38,46 @@ const coreCommand: CommandModule = {
key: keyCommandOption,
chains: chainsCommandOption,
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 outPath: string = argv.out;
await runCoreDeploy({ key, chainConfigPath, outPath });
const origin: string | undefined = argv.origin;
const remotes: string[] | undefined = argv.remotes
? argv.remotes.split(',').map((r: string) => r.trim())
: undefined;
const artifactsPath: string = argv.artifacts;
const ismConfigPath: string = argv.ism;
const skipConfirmation: boolean = argv.yes;
await runCoreDeploy({
key,
chainConfigPath,
artifactsPath,
ismConfigPath,
outPath,
origin,
remotes,
skipConfirmation,
});
process.exit(0);
},
};
Expand Down
11 changes: 9 additions & 2 deletions typescript/cli/src/commands/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export const keyCommandOption: Options = {

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

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

Expand All @@ -38,3 +38,10 @@ export const outputFileOption = (defaultPath: string): Options => ({
description: 'Output file path',
default: defaultPath,
});

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

0 comments on commit 7ed8bc2

Please sign in to comment.