mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-23 14:11:05 +00:00
Update Python Script to process Geth benchmarks
This commit is contained in:
@@ -28,7 +28,7 @@ from __future__ import annotations
|
|||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
import csv
|
import csv
|
||||||
from typing import List, Mapping, TypedDict
|
from typing import List, Mapping, TypedDict, no_type_check
|
||||||
|
|
||||||
|
|
||||||
class EthereumMinedBlockInformation(TypedDict):
|
class EthereumMinedBlockInformation(TypedDict):
|
||||||
@@ -69,7 +69,43 @@ class MinedBlockInformation(TypedDict):
|
|||||||
"""Block-level information for a mined block with both EVM and optional Substrate fields."""
|
"""Block-level information for a mined block with both EVM and optional Substrate fields."""
|
||||||
|
|
||||||
ethereum_block_information: EthereumMinedBlockInformation
|
ethereum_block_information: EthereumMinedBlockInformation
|
||||||
substrate_block_information: SubstrateMinedBlockInformation
|
substrate_block_information: SubstrateMinedBlockInformation | None
|
||||||
|
|
||||||
|
|
||||||
|
def substrate_block_information_ref_time(
|
||||||
|
block: SubstrateMinedBlockInformation | None,
|
||||||
|
) -> int | None:
|
||||||
|
if block is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return block["ref_time"]
|
||||||
|
|
||||||
|
|
||||||
|
def substrate_block_information_max_ref_time(
|
||||||
|
block: SubstrateMinedBlockInformation | None,
|
||||||
|
) -> int | None:
|
||||||
|
if block is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return block["max_ref_time"]
|
||||||
|
|
||||||
|
|
||||||
|
def substrate_block_information_proof_size(
|
||||||
|
block: SubstrateMinedBlockInformation | None,
|
||||||
|
) -> int | None:
|
||||||
|
if block is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return block["proof_size"]
|
||||||
|
|
||||||
|
|
||||||
|
def substrate_block_information_max_proof_size(
|
||||||
|
block: SubstrateMinedBlockInformation | None,
|
||||||
|
) -> int | None:
|
||||||
|
if block is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return block["max_proof_size"]
|
||||||
|
|
||||||
|
|
||||||
class Metric(TypedDict):
|
class Metric(TypedDict):
|
||||||
@@ -100,8 +136,19 @@ class Metrics(TypedDict):
|
|||||||
transaction_per_second: Metric
|
transaction_per_second: Metric
|
||||||
gas_per_second: Metric
|
gas_per_second: Metric
|
||||||
gas_block_fullness: Metric
|
gas_block_fullness: Metric
|
||||||
ref_time_block_fullness: Metric
|
ref_time_block_fullness: Metric | None
|
||||||
proof_size_block_fullness: Metric
|
proof_size_block_fullness: Metric | None
|
||||||
|
|
||||||
|
|
||||||
|
@no_type_check
|
||||||
|
def metrics_raw_item(
|
||||||
|
metrics: Metrics, name: str, target: str, index: int
|
||||||
|
) -> int | None:
|
||||||
|
l: list[int] = metrics.get(name, dict()).get("raw", dict()).get(target, dict())
|
||||||
|
try:
|
||||||
|
return l[index]
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class ExecutionReport(TypedDict):
|
class ExecutionReport(TypedDict):
|
||||||
@@ -144,12 +191,15 @@ BlockInformation = TypedDict(
|
|||||||
"Transaction Count": int,
|
"Transaction Count": int,
|
||||||
"TPS": int | None,
|
"TPS": int | None,
|
||||||
"GPS": int | None,
|
"GPS": int | None,
|
||||||
"Ref Time": int,
|
"Gas Mined": int,
|
||||||
"Max Ref Time": int,
|
"Block Gas Limit": int,
|
||||||
"Block Fullness Ref Time": int,
|
"Block Fullness Gas": float,
|
||||||
"Proof Size": int,
|
"Ref Time": int | None,
|
||||||
"Max Proof Size": int,
|
"Max Ref Time": int | None,
|
||||||
"Block Fullness Proof Size": int,
|
"Block Fullness Ref Time": int | None,
|
||||||
|
"Proof Size": int | None,
|
||||||
|
"Max Proof Size": int | None,
|
||||||
|
"Block Fullness Proof Size": int | None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
"""A typed dictionary used to hold all of the block information"""
|
"""A typed dictionary used to hold all of the block information"""
|
||||||
@@ -175,7 +225,7 @@ def main() -> None:
|
|||||||
report: ReportRoot = load_report(report_path)
|
report: ReportRoot = load_report(report_path)
|
||||||
|
|
||||||
# TODO: Remove this in the future, but for now, the target is fixed.
|
# TODO: Remove this in the future, but for now, the target is fixed.
|
||||||
target: str = "revive-dev-node-revm-solc"
|
target: str = sys.argv[2]
|
||||||
|
|
||||||
csv_writer = csv.writer(sys.stdout)
|
csv_writer = csv.writer(sys.stdout)
|
||||||
|
|
||||||
@@ -188,6 +238,12 @@ def main() -> None:
|
|||||||
|
|
||||||
resolved_blocks: list[BlockInformation] = []
|
resolved_blocks: list[BlockInformation] = []
|
||||||
for i, block_information in enumerate(blocks_information):
|
for i, block_information in enumerate(blocks_information):
|
||||||
|
mined_gas: int = block_information["ethereum_block_information"][
|
||||||
|
"mined_gas"
|
||||||
|
]
|
||||||
|
block_gas_limit: int = block_information[
|
||||||
|
"ethereum_block_information"
|
||||||
|
]["block_gas_limit"]
|
||||||
resolved_blocks.append(
|
resolved_blocks.append(
|
||||||
{
|
{
|
||||||
"Block Number": block_information[
|
"Block Number": block_information[
|
||||||
@@ -216,24 +272,37 @@ def main() -> None:
|
|||||||
"raw"
|
"raw"
|
||||||
][target][i - 1]
|
][target][i - 1]
|
||||||
),
|
),
|
||||||
"Ref Time": block_information[
|
"Gas Mined": block_information[
|
||||||
"substrate_block_information"
|
"ethereum_block_information"
|
||||||
]["ref_time"],
|
]["mined_gas"],
|
||||||
"Max Ref Time": block_information[
|
"Block Gas Limit": block_information[
|
||||||
"substrate_block_information"
|
"ethereum_block_information"
|
||||||
]["max_ref_time"],
|
]["block_gas_limit"],
|
||||||
"Block Fullness Ref Time": execution_report["metrics"][
|
"Block Fullness Gas": mined_gas / block_gas_limit,
|
||||||
"ref_time_block_fullness"
|
"Ref Time": substrate_block_information_ref_time(
|
||||||
]["raw"][target][i],
|
block_information["substrate_block_information"]
|
||||||
"Proof Size": block_information[
|
),
|
||||||
"substrate_block_information"
|
"Max Ref Time": substrate_block_information_max_ref_time(
|
||||||
]["proof_size"],
|
block_information["substrate_block_information"]
|
||||||
"Max Proof Size": block_information[
|
),
|
||||||
"substrate_block_information"
|
"Block Fullness Ref Time": metrics_raw_item(
|
||||||
]["max_proof_size"],
|
execution_report["metrics"],
|
||||||
"Block Fullness Proof Size": execution_report["metrics"][
|
"ref_time_block_fullness",
|
||||||
"proof_size_block_fullness"
|
target,
|
||||||
]["raw"][target][i],
|
i,
|
||||||
|
),
|
||||||
|
"Proof Size": substrate_block_information_proof_size(
|
||||||
|
block_information["substrate_block_information"]
|
||||||
|
),
|
||||||
|
"Max Proof Size": substrate_block_information_max_proof_size(
|
||||||
|
block_information["substrate_block_information"]
|
||||||
|
),
|
||||||
|
"Block Fullness Proof Size": metrics_raw_item(
|
||||||
|
execution_report["metrics"],
|
||||||
|
"proof_size_block_fullness",
|
||||||
|
target,
|
||||||
|
i,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user