Skip to content

Commit

Permalink
fixes after review.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristure committed Mar 18, 2024
1 parent 01e02fd commit 24c1ac4
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 68 deletions.
6 changes: 5 additions & 1 deletion scripts/docker-testnet/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
pushd ../..
#!/usr/bin/env bash

set -eux

cd ${MULTIVERSXDIR}

docker build -f docker/seednode/Dockerfile . -t seednode:dev

Expand Down
14 changes: 10 additions & 4 deletions scripts/docker-testnet/clean.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#!/usr/bin/env bash

set -eux

# Delete the entire testnet folder, which includes configuration, executables and logs.

export MULTIVERSXTESTNETSCRIPTSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

source "$MULTIVERSXTESTNETSCRIPTSDIR/variables.sh"

echo "Stopping all containers..."
docker stop $(docker ps -a -q)
# Get the IDs of containers attached to the network
CONTAINER_IDS=$(docker network inspect -f '{{range .Containers}}{{.Name}} {{end}}' "$DOCKER_NETWORK_NAME")

echo "Removing all containers..."
docker container prune -f
# Stop each container
echo "Removing containers..."
for CONTAINER_ID in $CONTAINER_IDS; do
docker stop "$CONTAINER_ID"
docker rm "$CONTAINER_ID"
done

echo "Removing network..."
docker network rm ${DOCKER_NETWORK_NAME}
Expand Down
69 changes: 35 additions & 34 deletions scripts/docker-testnet/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
IP_HOST_BYTE=3

cloneRepositories() {
if [[ -n $CI_RUN ]]; then
echo "Repositories have been cloned in the CI"
else
cd $(dirname $MULTIVERSXDIR)

git clone [email protected]:multiversx/mx-chain-deploy-go.git || true
git clone [email protected]:multiversx/mx-chain-proxy-go.git || true
fi
cd $(dirname $MULTIVERSXDIR)

git clone [email protected]:multiversx/mx-chain-deploy-go.git || true
git clone [email protected]:multiversx/mx-chain-proxy-go.git || true
}

buildNodeImages() {
cd $MULTIVERSXDIR

docker build -f docker/seednode/Dockerfile . -t seednode:dev

docker build -f docker/node/Dockerfile . -t node:dev
}

createDockerNetwork() {
Expand All @@ -25,10 +29,11 @@ createDockerNetwork() {
}

startSeedNode() {
docker run -d --name seednode -v ${TESTNETDIR}/seednode/config:/go/mx-chain-go/cmd/seednode/config \
--network ${DOCKER_NETWORK_NAME} \
seednode:dev \
--rest-api-interface=0.0.0.0:10000
docker run -d --name seednode \
-v ${TESTNETDIR}/seednode/config:/go/mx-chain-go/cmd/seednode/config \
--network ${DOCKER_NETWORK_NAME} \
seednode:dev \
--rest-api-interface=0.0.0.0:10000
}

startObservers() {
Expand All @@ -40,14 +45,14 @@ startObservers() {
KEY_INDEX=$((TOTAL_NODECOUNT - observerIdx - 1))

docker run -d --name "observer${observerIdx}-${NETWORK_ADDRESS}.${IP_HOST_BYTE}-10200-shard${i}" \
-v $TESTNETDIR/node/config:/go/mx-chain-go/cmd/node/config \
--network ${DOCKER_NETWORK_NAME} \
node:dev \
--destination-shard-as-observer $i \
--rest-api-interface=0.0.0.0:10200 \
--config ./config/config_observer.toml \
--sk-index=${KEY_INDEX} \
$EXTRA_OBSERVERS_FLAGS
-v $TESTNETDIR/node/config:/go/mx-chain-go/cmd/node/config \
--network ${DOCKER_NETWORK_NAME} \
node:dev \
--destination-shard-as-observer $i \
--rest-api-interface=0.0.0.0:10200 \
--config ./config/config_observer.toml \
--sk-index=${KEY_INDEX} \
$EXTRA_OBSERVERS_FLAGS


(( IP_HOST_BYTE++ ))
Expand Down Expand Up @@ -80,12 +85,12 @@ startValidators() {
for ((j = 0; j < SHARD_VALIDATORCOUNT; j++)); do

docker run -d --name "validator${validatorIdx}-${NETWORK_ADDRESS}.${IP_HOST_BYTE}-10200-shard${i}" \
-v $TESTNETDIR/node/config:/go/mx-chain-go/cmd/node/config \
--network ${DOCKER_NETWORK_NAME} \
node:dev \
--rest-api-interface=0.0.0.0:10200 \
--config ./config/config_validator.toml \
--sk-index=${validatorIdx} \
-v $TESTNETDIR/node/config:/go/mx-chain-go/cmd/node/config \
--network ${DOCKER_NETWORK_NAME} \
node:dev \
--rest-api-interface=0.0.0.0:10200 \
--config ./config/config_validator.toml \
--sk-index=${validatorIdx} \

(( IP_HOST_BYTE++ ))
((validatorIdx++)) || true
Expand Down Expand Up @@ -127,8 +132,6 @@ updateProxyConfigDocker() {

generateProxyObserverListDocker() {
local ipByte=3
OUTPUTFILE=$!


for ((i = 0; i < SHARDCOUNT; i++)); do
for ((j = 0; j < SHARD_OBSERVERCOUNT; j++)); do
Expand All @@ -154,8 +157,6 @@ generateProxyObserverListDocker() {

generateProxyValidatorListDocker() {
local ipByte=3
OUTPUTFILE=$!


for ((i = 0; i < SHARDCOUNT; i++)); do
for ((j = 0; j < SHARD_VALIDATORCOUNT; j++)); do
Expand Down Expand Up @@ -189,8 +190,8 @@ buildProxyImage() {

startProxyDocker() {
docker run -d --name "proxy" \
-p $PORT_PROXY:8080 \
-v $TESTNETDIR/proxy/config:/mx-chain-proxy-go/cmd/proxy/config \
--network ${DOCKER_NETWORK_NAME} \
proxy:dev
-v $TESTNETDIR/proxy/config:/mx-chain-proxy-go/cmd/proxy/config \
--network ${DOCKER_NETWORK_NAME} \
-p $PORT_PROXY:8080 \
proxy:dev
}
2 changes: 1 addition & 1 deletion scripts/docker-testnet/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -eux

export DOCKERTESTNETDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down
46 changes: 18 additions & 28 deletions scripts/docker-testnet/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@ export USE_TXGEN=0
# anyway.
export TESTNETDIR="$HOME/MultiversX/testnet"


# Path to mx-chain-deploy-go, branch: master. Default: near mx-chain-go.

if [[ -n $CI_RUN ]]; then
export CONFIGGENERATORDIR="$(dirname $MULTIVERSXDIR)/mx-chain-go/mx-chain-deploy-go/cmd/filegen"
else
export CONFIGGENERATORDIR="$(dirname $MULTIVERSXDIR)/mx-chain-deploy-go/cmd/filegen"
fi
export CONFIGGENERATORDIR="$(dirname $MULTIVERSXDIR)/mx-chain-deploy-go/cmd/filegen"

export CONFIGGENERATOR="$CONFIGGENERATORDIR/filegen" # Leave unchanged.
export CONFIGGENERATOROUTPUTDIR="output"
Expand Down Expand Up @@ -114,32 +108,28 @@ export PORT_ORIGIN_VALIDATOR_REST="9500"

# UI configuration profiles

# Use tmux or not. If set to 1, only 2 terminal windows will be opened, and
# tmux will be used to display the running executables using split windows.
# Recommended. Tmux needs to be installed.
export USETMUX=1

# Log level for the logger in the Node.
export LOGLEVEL="*:INFO"


if [ "$TESTNETMODE" == "debug" ]; then
LOGLEVEL="*:DEBUG,api:INFO"
fi

if [ "$TESTNETMODE" == "trace" ]; then
LOGLEVEL="*:TRACE"
fi
## Use tmux or not. If set to 1, only 2 terminal windows will be opened, and
## tmux will be used to display the running executables using split windows.
## Recommended. Tmux needs to be installed.
#export USETMUX=1
#
## Log level for the logger in the Node.
#export LOGLEVEL="*:INFO"
#
#
#if [ "$TESTNETMODE" == "debug" ]; then
# LOGLEVEL="*:DEBUG,api:INFO"
#fi
#
#if [ "$TESTNETMODE" == "trace" ]; then
# LOGLEVEL="*:TRACE"
#fi

########################################################################
# Proxy configuration

# Path to mx-chain-proxy-go, branch: master. Default: near mx-chain-go.
if [[ -n $CI_RUN ]]; then
export PROXYDIR="$(dirname $MULTIVERSXDIR)/mx-chain-go/mx-chain-proxy-go/cmd/proxy"
else
export PROXYDIR="$(dirname $MULTIVERSXDIR)/mx-chain-proxy-go/cmd/proxy"
fi
export PROXYDIR="$(dirname $MULTIVERSXDIR)/mx-chain-proxy-go/cmd/proxy"
export PROXY=$PROXYDIR/proxy # Leave unchanged.

export PORT_PROXY="7950"
Expand Down

0 comments on commit 24c1ac4

Please sign in to comment.