Skip to content

feat(benchmark): create pure ether transfer worst case #1742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 17, 2025

Conversation

LouisTsai-Csie
Copy link
Collaborator

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

🗒️ Description

In Nethermind’s test case, a block is filled with simple Ether transfer transactions, each transferring 1 wei. The purpose of this PR is to reproduce a specific scenario and expand test coverage. Four scenarios are included, as outlined below:

  1. Account A sends Ether to itself
  2. Account A sends Ether to Account B
  3. Account A sends Ether to multiple different accounts
  4. Multiple different accounts send Ether to Account A

🔗 Related Issues

Issue #1734

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Looks good, some comments.

@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review June 16, 2025 08:52
@LouisTsai-Csie LouisTsai-Csie force-pushed the feat/zkevm-ether-transfer branch from 72e8741 to ad65d97 Compare June 16, 2025 08:53
@LouisTsai-Csie
Copy link
Collaborator Author

@marioevz Thanks for the review, I had some update and left a few questions.

@marioevz
Copy link
Member

marioevz commented Jun 16, 2025

Just echoing the discussion we had in person a few minutes ago:

The solution to not having to know the exact balance at the start of the test is to have a contract call at the start of the block that simply records the starting balance, and then a final contract call after all eth send transactions to get the new balance and store the difference:

from ethereum_test_tools import Conditional
Conditional(
    condition=Op.ISZERO(Op.BALANCE(Op.CALLER)),
    if_true=Op.SSTORE(0, Op.BALANCE(Op.CALLER)),  # First tx, store the starting balance
    if_false=Op.SSTORE(0, Op.SUB(Op.SLOAD(0), Op.BALANCE(Op.CALLER))),  # Second tx, store the diff
)

It would add two transactions to the test, but I feel like preserving the ability for a test to be fillable and executable is important.

EDIT: This solution is broken, see my other comment.

@LouisTsai-Csie
Copy link
Collaborator Author

@marioevz Thanks for your explanation, I've updated with

  1. Change the sender/receiver function to iterator
  2. Remove the check for the case a_to_a

@LouisTsai-Csie LouisTsai-Csie requested a review from marioevz June 16, 2025 15:47
@LouisTsai-Csie LouisTsai-Csie force-pushed the feat/zkevm-ether-transfer branch from 6011b76 to d0687c5 Compare June 17, 2025 08:54
@LouisTsai-Csie LouisTsai-Csie requested a review from marioevz June 17, 2025 09:35
Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Perfect, thanks so much!

I've reviewed the logs and it seems to work exactly as expected.

@marioevz marioevz merged commit 618d307 into ethereum:main Jun 17, 2025
15 checks passed
@spencer-tb spencer-tb changed the title feat(zkevm): create pure ether transfer worst case feat(benchmark): create pure ether transfer worst case Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants