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

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

Closed
PaulRBerg opened this issue Oct 24, 2020 · 5 comments · Fixed by #999
Closed

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

PaulRBerg opened this issue Oct 24, 2020 · 5 comments · Fixed by #999

Comments

@PaulRBerg
Copy link
Contributor

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/buidler-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/buidler-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/buidler-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/buidler-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/buidler-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/buidler-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

As explained in this comment, this issue occurs only when the @nomiclabs/buidler-ganache is activated. When the tests are run against an instance of ganache-cli running in parallel, there is no "invalid opcode" error.

I haven't checked whether this has been solved with Hardhat.

Your Environment

  • @nomiclabs/buidler@1.4.8
  • @nomiclabs/buidler-ganache@1.3.3
  • ganache-cli@6.9.0
  • node@12.16.3
  • macOS@10.15.7
@alcuadrado
Copy link
Member

Thanks, @PaulRBerg! I think this is a bug in how we initialize it in the plugin. Will address it soon.

@PaulRBerg
Copy link
Contributor Author

Great, thanks for confirming, @alcuadrado.

@fvictorio
Copy link
Member

This is indeed an issue in hardhat-ganache.

The fix seems simple: add istanbul (and whatever other hardforks are missing) to the hardfork option validator, and then set the hardfork to istanbul. Maybe we should also update the default value, but I'm not sure if that counts as a breaking change.

@alcuadrado
Copy link
Member

This is a recurrent question I have. It's unclear if bumping the hardhfork of the network should actually be a breaking change, given that the users normally think of the default value as being "latest mainnet HF".

@fvictorio
Copy link
Member

Yeah, I agree. And even if it is a breaking change, it would break things only in extremely edge cases. I don't think it makes sense to be overly rigid with that.

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

Successfully merging a pull request may close this issue.

3 participants