Skip to content

feat: add Hardhat v3 artifact & build-info loading from disk - #1635

Draft
popescuoctavian wants to merge 6 commits into
mainfrom
popescuoctavian/move-artifact-loading-to-EDR
Draft

feat: add Hardhat v3 artifact & build-info loading from disk#1635
popescuoctavian wants to merge 6 commits into
mainfrom
popescuoctavian/move-artifact-loading-to-EDR

Conversation

@popescuoctavian

@popescuoctavian popescuoctavian commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

This PR adds the ability to load Hardhat v3 compilation artifacts and build infos
in EDR, so they are read from disk in Rust instead of being serialized and passed
over N-API.

New API

  • EdrContext.runSolidityTestsFromPaths — like runSolidityTests, but
    takes the paths of the project's artifact directories (in the Hardhat v3
    format) instead of Artifact[] and a tracing config. All artifacts and
    build infos are loaded from disk so that linking, cheatcodes and stack
    trace generation keep working. Test suites are selected with a new
    TestSuiteReference (source + name), which doesn't require knowing the
    solc version up front: it's resolved from the artifacts on disk, and both
    the user-facing source name (contracts/Counter.t.sol) and the compiler
    input source name (project/contracts/Counter.t.sol) are accepted.
  • ContractDecoder.fromProject — creates a decoder by reading a
    project's build infos from disk (artifactsDir, optional buildInfoDir
    and ignoreContracts).

Both existing entry points (runSolidityTests, ContractDecoder.withContracts)
are unchanged.

Implementation

  • New edr_solidity::project module that understands the Hardhat v3 artifact
    layout: hh3-artifact-1 artifact files (validated by _format), paired
    build-info/<id>.json + <id>.output.json files, and solc version
    extraction from build info ids
    (solc-<major>_<minor>_<patch>[-<compilerType>]-<hex>). Unlinked bytecode
    keeps its __$...$__ placeholders for the linker, matching the existing
    N-API conversion.
  • edr_napi's test execution path is refactored so both entry points share a
    common run_test_suites function; the disk-loading variant runs file IO on
    a blocking thread.

Code mapping: EDR ⇄ Hardhat (Claude-generated)

New EDR code vs. the Hardhat code it ports, verified against Hardhat 3.15.0
(latest release). Hardhat paths are relative to packages/hardhat/src/ in the
Hardhat monorepo.

New EDR code Ported from (Hardhat 3.15.0)
crates/edr_solidity/src/project.rsfind_artifact_files internal/builtin-plugins/artifacts/artifact-manager.ts#readFsDataFromFileSystem: same three conditions (.json files only, top-level files excluded, build-info dir excluded)
project.rsBUILD_INFO_DIR_NAME artifact-manager.tsBUILD_INFO_DIR_NAME
project.rsHardhatV3Artifact The Artifact interface in types/artifacts.ts (declared fields only)
project.rsload_artifacts / to_loaded_artifact (id from inputSourceName ?? sourceName, solc version from build info id, ABI + bytecodes + link references) internal/builtin-plugins/solidity-test/edr-artifacts.tsbuildEdrArtifactsWithMetadata (JSON reads via artifact-manager.ts readArtifact)
project.rssolc_version_from_build_info_id edr-artifacts.ts — the BUILD_INFO_FORMAT regex, including 3.15.0's hyphenated compiler types (solc-0_8_28-zk-solx-<hex>)
project.rsfind_build_info_files (flat dir, .json minus .output.json, pair with output) artifact-manager.tsgetAllBuildInfoIds + getBuildInfoPath + getBuildInfoOutputPath
project.rsload_build_info_config (skips build infos without an output) internal/builtin-plugins/network-manager/network-manager.ts#getBuildInfosAndOutputsAsBuffers (same skip-if-either-missing behavior)
crates/edr_napi/src/solidity_tests.rsload_project_inputs (loop over artifact directories, concatenate artifacts + build infos) internal/builtin-plugins/solidity-test/task-action.tsloadArtifacts (per-scope getArtifactsDirectorybuildEdrArtifactsWithMetadata + getBuildInfosAndOutputs)
solidity_tests.rs — hard error on a missing .output.json edr-artifacts.tsgetBuildInfosAndOutputs's assertHardhatInvariants on both paths (the strict counterpart to network-manager's skip)
solidity_tests.rsresolve_test_suites / LoadedArtifact.user_source_name (accepting either source name) task-action.ts — the sourceNameToUserSourceName map and userSourceName metadata threading; TestSuiteReference resolves the // TODO: This is a temporary solution... comment in edr-artifacts.ts about input vs. user source names
crates/edr_napi/src/contract_decoder.rsContractDecoder.fromProject Replaces the JS pipeline network-manager.ts #getBuildInfosAndOutputsAsBuffersinternal/builtin-plugins/network-manager/edr/edr-provider.ts createContractDecoderContractDecoder.withContracts
crates/edr_napi/src/context.rsrun_solidity_tests_from_paths Replaces the marshaling side of task-action.ts's run(...) call (passing edrArtifacts, testSuiteIds, tracingConfig over N-API)

Deliberately not ported (stays in Hardhat for now): deciding which contracts are
test suites (isTestSuiteArtifact in solidity-test/helpers.ts plus the
test-root filtering in task-action.ts — EDR receives explicit
TestSuiteReferences), and the artifact manager's name-lookup/caching
machinery (FQN maps, edit-distance suggestions).

Known behavioral delta: for a build info id that doesn't match the format,
Hardhat filters it out of the solc-version map and later fails an
assertHardhatInvariant when an artifact references it; EDR reports the typed
InvalidBuildInfoId error up front.

@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9ebb067

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/edr Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 20, 2026 10:14 — with GitHub Actions Inactive
@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 20, 2026 10:16 — with GitHub Actions Inactive
@popescuoctavian
popescuoctavian had a problem deploying to github-action-benchmark August 20, 2026 10:16 — with GitHub Actions Failure
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.51926% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.98%. Comparing base (a81dc28) to head (9ebb067).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
crates/edr_solidity/src/project.rs 87.50% 44 Missing and 13 partials ⚠️
crates/edr_napi/src/context.rs 86.74% 10 Missing and 14 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1635      +/-   ##
==========================================
- Coverage   80.01%   79.98%   -0.04%     
==========================================
  Files         464      462       -2     
  Lines       80392    80702     +310     
  Branches    80392    80702     +310     
==========================================
+ Hits        64329    64548     +219     
- Misses      13856    13923      +67     
- Partials     2207     2231      +24     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 20, 2026 11:03 — with GitHub Actions Inactive
@popescuoctavian

Copy link
Copy Markdown
Contributor Author

/bench

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for 2007f4bda3ad against Hardhat main (benchmarks matching test solidity,test mocha,test vitest).

@github-actions

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for 2007f4bda3ad against Hardhat main. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@popescuoctavian

Copy link
Copy Markdown
Contributor Author

/bench

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for 2007f4bda3ad against Hardhat main (benchmarks matching test solidity,test mocha,test vitest).

@github-actions

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for 2007f4bda3ad against Hardhat main. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@popescuoctavian

Copy link
Copy Markdown
Contributor Author

/bench hardhat-ref=popescuoctavian/artifact-loading-to-EDR

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for 2007f4bda3ad against Hardhat popescuoctavian/artifact-loading-to-EDR (benchmarks matching test solidity,test mocha,test vitest).

@github-actions

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for 2007f4bda3ad against Hardhat popescuoctavian/artifact-loading-to-EDR. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@popescuoctavian

Copy link
Copy Markdown
Contributor Author

/bench hardhat-ref=popescuoctavian/artifact-loading-to-EDR

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for 2007f4bda3ad against Hardhat popescuoctavian/artifact-loading-to-EDR (benchmarks matching test solidity,test mocha,test vitest).

@github-actions

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for 2007f4bda3ad against Hardhat popescuoctavian/artifact-loading-to-EDR. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@popescuoctavian

Copy link
Copy Markdown
Contributor Author

/bench

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for 2007f4bda3ad against Hardhat main (benchmarks matching test solidity,test mocha,test vitest).

@github-actions

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for 2007f4bda3ad against Hardhat main. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@popescuoctavian
popescuoctavian force-pushed the popescuoctavian/move-artifact-loading-to-EDR branch from 2007f4b to f0ce372 Compare August 25, 2026 08:08
@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 25, 2026 08:09 — with GitHub Actions Inactive
@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 25, 2026 08:14 — with GitHub Actions Inactive
@popescuoctavian
popescuoctavian had a problem deploying to github-action-benchmark August 25, 2026 08:14 — with GitHub Actions Failure
@popescuoctavian
popescuoctavian had a problem deploying to github-action-benchmark August 25, 2026 10:09 — with GitHub Actions Failure
@popescuoctavian

Copy link
Copy Markdown
Contributor Author

/bench hardhat-ref=popescuoctavian/artifact-loading-to-EDR

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for f0ce3723ac69 against Hardhat popescuoctavian/artifact-loading-to-EDR (benchmarks matching test solidity,test mocha,test vitest).

@github-actions

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for f0ce3723ac69 against Hardhat popescuoctavian/artifact-loading-to-EDR. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@popescuoctavian

Copy link
Copy Markdown
Contributor Author

/bench hardhat-ref=popescuoctavian/artifact-loading-to-EDR

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for f0ce3723ac69 against Hardhat popescuoctavian/artifact-loading-to-EDR (benchmarks matching test solidity,test mocha,test vitest).

@github-actions

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for f0ce3723ac69 against Hardhat popescuoctavian/artifact-loading-to-EDR. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 31, 2026 10:35 — with GitHub Actions Inactive
@popescuoctavian popescuoctavian self-assigned this Aug 31, 2026
@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 31, 2026 11:28 — with GitHub Actions Inactive
@popescuoctavian
popescuoctavian temporarily deployed to github-action-benchmark August 31, 2026 11:45 — with GitHub Actions Inactive
@popescuoctavian
popescuoctavian had a problem deploying to github-action-benchmark August 31, 2026 11:45 — with GitHub Actions Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant