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

tool: update jsutils tool #2898

Merged
merged 1 commit into from
Feb 17, 2025
Merged
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
13 changes: 8 additions & 5 deletions cmd/jsutils/getchainstatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ program.option("--startNum <startNum>", "start num")
program.option("--endNum <endNum>", "end num")
program.option("--miner <miner>", "miner", "")
program.option("--num <Num>", "validator num", 21)
program.option("--turnLength <Num>", "the consecutive block length", 4)
program.option("--topNum <Num>", "top num of address to be displayed", 20)
program.option("--blockNum <Num>", "block num", 0)
program.option("-h, --help", "")
Expand Down Expand Up @@ -34,7 +35,7 @@ function printUsage() {
console.log("\nExample:");
// mainnet https://bsc-mainnet.nodereal.io/v1/454e504917db4f82b756bd0cf6317dce
console.log(" node getchainstatus.js GetMaxTxCountInBlockRange --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000005")
console.log(" node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21")
console.log(" node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21 --turnLength 4")
console.log(" node getchainstatus.js GetTopAddr --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010 --topNum 10")
console.log(" node getchainstatus.js GetSlashCount --rpc https://bsc-testnet-dataseed.bnbchain.org --blockNum 40000001") // default: latest block
console.log(" node getchainstatus.js GetPerformanceData --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010")
Expand Down Expand Up @@ -193,12 +194,13 @@ async function getMaxTxCountInBlockRange() {
// 2.cmd: "GetBinaryVersion", usage:
// node getchainstatus.js GetBinaryVersion \
// --rpc https://bsc-testnet-dataseed.bnbchain.org \
// --num(optional): defualt 21, the number of blocks that will be checked
// --num(optional): default 21, the number of blocks that will be checked
// --turnLength(optional): default 4, the consecutive block length
async function getBinaryVersion() {
const blockNum = await provider.getBlockNumber();
console.log(blockNum);
let turnLength = program.turnLength
for (let i = 0; i < program.num; i++) {
let blockData = await provider.getBlock(blockNum - i);
let blockData = await provider.getBlock(blockNum - i*turnLength);
// 1.get Geth client version
let major = ethers.toNumber(ethers.dataSlice(blockData.extraData, 2, 3))
let minor = ethers.toNumber(ethers.dataSlice(blockData.extraData, 3, 4))
Expand All @@ -215,7 +217,8 @@ async function getBinaryVersion() {
lastGasPrice = txData.gasPrice
break
}
console.log(blockData.miner, "version =", major + "." + minor + "." + patch, " MinGasPrice = " + lastGasPrice)
var moniker = await getValidatorMoniker(blockData.miner, blockNum)
console.log(blockNum - i*turnLength, blockData.miner, "version =", major + "." + minor + "." + patch, " MinGasPrice = " + lastGasPrice, moniker)
}
};

Expand Down