Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

"invalid opcode" when reading chain id from inline assembly #654

Closed
PaulRBerg opened this issue Oct 24, 2020 · 4 comments
Closed

"invalid opcode" when reading chain id from inline assembly #654

PaulRBerg opened this issue Oct 24, 2020 · 4 comments

Comments

@PaulRBerg
Copy link

PaulRBerg commented Oct 24, 2020

Expected Behavior

The chain id should be accessible via inline assembly, as this is a feature available since solidity 0.5.12.

Current Behavior

The function that attempts to read the chain id fails with the following error:

Error: VM Exception while processing transaction: invalid opcode
  at HttpProvider.send (node_modules/@nomiclabs/buidler/src/internal/core/providers/http.ts:36:34)
  at /Users/paulrberg/Workspace/Pad/ganache-invalid-opcode/node_modules/@nomiclabs/buidler/src/internal/core/providers/gas-providers.ts:115:21
  at Proxy.cloningSendWrapper (node_modules/@nomiclabs/buidler/src/internal/core/providers/wrapper.ts:9:12)
  at /Users/paulrberg/Workspace/Pad/ganache-invalid-opcode/node_modules/@nomiclabs/buidler/src/internal/core/providers/accounts.ts:219:21
  at Proxy.cloningSendWrapper (node_modules/@nomiclabs/buidler/src/internal/core/providers/wrapper.ts:9:12)
  at /Users/paulrberg/Workspace/Pad/ganache-invalid-opcode/node_modules/@nomiclabs/buidler/src/internal/core/providers/gas-providers.ts:63:21
  at Proxy.cloningSendWrapper (node_modules/@nomiclabs/buidler/src/internal/core/providers/wrapper.ts:9:12)
  at /Users/paulrberg/Workspace/Pad/ganache-invalid-opcode/node_modules/@nomiclabs/buidler/src/internal/core/providers/gas-providers.ts:41:21
  at Proxy.cloningSendWrapper (node_modules/@nomiclabs/buidler/src/internal/core/providers/wrapper.ts:9:12)
  at EthersProviderWrapper.send (node_modules/@nomiclabs/buidler-ethers/src/ethers-provider-wrapper.ts:13:48)
  at EthersProviderWrapper.<anonymous> (node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:439:31)
  at step (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:46:23)
  at Object.next (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:27:53)
  at /Users/paulrberg/Workspace/Pad/ganache-invalid-opcode/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:71
  at new Promise (<anonymous>)
  at __awaiter (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:17:12)

Steps to Reproduce

  1. Clone paulrberg/ganache-invalid-opcode
  2. Install dependencies with yarn
  3. Generate artifacts with yarn run typechain
  4. Run the tests with yarn run test and get the same error as above

Context

I'm running Ganache via a Hardhat (formerly Buidler) plugin called @nomiclabs/buidler-ganache, yet I don't see why Hardhat would be the culprit, so that's why I opened the issue here. If you disable the plugin and run the latest version of ganache-cli in a parallel console session, you get the exact same error. Update: this is actually a bug with Hardhat, see below.

Finally, I know about #515 and the plan to patch the bug in v3.0, but I hadn't seen people complaining that reading the chain id reverts, as it happens in my case.

Your Environment

  • @nomiclabs/buidler-ganache@1.3.3
  • ganache-cli@6.9.0
  • node@12.16.3
  • macOS@10.15.7
@PaulRBerg PaulRBerg changed the title "invalid opcode" when readin chain id from inline assembly "invalid opcode" when reading chain id from inline assembly Oct 24, 2020
@PaulRBerg
Copy link
Author

@davidmurdoch
Copy link
Member

Can you try ganache-cli@6.12.0?

@PaulRBerg
Copy link
Author

PaulRBerg commented Oct 24, 2020

I cannot reproduce the bug if I disable the @nomiclabs/buidler-ganache plugin, as in, there is no "invalid opcode" with either ganache-cli v6.9.0 or 6.12.0.

Sorry, it may be the case that Hardhat has a bug, not Ganache. I'll keep this issue open only for a few hours to confirm my findings.

@PaulRBerg
Copy link
Author

Closing in favour of nomiclabs/hardhat#952.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants