Skip to content

Node network config#7989

Merged
alcuadrado merged 6 commits intomainfrom
node-network-config
Feb 23, 2026
Merged

Node network config#7989
alcuadrado merged 6 commits intomainfrom
node-network-config

Conversation

@alcuadrado
Copy link
Copy Markdown
Member

This PR introduces a new node network config, which is present by default, and whose type must always be edr-simulated. This last requirement is enforced during the validation of the config.

Depends on: #7805
Docs PR: NomicFoundation/hardhat-website#222

@alcuadrado alcuadrado requested a review from Copilot February 22, 2026 23:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 22, 2026

🦋 Changeset detected

Latest commit: 6a5f25d

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

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

This PR introduces a new node network configuration that is automatically added to all Hardhat projects. The node network is similar to the default network but with a key difference: its type must always be edr-simulated and cannot be overridden to http or any other type.

Changes:

  • Added automatic extension of user config to include a node network with edr-simulated type
  • Added validation to enforce that the node network type must be edr-simulated
  • Updated the node task action to use the new node network instead of respecting the global --network option

Reviewed changes

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

File Description
v-next/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/config.ts Extends user config to add the node network with default EDR network values
v-next/hardhat/src/internal/builtin-plugins/network-manager/type-validation.ts Adds validation to ensure node network type is always edr-simulated
v-next/hardhat/src/internal/builtin-plugins/node/task-action.ts Simplifies node task to use hardcoded node network and assertion
v-next/hardhat/test/internal/builtin-plugins/network-manager/hook-handlers/config.ts Adds comprehensive tests for node network extension and validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

override?: EdrNetworkConfigOverride;
} = {
network,
network: "node",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this mean we can’t run npx hardhat node --network myNodeNetwork anymore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's right. That's ignored. Maybe we should print warning or throw an error

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Or maybe use node just by default. Is that possible?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It wouldn't be possible, because --network has a default value of "default"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I guess if users want to be able to override we can add a task option --network-config or something like that in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can't you do?

const network =
    hre.globalOptions.network !== undefined
      ? hre.globalOptions.network
      : hre.config.network.node;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are right!

Comment on lines +163 to +166
assert.ok(
extendedConfig.networks?.node !== undefined,
"node network should be defined",
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor: this assertion is redundant, since the next one would fail if the node network is undefined. I'm fine if you want to keep it, as it makes the intent more explicit.

Comment on lines +289 to +291
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
-- testing invalid network type for js users */
const validationErrors = await validateNetworkUserConfig(config as any);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is the type assertion needed?

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.

Looks good. Left a question and some minor comments on the tests.

This network config is validated to be of type `edr-simulated` during
the config validation phase.
Base automatically changed from fix-default-network to main February 23, 2026 15:46
@alcuadrado alcuadrado added this pull request to the merge queue Feb 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 23, 2026
@alcuadrado alcuadrado added this pull request to the merge queue Feb 23, 2026
Merged via the queue into main with commit b98fede Feb 23, 2026
203 checks passed
@alcuadrado alcuadrado deleted the node-network-config branch February 23, 2026 19:04
@github-actions github-actions Bot mentioned this pull request Feb 23, 2026
@kanej
Copy link
Copy Markdown
Member

kanej commented Feb 25, 2026

This has been released as part of hardhat@3.1.10: https://github.com/NomicFoundation/hardhat/releases/tag/hardhat%403.1.10

This was referenced Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants