Skip to content

Commit

Permalink
Merge branch 'master' into stack-traces-error-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado committed Jun 8, 2021
2 parents 5ddcbe2 + 08353c3 commit 40b197e
Show file tree
Hide file tree
Showing 84 changed files with 58,737 additions and 959 deletions.
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ All tests are written using [mocha](https://mochajs.org) and [chai](https://www.
### Per-package
You can run a package's tests by executing `yarn test` inside its folder.

_Note_: for package [hardhat-vyper](./packages/hardhat-vyper) case, a running instance of Docker Desktop is required, with `ethereum/vyper` image pulled. To install it, run:
_Note_: for package [hardhat-vyper](./packages/hardhat-vyper) case, a running instance of Docker Desktop is required, with `vyperlang/vyper` image pulled. To install it, run:
```
docker pull ethereum/vyper:0.1.0b10
docker pull vyperlang/vyper:0.1.0b10
```

### Entire project
You can run all the tests at once by running `yarn test` from the root folder.

For the case of package [hardhat-vyper](./packages/hardhat-vyper), an `ethereum/vyper` docker instance installed is required (see previous section for details). _Exception_ of this requirement is if running on a Windows local machine, in this case we skip it by default since Win 10 Pro version would be also required.
For the case of package [hardhat-vyper](./packages/hardhat-vyper), an `vyperlang/vyper` docker instance installed is required (see previous section for details). _Exception_ of this requirement is if running on a Windows local machine, in this case we skip it by default since Win 10 Pro version would be also required.

## Code formatting

Expand Down Expand Up @@ -118,7 +118,7 @@ All these tips assume you are running `yarn watch` from the root directory.
You can [link](https://classic.yarnpkg.com/en/docs/cli/link/) any package to test it locally. For example, if you are working on
`hardhat`, you can follow these steps:

1. Go to `packages/hardhat` and run `yarn link`
1. Go to `packages/hardhat-core` and run `yarn link`
2. Go to some hardhat project and run `yarn link hardhat`

Now any change you make in the code will be reflected in that project.
Expand All @@ -134,7 +134,7 @@ alias lhh='node --preserve-symlinks $(node -e "console.log(require.resolve(\"har

If for any reason linking doesn't work for you, you can use [`yalc`](https://github.com/whitecolor/yalc).

1. Go to `packages/hardhat` and run `yalc publish`
1. Go to `packages/hardhat-core` and run `yalc publish`
2. Go to some hardhat project and run `yalc add hardhat`

Unlike linking, if you make a change in the code, you'll need to repeat the process.
Expand All @@ -143,7 +143,7 @@ Unlike linking, if you make a change in the code, you'll need to repeat the proc

An even more realistic way of using your local changes in a project is to use [`yarn pack`](https://classic.yarnpkg.com/en/docs/cli/pack/):

1. Go to `packages/hardhat` and run `yarn pack`. This will create a `nomiclabs-hardhat-x.y.z.tgz` file in that directory.
1. Go to `packages/hardhat-core` and run `yarn pack`. This will create a `nomiclabs-hardhat-x.y.z.tgz` file in that directory.
2. Go to some hardhat project and run `yarn add /path/to/hardhat/packages/hardhat/nomiclabs-hardhat-x.y.z.tgz`.

Unlike linking, if you make a change in the code, you'll need to repeat the process.
Expand Down
28 changes: 27 additions & 1 deletion docs/.vuepress/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ const plugins = [
"Easily integrate your Hardhat project with Tenderly. Tenderly is an Ethereum monitoring, debugging and analytics platform.",
tags: ["Debuggin", "Monitoring", "Alerting", "Tasks", "Scripts"],
},
{
name: "hardhat-ethernal",
author: "Ethernal",
authorUrl: "https://www.tryethernal.com",
url: "https://github.com/tryethernal/hardhat-ethernal/tree/master",
description: "Integrate your Hardhat project and Hardhat network with Ethernal. Ethernal is a block explorer for private chains.",
tags: ["explorer", "debugging", "development-tool"]
},
{
name: "hardhat-typechain",
author: "Rahul Sethuram",
Expand Down Expand Up @@ -268,7 +276,7 @@ const plugins = [
tags: ["Networks", "Config"],
},
{
name: "@eth-optimisim/smock",
name: "@eth-optimism/smock",
author: "Optimism",
authorUrl: "https://github.com/ethereum-optimism",
url: "https://github.com/ethereum-optimism/smock/tree/master",
Expand Down Expand Up @@ -304,6 +312,15 @@ const plugins = [
"A Hardhat plugin that generates a React hook component from your smart contracts. Hot reloaded into your React app. Deployed or not deployed. And everything typed and initialized.",
tags: ["Ethers", "React", "Deploy", "Typechain", "Frontend", "Web3modal"],
},
{
name: "hardhat-etherscan-abi",
author: "Roman Semenov",
authorUrl: "https://github.com/poma",
url:
"https://github.com/poma/hardhat-etherscan-abi/tree/master",
description: "Automatically fetch contract ABI from Etherscan",
tags: ["Etherscan", "ABI"],
},
{
name: "hardhat-tracer",
author: "Soham Zemse",
Expand All @@ -312,6 +329,15 @@ const plugins = [
description: "See emitted events during your hardhat tests in the console",
tags: ["Events", "Logs", "Trace", "Console", "Testing"],
},
{
name: "hardhat-circom",
author: "Project Sophon",
authorUrl: "https://github.com/projectsophon",
url:
"https://github.com/projectsophon/hardhat-circom/tree/master",
description: "Provide tasks to integrate Circom and SnarkJS",
tags: ["Circom", "Snarkjs", "Preprocessor", "Compiling", "Tasks", "Scripts"],
},
];

module.exports = plugins.map((p) => ({
Expand Down
8 changes: 4 additions & 4 deletions docs/.vuepress/theme/components/HHTopBar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template lang="pug">
section.top-bar
a(
href="https://medium.com/nomic-labs-blog/better-solidity-debugging-console-log-is-finally-here-fc66c54f2c4a",
href="https://www.notion.so/nomiclabs/Nomic-Labs-jobs-991b37c547554f75b89a95f437fd5056",
target="_blank",
rel="noopener noreferrer"
)
Expand All @@ -17,8 +17,8 @@ section.top-bar
|
|
span.top-text
a(:href="postUrl" class="top-bar-link" target="_blank" rel="noopener noreferrer") Buidler is now Hardhat: Learn more about the latest release and rebrand
span here
a(:href="postUrl" class="top-bar-link" target="_blank" rel="noopener noreferrer") Join the Hardhat team! Nomic Labs is
span hiring
span.colored.reverse.animation-6chars
span
|
Expand Down Expand Up @@ -55,7 +55,7 @@ export default {
data() {
return {
postUrl:
"https://medium.com/nomic-labs-blog/buidler-has-evolved-introducing-hardhat-4bccd13bc931",
"https://www.notion.so/nomiclabs/Nomic-Labs-jobs-991b37c547554f75b89a95f437fd5056",
};
},
};
Expand Down
4 changes: 2 additions & 2 deletions docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ You can set the following fields on the `hardhat` config:
- `hardfork`: This setting changes how Hardhat Network works, to mimic Ethereum's mainnet at a given hardfork. It must be one of `"byzantium"`, `"constantinople"`, `"petersburg"`, `"istanbul"`, `"muirGlacier"`, and `"berlin"`. Default value: `"berlin"`

- `throwOnTransactionFailures`: A boolean that controls if Hardhat Network throws on transaction failures.
If this value is `true`, Hardhat Network will throw [combined JavaScript and Soldity stack traces](../hardhat-network/README.md#solidity-stack-traces)
If this value is `true`, Hardhat Network will throw [combined JavaScript and Solidity stack traces](../hardhat-network/README.md#solidity-stack-traces)
on transaction failures. If it is `false`, it will return the failing transaction hash. In both cases
the transactions are added into the blockchain. Default value: `true`
- `throwOnCallFailures`: A boolean that controls if Hardhat Network throws on call failures.
If this value is `true`, Hardhat Network will throw [combined JavaScript and Soldity stack traces](../hardhat-network/README.md#solidity-stack-traces)
If this value is `true`, Hardhat Network will throw [combined JavaScript and Solidity stack traces](../hardhat-network/README.md#solidity-stack-traces)
when a call fails. If it is `false`, it will return the call's `return data`, which can contain
a revert reason. Default value: `true`

Expand Down
4 changes: 4 additions & 0 deletions docs/guides/compile-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ module.exports = {

We recommend always setting a compiler version to avoid unexpected behavior or compiling errors as new releases of Solidity are published.

:::: warning
Hardhat will automatically download the versions of `solc` that you set up. If you are behind an HTTP proxy, you may need to set the `HTTP_PROXY` or `HTTPS_PROXY` environment variable to the URL of your proxy.
::::

The expanded usage allows for more control of the compiler:

```js
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/mainnet-forking.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ await hre.network.provider.request({
)
```

If you are using [`hardhat-ethers`](https://github.com/nomiclabs/hardhat/tree/master/packages/hardhat-ethers), call `getSigner` to use the impersonated account:
If you are using [`hardhat-ethers`](https://github.com/nomiclabs/hardhat/tree/master/packages/hardhat-ethers), call `getSigner` after impersonating the account:

```
const signer = await ethers.provider.getSigner("0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6")
Expand Down
32 changes: 31 additions & 1 deletion docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,43 @@ If you are sure you need a `tsconfig.json` file, here's a template to base yours
However you modify it, please make sure your config file is included in your project. The easiest way of doing this is
by keeping its path in the `files` array.

### Support for path mappings

Typescript allows defining custom [path mappings](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) via the [`paths`](https://www.typescriptlang.org/tsconfig#paths) configuration option:

```json5
{
"compilerOptions": {
"paths": { "~/*": ["src/*"] },
// ...Other compilerOptions
},
"include": ["./scripts", "./test"],
"files": ["./hardhat.config.ts"]
}
```

To support this option when running Hardhat tests or scripts, you need to install the package [`tsconfig-paths`](https://www.npmjs.com/package/tsconfig-paths) and register it in your `hardhat.config.ts`:

```typescript
import { HardhatUserConfig } from 'hardhat/config';

// This adds support for typescript paths mappings
import 'tsconfig-paths/register';

const config: HardhatUserConfig = {
// Your type-safe config goes here
};

export default config;
```

## Performance optimizations

Under the hood, Hardhat uses [ts-node](https://www.npmjs.com/package/ts-node) to support TypeScript. By default, it
will recompile and type-check everything on every run. Depending on your project's size, this can get slow.

You can make Hardhat run faster by preventing `ts-node` from type-checking your project. This is done by setting the
`TS_NODE_TRANSPILE_ONLY` en variable to `1`.
`TS_NODE_TRANSPILE_ONLY` env variable to `1`.

For example, you can run your TypeScript-based tests faster like this `TS_NODE_TRANSPILE_ONLY=1 npx hardhat test`.

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/waffle-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Look at the `hardhat.config.js` file and you'll see that the Waffle plugin is en
<<< @/../packages/hardhat-core/sample-project/hardhat.config.js{1}

::: tip
There's no need for `require("@nomiclabs/hardhat-ethers")`, as `hardhat-waffle` already does it.
There's no need for `require("@nomiclabs/hardhat-ethers")`, as `@nomiclabs/hardhat-waffle` already does it.
:::

## Testing
Expand Down Expand Up @@ -77,7 +77,7 @@ const { expect } = require("chai");

We are requiring `Chai` which is an assertions library. These asserting functions are called "matchers", and the ones we're using here actually come from Waffle.

This is why we're using the `hardhat-waffle` plugin, which makes it easier to assert values from Ethereum. Check out [this section](https://ethereum-waffle.readthedocs.io/en/latest/matchers.html) in Waffle's documentation for the entire list of Ethereum-specific matchers.
This is why we're using the `@nomiclabs/hardhat-waffle` plugin, which makes it easier to assert values from Ethereum. Check out [this section](https://ethereum-waffle.readthedocs.io/en/latest/matchers.html) in Waffle's documentation for the entire list of Ethereum-specific matchers.

::: warning
Some Waffle matchers return a Promise rather than executing immediately. If you're making a call or sending a transaction, make sure to check Waffle's documentation, and `await` these Promises. Otherwise your tests may pass without running all checks.
Expand Down
41 changes: 40 additions & 1 deletion docs/hardhat-network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,45 @@ eth_call
This logging is enabled by default when using Hardhat Network's node (i.e. `npx hardhat node`), but disabled when using
the in-process Hardhat Network provider. See [Hardhat Network's config](../config/README.md#hardhat-network) to learn more about how to control its logging.

## The `debug_traceTransaction` method

You can get debug traces of already mined transactions using the
`debug_traceTransaction` RPC method. The returned object has a detailed
description of the transaction execution, including a list of steps describing
each executed opcode and the state of the EVM at that point.

To get a trace, call this method with the hash of the transaction as its
argument:

```js
const trace = await hre.network.provider.send("debug_traceTransaction",
["0x123..."])
```

You can also selectively disable some properties in the list of steps:

```js
const trace = await hre.network.provider.send("debug_traceTransaction", [
"0x123...",
{
disableMemory: true,
disableStack: true,
disableStorage: true,
}
]);
```

If you are using [mainnet forking](https://hardhat.org/guides/mainnet-forking.html) with an archive node,
you can get traces of transactions from the remote network even if the node you are using
doesn't support
`debug_traceTransaction`.

### Known limitations

- You can't trace transactions that use a hardfork older than [Spurious Dragon](https://ethereum.org/en/history/#spurious-dragon)
- The last step of a message is not guaranteed to have a correct value in the
`gasCost` property

## Hardhat Network initial state

Hardhat Network is initialized by default in this state:
Expand Down Expand Up @@ -344,7 +383,7 @@ To customise it, take a look at [the configuration section](/config/README.md#ha
- `eth_pendingTransactions`
- `eth_sendRawTransaction`
- `eth_sendTransaction`
- `eth_signTypedData`
- `eth_signTypedData_v4`
- `eth_sign`
- `eth_subscribe`
- `eth_syncing`
Expand Down
2 changes: 1 addition & 1 deletion docs/metamask-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you are using MetaMask with Hardhat Network, you might get an error like this
Incompatible EIP155-based V 2710 and chain id 31337. See the second parameter of the Transaction constructor to set the chain id.
```

This is because MetaMask mistakenly assumes all networks in `http://localhost:8545` to have a chain id of `1337`, but Hardhat uses a different number by default. **Please voice your support for MetaMask to fix this on [the MetaMask issue about it](https://github.com/MetaMask/metamask-extension/issues/9827).**
This is because MetaMask mistakenly assumes all networks in `http://localhost:8545` to have a chain id of `1337`, but Hardhat uses a different number by default. **Please voice your support for MetaMask to fix this on [the MetaMask issue about it](https://github.com/MetaMask/metamask-extension/issues/10290).**

In the meantime, to resolve this you can set the `chainId` of Hardhat Network to `1337` in your Hardhat config:

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/deploying-to-a-live-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = {

We're using [Alchemy](https://www.alchemyapi.io), but pointing `url` to any Ethereum node or gateway would work. Go grab your `ALCHEMY_API_KEY` and come back.

To deploy on Ropsten you need to send ropsten-ETH into the address that's going to be making the deployment. You can get some ETH for testnets from a faucet, a service that distributes testing-ETH for free. [Here's the one for Ropsten](https://faucet.metamask.io/), you'll have to change Metamask's network to Ropsten before transacting.
To deploy on Ropsten you need to send ropsten-ETH into the address that's going to be making the deployment. You can get some ETH for testnets from a faucet, a service that distributes testing-ETH for free. [Here's the one for Ropsten](https://faucet.ropsten.be/), you'll have to change Metamask's network to Ropsten before transacting.

::: tip
You can get some ETH for other testnets following these links:
Expand Down
Loading

0 comments on commit 40b197e

Please sign in to comment.