Conversation
|
Adding hash to ping/pong is a good way to solve the problem of different chains. |
| // We have a different chain | ||
|
|
||
| var header = Blockchain.Singleton.GetHeader(payload.LastBlockIndex); | ||
| if (header != null && header.Hash != payload.LastBlockHash) |
There was a problem hiding this comment.
I'm not sure it'll help. Suppose I'm a fresh node starting at block 0, there is a right chain with a height of 1000 and a wrong chain of height 300000 on the network. I'm synchronizing headers (and blocks) from the right chain up to 1000, then I'm receiving a pong message with [300000, SOME_HASH], now I don't (and won't for quite some time) have a header for block 300000 to verify SOME_HASH, so I'll try to get blocks/headers from this node anyway because it says it's at the height of 300000.
I don't think we can reliably do anything at this stage, the only thing we can do is react on wrong headers/blocks received from other nodes.
There was a problem hiding this comment.
I don't think we can reliably do anything at this stage
Well, maybe if we're to respond with a hash of the block from the ping (so that the protocol would be like [ping, HEIGHT_A, HASH_A, NONCE] -> [pong, HEIGHT_B, HASH_A, NONCE]) that would change something, still I don't think it's worth the effort as in general this data can't be trusted, it's just whatever some random node on the network wants to tell us. Reacting to header/block verification problems is way more reliable.
There was a problem hiding this comment.
This data can't be trusted, but you will remove a big percentage of the unwanted data, the bad nodes will send you the blocks, but when you will be able to validate them you will discard them.
|
I don't understand. If we receive a wrong block, we can find it and disconnect from the node. Why should we check it in |
|
Maybe #1826 is enough. |
Close #1825
Compatible with #1826