Skip to content

Commit

Permalink
Upgrade to EDR v0.5 and add enableRip7212 option (#5512)
Browse files Browse the repository at this point in the history
Co-authored-by: Franco Victorio <[email protected]>
  • Loading branch information
Wodann and fvictorio authored Jul 18, 2024
1 parent 739d593 commit f944cd5
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-crabs-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Added an `enableRip7212` optional flag to the Hardhat Network config that enables [RIP-7212 (Precompile for secp256r1 Curve Support)](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md).
5 changes: 5 additions & 0 deletions .changeset/modern-points-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Bumped EDR to [v0.5.0](https://github.com/NomicFoundation/edr/releases/tag/%40nomicfoundation%2Fedr%400.5.0).
4 changes: 4 additions & 0 deletions docs/src/content/hardhat-network/docs/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ The `baseFeePerGas` of the first block. Note that when forking a remote network,

The address used as coinbase in new blocks. Default value: `"0xc014ba5ec014ba5ec014ba5ec014ba5ec014ba5e"`.

#### `enableRip7212`

A flag indicating whether to enable [RIP-7212 (Precompile for secp256r1 Curve Support)](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md). Default value: `false`.

### Mining modes

You can configure the mining behavior under your Hardhat Network settings:
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"dependencies": {
"@ethersproject/abi": "^5.1.2",
"@metamask/eth-sig-util": "^4.0.0",
"@nomicfoundation/edr": "^0.4.2",
"@nomicfoundation/edr": "^0.5.0",
"@nomicfoundation/ethereumjs-common": "4.0.4",
"@nomicfoundation/ethereumjs-tx": "5.0.4",
"@nomicfoundation/ethereumjs-util": "9.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export async function createProvider(
paths !== undefined ? getForkCacheDirPath(paths) : undefined,
enableTransientStorage:
hardhatNetConfig.enableTransientStorage ?? false,
enableRip7212: hardhatNetConfig.enableRip7212 ?? false,
},
{
enabled: hardhatNetConfig.loggingEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ interface HardhatNetworkProviderConfig {
forkConfig?: ForkConfig;
forkCachePath?: string;
enableTransientStorage: boolean;
enableRip7212: boolean;
}

export function getNodeConfig(
Expand Down Expand Up @@ -255,6 +256,7 @@ export class EdrProviderWrapper
}),
cacheDir: config.forkCachePath,
coinbase: Buffer.from(coinbase.slice(2), "hex"),
enableRip7212: config.enableRip7212,
fork,
hardfork: ethereumsjsHardforkToEdrSpecId(hardforkName),
genesisAccounts: config.genesisAccounts.map((account) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class Exit {
case SuccessReason.Stop:
case SuccessReason.Return:
case SuccessReason.SelfDestruct:
case SuccessReason.EofReturnContract:
return new Exit(ExitCode.SUCCESS);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/hardhat-core/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface HardhatNetworkUserConfig {
coinbase?: string;
chains?: HardhatNetworkChainsUserConfig;
enableTransientStorage?: boolean;
enableRip7212?: boolean;
}

export type HardhatNetworkAccountsUserConfig =
Expand Down Expand Up @@ -155,6 +156,7 @@ export interface HardhatNetworkConfig {
chains: HardhatNetworkChainsConfig;
allowBlocksWithSameTimestamp?: boolean;
enableTransientStorage?: boolean;
enableRip7212?: boolean;
}

export type HardhatNetworkAccountsConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function useProvider({
coinbase,
allowBlocksWithSameTimestamp,
enableTransientStorage: false,
enableRip7212: false,
},
{
enabled: loggerEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function instantiateProvider(
coinbase: "0x0000000000000000000000000000000000000000",
initialBaseFeePerGas: 0,
enableTransientStorage: false,
enableRip7212: false,
};

const provider = await EdrProviderWrapper.create(
Expand Down
66 changes: 33 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f944cd5

Please sign in to comment.