Skip to content

Conversation

LouisTsai-Csie
Copy link
Collaborator

@LouisTsai-Csie LouisTsai-Csie commented Jun 30, 2025

πŸ—’οΈ Description

Create benchmark test with pure payload data, there are two scenario: null / non-null bytes payload.

πŸ”— Related Issues or PRs

Issue #1734

βœ… Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx --with=tox-uv tox -e lint,typecheck,spellcheck,markdownlint
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered adding an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

@LouisTsai-Csie LouisTsai-Csie self-assigned this Jun 30, 2025
@LouisTsai-Csie LouisTsai-Csie added feature:benchmark type:test Type: Add/refactor fw unit tests; no fw or el client test case changes labels Jun 30, 2025
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review June 30, 2025 15:41
@LouisTsai-Csie
Copy link
Collaborator Author

This test located in test_worst_blocks.py, but it is not a blockchain test. But after reviewing the folder structure, I still could not find a best place for the test case. Any suggestion is welcome!

@marioevz
Copy link
Member

marioevz commented Jul 1, 2025

#1804 got merged! Please rebase the branch and move the tests to the appropriate folder.

@LouisTsai-Csie
Copy link
Collaborator Author

@marioevz thank you, I've rebased accordingly. And this PR is ready for review now

@LouisTsai-Csie
Copy link
Collaborator Author

LouisTsai-Csie commented Jul 3, 2025

I read the proposal as well as some analysis (this is a good one), and refactored the benchmark accordingly. Please let me know if my understanding is incorrect:

According to EIP-7623, the gas cost is calculated as follows:

tx.gasUsed = 21000 + max(
    STANDARD_TOKEN_COST * tokens_in_calldata
    + execution_gas_used
    + isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata)),
    TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata,
)

In this test case, since the transaction only includes a payload and does not execute any bytecode or create a contract, both execution_gas_used and isContractCreation are zero. This simplifies the formula to:

tx.gasUsed = 21000 + max(
    STANDARD_TOKEN_COST * tokens_in_calldata,
    TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata,
)

Given that STANDARD_TOKEN_COST = 4 and TOTAL_COST_FLOOR_PER_TOKEN = 10, the max(...) term always evaluates to the latter. So the formula can be further simplified to:

tx.gasUsed = 21000 + 10 * tokens_in_calldata

By definition:

tokens_in_calldata = zero_bytes_in_calldata + 4 * nonzero_bytes_in_calldata

We use this relationship to compute the total number of bytes that can fit in the payload under the available gas limit.

Note: I also add the explanation in the test case for clarity

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question/remark πŸ˜„ πŸ‘

@LouisTsai-Csie LouisTsai-Csie changed the title feat(benchmark): add empty payload test feat(benchmark): add pure calldata transaction case Jul 4, 2025
Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! πŸ˜„ πŸ‘

Copy link
Contributor

@spencer-tb spencer-tb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@spencer-tb spencer-tb merged commit d4968fa into ethereum:main Jul 8, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:benchmark type:test Type: Add/refactor fw unit tests; no fw or el client test case changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants