Setup Nitro config
This commit is contained in:
parent
c72070a080
commit
adc4607fd7
@ -81,7 +81,6 @@ services:
|
||||
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC}
|
||||
CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL}
|
||||
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
|
||||
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER}
|
||||
CERC_RELAY_PEERS: ${CERC_RELAY_PEERS}
|
||||
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
||||
CERC_PUBSUB: ${CERC_PUBSUB}
|
||||
@ -91,14 +90,16 @@ services:
|
||||
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
||||
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
||||
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
||||
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER}
|
||||
CERC_PRIVATE_KEY_NITRO: ${CERC_PRIVATE_KEY_NITRO}
|
||||
entrypoint: ["bash", "-c"]
|
||||
command: ["./deploy-nitro-contracts.sh && ./read-nitro-contracts.sh && ./start-server.sh"]
|
||||
command: ["./deploy-nitro-contracts.sh && ./start-server.sh"]
|
||||
volumes:
|
||||
- ../config/watcher-mobymask-v3/deploy-nitro-contracts.sh:/app/deploy-nitro-contracts.sh
|
||||
- ../config/watcher-mobymask-v3/deploy-nitro-contracts.ts:/app/deploy-nitro-contracts.ts
|
||||
- ../config/watcher-mobymask-v3/read-nitro-contracts.sh:/app/read-nitro-contracts.sh
|
||||
- ../config/watcher-mobymask-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml
|
||||
- ../config/watcher-mobymask-v2/start-server.sh:/app/start-server.sh
|
||||
- ../config/watcher-mobymask-v3/watcher-config-rates.toml:/app/environments/rates.toml
|
||||
- ../config/watcher-mobymask-v3/start-server.sh:/app/start-server.sh
|
||||
- peers_ids:/app/peers
|
||||
- nitro_addresses:/nitro
|
||||
- mobymask_deployment:/server
|
||||
|
@ -18,11 +18,11 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
echo "Using the above addresses and skipping Nitro contracts deployment"
|
||||
|
||||
# Create the required JSON and write it to a file
|
||||
nitro_addresses_json="{
|
||||
\"nitroAdjudicatorAddress\": \"$CERC_NA_ADDRESS\",
|
||||
\"virtualPaymentAppAddress\": \"$CERC_VPA_ADDRESS\",
|
||||
\"consensusAppAddress\": \"$CERC_CA_ADDRESS\"
|
||||
}"
|
||||
nitro_addresses_json=$(jq -n \
|
||||
--arg na "$CERC_NA_ADDRESS" \
|
||||
--arg vpa "$CERC_VPA_ADDRESS" \
|
||||
--arg ca "$CERC_CA_ADDRESS" \
|
||||
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
|
||||
echo "$nitro_addresses_json" > "${NITRO_ADDRESSES_FILE_PATH}"
|
||||
|
||||
exit
|
||||
|
@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
NITRO_ADDRESSES_FILE_PATH="/nitro/nitro-addresses.json"
|
||||
DESTINATION_FILE_PATH="./src/nitro-addresses.json"
|
||||
|
||||
# Check if the file exists
|
||||
if [ -f "$NITRO_ADDRESSES_FILE_PATH" ]; then
|
||||
cat "$NITRO_ADDRESSES_FILE_PATH" > "$DESTINATION_FILE_PATH"
|
||||
echo "Nitro addresses set to ${DESTINATION_FILE_PATH}"
|
||||
else
|
||||
echo "File ${NITRO_ADDRESSES_FILE_PATH} does not exist"
|
||||
exit 1
|
||||
fi
|
67
app/data/config/watcher-mobymask-v3/start-server.sh
Executable file
67
app/data/config/watcher-mobymask-v3/start-server.sh
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
CERC_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}"
|
||||
|
||||
CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}"
|
||||
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
|
||||
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
|
||||
CERC_RELAY_ANNOUNCE_DOMAIN="${CERC_RELAY_ANNOUNCE_DOMAIN:-${DEFAULT_CERC_RELAY_ANNOUNCE_DOMAIN}}"
|
||||
CERC_ENABLE_PEER_L2_TXS="${CERC_ENABLE_PEER_L2_TXS:-${DEFAULT_CERC_ENABLE_PEER_L2_TXS}}"
|
||||
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
|
||||
|
||||
NITRO_ADDRESSES_FILE_PATH="/nitro/nitro-addresses.json"
|
||||
DESTINATION_FILE_PATH="./src/nitro-addresses.json"
|
||||
|
||||
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
|
||||
|
||||
# Use public domain for relay multiaddr in peer config if specified
|
||||
# Otherwise, use the docker container's host IP
|
||||
if [ -n "$CERC_RELAY_ANNOUNCE_DOMAIN" ]; then
|
||||
CERC_RELAY_MULTIADDR="/dns4/${CERC_RELAY_ANNOUNCE_DOMAIN}/tcp/443/wss/p2p/$(jq -r '.id' /app/peers/relay-id.json)"
|
||||
else
|
||||
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' /app/peers/relay-id.json)"
|
||||
fi
|
||||
|
||||
# Use contract address from environment variable or set from config.json in mounted volume
|
||||
if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
|
||||
CONTRACT_ADDRESS="${CERC_DEPLOYED_CONTRACT}"
|
||||
else
|
||||
# Assign deployed contract address from server config (created by mobymask container after deploying contract)
|
||||
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
|
||||
fi
|
||||
|
||||
# Copy the deployed Nitro addresses to the required path
|
||||
if [ -f "$NITRO_ADDRESSES_FILE_PATH" ]; then
|
||||
cat "$NITRO_ADDRESSES_FILE_PATH" > "$DESTINATION_FILE_PATH"
|
||||
echo "Nitro addresses set to ${DESTINATION_FILE_PATH}"
|
||||
else
|
||||
echo "File ${NITRO_ADDRESSES_FILE_PATH} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Using CERC_PRIVATE_KEY_PEER (account with funds) from env for sending txs to L2"
|
||||
echo "Using CERC_PRIVATE_KEY_NITRO from env for Nitro account"
|
||||
|
||||
# Read in the config template TOML file and modify it
|
||||
WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml)
|
||||
WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
|
||||
sed -E "s|REPLACE_WITH_CERC_RELAY_PEERS|${CERC_RELAY_PEERS}|g; \
|
||||
s|REPLACE_WITH_CERC_DENY_MULTIADDRS|${CERC_DENY_MULTIADDRS}|g; \
|
||||
s/REPLACE_WITH_CERC_PUBSUB/${CERC_PUBSUB}/g; \
|
||||
s/REPLACE_WITH_CERC_RELAY_ANNOUNCE_DOMAIN/${CERC_RELAY_ANNOUNCE_DOMAIN}/g; \
|
||||
s|REPLACE_WITH_CERC_RELAY_MULTIADDR|${CERC_RELAY_MULTIADDR}|g; \
|
||||
s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \
|
||||
s/REPLACE_WITH_CERC_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \
|
||||
s/REPLACE_WITH_CERC_PRIVATE_KEY_NITRO/${CERC_PRIVATE_KEY_NITRO}/g; \
|
||||
s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \
|
||||
s|REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ")
|
||||
|
||||
# Write the modified content to a new file
|
||||
echo "$WATCHER_CONFIG" > environments/local.toml
|
||||
|
||||
echo 'yarn server'
|
||||
yarn server
|
@ -0,0 +1,14 @@
|
||||
freeQueriesLimit = 10
|
||||
|
||||
freeQueriesList = []
|
||||
|
||||
[queries]
|
||||
multiNonce = ''
|
||||
_owner = ''
|
||||
isRevoked = ''
|
||||
isPhisher = ''
|
||||
isMember = ''
|
||||
|
||||
[mutations]
|
||||
invoke = ''
|
||||
revoke = ''
|
@ -46,6 +46,23 @@
|
||||
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
|
||||
contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS'
|
||||
|
||||
[server.p2p.nitro]
|
||||
store = './out/nitro-db'
|
||||
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_NITRO'
|
||||
chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
|
||||
|
||||
[server.p2p.nitro.payments]
|
||||
ratesFile = './environments/rates.toml'
|
||||
requestTimeoutInSecs = 10
|
||||
|
||||
[server.p2p.nitro.payments.cache]
|
||||
maxAccounts = 1000
|
||||
accountTTLInSecs = 1800
|
||||
maxVouchersPerAccount = 1000
|
||||
voucherTTLInSecs = 300
|
||||
maxPaymentChannels = 10000
|
||||
paymentChannelTTLInSecs = 1800
|
||||
|
||||
[metrics]
|
||||
host = "0.0.0.0"
|
||||
port = 9000
|
||||
|
@ -37,7 +37,6 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
||||
# OR
|
||||
# Specify the required account credentials
|
||||
CERC_PRIVATE_KEY_DEPLOYER=
|
||||
CERC_PRIVATE_KEY_PEER=
|
||||
|
||||
# Base URI for mobymask-app
|
||||
# (used for generating a root invite link after deploying the contract)
|
||||
@ -65,6 +64,12 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
||||
CERC_NA_ADDRESS=
|
||||
CERC_VPA_ADDRESS=
|
||||
CERC_CA_ADDRESS=
|
||||
|
||||
# Specify private key of a funded account for sending txs to L2
|
||||
CERC_PRIVATE_KEY_PEER=
|
||||
|
||||
# Specify private key for the Nitro account
|
||||
CERC_PRIVATE_KEY_NITRO=
|
||||
```
|
||||
|
||||
* NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
|
||||
|
Loading…
Reference in New Issue
Block a user