-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: debug trace transaction #4398
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
f1d9261
to
f072615
Compare
c24bc0b
to
44be7f6
Compare
packages/hardhat-core/src/internal/hardhat-network/provider/utils/convertToRethnet.ts
Show resolved
Hide resolved
packages/hardhat-core/src/internal/hardhat-network/provider/vm/rethnet.ts
Outdated
Show resolved
Hide resolved
packages/hardhat-core/test/internal/hardhat-network/provider/modules/debug.ts
Show resolved
Hide resolved
packages/hardhat-core/test/internal/hardhat-network/provider/modules/debug.ts
Show resolved
Hide resolved
packages/hardhat-core/test/internal/hardhat-network/provider/utils/assertEqualTraces.ts
Show resolved
Hide resolved
Co-authored-by: Wodann <[email protected]>
packages/hardhat-core/src/internal/hardhat-network/provider/utils/convertToRethnet.ts
Outdated
Show resolved
Hide resolved
Were you able to get the dual mode adapter working properly, @agostbiro? I'd also appreciate if you could have a look at the TS code, @fvictorio 🙏 |
No, unfortunately not. Looks like my comments got lost: #4398 (comment) |
Merging this as it all tests are succeeding and I don't see any issues with the TS. When you have time to look at the TS, could you please let us know if there are any issues, @fvictorio ? |
WIP to add
debug_traceTransaction
support for EDR.I verified that the simple tracer API and the EIP-3155 API are mutually exclusive, so we don’t have support them both for the same transaction execution and we don’t have to change the
with_trace
logic in the run ,dry_run
andguaranteed_dry_run
methods.We initially thought the quickest way to add
debug_traceTransaction
was to keep most of thedebug_traceTransaction
implementation in JS for now and add arethnet
variant forVMDebugTracer
of Hardhat Network. This has proven difficult, becauseVMDebugTracer
is tightly coupled with theethereum-js
vm.After studying the code and experimenting a bit, I decided instead to expose a
debug_trace_transaction
function fromrethnet_evm_napi
that delegates to a corresponding function inrethnet_evm
. This function makes a clone of the state, and executes and commits all the prior transactions in the block to the cloned state and then executes the transaction with the matching hash withTracerEip3155
and returns the debug trace output. The transactions from the block are taken asVec<rethnet_evm_napi::TransactionRequest>
as a conversion method for this already exists on the JS side. For the othernapi
arguments I follow the pattern inruntime.rs
. For executing the transactions inrethnet_evm::debug_trace_transaction
I follow the pattern inBlockBuilder::add_transaction
.I decided to adapt the implementation of
revm::TracerEip3155
as it has an awkward interface to get the logs out and it doesn't follow the EIP-3155 spec. The biggest todo left is adding the fields that are obligatory in EIP-3155, but missing fromrevm::TracerEip3155
and adding the optional fields that Hardhat currently supports.