Skip to content

[Investigation] Config overrides should be based on merging the user config, not the resolved #6490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 26, 2025

Conversation

ChristopherDedominici
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Mar 20, 2025

⚠️ No Changeset found

Latest commit: 423a7e4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Mar 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 26, 2025 9:25am

@ChristopherDedominici ChristopherDedominici added no changeset needed This PR doesn't require a changeset and removed status:triaging labels Mar 21, 2025
@ChristopherDedominici ChristopherDedominici moved this from Backlog to In Progress in Hardhat Mar 21, 2025
* @param resolveConfigurationVariable A function to resolve configuration variables.
* @returns A Partial<NetworkConfig> containing the resolved values from the override.
*/
export function resolveNetworkConfigOverride(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method was removed as the validation logic has been simplified.
The user config is now merged with the Hardhat config and fully re-validated (so pickResolvedFromOverrides can be deleted too). Instead of selectively resolving overrides, it's sufficient to use resolveHttpNetwork or resolveEdrNetwork.


export default async (): Promise<Partial<HardhatRuntimeEnvironmentHooks>> => ({
created: async (context, hre) => {
let networkManager: NetworkManager | undefined;

// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- although `userConfig` is present on the hre, it isn’t typed in the official definition
const userConfigNetworks = (hre as HardhatRuntimeEnvironmentImplementation)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it expected to have userConfig in hre, or is this an error? Is it expected but intentionally left untyped to discourage users from accessing it?

Copy link
Member

Choose a reason for hiding this comment

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

@alcuadrado can you clarify this?

Copy link
Member

Choose a reason for hiding this comment

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

oh, this was clarified on slack. This should be properly declared in the HRE type.

@ChristopherDedominici ChristopherDedominici marked this pull request as ready for review March 24, 2025 11:15
networkConfigOverride,
this.#networkConfigs[resolvedNetworkName],
);
const newConfig = mergeConfigOverride(
Copy link
Member

Choose a reason for hiding this comment

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

I think this logic, mergeConfigOverride is probably now outdated. What do you think, @schaable ?

Copy link
Member

Choose a reason for hiding this comment

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

I think how we could do with a deep merge, without anything fancy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't seem like we have a deep merge in hh-utils. Should I add one?

Copy link
Member

Choose a reason for hiding this comment

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

I would say go for it, but keep it simple. You can probably reuse the mergeConfigOverride code. I'd leave functions, symbols, and classes out, since we probably don't want to merge those.

@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Mar 26, 2025
Merged via the queue into v-next with commit 5aa46b2 Mar 26, 2025
111 checks passed
@ChristopherDedominici ChristopherDedominici deleted the simplify-user-config-override branch March 26, 2025 14:09
@github-project-automation github-project-automation bot moved this from In Progress to Done in Hardhat Mar 26, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
no changeset needed This PR doesn't require a changeset
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Config overrides should be based on merging the user config, not the resolved
4 participants