From 372cace05f44e09bf8b631599e655d2f4f9c98d3 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 4 Jun 2024 12:40:03 +0530 Subject: [PATCH] Add a config option for testnet --- .../compose/docker-compose-bsc-node.yml | 3 ++- .../config/docker-entrypoint.sh | 22 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/stack-orchestrator/compose/docker-compose-bsc-node.yml b/stack-orchestrator/compose/docker-compose-bsc-node.yml index a2a2938..da6133b 100644 --- a/stack-orchestrator/compose/docker-compose-bsc-node.yml +++ b/stack-orchestrator/compose/docker-compose-bsc-node.yml @@ -2,7 +2,8 @@ services: bsc: image: ghcr.io/bnb-chain/bsc:1.4.8 restart: unless-stopped - # environment: + environment: + CERC_BSC_NETWORK: ${CERC_BSC_NETWORK:-mainnet} volumes: - ../config/docker-entrypoint.sh:/bsc/docker-entrypoint.sh - data:/data diff --git a/stack-orchestrator/config/docker-entrypoint.sh b/stack-orchestrator/config/docker-entrypoint.sh index 2e7afb4..4e1a243 100755 --- a/stack-orchestrator/config/docker-entrypoint.sh +++ b/stack-orchestrator/config/docker-entrypoint.sh @@ -1,18 +1,18 @@ #!/bin/bash set -e +echo "Setting up BSC $CERC_BSC_NETWORK" + BSC_CONFIG=${BSC_HOME}/config/config.toml BSC_GENESIS=${BSC_HOME}/config/genesis.json -# TODO: Check for testnet flag - if [ -f "$BSC_CONFIG" ]; then echo "Config file found at $BSC_CONFIG" else - echo "Config file not found at $BSC_CONFIG, downloading..." + echo "Config file not found at $BSC_CONFIG, downloading config for $CERC_BSC_NETWORK..." # Download and unzip the config files - wget -O config.zip $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4) + wget -O config.zip $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep $CERC_BSC_NETWORK |cut -d\" -f4) unzip config.zip -d config fi @@ -25,4 +25,16 @@ if [ ! -d "$GETH_DIR" ]; then fi # TODO: Check for archive mode flag -exec "geth" "--config" ${BSC_CONFIG} "--datadir" ${DATA_DIR} "$@" +exec "geth" \ + --config="${BSC_CONFIG}" \ + --datadir="${DATA_DIR}" \ + --http \ + --http.addr="0.0.0.0" \ + --http.port 8545 \ + --http.vhosts="*" \ + --http.corsdomain="*" \ + --ws \ + --ws.addr="0.0.0.0" \ + --ws.port 8546 \ + --ws.origins="*" \ + "$@"