Skip to content

Commit d37fdbe

Browse files
committed
test: pin the debug_trace* JSON-RPC contract
Add unit tests for the debug_traceTransaction and debug_traceCall handlers. They assert on the serialised GethTrace, which is the JSON that the provider returns. The reference is the Ethereum execution-apis spec at one pinned commit. The tests follow its opcode logger schema and the method clauses of trace.yaml. The tests are split into two modules. The spec module holds tests per spec requirement, each documented with the clause it pins. The edr module holds behaviour that the spec leaves undefined, and its module doc gives the reason EDR pins each one. The spec tests cover the struct log fields and their formats, and the meaning of pc, depth, gas and gasCost, including the cold SLOAD charge. Storage is pinned as a cumulative per-contract snapshot, which a DELEGATECALL shares with its caller. The refund counter is present on every step. After an SSTORE restores a slot's original value, the refund is the EIP-2200 restore refund. The trace's gas deducts the capped refund. Further tests cover the default stack, the memory, stack, storage and return data options and an empty tracer. The step limit is pinned to cap the recorded steps without stopping execution. Other tests cover the trace results of transfers, reverts, successful calls and a halting precompile call. debug_traceTransaction is pinned to replay the preceding transactions of its block. The edr tests cover the Unknown opcode name and the halt error text. disableMemory and disableReturnData are not spec options, but alloy reads them. disableMemory: false enables memory when enableMemory is absent, and enableMemory takes precedence when both are set. disableReturnData: false likewise enables return data. The edr tests also cover the callTracer result and the errors for an unknown tracer or transaction hash. For debug_traceCall they pin the default block, contract creation and state isolation. Hardhat 2 converts these traces back to its own format. That conversion depends on this contract, so a change in revm-inspectors, alloy or EDR's option handling now fails here first. A test_utils helper now builds transaction requests, and another builds a local fixture on a given hardfork.
1 parent f4a7ed8 commit d37fdbe

5 files changed

Lines changed: 1457 additions & 12 deletions

File tree

‎crates/edr_provider/src/requests/debug.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ where
6868

6969
Ok((result, call_trace_arenas))
7070
}
71+
72+
#[cfg(test)]
73+
mod tests;

0 commit comments

Comments
 (0)