Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Coding Enthusiast on December 15, 2020, 09:34:58 AM



Title: Question about ServiceFlags: None and NetworkLimited
Post by: Coding Enthusiast on December 15, 2020, 09:34:58 AM
1. Why or when would a node set its ServiceFlags to NONE?
I'm probably testing "fake" nodes again but they seem to be providing me with headers without an issue.

2. Are NetworkLimited nodes capable of supplying all block headers even though they don't have most of the blocks?


Title: Re: Question about ServiceFlags: None and NetworkLimited
Post by: NotATether on December 16, 2020, 12:24:17 AM
According to the source code, NetworkLimited nodes can only sere the latest 288 block headers. https://github.com/bitcoin/bitcoin/blob/42ed7f51fafa9f5de3b4262d28dbb7493c1eeb0f/src/protocol.h#L286-L289

NodeNone basically means it doesn't have NodeNetwork or any of the other ServiceFlags set. And since (paraphrasing from the code) "NODE_NETWORK means that the node is capable of serving the complete block chain" (source (https://github.com/bitcoin/bitcoin/blob/42ed7f51fafa9f5de3b4262d28dbb7493c1eeb0f/src/protocol.h#L273)), and it's "currently set by all Bitcoin Core non pruned nodes, and is unset by SPV clients or other light clients" (same line), that implies SPV nodes are running with a ServiceFlags of NodeNone.

I don't think fake, Sybil-kind nodes would use this ServiceFlag because they have to run in NodeNetwork mode for peers to download blockchain data from them.


Title: Re: Question about ServiceFlags: None and NetworkLimited
Post by: gmaxwell on December 16, 2020, 01:17:15 AM
According to the source code, NetworkLimited nodes can only sere the latest 288 block headers. https://github.com/bitcoin/bitcoin/blob/42ed7f51fafa9f5de3b4262d28dbb7493c1eeb0f/src/protocol.h#L286-L289
Blocks are not blockheaders.

Limited peers can serve all headers, but they only serve the latest 288 blocks from their tip.

https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki


If something is accepting connections but has a service flag of 0 it's probably some weird spything.  If it makes a connection to you with a service flag of zero it may be a SPV wallet, but its more likely a spynode pretending to be a spv wallet (as there are more spynodes than p2p spv wallets).


Title: Re: Question about ServiceFlags: None and NetworkLimited
Post by: Coding Enthusiast on December 16, 2020, 02:46:40 PM
I don't think fake, Sybil-kind nodes would use this ServiceFlag because they have to run in NodeNetwork mode for peers to download blockchain data from them.
There are all kinds of crazy "nodes" out there that weird service flag doesn't surprise me.
Just before I started this topic I received fake block headers with height <20000 from one; sadly I thought there was a bug in my code so I didn't record its IP address or the block hashes, just remember the useragent was saying bitcoinABC.


Title: Re: Question about ServiceFlags: None and NetworkLimited
Post by: NotATether on December 16, 2020, 03:09:49 PM
I don't think fake, Sybil-kind nodes would use this ServiceFlag because they have to run in NodeNetwork mode for peers to download blockchain data from them.
There are all kinds of crazy "nodes" out there that weird service flag doesn't surprise me.
Just before I started this topic I received fake block headers with height <20000 from one; sadly I thought there was a bug in my code so I didn't record its IP address or the block hashes, just remember the useragent was saying bitcoinABC.

That user agent name sounds like an unsynchronized bitcoin cash node back from when they could still connect to bitcoin nodes (CMIIW but I believe there was a timeframe when BCH nodes could connect to BTC nodes before a BIP was rolled out that prevented this?), maybe they defined a bunch of flags that are unrecognized in bitcoin. But the height doesn't correspond, but even then we know that someone had to have forked Bitcoin core to add those extra flags.


Title: Re: Question about ServiceFlags: None and NetworkLimited
Post by: Coding Enthusiast on December 16, 2020, 03:19:40 PM
They user agent name sounds like an unsynchronized bitcoin cash node back from when they could still connect to bitcoin nodes (CMIIW but I believe there was a timeframe when BCH nodes could connect to BTC nodes before a BIP was rolled out that prevented this?), maybe they defined a bunch of flags that are unrecognized in bitcoin. But the height doesn't correspond, but even then we know that someone had to have forked Bitcoin core to add those extra flags.
As far as I can tell there is no code in bitcoin core that blocks connection based on user-agent. There was a optional patch back in 2017 that people could use to block certain ones if they chose to IIRC.
That is irrelevant here since any of those fork-coins start from blocks in 2017 (height 500k maybe), this was a fake block in early days (height <20k).