Skip to content

Commit

Permalink
optimize deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
wanwiset25 committed Nov 16, 2023
1 parent e3585e4 commit e37cb89
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 64 deletions.
2 changes: 0 additions & 2 deletions deployment.config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
],
"gap": 450,
"epoch": 900
"xdcparentnet": "https://devnetstats.apothem.network/devnet",
"xdcsubnet": "https://devnetstats.apothem.network/subnet"
}
27 changes: 14 additions & 13 deletions docker/deploy_csc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,30 @@ if [[ ${PRIVATE_KEY::2} == "0x" ]]; then
fi
echo "PRIVATE_KEY=${PRIVATE_KEY}" > .env

if [[ -z "$PARENTCHAIN" ]]; then
echo 'PARENTCHAIN is not set, default to devnet'
DEPLOY_NET=xdcdevnet
if [[ -z "$PARENTCHAIN_URL" ]]; then
echo "PARENTCHAIN_URL not specified"
exit 1
else
echo "PARENTCHAIN=$PARENTCHAIN"
if [[ $PARENTCHAIN == 'devnet' || $PARENTCHAIN == 'xdcdevnet' ]]; then
DEPLOY_NET='xdcdevnet'
fi
if [[ $PARENTCHAIN == 'testnet' || $PARENTCHAIN == 'xdctestnet' ]]; then
DEPLOY_NET='xdctestnet'
fi
echo "Deploying to $DEPLOY_NET"
cat network.config.json | sed -e "s/\"xdcparentnet\".*/\"xdcparentnet\": \"$PARENTCHAIN_URL\",/" > temp.json
mv temp.json network.config.json
fi

if [[ -z "$SUBNET_URL" ]]; then
echo "SUBNET_URL not specified"
exit 1
else
cat network.config.json | sed -e "s/\"xdcsubnet\".*/\"xdcsubnet\": \"$SUBNET_URL\",/" > temp.json
mv temp.json network.config.json
fi

if [[ $RELAYER_MODE == 'full' ]]
then
echo "Deploying full CSC"
npx hardhat run scripts/FullCheckpointDeploy.js --network $DEPLOY_NET 2>&1 | tee csc.log
npx hardhat run scripts/FullCheckpointDeploy.js --network xdcparentnet 2>&1 | tee csc.log
elif [[ $RELAYER_MODE == 'lite' ]]
then
echo "Deploying lite CSC"
npx hardhat run scripts/LiteCheckpointDeploy.js --network $DEPLOY_NET 2>&1 | tee csc.log
npx hardhat run scripts/LiteCheckpointDeploy.js --network xdcparentnet 2>&1 | tee csc.log
else
echo "Unknown RELAYER_MODE"
exit 1
Expand Down
50 changes: 26 additions & 24 deletions docker/deploy_proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,40 @@ if [[ ${PRIVATE_KEY::2} == "0x" ]]; then
fi
echo "PRIVATE_KEY=${PRIVATE_KEY}" > .env

if [[ -z "$PARENTCHAIN" ]]; then
echo 'PARENTCHAIN is not set, default to devnet'
DEPLOY_NET=xdcdevnet
if [[ -z "$PARENTCHAIN_URL" ]]; then
echo "PARENTCHAIN_URL not specified"
exit 1
else
echo "PARENTCHAIN=$PARENTCHAIN"
if [[ $PARENTCHAIN == 'devnet' || $PARENTCHAIN == 'xdcdevnet' ]]; then
DEPLOY_NET='xdcdevnet'
fi
if [[ $PARENTCHAIN == 'testnet' || $PARENTCHAIN == 'xdctestnet' ]]; then
DEPLOY_NET='xdctestnet'
fi
echo "Deploying to $DEPLOY_NET"
cat network.config.json | sed -e "s/\"xdcparentnet\".*/\"xdcparentnet\": \"$PARENTCHAIN_URL\",/" > temp.json
mv temp.json network.config.json
fi

DEPLOY=$(npx hardhat run scripts/proxy/ProxyGatewayDeploy.js --network $DEPLOY_NET)
if [[ -z "$SUBNET_URL" ]]; then
echo "SUBNET_URL not specified"
exit 1
else
cat network.config.json | sed -e "s/\"xdcsubnet\".*/\"xdcsubnet\": \"$SUBNET_URL\",/" > temp.json
mv temp.json network.config.json
fi

DEPLOY=$(npx hardhat run scripts/proxy/ProxyGatewayDeploy.js --network xdcparentnet)
PROXY=$(echo $DEPLOY | awk '{print $NF}')
echo "Proxy Gateway Deployed: $PROXY"
JSON="{\"proxyGateway\": \"$PROXY\"}"
echo $JSON > upgrade.config.json
sleep 10
echo "PROXY_GATEWAY=$PROXY" >> config/common.env || echo 'config not mounted'


UPGRADE=$(npx hardhat run scripts/proxy/UpgradeCSC.js --network xdcparentnet | awk '{print $NF}')
FULL_CSC=$(echo $UPGRADE | cut -d' ' -f4)
FULL_CSC="FULL_CSC=$FULL_CSC"
echo $FULL_CSC >> config/common.env || echo 'config not mounted'

UPGRADE=$(npx hardhat run scripts/proxy/UpgradeCSC.js --network $DEPLOY_NET | awk '{print $NF}')
FULL=$(echo $UPGRADE | cut -d' ' -f4)
FULL="FULL=$FULL"
echo $FULL > csc.env

LITE=$(echo $UPGRADE | cut -d' ' -f5)
LITE="LITE=$LITE"
echo $LITE >> csc.env
LITE_CSC=$(echo $UPGRADE | cut -d' ' -f5)
LITE_CSC="LITE_CSC=$LITE_CSC"
echo $LITE_CSC >> config/common.env || echo 'config not mounted'
echo "Upgraded Proxy Gateway with CSC"
echo "$FULL"
echo "$LITE"
echo "$FULL_CSC"
echo "$LITE_CSC"

cp upgrade.config.json config/upgrade.config.json || echo 'config not mounted'
cp csc.env config/csc.env || echo 'config not mounted'
34 changes: 22 additions & 12 deletions docker/upgrade_csc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ if [[ ${PRIVATE_KEY::2} == "0x" ]]; then
fi
echo "PRIVATE_KEY=${PRIVATE_KEY}" > .env

if [[ -z "$PARENTCHAIN" ]]; then
echo 'PARENTCHAIN is not set, default to devnet'
DEPLOY_NET=xdcdevnet
if [[ -z "$PARENTCHAIN_URL" ]]; then
echo "PARENTCHAIN_URL not specified"
exit 1
else
echo "PARENTCHAIN=$PARENTCHAIN"
if [[ $PARENTCHAIN == 'devnet' || $PARENTCHAIN == 'xdcdevnet' ]]; then
DEPLOY_NET='xdcdevnet'
fi
if [[ $PARENTCHAIN == 'testnet' || $PARENTCHAIN == 'xdctestnet' ]]; then
DEPLOY_NET='xdctestnet'
fi
echo "Deploying to $DEPLOY_NET"
cat network.config.json | sed -e "s/\"xdcparentnet\".*/\"xdcparentnet\": \"$PARENTCHAIN_URL\",/" > temp.json
mv temp.json network.config.json
fi

if [[ -z "$SUBNET_URL" ]]; then
echo "SUBNET_URL not specified"
exit 1
else
cat network.config.json | sed -e "s/\"xdcsubnet\".*/\"xdcsubnet\": \"$SUBNET_URL\",/" > temp.json
mv temp.json network.config.json
fi

if [[ -z "$PROXY_GATEWAY" ]]; then
echo "PROXY_GATEWAY not specified"
exit 1
else
JSON="{\"proxyGateway\": \"$PROXY_GATEWAY\"}"
echo $JSON > upgrade.config.json
fi

# UPGRADE=$(npx hardhat run scripts/proxy/UpgradeCSC.js --network xdcparentnet | awk '{print $NF}')
Expand All @@ -49,5 +59,5 @@ fi
# echo "$FULL"
# echo "$LITE"

npx hardhat run scripts/proxy/UpgradeCSC.js --network $DEPLOY_NET
npx hardhat run scripts/proxy/UpgradeCSC.js --network xdcparentnet
# echo "Upgraded Proxy Gateway with CSC"
15 changes: 3 additions & 12 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ const { VoidSigner } = require("ethers");
require("@nomiclabs/hardhat-waffle");
require("hardhat-gas-reporter");
require("dotenv").config();

try {
var network = require("./deployment.config.json");
}
catch (e) {
var network = {
"xdcparentnet": "https://devnetstats.apothem.network/devnet",
"xdcsubnet": "https://devnetstats.apothem.network/subnet"
}
}
const network = require("./network.config.json");

/**
* @type import('hardhat/config').HardhatUserConfig
Expand Down Expand Up @@ -44,14 +35,14 @@ module.exports = {
],
},
xdcdevnet: {
url: "https://devnetstats.apothem.network/devnet",
url: network["xdcdevnet"],
accounts: [
process.env.PRIVATE_KEY ||
"1234567890123456789012345678901234567890123456789012345678901234",
],
},
xdctestnet: {
url: "https://erpc.apothem.network/",
url: network["xdctestnet"],
accounts: [
process.env.PRIVATE_KEY ||
"1234567890123456789012345678901234567890123456789012345678901234",
Expand Down
6 changes: 6 additions & 0 deletions network.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"xdcparentnet": "https://devnetstats.apothem.network/devnet",
"xdcsubnet": "https://devnetstats.apothem.network/subnet",
"xdcdevnet": "https://devnetstats.apothem.network/devnet",
"xdctestnet": "https://erpc.apothem.network/"
}
2 changes: 1 addition & 1 deletion scripts/utils/subnet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fetch = require("node-fetch").default;
const network = require("../../deployment.config.json");
const network = require("../../network.config.json");
async function data() {
const block0 = {
jsonrpc: "2.0",
Expand Down

0 comments on commit e37cb89

Please sign in to comment.