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

add check for gapblock when new subnet has not reached 450 blocks #50

Merged
merged 7 commits into from
Oct 4, 2024
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
4 changes: 2 additions & 2 deletions cicd/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PARENTNET_URL=
SUBNET_URL=
PARENTNET_WALLET_PK=0x2222222222222222222222222222222222222222222222222222222222222222
SUBNET_WALLET_PK=0x1111111111111111111111111111111111111111111111111111111111111111
PARENTNET_PK=0x2222222222222222222222222222222222222222222222222222222222222222
SUBNET_PK=0x1111111111111111111111111111111111111111111111111111111111111111
8 changes: 4 additions & 4 deletions cicd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions cicd/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions cicd/lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions cicd/reversefull.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 16 additions & 3 deletions cicd/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion network.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"xdcsubnet": "https://devnetstats.apothem.network/subnet",
"xdcdevnet": "https://devnetstats.apothem.network/devnet",
"xdctestnet": "https://erpc.apothem.network/"
}
}
Loading