Go-ethereum: getBlock("latest") return block zero when syncing

Created on 7 Sep 2017  路  3Comments  路  Source: ethereum/go-ethereum

System information

Geth version: 1.7.0-unstable
OS & Version: Windows 10
Commit hash : 23b51a68cbdd637824be906c9354a0b59c57491b

Expected behaviour

web3.eth.getBlock("latest") should return the latest block even while syncing

Actual behaviour

web3.eth.getSyncing(
returns

{"currentBlock":1624662,"highestBlock":1624817,"knownStates":12584837,"pulledStates":12577537,"startingBlock":921176}

while
web3.eth.getBlock("latest")
returns:

{
  difficulty: 1048576,
  extraData: "0x3535353535353535353535353535353535353535353535353535353535353535",
  gasLimit: 16777216,
  gasUsed: 0,
  hash: "0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x0000000000000000000000000000000000000000",
  mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  nonce: "0x0000000000000042",
  number: 0,
  parentHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 540,
  stateRoot: "0x217b0bbcfb72e2d57e28f33cb361b9983513177755dc3f33ce3e7022ed62b77b",
  timestamp: 0,
  totalDifficulty: 1048576,
  transactions: [],
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}

(the block zero)

Steps to reproduce the behaviour

geth --testnet --syncmode "fast"
geth attach

and call the above method while syncing

Could it be because of "fast" syncmode ?

Most helpful comment

As Bas said, during fast sync, there's no full block yet (states are missing) and only the head block of the chain will be fully available. Hence during sync, the latest block will always be the genesis.

You can track sync progress via eth.syncing.

All 3 comments

Yes, fast sync (default behavior) is causing this. Fast sync will download blocks and state concurrent. Once caught up geth will synchronize "normal".

--syncmode=full will give you immediately the latest block but it will download the entire chain and execute all transaction.

As Bas said, during fast sync, there's no full block yet (states are missing) and only the head block of the chain will be fully available. Hence during sync, the latest block will always be the genesis.

You can track sync progress via eth.syncing.

ok, thanks for the info

Was this page helpful?
0 / 5 - 0 ratings