Skip to content
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

feat/statetest: Implement StateTestOnly, Change Blob Tx 4844 Tests to StateTest, Use latest geth master #368

Conversation

marioevz
Copy link
Member

@marioevz marioevz commented Dec 22, 2023

🗒️ Description

Included changes

  • Fixes all issues in 4844 tests.
  • Partly converts tests to state tests when possible: the only tests converted in this PR are the ones that needed updates due to failures in the master geth branch, the rest of the tests (4844 and others) will be converted to StateTest in a separate PR. Converted tests:
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_invalid_normal_gas
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_insufficient_balance_blob_tx
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_invalid_tx_blob_count
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_invalid_blob_hash_versioning_single_tx
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_tx_attribute_opcodes
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_tx_attribute_value_opcode
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_tx_attribute_calldata_opcodes
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_tx_attribute_gasprice_opcode
    • tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_type_tx_pre_fork
  • Required geth changes are now in master Requires this geth branch: https://github.com/marioevz/go-ethereum/tree/t8n-statetest-fixes

Important considerations

One issue I have not been able to figure out is the use of parent blob gas used in BlockchainTest vs StateTest:

In the state test we can modify currentExcessBlobGas to state the blob gas in the current header of the environment where the transaction is supposed to be executed.

In the blockchain test, we cannot set this directly, so we generate a Block 1 to introduce blob transactions and bump the value of block 2 for the test to actually happen.

Right now, since the env for each test is different, I could not think of a better solution than to create two different test functions:

  • One that generates the blockchain test
  • A second one that uses an special class called StateTestOnly which generates only the state test, but not a blockchain test.

I'll keep thinking of a way to solve this.

Merging

I'm planning to merge this using rebase, because the three commits included all do very different things, but they are all required to pass the CI tests (updating to master breaks some test fillers).

🔗 Related Issues

✅ 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.

@marioevz marioevz changed the base branch from main to feat/statetest December 22, 2023 01:39
@marioevz marioevz force-pushed the feat/statetest-use-latest-geth-master branch 2 times, most recently from 393e842 to 28fc219 Compare December 22, 2023 23:02
@marioevz marioevz changed the title Feat/statetest use latest geth master feat/statetest: Implement StateTestOnly, Change 4844 Tests to StateTest, Use latest geth master Dec 22, 2023
@marioevz marioevz marked this pull request as ready for review January 3, 2024 14:16
@marioevz marioevz changed the title feat/statetest: Implement StateTestOnly, Change 4844 Tests to StateTest, Use latest geth master feat/statetest: Implement StateTestOnly, Change Blob Tx 4844 Tests to StateTest, Use latest geth master Jan 3, 2024
@marioevz marioevz added scope:tests Scope: Test cases scope:fw Scope: Framework (evm|tools|forks|pytest) labels Jan 3, 2024
@marioevz marioevz force-pushed the feat/statetest-use-latest-geth-master branch from 28fc219 to 6dbdcb1 Compare January 3, 2024 18:02
@marioevz marioevz force-pushed the feat/statetest-use-latest-geth-master branch from 6dbdcb1 to 15da48d Compare January 4, 2024 18:13
Copy link
Collaborator

@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.

Really nice! Only small suggestions - mostly based on personal preference :)


### 🔧 EVM Tools

### 📋 Misc

- 🔀 Docs: Update `t8n` tool branch to fill tests for development features in the [readme](https://github.com/ethereum/execution-spec-test) ([#338](https://github.com/ethereum/execution-spec-tests/pull/338)).
- 🔀 Filling tool: Updated filling tool to go-ethereum@master ([#368](https://github.com/ethereum/execution-spec-tests/pull/368))
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should update it here in the README as well: https://github.com/ethereum/execution-spec-tests/blob/main/README.md?plain=1#L73

Or point people to the evm-config.yaml file in the README.

I think I prefer the latter, easier to maintain - what do you think? Could be a seperate PR, I'm happy to add it :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it makes sense to include it right here, I'll update it 👍

@@ -305,22 +306,50 @@ def pre( # noqa: D103
"""
return {
TestAddress: Account(balance=total_account_minimum_balance + account_balance_modifier),
TestAddress2: Account(balance=10**9),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to only be used by the blockchain test version of test_invalid_tx_max_fee_per_blob_gas, leading me to take a look at the usage of non_zero_blob_gas_used_genesis_block from conftest.py. Which also is only used in that test within blob_txs.py.

I think this threw me off when reviewing! My preference would be to keep the test how it was before, purely for readability. It also has added benefit of keeping the fixtures slightly smaller

More below on the latter :)



@pytest.fixture
def blocks(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could remove blocks here only retaining test_block, assuming the latter below

txs: List[Transaction],
):
"""
Reject blocks with invalid blob txs due to:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Reject blocks with invalid blob txs due to:
Reject an invalid blob transaction due to:

Comment on lines 534 to 536
if parent_blobs:
pre[TestAddress2] = Account(balance=10**9)
blocks.insert(0, non_zero_blob_gas_used_genesis_block)
Copy link
Collaborator

Choose a reason for hiding this comment

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

My preference would be to keep this here as its specific to this test within the module

@marioevz marioevz force-pushed the feat/statetest-use-latest-geth-master branch 2 times, most recently from 341351e to 9e13d24 Compare January 5, 2024 23:36
@marioevz marioevz force-pushed the feat/statetest-use-latest-geth-master branch from 9e13d24 to 6524d86 Compare January 5, 2024 23:42
@marioevz marioevz merged commit d05ce2c into ethereum:feat/statetest Jan 5, 2024
5 checks passed
@marioevz marioevz deleted the feat/statetest-use-latest-geth-master branch January 5, 2024 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:fw Scope: Framework (evm|tools|forks|pytest) scope:tests Scope: Test cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants