feat(test-benchmark): support fractional gas benchmark values#2694
feat(test-benchmark): support fractional gas benchmark values#2694shrirajpawar4 wants to merge 1 commit intoethereum:forks/amsterdamfrom
Conversation
danceratopz
left a comment
There was a problem hiding this comment.
Hey @shrirajpawar4 thanks a lot for giving this a go. I think this PR went down the wrong path. Please check my comment about updating the pydantic model instead - it would be easier to change the type there from int to float which would enable pydantic to parse these values correctly, preferably with a reasonable / heuristically determined minimum value that gets checked in a validation step.
As #2693 landed (just) before this PR and is heading down the wrong path, I will close this PR and focus on #2693. I'm sorry about that, bad luck with timing. If you'd like to tackle a different issue, feel free to reach out.
| ```console | ||
| {% if is_benchmark %} | ||
| fill -v {{ pytest_node_id }} --gas-benchmark-values 1 | ||
| fill -v {{ pytest_node_id }} --gas-benchmark-values 0.5 |
There was a problem hiding this comment.
Just a comment, I would avoid inflating the changeset in a PR across too many files unnecessarily. An example might be worth including, but I think this includes too many doc changes for what is otherwise, a relatively small change.
| ] | ||
|
|
||
|
|
||
| def _parse_gas_limit_millions(value: str) -> int: |
There was a problem hiding this comment.
Ah I think this approach is too verbose. I believe a better idea, would be to update the pydantic model above in L77, see here:
There was a problem hiding this comment.
I.e, change the pydantic model to allow a List[float] instead of a List[int] in L177.
There was a problem hiding this comment.
I agree the original diff was broader. The reason I did not stop at changing GasBenchmarkValues to List[float] is that I think the parsing error is only one part of the problem
The benchmark pipeline internally works with integer gas-unit budgets, not floats. If we accept floats directly and then do int(value * 1_000_000), we silently truncate and can also end up with
inconsistent benchmark IDs.
please correct me if i am wrong this will help me understand the system better.
Summary
Fixes #2673 by allowing fractional Mgas inputs for
--gas-benchmark-values, while keeping the benchmark/test pipeline integer-based after parsing.The issue is not just “accept
0.5”. The important part is to preserve benchmark semantics downstream:gas_benchmark_valueas an absolute gas budget in gas unitsWhat changed
--gas-benchmark-valuesas decimal Mgas inputs and convert them immediately to integer gas-unit budgetsgas_benchmark_valueinteger-based for downstream benchmark logicbenchmark-gas-value_0.5Mjust bench-gasfrom--gas-benchmark-values 1to0.5Why this approach
Using raw
floatvalues all the way through is the wrong boundary for this repo. The safe place to handle fractions is the CLI/input layer; below that, the code should continue to operate on integergas budgets.
This keeps the fix scoped to the benchmark tooling and avoids changing benchmark test semantics under
tests/benchmark/**.Validation
Ran targeted benchmark plugin and collection tests locally:
I did not run the full just bench-gas recipe locally because that needs the benchmark evm binary available in PATH / EVM_BIN.