ethereum / interfaces

Interface Specifications inside Ethereum
36 stars 175 forks source link

Add net_id to provide the current network id #6

Open frozeman opened 7 years ago

frozeman commented 7 years ago

Making the network id accessible on the RPC will allow dapps to know on which network they are right now.

We would need that in mist to know the difference between networks and store accounts accordingly.

@bas-vk @debris @chriseth

debris commented 7 years ago

cc @tomusdrw @jacogr

tomusdrw commented 7 years ago

net_version is returning Network Id in Parity and Geth (not sure about other clients).

https://github.com/ethcore/parity/blob/master/rpc/src/v1/impls/net.rs#L39

https://github.com/ethereum/go-ethereum/blob/3885907c7deb598ed491ca4deccc562b27b31d66/eth/api.go#L1952 https://github.com/ethereum/go-ethereum/blob/fed692f67e81bd3937a5efab38f56a9b99d04d41/eth/backend.go#L210

Maybe we should just update the spec or rename the method?

bas-vk commented 7 years ago

It looks like parity and geth are not following the spec and both return the network id instead of the network protocol version.

I would suggest:

  1. fix net_version and return the network protocol version as HEXNUM instead of a string. Maybe instead of a single version a min and max supported version.
  2. Introduce a new method net_id that returns the network id as HEXNUM
tomusdrw commented 7 years ago

I guess the reason for this is that there is already eth_protocolVersion that returns current protocol version. This is why I suggested to rename the method (or update spec).

If we are going to update this method I suggest it should return id and also latest fork block hash (or at least number) to distinguish possible forks (ETH vs ETC).

danfinlay commented 7 years ago

I'd prefer a non breaking migration path. If we change net_version to net_id, add the new method some period of time before deprecating the old method.

Otherwise, I think updating the spec is a decent immediate step.