-
Notifications
You must be signed in to change notification settings - Fork 174
Blocktest builder #2190
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
base: main
Are you sure you want to change the base?
Blocktest builder #2190
Conversation
CLAUDE.md
Outdated
**IMPORTANT**: Always activate the virtual environment first before running any commands: | ||
```bash | ||
source .venv/bin/activate | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, you should run uv sync --all-extras
, but this should be covered.
src/cli/fuzzer_bridge/README.md
Outdated
``` | ||
ββββββββββββββββ JSON ββββββββββββββββ Fixtures ββββββββββββββββ | ||
β Blocktest β βββββββββββΆ β Fuzzer β βββββββββββββββΆ β Ethereum β | ||
β Fuzzer β (v2 format) β Bridge β (Blockchain β Clients β | ||
ββββββββββββββββ ββββββββββββββββ Tests) ββββββββββββββββ | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The boxes for "fuzzer bridge" and "ethereum clients" are messed up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bshastry, really nice idea to "dynamically" generate blockchain tests from fuzzer output using EEST!
I have a few suggestions below, very happy to help you get this in a form that is more compatible with EEST's libraries and pydantic models. I'll message you on Signal to figure out how we'd like to proceed!
CLAUDE.md
Outdated
**IMPORTANT**: Always activate the virtual environment first before running any commands: | ||
```bash | ||
source .venv/bin/activate | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this, the user should never manage .venv
(uv
manages it). All commands should be prefixed with uv run
(as noted just above), then they'll use the .venv
created by uv sync --all-extras
(also above in this file in Setup; we could mention at that point that this command creates a venv there to help avoid Claude getting confused).
src/cli/fuzzer_bridge/README.md
Outdated
``` | ||
ββββββββββββββββ JSON ββββββββββββββββ Fixtures ββββββββββββββββ | ||
β Blocktest β βββββββββββΆ β Fuzzer β βββββββββββββββΆ β Ethereum β | ||
β Fuzzer β (v2 format) β Bridge β (Blockchain β Clients β | ||
ββββββββββββββββ ββββββββββββββββ Tests) ββββββββββββββββ | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helpful! But could you ask Claude to add a mermaid diagram instead of ascii art? :)
src/cli/fuzzer_bridge/README.md
Outdated
1. **Private Keys**: Any account that sends transactions MUST include a `privateKey` field | ||
2. **Address-Key Match**: Private keys must generate the corresponding addresses | ||
3. **Environment**: Describes the environment for block 1 (genesis is automatically derived) | ||
4. **Version**: Use "2.0" for this format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. **Private Keys**: Any account that sends transactions MUST include a `privateKey` field | |
2. **Address-Key Match**: Private keys must generate the corresponding addresses | |
3. **Environment**: Describes the environment for block 1 (genesis is automatically derived) | |
4. **Version**: Use "2.0" for this format | |
1. **Private Keys**: Any account that sends transactions MUST include a `privateKey` field. | |
2. **Address-Key Match**: Private keys must generate the corresponding addresses. | |
3. **Environment**: Describes the environment for block 1 (genesis is automatically derived). | |
4. **Version**: Use "2.0" for this format. |
@@ -0,0 +1,205 @@ | |||
# Fuzzer Bridge for Execution Spec Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minimal readme is ok, but I think this should rather point to a page in the online documentation for easier sharing.
Unfortunately, we don't have a great top-level section for this, but perhaps we can put it in https://eest.ethereum.org/main/writing_tests/
For this, you'll need to:
- Create an .md in ./docs/writing_tests/.
- Add an entry to the table of contents in docs/navigation.md linking to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But maybe, it could be a new top-level section in "Running Tests"? Wdyt?
https://eest.ethereum.org/main/running_tests/
```json | ||
{ | ||
"version": "2.0", | ||
"fork": "Prague", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this is called network
in blockchain fixtures. I guess we can live with the inconsistency :)
src/cli/fuzzer_bridge/README.md
Outdated
|
||
## Production Test Suite | ||
|
||
See `production_test.py` for a complete example that: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
production_test.py
in missing from this PR.
src/cli/fuzzer_bridge/README.md
Outdated
## Contributing | ||
|
||
When modifying the fuzzer bridge: | ||
1. Update the version number in `__init__.py` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tell Claude to always punctuate his bullet points.
src/cli/fuzzer_bridge/README.md
Outdated
## License | ||
|
||
See the main execution-spec-tests repository for license information. No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary. Especially in the docs.
src/cli/fuzzer_bridge/README.md
Outdated
## Contributing | ||
|
||
When modifying the fuzzer bridge: | ||
1. Update the version number in `__init__.py` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no version number in init.py.
@@ -0,0 +1,240 @@ | |||
"""Build valid blocktests from fuzzer-generated transactions and pre-state.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned pydantic models above, there's a lot of opportunity here to align this code with EEST code standards to streamline it and make it more maintainable and future proof. This is what I'd suggest (also with some ai-help):
-
Create Pydantic Models for Fuzzer Output:
- Define
FuzzerOutput
Pydantic model to replace dict parsing. - Add nested models:
FuzzerAccount
,FuzzerTransaction
,FuzzerEnvironment
. - Implement validation and type coercion at the model level.
- Define
-
Add
from_fuzzer
Method toBlockchainTest
in./src/ethereum_test_specs/blockchain.py
.- Create class method on
BlockchainTest
to directly construct fromFuzzerOutput
. - Move all conversion logic into this method for better encapsulation.
- Eliminate the need for separate
BlocktestBuilder
class.
- Create class method on
- Remove incorrect venv activation instructions from CLAUDE.md - Replace ASCII art with Mermaid diagram in README - Add fuzzer_bridge as CLI entry point in pyproject.toml - Create comprehensive documentation in docs/writing_tests/ - Add Pydantic models for type-safe fuzzer output parsing - Add BlockchainTest.from_fuzzer() classmethod for better integration - Simplify BlocktestBuilder to use new architecture - Fix README inconsistencies (punctuation, references, sections) This refactoring aligns the fuzzer bridge with EEST code standards and makes it more maintainable and future-proof. π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add ruff noqa comment for mixedCase variables in Pydantic models - Fix line length issues in performance_utils.py - Replace bare except with specific Exception handling - Apply automated formatting from ruff π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
862d70e
to
5472e9b
Compare
- Fix markdown linting errors in fuzzer_bridge.md documentation - Apply ruff formatting to blockchain.py - Fix mypy type errors in fuzzer bridge modules: - Make orjson import optional with proper error handling - Fix TransitionTool instantiation to use GethTransitionTool - Correct EOA usage and add missing class attributes - Fix json.dump parameter usage to avoid kwargs issues - Fix docstring line lengths to comply with 79-char limit - Fix line length issues in function signatures All linting (ruff) and type checking (mypy) now pass successfully. π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add support for two critical Ethereum features in the fuzzer bridge: 1. EIP-7702 Authorization Lists (Prague+) - Add FuzzerAuthorization model for authorization tuples - Parse authorizationList from transactions - Translate to AuthorizationTuple in from_fuzzer() - Enables testing of SetCode transactions (tx type 0x04) 2. EIP-4788 Parent Beacon Block Root (Cancun+) - Add parentBeaconBlockRoot as top-level field in FuzzerOutput - Pass to Block during creation in from_fuzzer() - Must be 32-byte hash from consensus layer - Enables testing of beacon root contract (EIP-4788) These changes close significant coverage gaps in geth core validation: - tx_setcode.go: Authorization validation paths - block_validator.go: Beacon root handling - state_transition.go: Beacon root system contract calls The implementation follows existing patterns (similar to blob sidecar handling) and maintains backwards compatibility through optional fields. π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add support for splitting fuzzer transactions across multiple blocks to enable testing of state transitions and block boundaries. New CLI Options: - --num-blocks: Number of blocks to generate (default: 1) - --block-strategy: Transaction distribution strategy - "distribute": Sequential chunks preserving nonce order - "first-block": All txs in first block, rest empty - --block-time: Seconds between blocks (default: 12) Implementation: - Sequential distribution maintains nonce ordering per account - Timestamps increment by block_time for each block - Only first block receives parent_beacon_block_root - Fully backward compatible (single-block default) Example Usage: fuzzer_bridge --num-blocks 3 --block-strategy distribute \ --fork Osaka input.json output/ This enables testing multi-block scenarios like: - State evolution across blocks - Transaction dependencies spanning blocks - Block time-sensitive operations - Cross-block state transitions π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add --random-blocks flag to enable intelligent automatic selection of block counts for comprehensive testing coverage. New Feature: - --random-blocks: Randomly choose number of blocks (1 to min(num_txs, 10)) Implementation: - choose_random_num_blocks() helper with uniform distribution - Each file gets independent random selection in parallel mode - Edge case handling: empty blocks (0 txs β 1 block) - Cap at 10 blocks to prevent fixture bloat with large tx counts Algorithm Rationale: - Uniform distribution provides equal coverage for testing - Max of 10 blocks balances thoroughness with practicality - Independent per-file randomization maximizes corpus diversity Example Usage: # Random mode - each file gets random block count fuzzer_bridge --random-blocks --fork Osaka input/ output/ # Still works with fixed mode fuzzer_bridge --num-blocks 3 --fork Osaka input/ output/ Benefits: - Automated testing of various block configurations - Discovers edge cases in block boundary handling - Comprehensive multi-block scenario coverage - Zero configuration needed for random testing π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
ποΈ Description
π Related Issues or PRs
N/A.
β Checklist
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
type(scope):
.mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_from
marker.