Skip to content

chore: adapt to EDR's new hardfork API - #8574

Draft
anaPerezGhiglia wants to merge 2 commits into
mainfrom
chore/adapt-to-edr-new-hardforks
Draft

chore: adapt to EDR's new hardfork API#8574
anaPerezGhiglia wants to merge 2 commits into
mainfrom
chore/adapt-to-edr-new-hardforks

Conversation

@anaPerezGhiglia

@anaPerezGhiglia anaPerezGhiglia commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Context

Adapts HH to the hardfork API changes shipping in EDR with NomicFoundation/edr#1645:

  • the SpecId enum is renamed to L1Hardfork
  • hardfork name strings are now camelCase matching Hardhat's own definitions
  • the exported name string constants are removed
  • pre-Byzantium L1 hardforks are no longer supported.

Changes

  • removed no longer mapping from Hardhat hardfork strings to EDR's
  • kept EDR→Hardhat mapping explicit with switch over the new L1Hardfork enum
  • Chain descriptor hardforkHistory entries for pre-Byzantium L1 hardforks are omitted from the EDR chain overrides, since EDR can no longer represent them.
  • By copilot suggestion, replaced the generic throw new Error fallthroughs with assertHardhatInvariant (which made the file's eslint-disable no-restricted-syntax exemption unnecessary).

Behavior changes

  • A chain descriptor's pre-Byzantium hardforkHistory entries no longer reach EDR
  • Renamed hardhatHardforkToEdrSpecId to getHardforkName (internal API).

Copilot AI lite review requested due to automatic review settings August 25, 2026 19:03
@changeset-bot

changeset-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1c11ee2

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates Hardhat’s EDR integration to align with EDR’s newer hardfork naming/typing (moving away from dropped exported constants/spec IDs), and adjusts both runtime code and tests to use the new hardfork-name flow consistently.

Changes:

  • Replace uses of EDR-exported hardfork constants/spec IDs with Hardhat hardfork-name enums and validation (getHardforkName).
  • Route local genesis/predeploy selection through a shared getChainGenesisState helper and pass validated hardfork names through provider config.
  • Update and extend tests to cover the new conversion behavior and chain override filtering (e.g. omitting pre-Byzantium L1 activations).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/hardhat/test/internal/builtin-plugins/solidity-test/helpers.ts Updates assertions to use Hardhat’s hardfork-name enums instead of EDR constants.
packages/hardhat/test/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts Adjusts conversion tests for the new “hardfork name passthrough” and adds coverage for chain override filtering.
packages/hardhat/test/internal/builtin-plugins/network-manager/edr/genesis-state.ts Updates tests to pass L1HardforkName.* values instead of EDR constants.
packages/hardhat/src/internal/builtin-plugins/solidity-test/helpers.ts Switches hardfork resolution to getHardforkName and predeploy selection to getChainGenesisState.
packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.ts Adds getHardforkName helper to validate and return the correct hardfork enum for a chain type.
packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts Moves L1 conversion to EDR’s L1Hardfork enum and updates chain override generation to use hardfork names + filtering.
packages/hardhat/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts Changes caching/keying to use hardfork names and factors out getChainGenesisState.
packages/hardhat/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts Passes validated hardfork names into genesis-state creation and provider config.
Suppressed comments (1)

packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts:86

  • Avoid throwing a generic Error here; use assertHardhatInvariant(false, ...) (or a HardhatError) for invariant violations so error handling stays consistent across Hardhat.
    default:
      const _exhaustiveCheck: never = hardfork;
      throw new Error(
        // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we want to print the fork
        `Unknown L1 hardfork '${hardfork as L1Hardfork}', this shouldn't happen`,
      );

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 26, 2026 21:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

packages/hardhat/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts:69

  • The cache is still typed as Map<string, ...>, but this function now uses L1HardforkName | OpHardforkName as the hardfork cache key. This can lead to TypeScript errors/mismatched typing (and makes the cache type less precise). Update the cache map key type to match hardforkName.
export async function getGenesisStateAndOwnedAccounts(
  accountsConfig: EdrNetworkAccountsConfig,
  forkingConfig: EdrNetworkForkingConfig | undefined,
  chainType: ChainType,
  hardforkName: L1HardforkName | OpHardforkName,

packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.ts:97

  • getHardforkName currently accepts any L1HardforkName, including pre-Byzantium forks (e.g. FRONTIER/DAO). But this EDR integration no longer maps/handles pre-Byzantium L1 hardforks (see the filtering in hardhatChainDescriptorsToEdrChainOverrides and the L1Hardfork enum usage), so allowing them here can lead to runtime failures when configuring the provider/genesis state. Consider rejecting pre-Byzantium L1 hardforks early in this validator.
export function getHardforkName(
  hardfork: string,
  chainType: ChainType,
): L1HardforkName | OpHardforkName {
  return chainType === OPTIMISM_CHAIN_TYPE
    ? getOpHardforkName(hardfork)
    : getL1HardforkName(hardfork);
}

packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.ts:97

  • This PR adds getHardforkName, but there are no tests covering its behavior (e.g. L1 vs OP selection and pre-Byzantium L1 rejection). Adding unit tests would help prevent regressions, especially since this function is now used to build provider configs and chain overrides.
export function getHardforkName(
  hardfork: string,
  chainType: ChainType,
): L1HardforkName | OpHardforkName {
  return chainType === OPTIMISM_CHAIN_TYPE
    ? getOpHardforkName(hardfork)
    : getL1HardforkName(hardfork);
}

@anaPerezGhiglia anaPerezGhiglia changed the title chore: adapt to EDR new harfork names and dropped consts chore: adapt to EDR's new hardfork API Aug 27, 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.

3 participants