Feature/blocktest tracing#9427
Closed
bshastry wants to merge 3 commits into
Closed
Conversation
Implements consolidated transaction tracing for blockchain tests, compatible with go-ethereum's blocktest trace format. Features: - Consolidated trace output to stderr (matching state test behavior) - Single stream for all blocks and transactions - JSON-lines format compatible with geth - CLI options for memory/stack control (-m/-s) - Unit tests with 4 test methods covering core functionality Implementation details: - BlockchainTestStreamingTracer: Streams traces to stderr - Fixed async block processing race condition in BlockchainTestBase - Tracer registration moved after StopAsync() for complete traces - Simplified architecture with single tracer per test run Usage: dotnet nethtest.dll -b -i test.json -t 2>trace.jsonl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The gas increase detection logic incorrectly identified instructions after RETURN/CREATE operations as "jumped over" and skipped tracing them. This caused trace divergences where: - After RETURN (depth 2→1): Gas appears to "increase" due to context switch - Heuristic wrongly skipped next instruction, causing PC misalignment - Nethermind traces missing instructions that Geth correctly traces Root cause: The >50 gas threshold conflated: 1. Actual gas stipend increases (CALL/DELEGATECALL) 2. Apparent increases from context returns (RETURN/CREATE) Fix: Remove selective tracing logic and unconditionally emit all trace entries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements testEnd marker written to stderr after each blocktest execution:
- Format: {"testEnd":{"name":"...","pass":bool,"fork":"...","v":1,...}}
- Includes test metrics: duration, gasUsed, txs, blocks, finalStateRoot
- Written BEFORE tracer removal to ensure it's the last trace line
- Written even on test failure for proper fuzzer integration
Changes:
- BlockchainTestStreamingTracer: Add WriteTestEndMarker() method
- BlockchainTestBase: Call marker method via reflection before assertions
- Track transaction count, block count, and total gas for metrics
Required for differential fuzzing between Nethermind and Geth.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
16 tasks
5 tasks
Member
|
Thank you for great contribution. I took a liberty to enhance it a bit in #9432, so closing this in favor of that. Can you check if I didn't break anything? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Blocktest Tracing Support to nethtest Tool
Changes
BlockchainTestStreamingTracerfor consolidated trace output to stderrBlockchainTestStreamingTracerTests.cs) with 4 test methodsBlockchainTestBaseRunTest()methodProgram.csfor blocktest tracingBlockchainTestsRunnerwith single tracer per test runTypes of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Unit Tests:
Added
BlockchainTestStreamingTracerTests.cswith 4 test methods:Tracer_writes_to_provided_output- Verifies basic trace outputTracer_handles_multiple_transactions- Tests multiple transactions per blockTracer_handles_multiple_blocks- Tests tracing across multiple blocksTracer_disposes_cleanly- Validates proper resource disposal (includes double-dispose safety check)Manual/Integration Testing:
Validated with real blockchain tests:
Test execution:
Documentation
Requires documentation update
Requires explanation in Release Notes
Release Notes:
New Feature: Blocktest Tracing in nethtest Tool
The
nethtesttool now supports transaction tracing for blockchain tests, enabling differential testing and trace comparison with go-ethereum.Usage:
Features:
This enhancement enables better EVM implementation validation and debugging for multi-transaction test scenarios.
Remarks
Implementation Highlights
Race Condition Fix: The implementation revealed and fixed a subtle async block processing bug where tracer removal before
StopAsync()caused incomplete traces. This fix ensures all blocks are traced correctly.Design Philosophy: Following Unix conventions, traces go to stderr (not files) for consistency with state tests and maximum flexibility (users can redirect or pipe as needed).
geth Compatibility: The trace format exactly matches go-ethereum's blocktest output, enabling seamless differential testing workflows.
Why This Matters
Testing Workflow Example