Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
RPC status call gives wrong height when syncing #2261
The RPC status call returns the same height as the HTTP during sync
The RPC status call returns a fixed height and broadhash for a very ling time, even if the node's height increases during sync.
In this example, I called the RPC status every 2 seconds on my node between 20:12:01 and 20:36:40 UTC. The returned status increases only a handful of times and I get the same height for a very long period of time
Steps to reproduce
Repeatedly run the RPC status call on a given node that is syncing
Which version(s) does this affect? (Environment, OS, etc...)
RPC status returns the height out of Peer headers stored in System module. During the sync process headers are not updated after every block.
Headers will be updated only when blocks.processBlocks will be called with broadcast = true, which happens when:
Headers are also updated directly after the whole sync process finished -
It will happen un-deterministically after node encounters an error during sync 5 times. That's why your height gathered through rpc.status was updated on particular cliffs - only when your sync loop stopped.
I wouldn't consider the current behaviour as a wrong one - during sync Node cannot be considered as a valid Peer to sync with for others. There is no point to broadcast headers during sync loop multiple times each second after every block application. RPC should provide the valuable messages for P2P connections purposes only. HTTP public API should be considered as a source of information for a user.
@MaciejBaj I believe during sync process:
Any information published through any interface (HTTP/WebSocket) must be valid and accurate information. So if a node is on particular height, both interfaces should respond with accurate and same height. HTTP returning one height and WebSocket returning other height is absolutely acceptable behavior in my perspective.