diff --git a/Makefile b/Makefile index 7f9d6bc6f2..24c6425f59 100644 --- a/Makefile +++ b/Makefile @@ -10,18 +10,12 @@ GORUN = go run #? XDC: Build XDC. XDC: + @echo "Rebuild the XDC" go run build/ci.go install ./cmd/XDC @echo "Done building." @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 - +XDC-devnet-local: XDC @echo "Run the devnet script in local" cd cicd/devnet && ./start-local-devnet.sh diff --git a/cicd/Dockerfile b/cicd/Dockerfile index 7e1b6c7f8f..3621285e88 100644 --- a/cicd/Dockerfile +++ b/cicd/Dockerfile @@ -5,20 +5,11 @@ FROM golang:1.25-alpine AS builder RUN apk add make build-base linux-headers -COPY . /builder +WORKDIR /builder -RUN cd /builder && make puppeth +COPY . . -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.local /builder/common/constants.go -RUN cd /builder && make && mv /builder/build/bin/XDC /builder/build/bin/XDC-local +RUN make puppeth && make # The runtime image FROM alpine:3 @@ -30,10 +21,7 @@ WORKDIR /work RUN apk add --no-cache bash curl COPY --from=builder /builder/build/bin/puppeth /usr/bin -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 --from=builder /builder/build/bin/XDC /usr/bin/XDC # # Copy over files ADD cicd/local /work/local diff --git a/cicd/entry.sh b/cicd/entry.sh index 0cd11b4ea4..97118b672e 100755 --- a/cicd/entry.sh +++ b/cicd/entry.sh @@ -1,13 +1,20 @@ #!/bin/bash -if test -z "$NETWORK" -then - echo "NETWORK env Must be set, mainnet/testnet/devnet/local" - exit 1 -fi + +case "$NETWORK" in + "") + echo "NETWORK environment variable must be set. Allowed values: mainnet/testnet/devnet/local" + exit 1 + ;; + mainnet|testnet|devnet|local) + ;; + *) + echo "Invalid NETWORK: $NETWORK. Allowed: mainnet/testnet/devnet/local" + exit 1 + ;; +esac echo "Select to run $NETWORK..." -ln -s /usr/bin/XDC-$NETWORK /usr/bin/XDC -cp -n /work/$NETWORK/* /work +cp -n /work/"$NETWORK"/* /work echo "Start Node..." -/work/start.sh \ No newline at end of file +/work/start.sh diff --git a/common/constants.go b/common/constants.go index 160d1eb27f..6b6eae65f5 100644 --- a/common/constants.go +++ b/common/constants.go @@ -1,8 +1,4 @@ // Notice: this file only saves const variables for all network. -// Please run the following commands after modify this file: -// cp common/constants.go common/constants/constants.go.testnet -// cp common/constants.go common/constants/constants.go.devnet -// cp common/constants.go common/constants/constants.go.local package common diff --git a/common/constants/constants.go.devnet b/common/constants/constants.go.devnet deleted file mode 100644 index 160d1eb27f..0000000000 --- a/common/constants/constants.go.devnet +++ /dev/null @@ -1,34 +0,0 @@ -// Notice: this file only saves const variables for all network. -// Please run the following commands after modify this file: -// cp common/constants.go common/constants/constants.go.testnet -// cp common/constants.go common/constants/constants.go.devnet -// cp common/constants.go common/constants/constants.go.local - -package common - -// const variables for all network. -const ( - RewardMasterPercent = 90 - RewardVoterPercent = 0 - RewardFoundationPercent = 10 - EpocBlockSecret = 800 - EpocBlockOpening = 850 - EpocBlockRandomize = 900 - MaxMasternodes = 18 - LimitPenaltyEpoch = 4 - LimitPenaltyEpochV2 = 0 - LimitThresholdNonceInQueue = 10 - DefaultMinGasPrice = 250000000 - MergeSignRange = 15 - RangeReturnSigner = 150 - MinimunMinerBlockPerEpoch = 1 - BlocksPerYearTest = uint64(200000) - BlocksPerYear = uint64(15768000) - OneYear = uint64(365 * 86400) - LiquidateLendingTradeBlock = uint64(100) - LimitTimeFinality = uint64(30) // limit in 30 block - - HexSignMethod = "e341eaa4" - HexSetSecret = "34d38600" - HexSetOpening = "e11f5ba2" -) diff --git a/common/constants/constants.go.local b/common/constants/constants.go.local deleted file mode 100644 index 160d1eb27f..0000000000 --- a/common/constants/constants.go.local +++ /dev/null @@ -1,34 +0,0 @@ -// Notice: this file only saves const variables for all network. -// Please run the following commands after modify this file: -// cp common/constants.go common/constants/constants.go.testnet -// cp common/constants.go common/constants/constants.go.devnet -// cp common/constants.go common/constants/constants.go.local - -package common - -// const variables for all network. -const ( - RewardMasterPercent = 90 - RewardVoterPercent = 0 - RewardFoundationPercent = 10 - EpocBlockSecret = 800 - EpocBlockOpening = 850 - EpocBlockRandomize = 900 - MaxMasternodes = 18 - LimitPenaltyEpoch = 4 - LimitPenaltyEpochV2 = 0 - LimitThresholdNonceInQueue = 10 - DefaultMinGasPrice = 250000000 - MergeSignRange = 15 - RangeReturnSigner = 150 - MinimunMinerBlockPerEpoch = 1 - BlocksPerYearTest = uint64(200000) - BlocksPerYear = uint64(15768000) - OneYear = uint64(365 * 86400) - LiquidateLendingTradeBlock = uint64(100) - LimitTimeFinality = uint64(30) // limit in 30 block - - HexSignMethod = "e341eaa4" - HexSetSecret = "34d38600" - HexSetOpening = "e11f5ba2" -) diff --git a/common/constants/constants.go.testnet b/common/constants/constants.go.testnet deleted file mode 100644 index 160d1eb27f..0000000000 --- a/common/constants/constants.go.testnet +++ /dev/null @@ -1,34 +0,0 @@ -// Notice: this file only saves const variables for all network. -// Please run the following commands after modify this file: -// cp common/constants.go common/constants/constants.go.testnet -// cp common/constants.go common/constants/constants.go.devnet -// cp common/constants.go common/constants/constants.go.local - -package common - -// const variables for all network. -const ( - RewardMasterPercent = 90 - RewardVoterPercent = 0 - RewardFoundationPercent = 10 - EpocBlockSecret = 800 - EpocBlockOpening = 850 - EpocBlockRandomize = 900 - MaxMasternodes = 18 - LimitPenaltyEpoch = 4 - LimitPenaltyEpochV2 = 0 - LimitThresholdNonceInQueue = 10 - DefaultMinGasPrice = 250000000 - MergeSignRange = 15 - RangeReturnSigner = 150 - MinimunMinerBlockPerEpoch = 1 - BlocksPerYearTest = uint64(200000) - BlocksPerYear = uint64(15768000) - OneYear = uint64(365 * 86400) - LiquidateLendingTradeBlock = uint64(100) - LimitTimeFinality = uint64(30) // limit in 30 block - - HexSignMethod = "e341eaa4" - HexSetSecret = "34d38600" - HexSetOpening = "e11f5ba2" -)