Skip to content

Commit

Permalink
Subnet Generator V1 with UI (#155)
Browse files Browse the repository at this point in the history
* use formatter

* add helper scripts

* add xdc-zero config generation

* added configuration generator ui

* add helpers with address generator and useful links

* add faucet and faucet-server

* minor fixes

* bump version for v1 release
  • Loading branch information
wanwiset25 authored Oct 4, 2024
1 parent 524d0fd commit d2b637a
Show file tree
Hide file tree
Showing 37 changed files with 1,917 additions and 518 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ subnet/logs
subnet/relayer
subnet/stats-service
subnet/deployment-generator/script/gen.env*
.DS_Store
XDC-Subnet
keys.json
node_modules
package-lock.json
generated
*.env
temp
*.env*
**temp
1 change: 1 addition & 0 deletions subnet/deployment-generator/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:18.15
WORKDIR /app

COPY ./src /app/src
COPY ./scripts /app/scripts
COPY ./docker/start.sh /app/start.sh

RUN chmod +x /app/start.sh
Expand Down
3 changes: 2 additions & 1 deletion subnet/deployment-generator/docker/start.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
node /app/src/gen.js
node /app/src/ui.js
# node /app/src/gen.js
42 changes: 0 additions & 42 deletions subnet/deployment-generator/script/generate.sh

This file was deleted.

29 changes: 29 additions & 0 deletions subnet/deployment-generator/scripts/check-mining.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

echo "getting latest block"
resp=$(curl -s --location 'http://localhost:8545' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"XDPoS_getV2BlockByNumber","params":["latest"],"id":1}')

num=$(echo $resp | grep -o '"Number":[0-9]*' | cut -d':' -f2 | tr -d ' ')
echo $num

if [[ $num == "null" ]] || [[ $num == "" ]]; then
echo "no block has been mined, please check if nodes are peering properly"
exit
else
for i in 2 3 4
do
sleep 3
echo "getting latest block $i"
resp=$(curl -s --location 'http://localhost:8545' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"XDPoS_getV2BlockByNumber","params":["latest"],"id":1}')
nextnum=$(echo $resp | grep -o '"Number":[0-9]*' | cut -d':' -f2 | tr -d ' ')
echo $nextnum
done
fi

if [[ $nextnum > $num ]]; then
echo "subnet successfully running and mining blocks"
fi
9 changes: 9 additions & 0 deletions subnet/deployment-generator/scripts/check-peer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

resp=$(curl -s --location "http://localhost:8545" \
--header 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}')
echo $resp
num_peers=$(echo $resp | grep -o '"result":"[^"]*"' | cut -d'"' -f4)
num_peers_dec=$(printf "%d\n" $num_peers)
echo "peers: $num_peers_dec"
16 changes: 16 additions & 0 deletions subnet/deployment-generator/scripts/csc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

cd "$(dirname "$0")"

if [[ -z $1 ]] || [[ -z $2 ]]; then
echo "Missing argument"
echo "Usage: csc.sh VERSION MODE"
echo "Version: latest or check documentation for available versions"
echo "Mode: lite, full, or reverse"
exit
fi


docker pull xinfinorg/csc:$1
docker run --env-file ../contract_deploy.env --network generated_docker_net xinfinorg/csc:$1 $2

16 changes: 16 additions & 0 deletions subnet/deployment-generator/scripts/docker-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

cd "$(dirname "$0")"


if [[ -z $1 ]]; then
echo "Missing argument"
echo "Usage: docker-down.sh PROFILE"
echo "Profile:"
echo " machine1 - subnet nodes"
echo " services - relayer, backend, frontend"
exit
fi

docker compose --env-file ../docker-compose.env --profile $1 down

16 changes: 16 additions & 0 deletions subnet/deployment-generator/scripts/docker-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

cd "$(dirname "$0")"

if [[ -z $1 ]]; then
echo "Missing argument"
echo "Usage: docker-up.sh PROFILE"
echo "Profile:"
echo " machine1 - subnet nodes"
echo " services - relayer, backend, frontend"
exit
fi

docker compose --env-file ../docker-compose.env --profile $1 pull
docker compose --env-file ../docker-compose.env --profile $1 up -d

File renamed without changes.
15 changes: 15 additions & 0 deletions subnet/deployment-generator/scripts/faucet-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
VERSION_GENERATOR="v1.0.0"

cd "$(dirname "$0")"
cd ..

read -p "Input Grandmaster PK (or any source wallet with funds): " SOURCE_PK

extra=""
if [[ "$OSTYPE" == "darwin"* ]]; then
extra="--network generated_docker_net"
fi

docker pull xinfinorg/subnet-generator:$VERSION_GENERATOR
docker run --env-file common.env --entrypoint node -p 5211:5211 $extra xinfinorg/subnet-generator:$VERSION_GENERATOR /app/src/faucet.js server $SOURCE_PK
17 changes: 17 additions & 0 deletions subnet/deployment-generator/scripts/faucet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
VERSION_GENERATOR="v1.0.0"

cd "$(dirname "$0")"
cd ..

read -p "Input Grandmaster PK (or any source wallet with funds): " SOURCE_PK
read -p "Input destination wallet address: " DEST_ADDR
read -p "Input transfer amount: " AMOUNT

extra=""
if [[ "$OSTYPE" == "darwin"* ]]; then
extra="--network generated_docker_net"
fi

docker pull xinfinorg/subnet-generator:$VERSION_GENERATOR
docker run --env-file common.env --entrypoint node $extra xinfinorg/subnet-generator:$VERSION_GENERATOR /app/src/faucet.js $SOURCE_PK $DEST_ADDR $AMOUNT
27 changes: 27 additions & 0 deletions subnet/deployment-generator/scripts/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
VERSION_GENERATOR="v1.0.0"
VERSION_GENESIS="v0.3.1"

current_dir="$(cd "$(dirname "$0")" && pwd)"

echo 'pull docker images'
docker pull xinfinorg/subnet-generator:$VERSION_GENERATOR
docker pull xinfinorg/xdcsubnets:$VERSION_GENESIS


echo ''
echo 'go to http://localhost:5210 to access Subnet Configuration Generator UI'
echo 'or use ssh tunnel if this is running on your server'
echo 'ssh -N -L localhost:5210:localhost:5210 <username>@<ip_address> -i <private_key_file>'
mkdir -p generated/scripts
docker run -p 5210:5210 -v $current_dir/generated:/app/generated xinfinorg/subnet-generator:$VERSION_GENERATOR


echo 'generating genesis.json'
docker run -v $current_dir/generated/:/app/generated/ --entrypoint 'bash' xinfinorg/xdcsubnets:$VERSION_GENESIS /work/puppeth.sh || pup_success=false
if [[ $pup_success == false ]]; then
echo 'genesis.json generation failed'
exit 1
fi

echo 'subnet generation successful'
1 change: 1 addition & 0 deletions subnet/deployment-generator/scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wip
13 changes: 0 additions & 13 deletions subnet/deployment-generator/src/.eslintrc.json

This file was deleted.

Loading

0 comments on commit d2b637a

Please sign in to comment.