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

block header validation in context of blockchain test #1230

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

Conversation

winsvega
Copy link
Contributor

@winsvega winsvega commented Feb 18, 2025

🗒️ Description

this is a unit test setup for blockheader schema validation in context of blockchain tests

it sets up a fork for validation of blockheader model.
and a unit test that will check missing or extra fields errors

🔗 Related Issues

#940

✅ 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 have been added to converted-ethereum-tests.txt.
  • Tests: A PR with removal of converted JSON/YML 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.

@winsvega
Copy link
Contributor Author

winsvega commented Feb 18, 2025

But in any code if we don't provide fork value to FixtureHeader before pydantic validation, it will not validate the corectness of the fields.

there is one approach is the we derive fork field when validating FixtureHeader by looking at what fields are there.
and then on blockchain fixture level we will verify the header fork value.
but that requires rethinking FixtureHeader validation style.

@winsvega winsvega requested a review from marioevz February 18, 2025 14:22
@winsvega winsvega self-assigned this Feb 18, 2025
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 overall, just a minor suggestion to make this more future-proof. Thanks!

Comment on lines 43 to 52
from ethereum_test_forks import (
Cancun,
Constantinople,
Fork,
Frontier,
Homestead,
Istanbul,
Paris,
Prague,
)
Copy link
Member

Choose a reason for hiding this comment

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

We could use get_forks to make the fork resolution by name more dynamic.

Suggested change
from ethereum_test_forks import (
Cancun,
Constantinople,
Fork,
Frontier,
Homestead,
Istanbul,
Paris,
Prague,
)
from ethereum_test_forks import Fork, Paris, get_forks

And then simply define something like:

all_forks_by_name = {fork.name(): fork for fork in get_forks()}

Comment on lines 492 to 505
if network == "Frontier":
header["fork"] = Frontier
elif network == "Homestead":
header["fork"] = Homestead
elif network == "Constantinople":
header["fork"] = Constantinople
elif network == "Istanbul":
header["fork"] = Istanbul
elif network == "Paris":
header["fork"] = Paris
elif network == "Cancun":
header["fork"] = Cancun
elif network == "Prague":
header["fork"] = Prague
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if network == "Frontier":
header["fork"] = Frontier
elif network == "Homestead":
header["fork"] = Homestead
elif network == "Constantinople":
header["fork"] = Constantinople
elif network == "Istanbul":
header["fork"] = Istanbul
elif network == "Paris":
header["fork"] = Paris
elif network == "Cancun":
header["fork"] = Cancun
elif network == "Prague":
header["fork"] = Prague
if network in all_forks_by_name:
header["fork"] = all_forks_by_name[network]

Follow up to the previous comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants