0x-mesh icon indicating copy to clipboard operation
0x-mesh copied to clipboard

mesh: Make sure Ethereum RPC URL points to configured networkId

Open fabioberger opened this issue 5 years ago • 4 comments

Mesh operators can specify both a ETHEREUM_RPC_URL and ETHEREUM_CHAIN_ID. They could inadvertently specify an Ethereum RPC URL pointing to an Ethereum node running on a different network then the networkId specified by ETHEREUM_CHAIN_ID.

We could either:

  • Remove the ETHEREUM_NETWORK_ID config and on boot-up fetch the networkId from the Ethereum node. OR
  • Fetch the networkId from the Ethereum node, compare it to the supplied ETHEREUM_NETWORK_ID and simply check that they are the same.

fabioberger avatar Jun 15 '19 00:06 fabioberger

Fetch the networkId from the Ethereum node, compare it to the supplied ETHEREUM_NETWORK_ID and simply check that they are the same.

This is my preferred option because the other would incur additional start up latency which is unnecessary in most cases. (Not to say that this check is unimportant. Just that most of the time the configured networkId will be correct).

albrow avatar Jun 18 '19 23:06 albrow

Should we crash if it turns out it isn't correct? Or simply print a warning to the console?

fabioberger avatar Jun 26 '19 21:06 fabioberger

@albrow Can we close this now that #733 has been merged?

jalextowle avatar Jul 17 '20 20:07 jalextowle

There are still some issues with the approach taken in #733. We made the decision to do the chainId check in a separate goroutine so that we don't slow down the rest of Mesh when first starting up. However, that also means there is currently a race condition where we can start processing blocks or incoming orders before we realize there is a chainId mismatch.

I proposed a different solution in https://github.com/0xProject/0x-mesh/issues/866. We can close this issue if we decide to go that route. Otherwise we should leave it open and address the problems with the current implementation somehow.

albrow avatar Jul 17 '20 20:07 albrow