NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.28k stars 1.41k forks source link

Throws "Option:unwrap() on None" #5784

Closed peersky closed 1 month ago

peersky commented 1 month ago

Version of Hardhat

2.22.12

What happened?

Getting error when running my tests:

Error: called `Option::unwrap()` on a `None` value
      at EdrProviderWrapper._rawTraceToSolidityStackTrace (node_modules/.pnpm/hardhat@2.22.12_bufferutil@4.0.8_ts-node@10.9.2_@types+node@17.0.45_typescript@5.6.2__typescr_fivwhmpgpti4rjcnin4liao2wi/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:584:38)
      at EdrProviderWrapper.request (node_modules/.pnpm/hardhat@2.22.12_bufferutil@4.0.8_ts-node@10.9.2_@types+node@17.0.45_typescript@5.6.2__typescr_fivwhmpgpti4rjcnin4liao2wi/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:424:33)
      at async EthersProviderWrapper.send (node_modules/.pnpm/@nomiclabs+hardhat-ethers@2.2.3_ethers@5.7.2_bufferutil@4.0.8_utf-8-validate@5.0.10__hardhat@_5uj7fj26vun34ezzedn6lrmbnm/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

Minimal reproduction steps

Likely because of 2.22.12 release (does not happen in 2.22.11).

here is my dependency list:

"devDependencies": {
    "@changesets/changelog-github": "^0.4.8",
    "@changesets/cli": "^2.26.2",
    "@nomicfoundation/hardhat-chai-matchers": "^1.0.1",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.9",
    "@nomicfoundation/hardhat-toolbox": "^2.0.2",
    "@nomiclabs/buidler": "^1.4.8",
    "@nomiclabs/buidler-web3": "^1.3.4",
    "@nomiclabs/hardhat-ethers": "^2.0.6",
    "@nomiclabs/hardhat-etherscan": "^3.1.8",
    "@peeramid-labs/eds": "^1.0.0",
    "@shopify/eslint-plugin": "^43.0.0",
    "@solidstate/contracts": "^0.0.35",
    "@typechain/ethers-v5": "^11.1.2",
    "@typechain/hardhat": "^7.0.0",
    "@typechain/web3-v1": "^6.0.1",
    "@types/cli-table": "^0.3.0",
    "@types/crypto-js": "^4.1.1",
    "@types/node-fetch": "^2.6.2",
    "@typescript-eslint/parser": "^7.16.0",
    "chai": "^4.3.6",
    "crypto-js": "^4.1.1",
    "eslint": "^9.6.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-promise": "^6.4.0",
    "eth-create2-calculator": "^1.1.5",
    "ethers": "^5.6.6",
    "globals": "^15.9.0",
    "hardhat": "=2.22.11",
    "hardhat-abi-exporter": "^2.9.0",
    "hardhat-contract-sizer": "^2.6.1",
    "hardhat-deploy": "^0.12.2",
    "hardhat-diamond-abi": "^3.0.0",
    "keccak": "^3.0.1",
    "mocha": "^10.0.0",
    "prettier-plugin-solidity": "^1.1.3",
    "solhint": "^3.6.2",
    "solidity-coverage": "^0.8.5",
    "solidity-docgen": "^0.6.0-beta.36",
    "typechain": "^8.0.0",
    "web3": "^1.8.2"
  },
  "dependencies": {
    "@aragon/osx": "^1.3.0",
    "@aragon/osx-ethers": "^1.3.0",
    "@aragon/sdk-client": "^1.26.0",
    "@ethersproject/abi": "^5.7.0",
    "@ethersproject/providers": "^5.7.2",
    "@openzeppelin/contracts": "^5.0.0",
    "@openzeppelin/contracts-upgradeable": "^5.0.0",
    "@safe-global/safe-contracts": "1.4.1-build.0",
    "@types/chai": "^4.3.1",
    "@types/mocha": "^9.1.1",
    "@types/node": "^17.0.36",
    "chalk": "^4.1.2",
    "cli-table": "^0.3.11",
    "hardhat-gas-reporter": "^1.0.9",
    "ts-node": "^10.9.1",
    "typescript": "^5.2.2"
  }

Search terms

No response

holyhansss commented 1 month ago

I recommend using Hardhat version 2.22.9. After updating to a newer version, I encountered an unexpected issue where my tests began throwing an 'Option:unwrap() on None' error. Reverting to the previous version should resolve this problem.

    "hardhat": "^2.22.9",
peersky commented 1 month ago

I recommend using Hardhat version 2.22.9. After updating to a newer version, I encountered an unexpected issue where my tests began throwing an 'Option:unwrap() on None' error. Reverting to the previous version should resolve this problem.

    "hardhat": "^2.22.9",

Same here, I reverted to 2.22.11

kanej commented 1 month ago

Hey @peersky, this is a likely a bug in changes around our tracing API. Do you have an example to help us reproduce the issue and put together a bug fix?

peersky commented 1 month ago

Hey @peersky, this is a likely a bug in changes around our tracing API. Do you have an example to help us reproduce the issue and put together a bug fix?

git clone https://github.com/peeramid-labs/contracts
git checkout ebd6e2192559c2a847cb2c203a7de5118292f7d5
export FORK_RPC_URL=<set_some_arbitrum>  
pnpm install 
pnpm add -D hardhat@2.22.12 --save-exact 
pnpm run test --bail 

You should receive

  1) DNSFacet.ts
       Transfer ownership can be done only by contract owner:
     Error: called `Option::unwrap()` on a `None` value
Wodann commented 1 month ago

I tried running the example locally but wasn't able to. To generate a stack trace, could you please try running:

RUST_BACKTRACE=full pnpm run test --bail

peersky commented 1 month ago
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:        0x11ec34210 - _napi_register_module_v1
   1:        0x11ec522d0 - _napi_register_module_v1
   2:        0x11ec31a44 - _napi_register_module_v1
   3:        0x11ec34068 - _napi_register_module_v1
   4:        0x11ec35008 - _napi_register_module_v1
   5:        0x11ec34cfc - _napi_register_module_v1
   6:        0x11ec358c0 - _napi_register_module_v1
   7:        0x11ec352c4 - _napi_register_module_v1
   8:        0x11ec34698 - _napi_register_module_v1
   9:        0x11ec35060 - _napi_register_module_v1
  10:        0x11ec959f8 - _napi_register_module_v1
  11:        0x11ec95a78 - _napi_register_module_v1
  12:        0x11ec959b0 - _napi_register_module_v1
  13:        0x11e8a6e24 - <unknown>
  14:        0x11e8a6f40 - <unknown>
  15:        0x11e616e6c - <unknown>
  16:        0x11e6c59e0 - <unknown>
  17:        0x11e806d98 - <unknown>
  18:        0x11e616eb0 - <unknown>
  19:        0x11e56018c - <unknown>
peersky commented 1 month ago

tried running the example locally but wasn't able to. T

what issue you faced?

Wodann commented 1 month ago

Error: Trying to initialize a provider with block 257223284 but the current block is 20876867

I assumed that you're developing for Ethereum mainnet, so used a remote endpoint for that.

peersky commented 1 month ago

Error: Trying to initialize a provider with block 257223284 but the current block is 20876867

I assumed that you're developing for Ethereum mainnet, so used a remote endpoint for that.

arbitrum, forgot to mention, soz :)

peersky commented 1 month ago

tbh I have quite outdated some of my dependencies because of efforts to migrate all tests and other tooling to ethers-v6, I could think of that as one of possible reasons, as some of peer deps are not met.

But given fact that @holyhansss also reported same, could be also on your side.

agostbiro commented 1 month ago

Thanks for the detailed bug report @peersky !

We've released EDR v0.6.3 with a fix for this issue (EDR is a dependency of Hardhat).

To upgrade to the latest EDR version immediately, you can remove your node_modules directory and npm/yarn/pnpm lock file and reinstall your dependencies. Otherwise you can wait for the next Hardhat release which will automatically use the latest EDR version.

You can verify that you’re using the latest version of EDR by running the following command: npm ls @nomicfoundation/edr.

kanej commented 4 weeks ago

The EDR v0.6.3 version was released in Hardhat as part of v2.22.13:

https://github.com/NomicFoundation/hardhat/releases/tag/hardhat%402.22.13