edr
edr copied to clipboard
feat: Port existing stack trace refinement 1:1 from Hardhat
Based on https://github.com/NomicFoundation/edr/pull/544.
This feature branch will track porting the existing stack trace logic 1:1 from Hardhat. The main goal is to gradually port it while retaining the existing logic. While porting, we aim to retain the JS interface ideally as-is; once the port is complete, we can then attempt to simplify the internal code (as it won't necessarily have to be exported/accessed via JS as much) or doing the decoupling work outlined in #246.
To continuously test the changes, we will use the vendored hardhat-tests
suite. However, to not have to vendor the entire Hardhat repository, we will collect patches (created via pnpm patch
) to facilitate the review and to allow better grouping of the related changes. Each commit with a patch should ideally point to a commit in the NomicFoundation/hardhat repository.
I tried to use the patch mechanism from the github repository directly via package.json but I don't think it's possible to do given the Hardhat repository setup (monorepo, the root
package workaround) as I encountered errors. I'd be happy to switch to that, instead, if we found a way to make it work.
The initial work included here tries to tackle #247. We consume the compiler input/output JSON from the JS and create the relevant model in the Rust side, while exposing the same class instances and relationship to JS via napi-rs
.
To test this locally, you can also:
- clone the two repositories and in the Hardhat repository:
- use the companion branch https://github.com/NomicFoundation/hardhat/tree/refactor/port-solidity-stack-traces
- Link to the EDR (
edr_napi
crate) locally viapnpm link
- run the test suite there for the
hardhat-core
package (and to optionally speed things up, only run the relevant suite viadescribe.only("Stack traces", ...)
.