Skip to content

Commit

Permalink
Merge pull request #5865 from NomicFoundation/edr-config-changes
Browse files Browse the repository at this point in the history
Small improvements to the config resolution of EDR networks
  • Loading branch information
alcuadrado authored Oct 28, 2024
2 parents 0fbe19d + 86b9c58 commit 0969184
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class EdrProvider extends EventEmitter implements EthereumProvider {
const provider = await context.createProvider(
config.chainType === "optimism"
? OPTIMISM_CHAIN_TYPE
: GENERIC_CHAIN_TYPE,
: GENERIC_CHAIN_TYPE, // TODO: l1 is missing here
{
allowBlocksWithSameTimestamp:
config.allowBlocksWithSameTimestamp ?? false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ export async function resolveUserConfig(
const resolvedNetworkConfig: EdrNetworkConfig = {
type: "edr",
chainId: networkConfig.chainId,
chainType: networkConfig.chainType ?? "l1",
chainType: networkConfig.chainType,
from: networkConfig.from,
gas: resolveGasConfig(networkConfig.gas),
gasMultiplier: networkConfig.gasMultiplier ?? 1,
gasPrice: resolveGasConfig(networkConfig.gasPrice),

// TODO: This isn't how it's called in v2
forkConfig: networkConfig.forkConfig,
hardfork: networkConfig.hardfork ?? "cancun",
networkId: networkConfig.networkId ?? networkConfig.chainId,
blockGasLimit: networkConfig.blockGasLimit ?? 12_500_000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,26 @@ export class NetworkManagerImplementation {
);

if (resolvedNetworkConfig.type === "edr") {
if (
resolvedChainType !== "optimism" &&
resolvedChainType !== "generic" &&
resolvedChainType !== "l1"
) {
throw new HardhatError(
HardhatError.ERRORS.GENERAL.UNSUPPORTED_OPERATION,
{ operation: `Simulating chain type ${resolvedChainType}` },
);
}

return EdrProvider.create(
resolvedNetworkConfig,
// The resolvedNetworkConfig can have its chainType set to `undefined`
// so we default to the default chain type here.
{
...resolvedNetworkConfig,
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions --
This case is safe because we have a check above */
chainType: resolvedChainType as ChainType,
},
{ enabled: false },
{},
(request, defaultBehavior) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ declare module "../../../../types/config.js" {
allowBlocksWithSameTimestamp?: boolean;
enableTransientStorage?: boolean;
enableRip7212?: boolean;

initialBaseFeePerGas?: number;
initialDate?: Date;
coinbase?: string;
// TODO: This isn't how it's called in v2
forkConfig?: ForkConfig;
// TODO: This isn't configurable in v2
forkCachePath?: string;
}

Expand Down

0 comments on commit 0969184

Please sign in to comment.