Skip to content

Commit

Permalink
cmd/jsutil: dump MinGasPrice for validator (#2314)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzckck authored Mar 21, 2024
1 parent ebe88c0 commit 1324884
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/jsutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
```
3 changes: 3 additions & 0 deletions cmd/jsutils/gettxcount.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import program from "commander";
program.option("--rpc <rpc>", "Rpc");
program.option("--startNum <startNum>", "start num")
program.option("--endNum <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>", "miner", "")
program.parse(process.argv);

Expand Down
15 changes: 14 additions & 1 deletion cmd/jsutils/getvalidatorversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 1324884

Please sign in to comment.