Remove unused environment variables from compose files (#9)

Part of [Create bridge channel in go-nitro](https://www.notion.so/Create-bridge-channel-in-go-nitro-22ce80a0d8ae4edb80020a8f250ea270)
- Use variable for chain ID instead of hardcoding

Co-authored-by: Neeraj <neeraj.rtly@gmail.com>
Reviewed-on: #9
This commit is contained in:
nabarun 2024-09-04 10:27:10 +00:00
parent da17fd2f7a
commit b3e58e8d74
7 changed files with 33 additions and 34 deletions

View File

@ -301,7 +301,7 @@
- Create a deployment spec-file for L1 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,GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600"
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,GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,GETH_CHAIN_ID=1212,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600"
```
- Create a deployment `nitro-contracts` from the spec file
@ -325,16 +325,17 @@
```bash
# Nitro contract addresses
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
export L1_ASSET_ADDRESS="$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")"
export GETH_CHAIN_ID="1212"
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
export L1_ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")
```
- Create a spec-file for the deployment, map container ports to host ports and set env variables:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy init --map-ports-to-host any-same --output bridge-nitro-spec.yml --config "NITRO_L1_CHAIN_URL=ws://host.docker.internal:8546,NITRO_L2_CHAIN_URL=ws://host.docker.internal:9546,NITRO_CHAIN_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,NITRO_SC_PK=0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4,GETH_URL=http://host.docker.internal:8545,OPTIMISM_URL=http://host.docker.internal:9545,GETH_DEPLOYER_PK=$ACCOUNT_PK,OPTIMISM_DEPLOYER_PK=$ACCOUNT_PK,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600,NA_ADDRESS=$NA_ADDRESS,VPA_ADDRESS=$VPA_ADDRESS,CA_ADDRESS=$CA_ADDRESS,L1_ASSET_ADDRESS=$L1_ASSET_ADDRESS"
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy init --map-ports-to-host any-same --output bridge-nitro-spec.yml --config "NITRO_L1_CHAIN_URL=ws://host.docker.internal:8546,NITRO_L2_CHAIN_URL=ws://host.docker.internal:9546,NITRO_CHAIN_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,NITRO_SC_PK=0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4,OPTIMISM_URL=http://host.docker.internal:9545,OPTIMISM_DEPLOYER_PK=$ACCOUNT_PK,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600,NA_ADDRESS=$NA_ADDRESS,VPA_ADDRESS=$VPA_ADDRESS,CA_ADDRESS=$CA_ADDRESS,L1_ASSET_ADDRESS=$L1_ASSET_ADDRESS"
```
- Create a deployment from the spec file:
@ -360,7 +361,8 @@
- Export variables for L1 token address
```bash
export L1_ASSET_ADDRESS="$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")"
export GETH_CHAIN_ID="1212"
export L1_ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")
export A_CHAIN_ADDRESS="0xe22AD83A0dE117bA0d03d5E94Eb4E0d80a69C62a"
export C_CHAIN_ADDRESS="0xf1ac8Dd1f6D6F5c0dA99097c57ebF50CD99Ce293"
@ -370,22 +372,24 @@
```bash
# Send tokens to Alice
laconic-so deployment --dir bridge-deployment exec l2-nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $L1_ASSET_ADDRESS --to $A_CHAIN_ADDRESS --amount 1000 --network geth"
laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $L1_ASSET_ADDRESS --to $A_CHAIN_ADDRESS --amount 1000 --network geth"
#Send tokens to Charlie
laconic-so deployment --dir bridge-deployment exec l2-nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $L1_ASSET_ADDRESS --to $C_CHAIN_ADDRESS --amount 1000 --network geth"
laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $L1_ASSET_ADDRESS --to $C_CHAIN_ADDRESS --amount 1000 --network geth"
```
- Get the deployed nitro contract addresses (run in the directory where the deployments were created):
```bash
# Nitro contract addresses
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
export GETH_CHAIN_ID="1212"
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
# Contract address of bridge
export BRIDGE_ADDRESS=$(laconic-so deployment --dir bridge-deployment exec nitro-bridge "jq -r '.\"42069\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json")
export OPTIMISM_CHAIN_ID="42069"
export BRIDGE_ADDRESS=$(laconic-so deployment --dir bridge-deployment exec nitro-bridge "jq -r '.\"$OPTIMISM_CHAIN_ID\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json")
```
```bash
@ -537,7 +541,8 @@
```bash
export BRIDGE_NITRO_ADDRESS=0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94
export L1_ASSET_ADDRESS="$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")"
export GETH_CHAIN_ID="1212"
export L1_ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")
```
- Create ledger channel between A and Bridge with custom token

View File

@ -128,7 +128,7 @@
- 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,GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600"
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,GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,GETH_CHAIN_ID=1212,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600"
```
- Create a deployment `nitro-contracts` from the spec file
@ -150,9 +150,10 @@
```bash
# Nitro contract addresses
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
export GETH_CHAIN_ID="1212"
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
```
- Send custom tokens to Alice and Charlie
@ -160,8 +161,8 @@
- Export variables for token address
```bash
export ASSET_ADDRESS="$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")"
export GETH_CHAIN_ID="1212"
export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")
export A_CHAIN_ADDRESS="0xe22AD83A0dE117bA0d03d5E94Eb4E0d80a69C62a"
export C_CHAIN_ADDRESS="0xf1ac8Dd1f6D6F5c0dA99097c57ebF50CD99Ce293"
```
@ -282,13 +283,15 @@
- Set address of custom token in the current terminal
```bash
export ASSET_ADDRESS="$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")"
export GETH_CHAIN_ID="1212"
export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")
```
- Create ledger channel between Alice and Charlie with custom token
```bash
laconic-so deployment --dir alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client direct-fund 0x03Eb7a84E286c671836b9897AaE24b31D36f9cA8 --assetAddress $ASSET_ADDRESS --alphaAmount 1000000 --betaAmount 1000000 -p 4005 -h nitro-node"
export COUNTERPARTY="0x03Eb7a84E286c671836b9897AaE24b31D36f9cA8"
laconic-so deployment --dir alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client direct-fund $COUNTERPARTY --assetAddress $ASSET_ADDRESS --alphaAmount 1000000 --betaAmount 1000000 -p 4005 -h nitro-node"
LEDGER_CHANNEL_ID=<ledger channel id>
```
@ -316,7 +319,7 @@
- Create virtual channel from Alice to Charlie
```bash
laconic-so deployment --dir alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client virtual-fund 0x03Eb7a84E286c671836b9897AaE24b31D36f9cA8 --amount 1000 -p 4005 -h nitro-node"
laconic-so deployment --dir alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client virtual-fund $COUNTERPARTY --amount 1000 -p 4005 -h nitro-node"
```
- Set the payment channel id in a variable

View File

@ -6,11 +6,8 @@ services:
restart: on-failure
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
GETH_URL: ${GETH_URL}
OPTIMISM_DEPLOYER_PK: ${OPTIMISM_DEPLOYER_PK}
OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID:-42069}
GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212}
GETH_DEPLOYER_PK: ${OPTIMISM_DEPLOYER_PK}
OPTIMISM_URL: ${OPTIMISM_URL}
TOKEN_NAME: ${TOKEN_NAME}
TOKEN_SYMBOL: ${TOKEN_SYMBOL}
@ -33,7 +30,6 @@ services:
condition: service_started
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212}
OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID:-42069}
NITRO_L1_CHAIN_URL: ${NITRO_L1_CHAIN_URL}
NITRO_L2_CHAIN_URL: ${NITRO_L2_CHAIN_URL}

View File

@ -10,7 +10,6 @@ services:
GETH_URL: ${GETH_URL}
GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212}
GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK}
OPTIMISM_DEPLOYER_PK: ${GETH_DEPLOYER_PK}
TOKEN_NAME: ${TOKEN_NAME}
TOKEN_SYMBOL: ${TOKEN_SYMBOL}
INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY}

View File

@ -23,6 +23,7 @@ echo "NITRO_L2_EXT_MULTIADDR: ${NITRO_L2_EXT_MULTIADDR}"
echo "NA_ADDRESS: ${NA_ADDRESS}"
echo "CA_ADDRESS: ${CA_ADDRESS}"
echo "VPA_ADDRESS: ${VPA_ADDRESS}"
echo "OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID}"
echo "Waiting for $bridge_assets_map_file to be ready"

View File

@ -11,6 +11,7 @@ nitro_addresses_file="/app/deployment/nitro-addresses.json"
echo "Using the following environment variables:"
echo "GETH_URL: ${GETH_URL}"
echo "GETH_CHAIN_ID: ${GETH_CHAIN_ID}"
echo "GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK}"
echo "TOKEN_NAME: ${TOKEN_NAME}"
echo "TOKEN_SYMBOL: ${TOKEN_SYMBOL}"
echo "INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY}"

View File

@ -13,9 +13,6 @@ echo "Using the following environment variables:"
echo "OPTIMISM_URL: ${OPTIMISM_URL}"
echo "OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID}"
echo "OPTIMISM_DEPLOYER_PK: ${OPTIMISM_DEPLOYER_PK}"
echo "GETH_URL: ${GETH_URL}"
echo "GETH_CHAIN_ID: ${GETH_CHAIN_ID}"
echo "GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK}"
echo "TOKEN_NAME: ${TOKEN_NAME}"
echo "TOKEN_SYMBOL: ${TOKEN_SYMBOL}"
echo "INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY}"
@ -45,6 +42,3 @@ l2AssetAddress = "$L2_ASSET_ADDRESS"
EOF
echo "Done"
# Keep the container running for future asset transfers
tail -f /dev/null