Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Definition of 'startingheight' field in RPC getpeerinfo #1387

Closed
dbkeys opened this Issue Oct 7, 2016 · 3 comments

Comments

Projects
None yet
3 participants

dbkeys commented Oct 7, 2016

Location: https://bitcoin.jp/en/developer-reference#getpeerinfo

"...startingheight is the node’s earliest block." <--- This statement is unclear to me.
An updated, functioning node should have the complete block chain, so wouldn't its "earliest block" be the genesis block.
¿What is startingheight exactly, as reported by getpeerinfo?
¿Is it the first block we received from that peer node? ¿Is it the blockheight at the time we first connected with the node?

// Did some research and found this, but does not really clarify for me.

http://bitcoinstats.com/irc/bitcoin-dev/logs/2012/07/01
00:12 gmaxwell jgarzik: is height in getpeerinfo the starting height or the current one?
...
01:33 jgarzik gmaxwell: nStartingHeight
01:34 gmaxwell yea. I went and looked eventually. I suspect this is going to cause users to spaz out thinking they have peers which are behind on the chain.
01:35 jgarzik gmaxwell: I don't think we track that, so the options would be (a) track it, imperfectly or (b) ditch it
01:36 jgarzik we just know what they report in 'version', and what they request, AFAICS
01:36 gmaxwell or just call it "initialheight" or "startingheight" in the output.
01:37 gmaxwell Which is what I thought your patch did initially.
01:37 jgarzik true. I can change it back to startingheight
01:38 jgarzik if that will not be just as confusing to users
01:39 gmaxwell I think that would have less potential for confusion, and the starting height is at least somewhat useful. (though its more useful in combination with the current height)

Contributor

laanwj commented Oct 11, 2016

Is it the blockheight at the time we first connected with the node?

Yes, it is. Although you shouldn't trust it. A node can put any value there, it's not verified in any way, and it's not used by the software itself. It's just there for visual inspection/indication.

dbkeys commented Oct 13, 2016 edited

Thanks for your reply. I understand the security aspect (or lack thereof), but I'm still wondering what exactly is startingheight supposed to mean, ie.: ¿ What is a more rigurous definition for startingheight ? (Assuming of course no funny business or lies from the peer)

Contributor

laanwj commented Oct 13, 2016 edited

In Bitcoin Core it is the current tip height (e.g. validated block number) at the time of making the connection. E.g. see https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L391 , CConnman::ConnectNode where a CNode object is created with GetBestHeight().

Some SPV clients and "spy nodes" send wildly different numbers though. For example "0" seemse to be used for "I don't know". I'd really recommend ignoring the field :)

@wbnns wbnns self-assigned this Dec 9, 2016

@wbnns wbnns closed this Dec 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment