diff --git a/cicd/.env.example b/cicd/.env.example index 2680960..fb38800 100644 --- a/cicd/.env.example +++ b/cicd/.env.example @@ -1,4 +1,4 @@ PARENTNET_URL= SUBNET_URL= -PARENTNET_WALLET_PK=0x2222222222222222222222222222222222222222222222222222222222222222 -SUBNET_WALLET_PK=0x1111111111111111111111111111111111111111111111111111111111111111 +PARENTNET_PK=0x2222222222222222222222222222222222222222222222222222222222222222 +SUBNET_PK=0x1111111111111111111111111111111111111111111111111111111111111111 diff --git a/cicd/README.md b/cicd/README.md index 49d4c29..d4cf559 100644 --- a/cicd/README.md +++ b/cicd/README.md @@ -8,8 +8,8 @@ Based on the provided `.env.example`, create your own `.env` file with the follo - **`PARENTNET_URL`**: RPC URL for the parentnet endpoint. - **`SUBNET_URL`**: RPC URL for the subnet. -- **`PARENTNET_WALLET_PK`**: Private key used for CSC deployment, there should be some funds. -- **`SUBNET_WALLET_PK`**: Private key for subnet deployment. (only required for reverse CSC) +- **`PARENTNET_PK`**: Private key used for CSC deployment, there should be some funds. +- **`SUBNET_PK`**: Private key for subnet deployment. (only required for reverse CSC) #### Step 2: Deploy CSC You have a choice to deploy one of three types of CSC @@ -40,8 +40,8 @@ Based on the provided `.env.example`, create your own `.env` file with the follo - **`PARENTNET_URL`**: RPC URL for the parentnet endpoint. - **`SUBNET_URL`**: RPC URL for the subnet. -- **`PARENTNET_WALLET_PK`**: Private key used for CSC deployment, there should be some funds. -- **`SUBNET_WALLET_PK`**: Private key for subnet deployment. (only required for reverse CSC) +- **`PARENTNET_PK`**: Private key used for CSC deployment, there should be some funds. +- **`SUBNET_PK`**: Private key for subnet deployment. (only required for reverse CSC) #### Step 2: Create a `deployment.config.json` File to cicd/mount diff --git a/cicd/full.js b/cicd/full.js index 67e8bce..1d7f72b 100644 --- a/cicd/full.js +++ b/cicd/full.js @@ -18,16 +18,16 @@ async function main() { } function initDeployFull() { - const reqENV = ["PARENTNET_URL", "SUBNET_URL", "PARENTNET_WALLET_PK"]; + const reqENV = ["PARENTNET_URL", "SUBNET_URL", "PARENTNET_PK"]; const isEnabled = reqENV.every((envVar) => envVar in process.env); if (!isEnabled) { throw Error( - "incomplete ENVs, require PARENTNET_URL, SUBNET_URL, PARENTNET_WALLET_PK" + "incomplete ENVs, require PARENTNET_URL, SUBNET_URL, PARENTNET_PK" ); } - parentnetPK = process.env.PARENTNET_WALLET_PK.startsWith("0x") - ? process.env.PARENTNET_WALLET_PK - : `0x${process.env.PARENTNET_WALLET_PK}`; + parentnetPK = process.env.PARENTNET_PK.startsWith("0x") + ? process.env.PARENTNET_PK + : `0x${process.env.PARENTNET_PK}`; config["parentnetPK"] = parentnetPK; config["parentnetURL"] = process.env.PARENTNET_URL; config["subnetURL"] = process.env.SUBNET_URL; diff --git a/cicd/lite.js b/cicd/lite.js index edcc4d8..8dc6132 100644 --- a/cicd/lite.js +++ b/cicd/lite.js @@ -18,16 +18,16 @@ async function main() { } function initDeployLite() { - const reqENV = ["PARENTNET_URL", "SUBNET_URL", "PARENTNET_WALLET_PK"]; + const reqENV = ["PARENTNET_URL", "SUBNET_URL", "PARENTNET_PK"]; const isEnabled = reqENV.every((envVar) => envVar in process.env); if (!isEnabled) { throw Error( - "incomplete ENVs, require PARENTNET_URL, SUBNET_URL, PARENTNET_WALLET_PK" + "incomplete ENVs, require PARENTNET_URL, SUBNET_URL, PARENTNET_PK" ); } - parentnetPK = process.env.PARENTNET_WALLET_PK.startsWith("0x") - ? process.env.PARENTNET_WALLET_PK - : `0x${process.env.PARENTNET_WALLET_PK}`; + parentnetPK = process.env.PARENTNET_PK.startsWith("0x") + ? process.env.PARENTNET_PK + : `0x${process.env.PARENTNET_PK}`; config["parentnetPK"] = parentnetPK; config["parentnetURL"] = process.env.PARENTNET_URL; config["subnetURL"] = process.env.SUBNET_URL; diff --git a/cicd/reversefull.js b/cicd/reversefull.js index 695c4bc..b5a755f 100644 --- a/cicd/reversefull.js +++ b/cicd/reversefull.js @@ -18,16 +18,16 @@ async function main() { } function initDeployReverse() { - const reqENV = ["PARENTNET_URL", "SUBNET_URL", "SUBNET_WALLET_PK"]; + const reqENV = ["PARENTNET_URL", "SUBNET_URL", "SUBNET_PK"]; const isEnabled = reqENV.every((envVar) => envVar in process.env); if (!isEnabled) { throw Error( - "incomplete ENVs, require PARENTNET_URL, SUBNET_URL, SUBNET_WALLET_PK" + "incomplete ENVs, require PARENTNET_URL, SUBNET_URL, SUBNET_PK" ); } - subnetPK = process.env.SUBNET_WALLET_PK.startsWith("0x") - ? process.env.SUBNET_WALLET_PK - : `0x${process.env.SUBNET_WALLET_PK}`; + subnetPK = process.env.SUBNET_PK.startsWith("0x") + ? process.env.SUBNET_PK + : `0x${process.env.SUBNET_PK}`; config["parentnetURL"] = process.env.PARENTNET_URL; config["subnetURL"] = process.env.SUBNET_URL; config["subnetPK"] = subnetPK; diff --git a/cicd/util.js b/cicd/util.js index 35d6156..c136518 100644 --- a/cicd/util.js +++ b/cicd/util.js @@ -69,17 +69,30 @@ async function getGapSubnet(config) { params: ["latest"], id: 1, }; - await axios.post(config.subnetURL, data).then((response) => { + return await axios.post(config.subnetURL, data, {timeout: 10000}).then((response) => { + // console.log(response) if (response.status == 200) { + if (response.data.error){ + if (response.data.error.code == -32601){ + return 1 + } + console.log("response.data.error", response.data.error) + throw Error("error in subnet gapblock response") + } epochBlockNum = response.data.result.EpochBlockNumber; gapBlockNum = epochBlockNum-450+1 + if (gapBlockNum < 1){ + gapBlockNum = 1 + } + return gapBlockNum + } else { console.log("response.status", response.status); // console.log("response.data", response.data); throw Error("could not get gapblock in subnet"); } }); - return gapBlockNum + } async function getEpochParentnet(config) { @@ -90,7 +103,7 @@ async function getEpochParentnet(config) { params: ["latest"], id: 1, }; - await axios.post(config.parentnetURL, data).then((response) => { + await axios.post(config.parentnetURL, data, {timeout: 10000}).then((response) => { if (response.status == 200) { epochBlockNum = response.data.result.EpochBlockNumber; console.log("epochBlockNum", epochBlockNum) diff --git a/network.config.json b/network.config.json index b88ee18..a397ecc 100644 --- a/network.config.json +++ b/network.config.json @@ -3,4 +3,4 @@ "xdcsubnet": "https://devnetstats.apothem.network/subnet", "xdcdevnet": "https://devnetstats.apothem.network/devnet", "xdctestnet": "https://erpc.apothem.network/" -} +} \ No newline at end of file