Skip to content
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

Support older hard forks #1372

Merged
merged 15 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments
  • Loading branch information
alcuadrado committed Apr 6, 2021
commit 889d219506d3cf7c77ccd82d0f28f99c32847537
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class HardhatNode extends EventEmitter {
common = await makeForkCommon(config);

this._validateHardforks(
config.hardfork,
config.forkConfig.blockNumber,
common,
forkClient.getNetworkId()
Expand Down Expand Up @@ -197,7 +196,6 @@ export class HardhatNode extends EventEmitter {
}

private static _validateHardforks(
Copy link
Member Author

Choose a reason for hiding this comment

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

We validate this here because:

  1. The config validation can't make requests and fetch the remote chainId.
  2. The node task can provide a different block number so the config validation won't be enough.

localHardfork: string,
forkBlockNumber: number | undefined,
common: Common,
remoteChainId: number
Expand All @@ -206,7 +204,7 @@ export class HardhatNode extends EventEmitter {
throw new InternalError(
Copy link
Member Author

Choose a reason for hiding this comment

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

Throwing ProviderErrors because this are thrown from a request, as the HardhatNode instance is created on the first RPC request.

`Invalid hardfork selected in Hardhat Network's config.

The hardfork must be at least spuriousDragon, but ${localHardfork} was given.`
The hardfork must be at least spuriousDragon, but ${common.hardfork()} was given.`
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("Hardhat Network special options", function () {
useFixtureProject("hardhat-network-spurious-dragon");
useEnvironment();

it("should accept hard forks as late as chainnstart and use them", async function () {
it("should accept hardforks as late as chainstart and use them", async function () {
const [sender] = await this.env.network.provider.send("eth_accounts");
await assert.isRejected(
this.env.network.provider.send("eth_sendTransaction", [
Expand Down