Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New devnet #781

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,61 @@ jobs:
echo "image_name=$image_name"
echo "image_name=$image_name" >> "$GITHUB_OUTPUT"

devnet_k8_apply:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
needs: devnet_build_push
steps:
- uses: actions/checkout@v4
- name: Set up kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.19.11'
- name: Decode and configure kubeconfig
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBE_CONFIG }}" | base64 --decode > $HOME/.kube/config
chmod 600 $HOME/.kube/config
git_hash=$(git rev-parse --short "$GITHUB_SHA")
kubectl set image deployment/devnet1 devnet1=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet2 devnet2=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet3 devnet3=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet4 devnet4=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet5 devnet5=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet6 devnet6=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet7 devnet7=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet8 devnet8=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet9 devnet9=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet10 devnet10=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet11 devnet11=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet12 devnet12=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet13 devnet13=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet14 devnet14=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet15 devnet15=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet16 devnet16=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet17 devnet17=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/devnet18 devnet18=xinfinorg/devnet:dev-upgrade-${git_hash}

rpc_k8_apply:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
needs: devnet_build_push
steps:
- uses: actions/checkout@v4
- name: Set up kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.19.11'
- name: Decode and configure kubeconfig
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBE_CONFIG }}" | base64 --decode > $HOME/.kube/config
chmod 600 $HOME/.kube/config
git_hash=$(git rev-parse --short "$GITHUB_SHA")
kubectl set image deployment/devnetrpc devnetrpc=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/testnetrpc testnetrpc=xinfinorg/devnet:dev-upgrade-${git_hash}
kubectl set image deployment/mainnetrpc mainnetrpc=xinfinorg/devnet:dev-upgrade-${git_hash}

rpcnode_terraform_apply:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
Expand Down
9 changes: 7 additions & 2 deletions cicd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ RUN apk add make build-base linux-headers
COPY . /builder
RUN cd /builder && make && mv /builder/build/bin/XDC /builder/build/bin/XDC-mainnet

RUN mv /builder/common/constants/constants.go.testnet /builder/common/constants.go
RUN cd /builder && make && mv /builder/build/bin/XDC /builder/build/bin/XDC-testnet

RUN mv /builder/common/constants/constants.go.devnet /builder/common/constants.go
RUN cd /builder && make && mv /builder/build/bin/XDC /builder/build/bin/XDC-devnet

RUN mv /builder/common/constants/constants.go.testnet /builder/common/constants.go
RUN cd /builder && make && mv /builder/build/bin/XDC /builder/build/bin/XDC-testnet
RUN mv /builder/common/constants/constants.go.local /builder/common/constants.go
RUN cd /builder && make && mv /builder/build/bin/XDC /builder/build/bin/XDC-local

# The runtime image
FROM alpine:3
Expand All @@ -18,11 +21,13 @@ WORKDIR /work

RUN apk add --no-cache bash curl

COPY --from=builder /builder/build/bin/XDC-local /usr/bin
COPY --from=builder /builder/build/bin/XDC-devnet /usr/bin
COPY --from=builder /builder/build/bin/XDC-testnet /usr/bin
COPY --from=builder /builder/build/bin/XDC-mainnet /usr/bin

# # Copy over files
ADD cicd/local /work/local
ADD cicd/devnet /work/devnet
ADD cicd/testnet /work/testnet
ADD cicd/mainnet /work/mainnet
Expand Down
2 changes: 2 additions & 0 deletions cicd/devnet/bootnodes.list
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
enode://00d49d72a48164681906ad61924568da0d3049937efdbaed0b7533e34a99f55814f1839d909cdc82f78e04a36ac04737d80b41b22905c7d6cac3c80bb5cdbbc4@66.94.98.186:30301
enode://d6793b02a478f13ed6d01c30778935f6f8f7461a75aebedcb310def4ed9b066f995a0dca046d0c7ea7f5ffdd8e3f1f53c6b6dce909d1693650504921aad62f1a@194.163.167.177:30301
enode://c7a38ecc7fd5849eaefb3e928f882ab2f1260d5591bd1fef1db39c8ae0d9fe21d86e2d4efee6def0f4f16d0b6103f86f92f7e910295b849266fef83f05768596@10.244.1.77:30301
enode://9160713d41656154ce3fdaa9d0f9799dd8546652b1784edecf82ce7a5b54a977f897ea617a9b3b4db513dc6b0dc98c1c3ad8a1914075ab87ded4e367c89dcd3b@10.244.2.53:30301
273 changes: 211 additions & 62 deletions cicd/devnet/genesis.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cicd/entry.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash
if test -z "$NETWORK"
then
echo "NETWORK env Must be set, mainnet/testnet/devnet"
echo "NETWORK env Must be set, mainnet/testnet/devnet/local"
exit 1
fi

echo "Select to run $NETWORK..."
ln -s /usr/bin/XDC-$NETWORK /usr/bin/XDC
cp /work/$NETWORK/* /work
cp -n /work/$NETWORK/* /work
wanwiset25 marked this conversation as resolved.
Show resolved Hide resolved

echo "Start Node..."
/work/start.sh
10 changes: 10 additions & 0 deletions cicd/local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To set up local xdpos you need pass env NETWORK=local and inject 2 files when starting the container
1. genesis.json - deploy to path "/work/genesis.json" in the container.
- Creating genesis.json using puppeth
1. "make puppeth" from base repo directory
2. run the binary (genesis wizard) "./build/bin/puppeth"
3. the output genesis.json will be in your ~/.puppeth directory

2. bootnodes.list - deploy to path "/work/bootnodes.list" in the container.
- check example bootnode format in cicd/devnet or cicd/testnet
- REQUIRES newline at the end of the file, or the last line won't read
67 changes: 67 additions & 0 deletions cicd/local/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
gzliudan marked this conversation as resolved.
Show resolved Hide resolved
set -eo pipefail

if [ ! -d /work/xdcchain/XDC/chaindata ]
then
if test -z "$PRIVATE_KEY"
then
echo "PRIVATE_KEY environment variable has not been set."
exit 1
fi
echo $PRIVATE_KEY >> /tmp/key
wallet=$(XDC account import --password .pwd --datadir /work/xdcchain /tmp/key | awk -F '[{}]' '{print $2}')
XDC --datadir /work/xdcchain init /work/genesis.json
else
wallet=$(XDC account list --datadir /work/xdcchain | head -n 1 | awk -F '[{}]' '{print $2}')
fi

input="/work/bootnodes.list"
bootnodes=""
while IFS= read -r line
do
if [ -z "${bootnodes}" ]
then
bootnodes=$line
else
bootnodes="${bootnodes},$line"
fi
done < "$input"

log_level="${LOG_LEVEL:-3}"

gzliudan marked this conversation as resolved.
Show resolved Hide resolved
port="${PORT:-30303}"

rpc_port="${RPC_PORT:-8545}"

ws_port="${WS_PORT:-8555}"

netstats="${NODE_NAME}-${wallet}:xinfin_xdpos_hybrid_network_stats@devnetstats.apothem.network:2000"


echo "Running a node with wallet: ${wallet}"
echo "Starting nodes with $bootnodes ..."

# Note: --gcmode=archive means node will store all historical data. This will lead to high memory usage. But sync mode require archive to sync
# https://github.com/XinFinOrg/XDPoSChain/issues/268

XDC --ethstats ${netstats} \
--gcmode archive \
--bootnodes ${bootnodes} \
--syncmode full \
--datadir /work/xdcchain \
--networkid 551 \
-port $port \
--rpc --rpccorsdomain "*" \
--rpcaddr 0.0.0.0 \
--rpcport $rpc_port \
--rpcapi db,eth,debug,net,shh,txpool,personal,web3,XDPoS \
--rpcvhosts "*" \
--unlock "${wallet}" \
--password /work/.pwd --mine \
--gasprice "1" --targetgaslimit "420000000" \
--verbosity ${log_level} \
--debugdatadir /work/xdcchain \
--ws \
--wsaddr=0.0.0.0 \
--wsport $ws_port \
--wsorigins "*" 2>&1 >>/work/xdcchain/xdc.log | tee -a /work/xdcchain/xdc.log
gzliudan marked this conversation as resolved.
Show resolved Hide resolved
wanwiset25 marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 6 additions & 6 deletions cmd/puppeth/wizard_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ func (w *wizard) makeGenesis() {
Difficulty: big.NewInt(524288),
Alloc: make(core.GenesisAlloc),
Config: &params.ChainConfig{
HomesteadBlock: big.NewInt(1),
EIP150Block: big.NewInt(2),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(4),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
},
}
// Figure out which consensus engine to choose
Expand Down Expand Up @@ -147,7 +147,7 @@ func (w *wizard) makeGenesis() {
fmt.Println()
fmt.Printf("Proportion of total masternodes v2 vote collection to generate a QC (float value), should be two thirds of masternodes? (default = %f)\n", 0.667)
genesis.Config.XDPoS.V2.CurrentConfig.CertThreshold = w.readDefaultFloat(0.667)

genesis.Config.XDPoS.V2.CurrentConfig.MaxMasternodes = 108
genesis.Config.XDPoS.V2.AllConfigs[0] = genesis.Config.XDPoS.V2.CurrentConfig

fmt.Println()
Expand Down
36 changes: 18 additions & 18 deletions common/constants/constants.go.devnet
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ const (

var Rewound = uint64(0)

var TIP2019Block = big.NewInt(1)
var TIPSigning = big.NewInt(225000)
var TIPRandomize = big.NewInt(225000)
var TIP2019Block = big.NewInt(0)
var TIPSigning = big.NewInt(0)
var TIPRandomize = big.NewInt(0)

var TIPV2SwitchBlock = big.NewInt(7074000)
var TIPV2SwitchBlock = big.NewInt(1800)

var TIPIncreaseMasternodes = big.NewInt(225000) // Upgrade MN Count at Block.
var TIPNoHalvingMNReward = big.NewInt(429987) // hardfork no halving masternodes reward
var BlackListHFNumber = uint64(225000)
var TIPXDCX = big.NewInt(225000)
var TIPXDCXLending = big.NewInt(225000)
var TIPXDCXCancellationFee = big.NewInt(225000)
var TIPXDCXCancellationFeeTestnet = big.NewInt(225000)
var TIPXDCXMinerDisable = big.NewInt(15894900)
var TIPXDCXReceiverDisable = big.NewInt(18018000)
var BerlinBlock = big.NewInt(16832700)
var LondonBlock = big.NewInt(16832700)
var MergeBlock = big.NewInt(16832700)
var ShanghaiBlock = big.NewInt(16832700)
var Eip1559Block = big.NewInt(23035500)
var TIPIncreaseMasternodes = big.NewInt(0) // Upgrade MN Count at Block.
var TIPNoHalvingMNReward = big.NewInt(0) // hardfork no halving masternodes reward
var BlackListHFNumber = uint64(0)
var TIPXDCX = big.NewInt(0)
var TIPXDCXLending = big.NewInt(0)
var TIPXDCXCancellationFee = big.NewInt(0)
var TIPXDCXCancellationFeeTestnet = big.NewInt(0)
var TIPXDCXMinerDisable = big.NewInt(0)
var TIPXDCXReceiverDisable = big.NewInt(0)
var BerlinBlock = big.NewInt(0)
var LondonBlock = big.NewInt(0)
var MergeBlock = big.NewInt(0)
var ShanghaiBlock = big.NewInt(0)
var Eip1559Block = big.NewInt(0)

var TIPXDCXTestnet = big.NewInt(0)
var IsTestnet bool = false
Expand Down
Loading
Loading