Skip to content

feat(tests): add worst-case block test for 7702 set code #1758

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LouisTsai-Csie
Copy link
Collaborator

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

πŸ—’οΈ Description

Add blockchain test for EIP-7702 set code transaction.

πŸ”— Related Issues

Issue #1453

βœ… 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: All converted JSON/YML tests from ethereum/tests/tests/static have been assigned @ported_from marker.
  • Tests: A PR with removal of converted JSON/YML blockchain tests from ethereum/tests have been opened.
  • 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.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.

@LouisTsai-Csie LouisTsai-Csie self-assigned this Jun 18, 2025
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review June 18, 2025 13:15
"""
env = Environment()
attack_gas_limit = env.gas_limit
sender = pre.fund_eoa()
Copy link
Member

Choose a reason for hiding this comment

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

We probably need to pre-set these to an authorization for the reset to do something.

Suggested change
sender = pre.fund_eoa()
sender = pre.fund_eoa(delegation=Address(0x1))

Copy link
Collaborator

@jsign jsign Jun 18, 2025

Choose a reason for hiding this comment

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

Agree, but sounds it would only have effects for the first tx of the list. Starting with the second and further txs, the delegation will be considered a noop, no? So most tx won't be doing any real work.

I wonder if this test should probably:

  • Try calculating the maximum number of delegations possible for gas_limit (and remove the iteration_count parameter).
  • Create N different accounts as suggested by @marioevz code suggestion.
  • Create the N different delegations for target T in a single tx (to save as much intrinsic gas as possible? But not sure this will have a limit reg tx size)
  • Let T in the bullet above be parametrizable, i.e.: 0x00 for testing as many resets, and non-0x00 for testing real delegations.

def test_block_full_of_7702_set_code(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
iteration_count: int,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this missing a defined parametrization?
(Edit: see also my message below)

"""
env = Environment()
attack_gas_limit = env.gas_limit
sender = pre.fund_eoa()
Copy link
Collaborator

@jsign jsign Jun 18, 2025

Choose a reason for hiding this comment

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

Agree, but sounds it would only have effects for the first tx of the list. Starting with the second and further txs, the delegation will be considered a noop, no? So most tx won't be doing any real work.

I wonder if this test should probably:

  • Try calculating the maximum number of delegations possible for gas_limit (and remove the iteration_count parameter).
  • Create N different accounts as suggested by @marioevz code suggestion.
  • Create the N different delegations for target T in a single tx (to save as much intrinsic gas as possible? But not sure this will have a limit reg tx size)
  • Let T in the bullet above be parametrizable, i.e.: 0x00 for testing as many resets, and non-0x00 for testing real delegations.

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