edr icon indicating copy to clipboard operation
edr copied to clipboard

feat: Port existing stack trace refinement 1:1 from Hardhat

Open Xanewok opened this issue 7 months ago • 4 comments

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:

  1. clone the two repositories and in the Hardhat repository:
  2. use the companion branch https://github.com/NomicFoundation/hardhat/tree/refactor/port-solidity-stack-traces
  3. Link to the EDR (edr_napi crate) locally via pnpm link
  4. run the test suite there for the hardhat-core package (and to optionally speed things up, only run the relevant suite via describe.only("Stack traces", ...).

Xanewok avatar Jul 05 '24 11:07 Xanewok