Skip to content

Fix remappings duplication#8120

Merged
alcuadrado merged 5 commits intomainfrom
no-duplicated-remappings
Apr 10, 2026
Merged

Fix remappings duplication#8120
alcuadrado merged 5 commits intomainfrom
no-duplicated-remappings

Conversation

@alcuadrado
Copy link
Copy Markdown
Member

There was a bug in the dependency graph, which could lead to remappings being duplicated, this PR fixes it.

Remappings are stored in the edges of the dependency graph, so that we can use only the necessary remappings when building a subgraph of the entire dependency graph. They are stored as a set within each edge, so they can't be duplicated in the same edge, even when merging graphs with the same edge.

The problem was that we weren't deduplicating across edges. For example, if a graph has an edge between A and B with remapping r1, and an edge between C and D with remapping r1, r1 would be duplicated.

This PR fixes it by doing a cross-edge deduplication in the getAllRemappings() method of the graph.

The way this is structured, the first commit add some regression (integration style) tests, and actual unit tests of the functionality. The second commit fixes it, which is tiny.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 10, 2026

🦋 Changeset detected

Latest commit: f971a0b

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

This PR includes changesets to release 1 package
Name Type
hardhat Patch

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

Copilot AI review requested due to automatic review settings April 10, 2026 14:13
@alcuadrado alcuadrado added no docs needed This PR doesn't require links to documentation no peer bump needed labels Apr 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a dependency-graph bug that could cause duplicate Solidity remappings by deduplicating remappings across all graph edges, and adds regression + unit coverage to prevent regressions.

Changes:

  • Deduplicate remappings across edges in DependencyGraphImplementation.getAllRemappings().
  • Add regression fixture project + integration-style tests for duplicated remappings scenarios.
  • Add unit tests covering remapping deduplication when merging graphs.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/dependency-graph.ts Updates getAllRemappings() to cross-edge deduplicate via Set.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/regressions/no-duplicated-remappings.ts Adds regression tests exercising compilation job remappings output.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/dependency-graph.ts Adds unit tests for remapping deduplication behavior after graph merge.
packages/hardhat/test/fixture-projects/no-duplicated-remappings/** Adds fixture project (contracts + config + remappings.txt) with duplicated remapping entries.
.changeset/yellow-cycles-grow.md Patch changeset documenting the fix.

@alcuadrado alcuadrado requested a review from schaable April 10, 2026 14:19
Copy link
Copy Markdown
Member

@schaable schaable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alcuadrado alcuadrado added this pull request to the merge queue Apr 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 10, 2026
@alcuadrado alcuadrado added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 27f94cc Apr 10, 2026
222 checks passed
@alcuadrado alcuadrado deleted the no-duplicated-remappings branch April 10, 2026 16:18
@github-actions github-actions bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no docs needed This PR doesn't require links to documentation no peer bump needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants