diff --git a/README.md b/README.md index c0f50cb..020b41e 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,5 @@ Stacks to run nitro-node and bridge Demo -- [nitro-bridge demo](./nitro-bridge-demo.md) \ No newline at end of file +- [nitro-bridge demo](./nitro-bridge-demo.md) +- [nitro-node demo](./nitro-node-demo.md) diff --git a/nitro-node-demo.md b/nitro-node-demo.md new file mode 100644 index 0000000..8c45c4d --- /dev/null +++ b/nitro-node-demo.md @@ -0,0 +1,146 @@ +# nitro-node demo + +## Setup + +### Fixturenet eth stack + +- Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-eth-stacks --pull + ``` + +- Clone required repositories: + + ```bash + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth setup-repositories --pull + + # If this throws an error as a result of being already checked out to a branch/tag in a repo, remove all repositories from that stack and re-run the command + # The repositories are located in $HOME/cerc by default + ``` + +- Build the container images: + + ```bash + # Remove any older foundry image with `latest` tag + docker rmi ghcr.io/foundry-rs/foundry:latest + + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth build-containers --force-rebuild + + # If errors are thrown during build, old images used by this stack would have to be deleted + ``` + + - NOTE: this will take >10 mins depending on the specs of your machine, and **requires** 16GB of memory or greater. + + - Remove any dangling Docker images (to clear up space): + + ```bash + docker image prune + ``` + +- Create spec files for deployment, which will map the stack's ports and volumes to the host: + + ```bash + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth deploy init --output fixturenet-eth-spec.yml + ``` + +- Configure ports: + - `fixturenet-eth-spec.yml` + + ```yml + ... + network: + ports: + fixturenet-eth-bootnode-geth: + - '9898:9898' + - '30303' + fixturenet-eth-geth-1: + - '8545:8545' + - '8546:8546' + - '40000' + - '6060' + fixturenet-eth-lighthouse-1: + - '8001' + ... + ``` +- Create deployments: + Once you've made any needed changes to the spec files, create deployments from them: + + ```bash + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth deploy create --spec-file fixturenet-eth-spec.yml --deployment-dir fixturenet-eth-deployment + ``` + +- Env configuration: + + ```bash + cat < fixturenet-eth-deployment/config.env + CERC_ALLOW_UNPROTECTED_TXS=true + EOF + ``` + +### Go-nitro + +- Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull + ``` + +- Clone required repositories: + + ```bash + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node setup-repositories --git-ssh --pull + ``` + +- Build the container images: + + ```bash + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers --force-rebuild + ``` + +## Run + +- Start fixturenet-eth stack: + (run steps in directory where the stack deployments had been created) + + - Start `fixturenet-eth-deployment` deployment: + + ```bash + laconic-so deployment --dir fixturenet-eth-deployment start + ``` + + - Check status of L1 + + - Run status check: + + ```bash + laconic-so deployment --dir fixturenet-eth-deployment exec fixturenet-eth-bootnode-lighthouse "/scripts/status-internal.sh" + ``` + + - Check geth logs to ensure that new blocks are getting created + + ```bash + laconic-so deployment --dir fixturenet-eth-deployment logs -f fixturenet-eth-geth-1 + ``` + +- Deploy nitro contracts + - Create a deployment spec-file for nitro contract: + + ```bash + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts deploy init --output nitro-contracts-spec.yml --config "GETH_URL=http://host.docker.internal:8545,OPTIMISM_URL=http://host.docker.internal:9545,GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600" + ``` + + - Create a deployment `nitro-contracts` from the spec file + + ```bash + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts deploy create --spec-file nitro-contracts-spec.yml --deployment-dir nitro-contracts-deployment + ``` + + - Start `nitro-contracts` deployment: + + ``` + laconic-so deployment --dir nitro-contracts-deployment start + + # Check the logs + laconic-so deployment --dir nitro-contracts-deployment logs nitro-contracts -f + ``` \ No newline at end of file diff --git a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml index 51cf2e7..695b591 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml @@ -8,9 +8,7 @@ services: environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} GETH_URL: ${GETH_URL} - OPTIMISM_URL: ${OPTIMISM_URL} GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212} - OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID:-42069} GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK} OPTIMISM_DEPLOYER_PK: ${GETH_DEPLOYER_PK} TOKEN_NAME: ${TOKEN_NAME} diff --git a/stack-orchestrator/config/nitro-contracts/deploy.sh b/stack-orchestrator/config/nitro-contracts/deploy.sh index 19f981d..e8524a2 100755 --- a/stack-orchestrator/config/nitro-contracts/deploy.sh +++ b/stack-orchestrator/config/nitro-contracts/deploy.sh @@ -7,15 +7,10 @@ fi addresses_deployment_file="packages/nitro-protocol/addresses.json" nitro_addresses_file="/app/deployment/nitro-addresses.json" -bridge_assets_map_file="/app/deployment/bridge-assets-map.toml" echo "Using the following environment variables:" echo "GETH_URL: ${GETH_URL}" -echo "OPTIMISM_URL: ${OPTIMISM_URL}" echo "GETH_CHAIN_ID: ${GETH_CHAIN_ID}" -echo "OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID}" -echo "GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK}" -echo "OPTIMISM_DEPLOYER_PK: ${OPTIMISM_DEPLOYER_PK}" echo "TOKEN_NAME: ${TOKEN_NAME}" echo "TOKEN_SYMBOL: ${TOKEN_SYMBOL}" echo "INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY}" @@ -34,29 +29,6 @@ else cp ${addresses_deployment_file} ${nitro_addresses_file} fi -# Check if L1 chain id key is present for L1 deployment -if [ -f "$nitro_addresses_file" ] && jq -e "has(\"$OPTIMISM_CHAIN_ID\")" ${nitro_addresses_file} > /dev/null; then - echo "L2 addresses found in ${nitro_addresses_file}, skipping deployment" -else - # Deploy Nitro contracts - yarn contracts:deploy-optimism - - # Deploy custom token - yarn contracts:deploy-token-optimism - - cp ${addresses_deployment_file} ${nitro_addresses_file} -fi - -L1_ASSET_ADDRESS=$(jq -r ".\"$GETH_CHAIN_ID\"[0].contracts.Token.address" ${nitro_addresses_file}) -L2_ASSET_ADDRESS=$(jq -r ".\"$OPTIMISM_CHAIN_ID\"[0].contracts.Token.address" ${nitro_addresses_file}) - -# Deploy custom tokens and create bridge-assets-map.toml -cat < "$bridge_assets_map_file" -[[assets]] -l1AssetAddress = "$L1_ASSET_ADDRESS" -l2AssetAddress = "$L2_ASSET_ADDRESS" -EOF - echo "Done" # Keep the container running for future asset transfers diff --git a/stack-orchestrator/stacks/nitro-contracts/README.md b/stack-orchestrator/stacks/nitro-contracts/README.md new file mode 100644 index 0000000..88f85d0 --- /dev/null +++ b/stack-orchestrator/stacks/nitro-contracts/README.md @@ -0,0 +1 @@ +# TODO: Update README \ No newline at end of file diff --git a/stack-orchestrator/stacks/nitro-contracts/stack.yml b/stack-orchestrator/stacks/nitro-contracts/stack.yml new file mode 100644 index 0000000..ece621d --- /dev/null +++ b/stack-orchestrator/stacks/nitro-contracts/stack.yml @@ -0,0 +1,9 @@ +version: "1.0" +name: nitro-contracts +description: "Deploy nitro contracts" +repos: + - github.com/cerc-io/go-nitro +containers: + - cerc/nitro-client +pods: + - nitro-contracts