From 1324884db7604b0d3fbcbdf8b2e75c2739bd80dc Mon Sep 17 00:00:00 2001 From: zzzckck <152148891+zzzckck@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:35:16 +0800 Subject: [PATCH] cmd/jsutil: dump MinGasPrice for validator (#2314) --- cmd/jsutils/README.md | 4 +++- cmd/jsutils/gettxcount.js | 3 +++ cmd/jsutils/getvalidatorversion.js | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cmd/jsutils/README.md b/cmd/jsutils/README.md index 30d512860..6fd4dcdf3 100644 --- a/cmd/jsutils/README.md +++ b/cmd/jsutils/README.md @@ -11,6 +11,7 @@ Install node.js dependency: npm install ``` ## Run +### 1.Get Validator's Information: Version, MinGasPrice mainnet validators version ```bash npm run startMainnet @@ -19,7 +20,8 @@ testnet validators version ```bash npm run startTestnet ``` -Transaction count + +### 2.Get Transaction Count ```bash node gettxcount.js --rpc ${url} --startNum ${start} --endNum ${end} --miner ${miner} (optional) ``` \ No newline at end of file diff --git a/cmd/jsutils/gettxcount.js b/cmd/jsutils/gettxcount.js index 921f80124..8bc7f2bdd 100644 --- a/cmd/jsutils/gettxcount.js +++ b/cmd/jsutils/gettxcount.js @@ -4,6 +4,9 @@ import program from "commander"; program.option("--rpc ", "Rpc"); program.option("--startNum ", "start num") program.option("--endNum ", "end num") +// --miner: +// specified: find the max txCounter from the specified validator +// not specified: find the max txCounter from all validators program.option("--miner ", "miner", "") program.parse(process.argv); diff --git a/cmd/jsutils/getvalidatorversion.js b/cmd/jsutils/getvalidatorversion.js index d0d9fc3d9..495b913f4 100644 --- a/cmd/jsutils/getvalidatorversion.js +++ b/cmd/jsutils/getvalidatorversion.js @@ -12,10 +12,23 @@ const main = async () => { console.log(blockNum); for (let i = 0; i < program.Num; i++) { let blockData = await provider.getBlock(blockNum - i); + // 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)) let patch = ethers.toNumber(ethers.dataSlice(blockData.extraData, 4, 5)) - console.log(blockData.miner, "version =", major + "." + minor + "." + patch) + + // 2.get minimum txGasPrice based on the last non-zero-gasprice transaction + let lastGasPrice = 0 + for (let txIndex = blockData.transactions.length - 1; txIndex >= 0; txIndex--) { + let txHash = blockData.transactions[txIndex] + let txData = await provider.getTransaction(txHash); + if (txData.gasPrice == 0) { + continue + } + lastGasPrice = txData.gasPrice + break + } + console.log(blockData.miner, "version =", major + "." + minor + "." + patch, " MinGasPrice = " + lastGasPrice) } }; main().then(() => process.exit(0))