Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/rethnet/main' into feat/rethne…
Browse files Browse the repository at this point in the history
…t-nodejs
  • Loading branch information
Wodann committed Sep 15, 2022
2 parents 9759d26 + d377c39 commit 7aacc7c
Show file tree
Hide file tree
Showing 43 changed files with 273 additions and 227 deletions.
5 changes: 0 additions & 5 deletions .changeset/breezy-geese-sleep.md

This file was deleted.

10 changes: 0 additions & 10 deletions .changeset/curly-files-pull.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/green-lemons-design.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/shaggy-pots-return.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/tame-mangos-appear.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/rethnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- "rust-toolchain"
pull_request:
branches: ["*"]
paths:
paths:
- "config/**"
- "crates/**"
- "Cargo.toml"
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ https://hardhat-lime.vercel.app/

## Adding content

Website content is located in `*.md` files withing `src/content` folder. It's written in Markdown syntax. Folders structure in `content` is reflected on the website.
Website content is located in `*.md` files within `src/content` folder. It's written in Markdown syntax. Folders structure in `content` is reflected on the website.

To tune pages, behavior and appearance also use optional `*.yaml` files with additional configurations.

Expand Down Expand Up @@ -181,7 +181,7 @@ There are two relatively independent processes in the build step:

Page paths are generated in the `getStaticPaths` functions in files of the `page` folder. The result of these functions is an array of page paths. Page pros are generated with the `getStaticProps` function which is executed once per page with a page path passed as an argument and returns all required page props.

Execution of `getStaticPaths` and `getStaticProps` is handled by NextJS on a build step and it runs them in isolation (which means we can't share common calculated parameters within them). To optimize a building time we store an intermediate config in a temporary file on the `getStaticPaths` execution and read it from `getStaticProps` functions. It contains layout settings and a map of pages with specific props.
Execution of `getStaticPaths` and `getStaticProps` is handled by NextJS on a build step and it runs them in isolation (which means we can't share common calculated parameters within them). To optimize building time, we store an intermediate config in a temporary file on the `getStaticPaths` execution and read it from `getStaticProps` functions. It contains layout settings and a map of pages with specific props.

## Styling

Expand Down
7 changes: 3 additions & 4 deletions docs/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ export const SOCIALS_LINKS = {
[SocialsEnum.DISCORD]: "/discord",
};

export const BANNER_LINK =
"/hardhat-runner/docs/guides/migrating-from-hardhat-waffle";
export const BANNER_LINK = "https://nomic.foundation/hiring";

export const PRIVACY_POLICY_PATH = "/privacy-policy.html";

export const bannerContent = {
text: "Using @nomiclabs/hardhat-waffle? Check out Hardhat’s new improved replacement!",
shortText: "Check out the new hardhat-waffle replacement!",
text: "Join the Hardhat team! Nomic Foundation is hiring",
shortText: "Join the Hardhat team! We are hiring",
href: BANNER_LINK,
};

Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/hardhat-chai-matchers/docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ await expect(contract.call()).to.be.revertedWith("Some revert message");
await expect(contract.call()).not.to.be.revertedWith("Another revert message");
```

The `revertedWithPanic` matcher allows you to assert that a revert did or didn't occurr with a specific [panic code](https://docs.soliditylang.org/en/v0.8.14/control-structures.html#panic-via-assert-and-error-via-require). You can match a panic code via its integer value (including via hexadecimal notation, such as `0x12`) or via the `PANIC_CODES` dictionary exported from this package:
The `revertedWithPanic` matcher allows you to assert that a revert did or didn't occur with a specific [panic code](https://docs.soliditylang.org/en/v0.8.14/control-structures.html#panic-via-assert-and-error-via-require). You can match a panic code via its integer value (including via hexadecimal notation, such as `0x12`) or via the `PANIC_CODES` dictionary exported from this package:

```js
const { PANIC_CODES } = require("@nomicfoundation/hardhat-chai-matchers/panic");
Expand Down
8 changes: 8 additions & 0 deletions docs/src/content/hardhat-runner/plugins/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ const communityPlugins: IPlugin[] = [
"frontend",
],
},
{
name: "@graphprotocol/hardhat-graph",
author: "The Graph",
authorUrl: "https://thegraph.com",
description:
"Develop your subgraph side by side with your contracts to save gas and increase productivity.",
tags: ["graphprotocol", "subgraph", "graphql", "development", "deployment"],
},
];

const officialPlugins: IPlugin[] = [
Expand Down
3 changes: 3 additions & 0 deletions packages/e2e/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const shell = require("shelljs");

shell.set("-e");

// make sure that this env var is not set
delete process.env.TS_NODE_TRANSPILE_ONLY;

const rootDir = path.join(__dirname, "..", "..");
const hardhatCoreDir = path.join(rootDir, "packages", "hardhat-core");

Expand Down
19 changes: 19 additions & 0 deletions packages/hardhat-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# hardhat

## 2.11.1

### Patch Changes

- f4101d1be: Fixed a problem when the wasm version of the solidity compiler was downloaded.
- 1a1fa4cd5: Fix an error when forking from non-POW chains

## 2.11.0

### Minor Changes

- f3ba15ca8: - Added support for the merge
- Added a new `hardhat_setPrevRandao` RPC method
- Optimized the compilation task
- Typechecking is now opt-in instead of opt-out
- Added a new `--flamegraph` flag for performance profiling
- Artifact paths are now cached
- d93ab3198: Added support for the merge.

## 2.10.2

### Patch Changes
Expand Down
24 changes: 13 additions & 11 deletions packages/hardhat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hardhat",
"version": "2.10.2",
"version": "2.11.1",
"author": "Nomic Labs LLC",
"license": "MIT",
"homepage": "https://hardhat.org",
Expand Down Expand Up @@ -66,6 +66,7 @@
"@types/find-up": "^2.1.1",
"@types/fs-extra": "^5.1.0",
"@types/glob": "^7.1.1",
"@types/keccak": "^3.0.1",
"@types/lodash": "^4.14.123",
"@types/mocha": "^9.1.0",
"@types/node": "^14.0.0",
Expand Down Expand Up @@ -96,18 +97,18 @@
"typescript": "~4.5.2"
},
"dependencies": {
"@nomicfoundation/ethereumjs-block": "^4.0.0-rc.1",
"@nomicfoundation/ethereumjs-blockchain": "^6.0.0-rc.1",
"@nomicfoundation/ethereumjs-common": "^3.0.0-rc.1",
"@nomicfoundation/ethereumjs-evm": "^1.0.0-rc.1",
"@nomicfoundation/ethereumjs-rlp": "^4.0.0-rc.1",
"@nomicfoundation/ethereumjs-statemanager": "^1.0.0-rc.1",
"@nomicfoundation/ethereumjs-trie": "^5.0.0-rc.1",
"@nomicfoundation/ethereumjs-tx": "^4.0.0-rc.1",
"@nomicfoundation/ethereumjs-util": "^8.0.0-rc.1",
"@nomicfoundation/ethereumjs-vm": "^6.0.0-rc.1",
"@ethersproject/abi": "^5.1.2",
"@metamask/eth-sig-util": "^4.0.0",
"@nomicfoundation/ethereumjs-block": "^4.0.0-rc.3",
"@nomicfoundation/ethereumjs-blockchain": "^6.0.0-rc.3",
"@nomicfoundation/ethereumjs-common": "^3.0.0-rc.3",
"@nomicfoundation/ethereumjs-evm": "^1.0.0-rc.3",
"@nomicfoundation/ethereumjs-rlp": "^4.0.0-rc.3",
"@nomicfoundation/ethereumjs-statemanager": "^1.0.0-rc.3",
"@nomicfoundation/ethereumjs-trie": "^5.0.0-rc.3",
"@nomicfoundation/ethereumjs-tx": "^4.0.0-rc.3",
"@nomicfoundation/ethereumjs-util": "^8.0.0-rc.3",
"@nomicfoundation/ethereumjs-vm": "^6.0.0-rc.3",
"@nomicfoundation/solidity-analyzer": "^0.0.3",
"@sentry/node": "^5.18.1",
"@types/bn.js": "^5.1.0",
Expand All @@ -130,6 +131,7 @@
"glob": "7.2.0",
"immutable": "^4.0.0-rc.12",
"io-ts": "1.10.4",
"keccak": "^3.0.2",
"lodash": "^4.17.11",
"mnemonist": "^0.38.0",
"mocha": "^10.0.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/hardhat-core/scripts/console-library-generator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const eutil = require("@ethereumjs/util");
const { keccak256 } = require("ethereum-cryptography/keccak");
const eutil = require("@nomicfoundation/ethereumjs-util");
const fs = require("fs");

const { keccak256 } = require("../internal/util/keccak");

const functionPrefix = "\tfunction";
const functionBody =
") internal view {" + '\n\t\t_sendLogPayload(abi.encodeWithSignature("log(';
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-core/scripts/test-recent-mainnet-block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Common } from "@ethereumjs/common";
import { Common } from "@nomicfoundation/ethereumjs-common";

import { makeForkClient } from "../src/internal/hardhat-network/provider/utils/makeForkClient";
import { runFullBlock } from "../test/internal/hardhat-network/provider/utils/runFullBlock";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-core/scripts/test-run-forked-block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Common } from "@ethereumjs/common";
import { Common } from "@nomicfoundation/ethereumjs-common";
import { request } from "undici";

import { runFullBlock } from "../test/internal/hardhat-network/provider/utils/runFullBlock";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-core/src/builtin-tasks/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD)
});
}

const wasmCompiler = await downloader.getCompiler(solcVersion);
const wasmCompiler = await wasmDownloader.getCompiler(solcVersion);

assertHardhatInvariant(
wasmCompiler !== undefined,
Expand Down
11 changes: 8 additions & 3 deletions packages/hardhat-core/src/internal/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import debug from "debug";
import semver from "semver";
import "source-map-support/register";

import { TASK_COMPILE, TASK_HELP } from "../../builtin-tasks/task-names";
import {
TASK_COMPILE,
TASK_HELP,
TASK_TEST,
} from "../../builtin-tasks/task-names";
import { TaskArguments } from "../../types";
import { HARDHAT_NAME } from "../constants";
import { HardhatContext } from "../context";
Expand Down Expand Up @@ -268,7 +272,8 @@ async function main() {

if (
timestampAfterRun - timestampBeforeRun >
ANALYTICS_SLOW_TASK_THRESHOLD
ANALYTICS_SLOW_TASK_THRESHOLD &&
taskName !== TASK_COMPILE
) {
await hitPromise;
} else {
Expand All @@ -288,7 +293,7 @@ async function main() {

// VSCode extension prompt for installation
if (
taskName === "test" &&
taskName === TASK_TEST &&
!isRunningOnCiServer() &&
process.stdout.isTTY === true
) {
Expand Down
15 changes: 15 additions & 0 deletions packages/hardhat-core/src/internal/core/errors-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,21 @@ If this error persists, run \`npx hardhat clean --global\`.`,
Please [report it](https://github.com/nomiclabs/hardhat/issues/new) to help us improve Hardhat.`,
shouldBeReported: true,
},
CANT_RUN_NATIVE_COMPILER: {
number: 505,
message: `A native version of solc failed to run.
If you are running MacOS, try installing Apple Rosetta.
If this error persists, run "npx hardhat clean --global".`,
title: "Failed to run native solc",
description: `Hardhat successfully downloaded a native version of solc but it doesn't run.
If you are running MacOS, try installing Apple Rosetta.
If this error persists, run "npx hardhat clean --global".`,
shouldBeReported: false,
},
},
BUILTIN_TASKS: {
COMPILE_FAILURE: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ export class BlockchainData {
timestamp,
},
},
{ common: this._common }
{
common: this._common,
skipConsensusFormatValidation: true,
}
),
oldReservation.previousBlockTotalDifficulty
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
toBuffer,
unpadBuffer,
} from "@nomicfoundation/ethereumjs-util";
import { keccak256 } from "ethereum-cryptography/keccak";
import { Map as ImmutableMap, Record as ImmutableRecord } from "immutable";

import { assertHardhatInvariant } from "../../../core/errors";
import { InternalError } from "../../../core/providers/errors";
import { keccak256 } from "../../../util/keccak";
import { JsonRpcClient } from "../../jsonrpc/client";
import { GenesisAccount } from "../node-types";
import { makeAccount } from "../utils/makeAccount";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { arrToBufArr, bufArrToArr } from "@nomicfoundation/ethereumjs-util";
import { keccak256 } from "ethereum-cryptography/keccak";

import {
bufferToRpcData,
rpcData,
} from "../../../core/jsonrpc/types/base-types";
import { validateParams } from "../../../core/jsonrpc/types/input/validation";
import { MethodNotFoundError } from "../../../core/providers/errors";
import { keccak256 } from "../../../util/keccak";
import { getPackageJson } from "../../../util/packageInfo";

/* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
Expand Down Expand Up @@ -46,6 +44,6 @@ export class Web3Module {
}

private async _sha3Action(buffer: Buffer): Promise<string> {
return bufferToRpcData(arrToBufArr(keccak256(bufArrToArr(buffer))));
return bufferToRpcData(keccak256(buffer));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,8 @@ Hardhat Network's forking functionality only works with blocks from at least spu
blockContext = Block.fromBlockData(blockContext, {
freeze: false,
common: this._vm._common,

skipConsensusFormatValidation: true,
});

(blockContext.header as any).baseFeePerGas = 0n;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export async function putGenesisBlock(
{
header,
},
{ common }
{
common,
skipConsensusFormatValidation: true,
}
);

await blockchain.putBlock(genesisBlock);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import type EthereumjsUtilT from "@nomicfoundation/ethereumjs-util";
import type EthereumCryptographyKeccakT from "ethereum-cryptography/keccak";
import type * as UtilKeccakT from "../../../util/keccak";

export class RandomBufferGenerator {
private constructor(private _nextValue: Uint8Array) {}
private constructor(private _nextValue: Buffer) {}

public static create(seed: string): RandomBufferGenerator {
const { bufArrToArr } =
require("@nomicfoundation/ethereumjs-util") as typeof EthereumjsUtilT;
const { keccak256 } =
require("ethereum-cryptography/keccak") as typeof EthereumCryptographyKeccakT;
const { keccak256 } = require("../../../util/keccak") as typeof UtilKeccakT;

const nextValue = keccak256(bufArrToArr(Buffer.from(seed)));
const nextValue = keccak256(Buffer.from(seed));

return new RandomBufferGenerator(nextValue);
}

public next(): Buffer {
const { arrToBufArr } =
require("@nomicfoundation/ethereumjs-util") as typeof EthereumjsUtilT;
const { keccak256 } =
require("ethereum-cryptography/keccak") as typeof EthereumCryptographyKeccakT;
const { keccak256 } = require("../../../util/keccak") as typeof UtilKeccakT;

const valueToReturn = this._nextValue;

this._nextValue = keccak256(this._nextValue);

return arrToBufArr(valueToReturn);
return valueToReturn;
}

public setNext(nextValue: Buffer) {
Expand Down

0 comments on commit 7aacc7c

Please sign in to comment.