-
Notifications
You must be signed in to change notification settings - Fork 680
istanbul chainId opcode returns bad value #515
Comments
After some investigation, this is what I've noticed:
Long story short, fixing this needs:
AND
|
The What we need to do (and will do in our v3 release) is expose a customisable chainId option in ganache-core and ganache-cli. We'll also update the default The Of course, if users find that this |
No one else might see the point, but if the chainId opcode was added it's because there are use-cases for that. I would personally say that it not being supported by ganache is currently preventing me from testing my 2 main projects. |
Also, while chainID and networkID are not strictly speaking the same thing, in the ETH community, the mainnet and the testnests (rinkey, ropsten, kovan, goerli) have this property that chainID = networkID. My usage is to be able to verify meta-transaction signatures that target contracts deployed at the same address on multiple network. When running |
Just spent hours debugging this, extremely frustrating. web3.eth.chainId() should give the same value as the chainId opcode |
It's an issue when using eip712. |
due to a BUG in metamask (MetaMask/metamask-extension#8385), it can't work with any network where chainId != networkid Alas, due to a BUG in ganache (trufflesuite/ganache#515), the chaind is completely broken. The solution is using local GETH for tests, and setting the networkid to the same value of chainid... use "gsn-with-geth" to bring up a local geth (using docker) on port 8545, and GSN running on top of it. for completeness, we also have "gsn-with-ganache" - which works fine, but you can't use it with metamask...
We have a contract that relies on the chainid to protect layer 2 transactions during a fork, and I've been sitting here trying to figure out why Ganache wasn't working correctly and tracked it down to this issue: chainid() should return the same thing as eth_chainId. I see there seems to be some confusion related to the network id: from EIP-695 eth_chainId is supposed to return the chain id (thankfully, given its name ;P), not the network id. This is simply a bug, and should be fixed without waiting for a new major version, because it simply makes Ganache incompatible with all production environments: eth_chainId is simply returning the wrong value (or alternatively is chainid), and so anyone who is attempting to use the chain id right now (which is probably rare, as this is a rather recent feature: only deployed a month after when this bug was filed) already has broken code when run against Ganache. |
@saurik, @dmihal you can pass in We were intending on releasing a major version release of ganache-core a while back, but haven't been able to devote the time to working on planned changes until recently. We have fixed this behavior in the |
Related issue: #557 |
due to a BUG in metamask (MetaMask/metamask-extension#8385), it can't work with any network where chainId != networkid Alas, due to a BUG in ganache (trufflesuite/ganache#515), the chaind is completely broken. The solution is using local GETH for tests, and setting the networkid to the same value of chainid... use "gsn-with-geth" to bring up a local geth (using docker) on port 8545, and GSN running on top of it. for completeness, we also have "gsn-with-ganache" - which works fine, but you can't use it with metamask...
@davidmurdoch Thanks; I don't actually know what a "ganache-core server/provider" is, but if this is exposed to the CLI version I can certainly switch to the CLI version and pass the flag. (Is this not going to be supported in the GUI? ;P Your web page only mentions a download for a GUI tool, and so that's what I was using before and what I had my Q/A team learn how to use.) |
@saurik you can now use the Ganache UI will be updated to add support for this option in the future :-) |
done in ganache@3.0.0-internal.0 |
Could this be backported to the current version? It makes it difficult to test contracts that use chainId. |
not sure why you want it to be backported - it is already available in published ganache-cli@6.12.2 When started with (they said they will make it the default with next major version) |
Thanks, that wasn't clear from the last few comments in the issue. I do hope the default gets fixed soon though, because this can be really difficult for people to debug in the context of EIP712 signatures. |
ganache seems to incorrectly report the chain ID: trufflesuite/ganache#515 If we set the chain ID explicitly, then ganache will use the provided chain ID when handling the CHAINID opcode.
ganache seems to incorrectly report the chain ID: trufflesuite/ganache#515 If we set the chain ID explicitly, then ganache will use the provided chain ID when handling the CHAINID opcode.
ganache seems to incorrectly report the chain ID: trufflesuite/ganache#515 If we set the chain ID explicitly, then ganache will use the provided chain ID when handling the CHAINID opcode.
ganache seems to incorrectly report the chain ID: trufflesuite/ganache#515 If we set the chain ID explicitly, then ganache will use the provided chain ID when handling the CHAINID opcode.
ganache seems to incorrectly report the chain ID: trufflesuite/ganache#515 If we set the chain ID explicitly, then ganache will use the provided chain ID when handling the CHAINID opcode.
I had a similiar problem. In truffel.js the networkId was set to 1337. In the Ganache GUI, too. But when I return the the chainId with the contract function
then i got 1 for the chainId. I know that the networkId is not the chainId. But theres is no way to configure the chainId when using the Ganache GUI. I could not solve the problem but it works with using the trufflesuite / ganache (https://github.com/trufflesuite/ganache) instead. When I start ganache with ganache --chain.chainId 1337 --chain.networkId 1337 The Ganache started on the command line work as good as the Ganache GUI but it is more flexible, because there are much more possibilities to configure Ganache when starting it up. |
@thomasoss It's on our road map to get Ganache UI updated with the latest Ganache. Since your problem is now more related to Ganache UI, I'm going to make your comment an issue in the |
Steps to reproduce
chainId()
function.I expect the returned value to be the chainId passed using the
-i
flag and accessible usingawait web3.eth.net.getId();
... but I get a value of1
The text was updated successfully, but these errors were encountered: