2

I have a full node running and I am using ZMQ to let me know when new blocks arrive. How can I make sure that this block that my node received is a valid block written in the blockchain ledger and it is not an orphan block? Can I rely on my full node to have the most recent blocks?

2 Answers 2

4

how can I make sure that this block that my node received is a valid block

Bitcoin Core will only announce (through ZMQ) blocks that change the tip of the best-known valid chain. This implies they together with all their ancestors are fully valid.

and it is not an orphan block

At the time it is announced, you know that it is part of the best-known valid chain. Of course, it's always possible that a better alternative branch is received later, which reorganizes the old one you heard about. In that case, you'll receive a new ZMQ notification for the new best tip.

Can I rely on my full node to have the most recent blocks?

No, of course not. The speed of communication around the earth is finite; if a new block has been found somewhere on earth, there is no way you can know about it before it's had time to propagate to you.

Even ignoring that, it's always possible for the nodes you are connected to to be slow, broken, or malicious, in a way that prevents them from propagating blocks to you.

The only correct way to think about this is that there simply is no such thing as "the best/most recent block", and every node is continuously trying to catch up with new information. In theory, you never have any guarantees. In practice, usually nodes learn about blocks within seconds, and if it takes way too long (say, hours), you'll know something is wrong.

2
  • Is it valid to have more than one full node to rely on? For example if I do have a full node in Asia, Europe, and America. Would it be safer to always rely on most recent info? Commented Apr 15, 2020 at 23:06
  • 3
    There is nothing unsafe about not having all information - it's a fact of life in a decentralized system. Instead of using multiple nodes, you can just run one and make it connect to peers in various places in the world that you know (using -addnode e.g.). Commented Apr 15, 2020 at 23:07
0

orphan rate is 0.5%. 1 orphan block in approx every 200 blocks. There is no guarantee the latest block is not an orphan block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.