mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-08 14:04:29 +00:00
Add script so that we can easily run local against the devnet (#224)
This commit is contained in:
parent
1430b74a98
commit
49fc016245
3 changed files with 74 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -55,4 +55,3 @@ go.sum
|
||||||
cicd/devnet/terraform/.terraform
|
cicd/devnet/terraform/.terraform
|
||||||
cicd/devnet/.pwd
|
cicd/devnet/.pwd
|
||||||
cicd/devnet/tmp/
|
cicd/devnet/tmp/
|
||||||
cicd/devnet/work/
|
|
||||||
11
Makefile
11
Makefile
|
|
@ -15,6 +15,17 @@ XDC:
|
||||||
@echo "Done building."
|
@echo "Done building."
|
||||||
@echo "Run \"$(GOBIN)/XDC\" to launch XDC."
|
@echo "Run \"$(GOBIN)/XDC\" to launch XDC."
|
||||||
|
|
||||||
|
XDC-devnet-local:
|
||||||
|
@echo "Rebuild the XDC first"
|
||||||
|
mv common/constants.go common/constants.go.tmp
|
||||||
|
cp common/constants/constants.go.devnet common/constants.go
|
||||||
|
make XDC
|
||||||
|
rm -rf common/constants.go
|
||||||
|
mv common/constants.go.tmp common/constants.go
|
||||||
|
|
||||||
|
@echo "Run the devnet script in local"
|
||||||
|
cd cicd/devnet && ./start-local-devnet.sh
|
||||||
|
|
||||||
gc:
|
gc:
|
||||||
go run build/ci.go install ./cmd/gc
|
go run build/ci.go install ./cmd/gc
|
||||||
@echo "Done building."
|
@echo "Done building."
|
||||||
|
|
|
||||||
62
cicd/devnet/start-local-devnet.sh
Executable file
62
cicd/devnet/start-local-devnet.sh
Executable file
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -d ./tmp/xdcchain ]
|
||||||
|
then
|
||||||
|
echo "Creating a temporary directory for storing the xdcchain"
|
||||||
|
mkdir tmp
|
||||||
|
mkdir -p ./tmp/xdcchain
|
||||||
|
touch ./tmp/.pwd
|
||||||
|
|
||||||
|
# Randomly select a key from environment variable, seperated by ','
|
||||||
|
if test -z "$PRIVATE_KEYS"
|
||||||
|
then
|
||||||
|
echo "PRIVATE_KEYS environment variable has not been set. Please run again with `export PRIVATE_KEYS={{your key}} && make XDC-devnet-local`"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
IFS=', ' read -r -a private_keys <<< "$PRIVATE_KEYS"
|
||||||
|
private_key=${private_keys[ $RANDOM % ${#private_keys[@]} ]}
|
||||||
|
|
||||||
|
echo "${private_key}" >> ./tmp/key
|
||||||
|
echo "Creating a new wallet"
|
||||||
|
wallet=$(../../build/bin/XDC account import --password ./tmp/.pwd --datadir ./tmp/xdcchain ./tmp/key | awk -v FS="({|})" '{print $2}')
|
||||||
|
../../build/bin/XDC --datadir /tmp/xdcchain init ./genesis.json
|
||||||
|
else
|
||||||
|
echo "Wallet already exist, re-use the same one. If you have changed the private key, please manually inspect the key if matches. Otherwise, delete the 'tmp' directory and start again!"
|
||||||
|
wallet=$(../../build/bin/XDC account list --datadir /tmp/xdcchain | head -n 1 | awk -v FS="({|})" '{print $2}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
input="./bootnodes.list"
|
||||||
|
bootnodes=""
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
if [ -z "${bootnodes}" ]
|
||||||
|
then
|
||||||
|
bootnodes=$line
|
||||||
|
else
|
||||||
|
bootnodes="${bootnodes},$line"
|
||||||
|
fi
|
||||||
|
done < "$input"
|
||||||
|
|
||||||
|
log_level=3
|
||||||
|
if test -z "$LOG_LEVEL"
|
||||||
|
then
|
||||||
|
echo "Log level not set, default to verbosity of 3"
|
||||||
|
else
|
||||||
|
echo "Log level found, set to $LOG_LEVEL"
|
||||||
|
log_level=$LOG_LEVEL
|
||||||
|
fi
|
||||||
|
|
||||||
|
netstats="${NODE_NAME}-${wallet}-local:xinfin_xdpos_hybrid_network_stats@devnetstats.apothem.network:2000"
|
||||||
|
|
||||||
|
echo "Running a node with wallet: ${wallet} at local"
|
||||||
|
|
||||||
|
../../build/bin/XDC --ethstats ${netstats} --gcmode=archive \
|
||||||
|
--bootnodes ${bootnodes} --syncmode full \
|
||||||
|
--datadir ./tmp/xdcchain --networkid 551 \
|
||||||
|
-port 30303 --rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 \
|
||||||
|
--rpcport 8545 \
|
||||||
|
--rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,XDPoS \
|
||||||
|
--rpcvhosts "*" --unlock "${wallet}" --password ./tmp/.pwd --mine \
|
||||||
|
--gasprice "1" --targetgaslimit "420000000" --verbosity ${log_level} \
|
||||||
|
--ws --wsaddr=0.0.0.0 --wsport 8555 \
|
||||||
|
--wsorigins "*" 2>&1 >>./tmp/xdc.log
|
||||||
Loading…
Reference in a new issue