-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into BEP-341-produce-consecutive-blocks
- Loading branch information
Showing
64 changed files
with
1,147 additions
and
1,141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
CVE-2024-34478 # "CWE-754: Improper Check for Unusual or Exceptional Conditions." This vulnerability is BTC only, BSC does not have the issue. | ||
CVE-2024-6104 # "CWE-532: Information Exposure Through Log Files" This is caused by the vulnerabilities go-retryablehttp@v0.7.4, it is only used in cmd devp2p, impact is limited. will upgrade to v0.7.7 later |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { ethers } from "ethers"; | ||
import program from "commander"; | ||
|
||
program.option("--rpc <rpc>", "Rpc"); | ||
program.option("--startNum <startNum>", "start num") | ||
program.option("--endNum <endNum>", "end num") | ||
program.parse(process.argv); | ||
|
||
const provider = new ethers.JsonRpcProvider(program.rpc) | ||
|
||
const main = async () => { | ||
let txCountTotal = 0; | ||
let gasUsedTotal = 0; | ||
let inturnBlocks = 0; | ||
let justifiedBlocks = 0; | ||
for (let i = program.startNum; i < program.endNum; i++) { | ||
let txCount = await provider.send("eth_getBlockTransactionCountByNumber", [ | ||
ethers.toQuantity(i)]); | ||
txCountTotal += ethers.toNumber(txCount) | ||
|
||
let header = await provider.send("eth_getHeaderByNumber", [ | ||
ethers.toQuantity(i)]); | ||
let gasUsed = eval(eval(header.gasUsed).toString(10)) | ||
gasUsedTotal += gasUsed | ||
let difficulty = eval(eval(header.difficulty).toString(10)) | ||
if (difficulty == 2) { | ||
inturnBlocks += 1 | ||
} | ||
let timestamp = eval(eval(header.timestamp).toString(10)) | ||
|
||
let justifiedNumber = await provider.send("parlia_getJustifiedNumber", [ | ||
ethers.toQuantity(i)]); | ||
if (justifiedNumber + 1 == i) { | ||
justifiedBlocks += 1 | ||
} else { | ||
console.log("justified unexpected", "BlockNumber =", i,"justifiedNumber",justifiedNumber) | ||
} | ||
console.log("BlockNumber =", i, "mod =", i%4, "miner =", header.miner , "difficulty =", difficulty, "txCount =", ethers.toNumber(txCount), "gasUsed", gasUsed, "timestamp", timestamp) | ||
} | ||
|
||
let blockCount = program.endNum - program.startNum | ||
let txCountPerBlock = txCountTotal/blockCount | ||
|
||
let startHeader = await provider.send("eth_getHeaderByNumber", [ | ||
ethers.toQuantity(program.startNum)]); | ||
let startTime = eval(eval(startHeader.timestamp).toString(10)) | ||
let endHeader = await provider.send("eth_getHeaderByNumber", [ | ||
ethers.toQuantity(program.endNum)]); | ||
let endTime = eval(eval(endHeader.timestamp).toString(10)) | ||
let timeCost = endTime - startTime | ||
let avgBlockTime = timeCost/blockCount | ||
let inturnBlocksRatio = inturnBlocks/blockCount | ||
let justifiedBlocksRatio = justifiedBlocks/blockCount | ||
let tps = txCountTotal/timeCost | ||
let M = 1000000 | ||
let avgGasUsedPerBlock = gasUsedTotal/blockCount/M | ||
let avgGasUsedPerSecond = gasUsedTotal/timeCost/M | ||
|
||
console.log("Get the performance between [", program.startNum, ",", program.endNum, ")"); | ||
console.log("txCountPerBlock =", txCountPerBlock, "txCountTotal =", txCountTotal, "BlockCount =", blockCount, "avgBlockTime =", avgBlockTime, "inturnBlocksRatio =", inturnBlocksRatio, "justifiedBlocksRatio =", justifiedBlocksRatio); | ||
console.log("txCountPerSecond =", tps, "avgGasUsedPerBlock =", avgGasUsedPerBlock, "avgGasUsedPerSecond =", avgGasUsedPerSecond); | ||
}; | ||
|
||
main().then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.