Replace running-locally.md docs with a script. (#466)

This bash script builds the relevant components, including relayer and
validator agents, launches them in the required order once dependent
services are ready, and writes stdout/stderr logs to unified
datetime-based directory.
pull/482/head
webbhorn 3 years ago committed by GitHub
parent 0fd42b63a4
commit ba29b50a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 106
      rust/run-locally.sh
  2. 99
      rust/running-locally.md

@ -0,0 +1,106 @@
#!/bin/bash
set -e
set -u
set +x
finish () {
kill -- -$$
}
trap finish SIGINT SIGTERM EXIT
DATE_STR="$(date "+%Y%m%d_%Hh%Mm%Ss")"
LOG_DIR="/tmp/logs/abacus-agents/${DATE_STR?}"
BUILD_LOG="${LOG_DIR?}/build.log"
HARDHAT_LOG="${LOG_DIR?}/hardhat.stdout.log"
RELAYER_STDOUT_LOG="${LOG_DIR?}/relayer.stdout.log"
RELAYER_STDERR_LOG="${LOG_DIR?}/relayer.stderr.log"
VALIDATOR_STDOUT_LOG="${LOG_DIR?}/validator.stdout.log"
VALIDATOR_STDERR_LOG="${LOG_DIR?}/validator.stderr.log"
KATHY_LOG="${LOG_DIR?}/kathy.stdout.log"
function relayer {(
export OPT_BASE_OUTBOX_CONNECTION_URL=http://localhost:8545
export OPT_BASE_INBOXES_TEST2_CONNECTION_URL=http://localhost:8545
export OPT_BASE_INBOXES_TEST3_CONNECTION_URL=http://localhost:8545
export BASE_CONFIG=test1_config.json
export RUN_ENV=test
export OPT_BASE_METRICS=9092
export OPT_BASE_TRACING_FMT=pretty
export OPT_BASE_TRACING_LEVEL=info
export OPT_BASE_DB=/tmp/local-relayer-test1-db
export OPT_BASE_SIGNERS_TEST1_KEY=8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61
export OPT_BASE_SIGNERS_TEST1_TYPE=hexKey
export OPT_BASE_SIGNERS_TEST2_KEY=f214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897
export OPT_BASE_SIGNERS_TEST2_TYPE=hexKey
export OPT_BASE_SIGNERS_TEST3_KEY=701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82
export OPT_BASE_SIGNERS_TEST3_TYPE=hexKey
export OPT_RELAYER_POLLINGINTERVAL=5
export OPT_RELAYER_SUBMISSIONLATENCY=5
export OPT_RELAYER_MAXRETRIES=5
export OPT_RELAYER_RELAYERMESSAGEPROCESSING=false
export OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_THRESHOLD=1
export OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_TYPE=localStorage
export OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_PATH=/tmp/validatorsignatures
RUST_BACKTRACE=full cargo run --bin relayer
)}
function validator {(
export OPT_BASE_OUTBOX_CONNECTION_URL=http://127.0.0.1:8545
export OPT_BASE_INBOXES_TEST2_CONNECTION_URL=http://127.0.0.1:8545
export OPT_BASE_INBOXES_TEST3_CONNECTION_URL=http://127.0.0.1:8545
export BASE_CONFIG=test1_config.json
export RUN_ENV=test
export OPT_BASE_METRICS=9091
export OPT_BASE_TRACING_FMT=pretty
export OPT_BASE_TRACING_LEVEL=info
export OPT_BASE_DB=/tmp/local-validator-test1-db
export OPT_BASE_VALIDATOR_KEY=59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
export OPT_BASE_VALIDATOR_TYPE=hexKey
export OPT_VALIDATOR_REORGPERIOD=0
export OPT_VALIDATOR_INTERVAL=5
export OPT_VALIDATOR_CHECKPOINTSYNCER_THRESHOLD=1
export OPT_VALIDATOR_CHECKPOINTSYNCER_TYPE=localStorage
export OPT_VALIDATOR_CHECKPOINTSYNCER_PATH=/tmp/validatorsignatures
RUST_BACKTRACE=full cargo run --bin validator
)}
mkdir -p ${LOG_DIR?}
echo "Logs in ${LOG_DIR?}"
echo "Building typescript..."
(cd ../typescript/infra && yarn install) > ${BUILD_LOG?}
(cd ../typescript && yarn build) >> ${BUILD_LOG?}
echo "Building relayer..." && cargo build --bin relayer >> ${BUILD_LOG?}
echo "Building validator..." && cargo build --bin validator >> ${BUILD_LOG?}
echo "Launching hardhat..."
(cd ../typescript/infra && yarn hardhat node) > ${HARDHAT_LOG?} &
while ! grep "Started HTTP" ${HARDHAT_LOG?}; do sleep 1; done
echo "Deploying abacus contracts..."
(cd ../typescript/infra && yarn abacus)
grep "Contract deployment" ${HARDHAT_LOG?} > /dev/null
echo "Spawning relayer..."
relayer > ${RELAYER_STDOUT_LOG?} 2> ${RELAYER_STDERR_LOG?} &
while ! grep -i "listening on" ${RELAYER_STDOUT_LOG?}; do sleep 1; done
echo "Spawning validator..."
validator > ${VALIDATOR_STDOUT_LOG?} 2> ${VALIDATOR_STDERR_LOG?} &
while ! grep -i "listening on" ${VALIDATOR_STDOUT_LOG?}; do sleep 1; done
echo "Setup complete! Agents running in background..."
echo "Ctrl+C to end execution..."
echo "Spawning Kathy to send Abacus message traffic..."
(cd ../typescript/infra && yarn kathy) > ${KATHY_LOG?} &
tail -f ${KATHY_LOG?} | grep "send"
wait

@ -1,99 +0,0 @@
## Setup
Example configuration files
<!--
`rust/local.checkpointer.env`
```shell
OPT_BASE_OUTBOX_CONNECTION_URL=http://localhost:8545
OPT_BASE_INBOXES_TEST2_CONNECTION_URL=http://localhost:8545
OPT_BASE_INBOXES_TEST3_CONNECTION_URL=http://localhost:8545
BASE_CONFIG=test1_config.json
RUN_ENV=test
OPT_BASE_METRICS=9090
OPT_BASE_TRACING_FMT=pretty
OPT_BASE_TRACING_LEVEL=info
OPT_BASE_DB=/tmp/local-checkpointer-test1-db
OPT_BASE_SIGNERS_TEST1_KEY=8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61
OPT_BASE_SIGNERS_TEST1_TYPE=hexKey
OPT_BASE_SIGNERS_TEST2_KEY=f214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897
OPT_BASE_SIGNERS_TEST2_TYPE=hexKey
OPT_BASE_SIGNERS_TEST3_KEY=701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82
OPT_BASE_SIGNERS_TEST3_TYPE=hexKey
OPT_CHECKPOINTER_POLLINGINTERVAL=5
OPT_CHECKPOINTER_CREATIONLATENCY=5
```
-->
`rust/local.relayer.env`
```shell
OPT_BASE_OUTBOX_CONNECTION_URL=http://localhost:8545
OPT_BASE_INBOXES_TEST2_CONNECTION_URL=http://localhost:8545
OPT_BASE_INBOXES_TEST3_CONNECTION_URL=http://localhost:8545
BASE_CONFIG=test1_config.json
RUN_ENV=test
OPT_BASE_METRICS=9092
OPT_BASE_TRACING_FMT=pretty
OPT_BASE_TRACING_LEVEL=info
OPT_BASE_DB=/tmp/local-relayer-test1-db
OPT_BASE_SIGNERS_TEST1_KEY=8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61
OPT_BASE_SIGNERS_TEST1_TYPE=hexKey
OPT_BASE_SIGNERS_TEST2_KEY=f214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897
OPT_BASE_SIGNERS_TEST2_TYPE=hexKey
OPT_BASE_SIGNERS_TEST3_KEY=701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82
OPT_BASE_SIGNERS_TEST3_TYPE=hexKey
OPT_RELAYER_POLLINGINTERVAL=5
OPT_RELAYER_SUBMISSIONLATENCY=5
OPT_RELAYER_MAXRETRIES=5
OPT_RELAYER_RELAYERMESSAGEPROCESSING=false
OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_THRESHOLD=1
OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_TYPE=localStorage
OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_PATH=/tmp/validatorsignatures
```
`rust/local.validator.env`
```shell
OPT_BASE_OUTBOX_CONNECTION_URL=http://127.0.0.1:8545
OPT_BASE_INBOXES_TEST2_CONNECTION_URL=http://127.0.0.1:8545
OPT_BASE_INBOXES_TEST3_CONNECTION_URL=http://127.0.0.1:8545
BASE_CONFIG=test1_config.json
RUN_ENV=test
OPT_BASE_METRICS=9091
OPT_BASE_TRACING_FMT=pretty
OPT_BASE_TRACING_LEVEL=info
OPT_BASE_DB=/tmp/local-validator-test1-db
OPT_BASE_VALIDATOR_KEY=59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
OPT_BASE_VALIDATOR_TYPE=hexKey
OPT_VALIDATOR_REORGPERIOD=0
OPT_VALIDATOR_INTERVAL=5
OPT_VALIDATOR_CHECKPOINTSYNCER_THRESHOLD=1
OPT_VALIDATOR_CHECKPOINTSYNCER_TYPE=localStorage
OPT_VALIDATOR_CHECKPOINTSYNCER_PATH=/tmp/validatorsignatures
```
## Running
In `typescript/infra` to start the ethereum node with
```shell
yarn hardhat node
```
and then deploy (in a new shell) the abacus contracts
```shell
yarn abacus
```
In `rust` then start the agents (you will need one shell for each)
<!-- env $(xargs <local.checkpointer.env) cargo run --bin checkpointer -->
```shell
env $(xargs <local.relayer.env) cargo run --bin relayer
env $(xargs <local.validator.env) cargo run --bin validator
```
Then to test, start `kathy` which will generate messages.
In `typescript/infra`
```shell
yarn kathy
```
Loading…
Cancel
Save