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

"eth_chainId" sometimes returns 0x0 instead of the correct chainId #20894

Closed
nicinuse opened this issue Apr 6, 2020 · 11 comments · Fixed by #21686
Closed

"eth_chainId" sometimes returns 0x0 instead of the correct chainId #20894

nicinuse opened this issue Apr 6, 2020 · 11 comments · Fixed by #21686
Assignees

Comments

@nicinuse
Copy link

nicinuse commented Apr 6, 2020

Hi there,

I am trying to set up a chainlinnk node with latest stable geth client, but it fails vecause of missing chainId value.

System information

Geth version:

Geth
Version: 1.9.12-stable
Git Commit: b6f1c8dcc058a936955eb8e5766e2962218924bc
Git Commit Date: 20200316
Architecture: amd64
Protocol Versions: [65 64 63]
Go Version: go1.13.8
Operating System: linux
GOPATH=
GOROOT=/usr/local/go

OS & Version:

Alpine Linux
```
Commit hash : (if `develop`)

#### Expected behaviour
Return the correct chainId


#### Actual behaviour
ChainId is always "0x0" (not available)


#### Steps to reproduce the behaviour
Run geth with
```
geth --testnet --nousb --rpc --rpcaddr '0.0.0.0' --rpcvhosts '*' --rpccorsdomain '*'
```
Ask for chainId
```
curl -k -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"eth_chainId","id":1}' http://localhost:8545
```
@ligi
Copy link
Member

ligi commented Apr 6, 2020

seems to just happen for "--testnet" - got the correct results for --goerli and main net. Testnet will be deprecated soon anyway as of #20852 - but should still be fixed IMHO. Thanks for the report

@ligi ligi changed the title missing "eth_chainId" via API "eth_chainId" returns 0x0 for --testnet Apr 6, 2020
@nicinuse
Copy link
Author

nicinuse commented Apr 7, 2020

Hi there,

running a geth client on main net

geth --nousb --ws
INFO [04-07|04:36:34.474] Bumping default cache on mainnet         provided=1024 updated=4096
WARN [04-07|04:36:34.474] Sanitizing cache to Go's GC limits       provided=4096 updated=1980
INFO [04-07|04:36:34.477] Maximum peer count                       ETH=50 LES=0 total=50
INFO [04-07|04:36:34.477] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [04-07|04:36:34.478] Starting peer-to-peer node               instance=Geth/v1.9.12-stable-b6f1c8dc/linux-amd64/go1.13.8
INFO [04-07|04:36:34.478] Allocated trie memory caches             clean=495.00MiB dirty=495.00MiB
INFO [04-07|04:36:34.479] Allocated cache and file handles         database=/root/.ethereum/geth/chaindata cache=990.00MiB handles=512
INFO [04-07|04:36:34.504] Opened ancient database                  database=/root/.ethereum/geth/chaindata/ancient
INFO [04-07|04:36:34.504] Writing default main-net genesis block
INFO [04-07|04:36:34.801] Persisted trie from memory database      nodes=12356 size=1.78MiB time=77.057798ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [04-07|04:36:34.801] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 Petersb
urg: 7280000 Istanbul: 9069000, Muir Glacier: 9200000, Engine: ethash}"

and trying to get the network id via ws api request returns "0x0" too.

wscat -c localhost:8546
Connected (press CTRL+C to quit)
> {"jsonrpc":"2.0","method":"eth_chainId","id":1}
< {"jsonrpc":"2.0","id":1,"result":"0x0"}

@ligi
Copy link
Member

ligi commented Apr 7, 2020

hm - very strange - for mainnet I get the correct result:


> {"jsonrpc":"2.0","method":"eth_chainId","id":1}
< {"jsonrpc":"2.0","id":1,"result":"0x1"}

@tyrion70
Copy link

tyrion70 commented Apr 7, 2020

Having no issues here on Ropsten either, @nicinuse could it be that your chain hasn't synced completely yet? If you try this on an unsynced chain you get the 0x0 result (not sure if thats correct behaviour @ligi though). Once the chain is synced it will give the right value.

@ligi
Copy link
Member

ligi commented Apr 7, 2020

for me it is also working when it is still syncing:

> {"jsonrpc":"2.0","method":"eth_syncing","id":1}
< {"jsonrpc":"2.0","id":1,"result":{"currentBlock":"0x3b927b","highestBlock":"0x8a61c9","knownStates":"0x0","pulledStates":"0x0","startingBlock":"0x3e2fc5"}}

> {"jsonrpc":"2.0","method":"eth_chainId","id":1}
< {"jsonrpc":"2.0","id":1,"result":"0x1"}

there must be something else to it. But I would also expect to give the correct result when it is still syncing.

@q9f
Copy link
Contributor

q9f commented Apr 8, 2020

seems to just happen for "--testnet" - got the correct results for --goerli and main net.

does it also happen for --ropsten? I'm ahead of time 🤣

@ligi
Copy link
Member

ligi commented Apr 8, 2020

wasn't the "--ropsten" just included by your PR? Did not try it on top of this - but also do not see why this would be the reason.

@MariusVanDerWijden
Copy link
Member

MariusVanDerWijden commented Apr 8, 2020

For me it works only for the --goerli testnet.

command output
geth --nousb --ws < {"jsonrpc":"2.0","id":1,"result":"0x0"}
geth --nousb --ws --rinkeby < {"jsonrpc":"2.0","id":1,"result":"0x0"}
geth --nousb --ws --testnet < {"jsonrpc":"2.0","id":1,"result":"0x0"}
geth --nousb --ws --goerli < {"jsonrpc":"2.0","id":1,"result":"0x5"}

@ligi ligi changed the title "eth_chainId" returns 0x0 for --testnet "eth_chainId" sometimes returns 0x0 instead of the correct chainId Apr 8, 2020
@ligi
Copy link
Member

ligi commented Apr 9, 2020

The PR implementing this feature: https://github.com/ethereum/go-ethereum/pull/19694/files

@ligi
Copy link
Member

ligi commented Apr 9, 2020

currently it depends on the sync state - but IMHO it should just take the value from the config

@karalabe
Copy link
Member

karalabe commented Apr 9, 2020

#17617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants