Skip to content

Conversation

bshastry
Copy link
Contributor

πŸ—’οΈ Description

πŸ”— Related Issues or PRs

N/A.

βœ… Checklist

  • All: Ran fast 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
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered adding an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • 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.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

CLAUDE.md Outdated
Comment on lines 31 to 35
**IMPORTANT**: Always activate the virtual environment first before running any commands:
```bash
source .venv/bin/activate
```

Copy link
Member

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.

Comment on lines 11 to 16
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” JSON β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” Fixtures β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Blocktest β”‚ ──────────▢ β”‚ Fuzzer β”‚ ──────────────▢ β”‚ Ethereum β”‚
β”‚ Fuzzer β”‚ (v2 format) β”‚ Bridge β”‚ (Blockchain β”‚ Clients β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Tests) β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
Copy link
Member

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.

Copy link
Member

@danceratopz danceratopz left a 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
Comment on lines 31 to 35
**IMPORTANT**: Always activate the virtual environment first before running any commands:
```bash
source .venv/bin/activate
```

Copy link
Member

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

Comment on lines 11 to 16
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” JSON β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” Fixtures β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Blocktest β”‚ ──────────▢ β”‚ Fuzzer β”‚ ──────────────▢ β”‚ Ethereum β”‚
β”‚ Fuzzer β”‚ (v2 format) β”‚ Bridge β”‚ (Blockchain β”‚ Clients β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Tests) β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
Copy link
Member

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? :)

Comment on lines 67 to 70
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
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
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
Copy link
Member

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:

  1. Create an .md in ./docs/writing_tests/.
  2. Add an entry to the table of contents in docs/navigation.md linking to it.

Copy link
Member

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",
Copy link
Member

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 :)


## Production Test Suite

See `production_test.py` for a complete example that:
Copy link
Member

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.

## Contributing

When modifying the fuzzer bridge:
1. Update the version number in `__init__.py`
Copy link
Member

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.

Comment on lines 203 to 205
## License

See the main execution-spec-tests repository for license information. No newline at end of file
Copy link
Member

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.

## Contributing

When modifying the fuzzer bridge:
1. Update the version number in `__init__.py`
Copy link
Member

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."""
Copy link
Member

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):

  1. 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.
  2. Add from_fuzzer Method to BlockchainTest in ./src/ethereum_test_specs/blockchain.py.

    • Create class method on BlockchainTest to directly construct from FuzzerOutput.
    • Move all conversion logic into this method for better encapsulation.
    • Eliminate the need for separate BlocktestBuilder class.

@danceratopz danceratopz self-assigned this Sep 29, 2025
bshastry and others added 11 commits September 29, 2025 13:37
- 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]>
bshastry and others added 5 commits September 29, 2025 14:35
- 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]>
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.

3 participants