From 504bf85a73337953d32dd7a56b22dbe4a1176efa Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Mon, 5 Aug 2024 14:58:20 +0400 Subject: [PATCH 1/7] add check for new subnet --- cicd/util.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cicd/util.js b/cicd/util.js index 35d6156..1f202ab 100644 --- a/cicd/util.js +++ b/cicd/util.js @@ -69,17 +69,21 @@ async function getGapSubnet(config) { params: ["latest"], id: 1, }; - await axios.post(config.subnetURL, data).then((response) => { + await axios.post(config.subnetURL, data, {timeout: 2000}).then((response) => { + console.log(response) if (response.status == 200) { epochBlockNum = response.data.result.EpochBlockNumber; gapBlockNum = epochBlockNum-450+1 - } else { + return gapBlockNum + } + if (response.status == -32601){ + return 0 + } 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) { From 6b0e2ee6ce24d98f2e401e2ce513a16624bd28af Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Mon, 5 Aug 2024 15:00:02 +0400 Subject: [PATCH 2/7] timeout --- cicd/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cicd/util.js b/cicd/util.js index 1f202ab..918ad72 100644 --- a/cicd/util.js +++ b/cicd/util.js @@ -69,7 +69,7 @@ async function getGapSubnet(config) { params: ["latest"], id: 1, }; - await axios.post(config.subnetURL, data, {timeout: 2000}).then((response) => { + await axios.post(config.subnetURL, data, {timeout: 10000}).then((response) => { console.log(response) if (response.status == 200) { epochBlockNum = response.data.result.EpochBlockNumber; @@ -94,7 +94,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) From 0dfc46733e77085f57b434f2a26f690ea1dcf3a0 Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Mon, 5 Aug 2024 15:33:48 +0400 Subject: [PATCH 3/7] remove WALLET from env key --- cicd/.env.example | 4 ++-- cicd/README.md | 8 ++++---- cicd/full.js | 10 +++++----- cicd/lite.js | 10 +++++----- cicd/reversefull.js | 10 +++++----- 5 files changed, 21 insertions(+), 21 deletions(-) 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; From 9bb6e24ed5e0b4b6c5797b4229dea5a6474f96b6 Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Tue, 6 Aug 2024 22:37:47 +0400 Subject: [PATCH 4/7] upd --- cicd/util.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cicd/util.js b/cicd/util.js index 918ad72..59fd0e1 100644 --- a/cicd/util.js +++ b/cicd/util.js @@ -69,21 +69,26 @@ async function getGapSubnet(config) { params: ["latest"], id: 1, }; - await axios.post(config.subnetURL, data, {timeout: 10000}).then((response) => { - console.log(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 0 + } + console.log("response.data.error", response.data.error) + throw Error("error in subnet gapblock response") + } epochBlockNum = response.data.result.EpochBlockNumber; gapBlockNum = epochBlockNum-450+1 return gapBlockNum - } - if (response.status == -32601){ - return 0 - } + } else { console.log("response.status", response.status); // console.log("response.data", response.data); throw Error("could not get gapblock in subnet"); - + } }); + } async function getEpochParentnet(config) { From 019b1435def89d2a43a618c10f1927472932673e Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Tue, 6 Aug 2024 22:43:52 +0400 Subject: [PATCH 5/7] as --- cicd/util.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cicd/util.js b/cicd/util.js index 59fd0e1..5451b76 100644 --- a/cicd/util.js +++ b/cicd/util.js @@ -81,7 +81,11 @@ async function getGapSubnet(config) { } epochBlockNum = response.data.result.EpochBlockNumber; gapBlockNum = epochBlockNum-450+1 + if (gapBlockNum < 0){ + gapBlockNum = 0 + } return gapBlockNum + } else { console.log("response.status", response.status); // console.log("response.data", response.data); From 2f3e5fba85e4e14054857b988410dbe391dc0648 Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Wed, 7 Aug 2024 16:25:17 +0400 Subject: [PATCH 6/7] gsbn = 1 not 0 --- cicd/util.js | 6 +++--- network.config.json | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cicd/util.js b/cicd/util.js index 5451b76..c136518 100644 --- a/cicd/util.js +++ b/cicd/util.js @@ -74,15 +74,15 @@ async function getGapSubnet(config) { if (response.status == 200) { if (response.data.error){ if (response.data.error.code == -32601){ - return 0 + 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 < 0){ - gapBlockNum = 0 + if (gapBlockNum < 1){ + gapBlockNum = 1 } return gapBlockNum diff --git a/network.config.json b/network.config.json index b88ee18..f351d39 100644 --- a/network.config.json +++ b/network.config.json @@ -1,6 +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/" -} + "xdcsubnet": "http://localhost:8545", + "xdcparentnet": "https://erpc.apothem.network/", + "xdcdevnet": "", + "xdctestnet": "" +} \ No newline at end of file From ee7bc1b156826d4e30fec0f1d661c4c27481559f Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Fri, 4 Oct 2024 14:40:12 +0400 Subject: [PATCH 7/7] fix network.config.json --- network.config.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/network.config.json b/network.config.json index f351d39..a397ecc 100644 --- a/network.config.json +++ b/network.config.json @@ -1,6 +1,6 @@ { - "xdcsubnet": "http://localhost:8545", - "xdcparentnet": "https://erpc.apothem.network/", - "xdcdevnet": "", - "xdctestnet": "" + "xdcparentnet": "https://devnetstats.apothem.network/devnet", + "xdcsubnet": "https://devnetstats.apothem.network/subnet", + "xdcdevnet": "https://devnetstats.apothem.network/devnet", + "xdctestnet": "https://erpc.apothem.network/" } \ No newline at end of file