HH2: Port hardhat-network provider to the current EDR API and restore trace events - #8422
HH2: Port hardhat-network provider to the current EDR API and restore trace events#8422nebasuke wants to merge 2 commits into
Conversation
Adapts hardhat-core from @NomicFoundation/edr 0.12.0-next.23 to the current EDR API. The provider/convertToEdr changes are taken from the EDR repo's own hardhat@2.28.4 patch (patches/hardhat@2.28.4.patch), which the EDR CI has been maintaining against its vendored hardhat test suite: - ProviderConfig: `fork` is replaced by the `network` union (local config or fork config) and `defaultTransactionGasLimit` is required. - Response no longer exposes `traces`. - `stackTrace()` returns a kind-tagged result (StackTrace | UnexpectedError | HeuristicFailed | UnsafeToReplay) instead of an entry array. - `getLatestSupportedSolcVersion` is renamed to `latestSupportedSolidityVersion` (test-only usage). One addition over the EDR-side patch: `stackTrace.entries` is now cast to Hardhat's local `SolidityStackTrace` union. EDR's typings export `SolidityStackTraceEntry` (previously a dangling reference that typechecked as `any`), and EDR's union includes `CheatcodeErrorStackTraceEntry`, which only fires in solidity-test runs, never on the network-provider path. Validated against a local napi-rs v3 EDR build: hardhat-core builds clean and the full test suite passes (1149 passing, 0 failing).
The glue port left the vm trace-event bridge commented out because EDR no longer exposed Response.traces. EDR now re-adds it as a method (Response.traces()), returning napi-v3-shaped trace items. Re-enable the bridge: iterate traces() -> emit step/beforeMessage/afterMessage on the minimal vm, and update convertToEdr marshalling to the new shapes (step.opcode.name, step.memory, tracingMessageResult.execResult).
|
There was a problem hiding this comment.
Pull request overview
Ports Hardhat Network’s EDR-backed provider integration to the current EDR API, and re-enables the VM trace-event bridge that HH2 plugins rely on.
Changes:
- Updated tests to use EDR’s renamed “latest supported Solidity version” helper.
- Updated provider config plumbing from
fork/initialDate/top-levelblockGasLimitto EDR’snetworkunion andmining.blockGasLimit/defaultTransactionGasLimit, includinghardhat_resethandling. - Restored the trace-event bridge by iterating
Response.traces()and emittingstep/beforeMessage/afterMessagewith updated trace-item shapes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/hardhat-core/test/helpers/compilation.ts | Updates EDR API usage for “latest supported Solidity version” in compilation helpers. |
| packages/hardhat-core/test/builtin-tasks/compile.ts | Updates EDR API usage for “latest supported Solidity version” in compile-task tests. |
| packages/hardhat-core/src/internal/hardhat-network/provider/utils/convertToEdr.ts | Updates trace marshalling to match new EDR trace shapes. |
| packages/hardhat-core/src/internal/hardhat-network/provider/provider.ts | Ports provider config to the new EDR API and re-enables trace-event bridging + reset behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| name: step.opcode.name, | ||
| }, | ||
| stack: step.stack, | ||
| memory: step.memory, | ||
| }; |
| mining: { | ||
| autoMine: config.automine, | ||
| blockGasLimit: BigInt(config.blockGasLimit), | ||
| interval: ethereumjsIntervalMiningConfigToEdr(config.intervalMining), | ||
| memPool: { | ||
| order: ethereumjsMempoolOrderToEdrMineOrdering(config.mempoolOrder), | ||
| }, | ||
| }, | ||
| network, | ||
| networkId: BigInt(config.networkId), | ||
| observability: {}, | ||
| ownedAccounts, |
|
Duplicate of #7985 |
Draft in preparation of N-API v3 and re-enabling traces for HH2.
Claude summary
What
Ports the
hardhat-networkprovider glue to the current EDR API and restores the vm trace-event bridge that HH2 plugins (e.g.solidity-coverage,smock) rely on:fork/initialDate/top-levelblockGasLimitprovider config is replaced by thenetworkunion andmining.blockGasLimit/defaultTransactionGasLimit; local-network genesis block gas limit and time are threaded throughhardhat_reset;convertToEdrdrops the converters for removed EDR surface.Response.traces()(a method returning napi-v3-shaped items). The previously commented-out bridge is re-enabled: iteratetraces()and emitstep/beforeMessage/afterMessageon the minimal vm, with marshalling updated to the new shapes (step.opcode.name,step.memory,tracingMessageResult.execResult).includeCallTracesdefaults toNone, in which casetraces()returns no arenas and the bridge silently emits nothing (the solidity-coverage 0%-coverage failure mode). The provider now requestsIncludeTraces.Allat creation.Status / blocked on
Draft until an EDR release ships the
Response.traces()work (NomicFoundation/edr#1301); the@nomicfoundation/edrversion bump is intentionally not part of this branch yet.Testing
hardhat-coretest run for the glue port, and the bridge verified end-to-end (step/beforeMessage/afterMessage counts) by a dedicated spec in EDR'shardhat-testssuite.patches/hardhat@2.28.6.patchEDR applies in itshardhat-testsCI, so this branch is exercised continuously on the EDR side.