Do not let an invalid peer block take the node offline#42
Open
1440000bytes wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A single block from a peer that fails consensus validation permanently kills the net task, taking the node's networking fully offline.
In the
NewTipReadyhandler,reorg_to_tip(...)?propagates any error out ofrun():run()'s caller only logs the error and lets the task end:So when a peer sends a block whose body fails state validation e.g. a transaction with
value out > value in, surfacing asstate error: value in is less than value out(NotEnoughValueIn) the whole net task dies. After that nothing services peer connections, producing an endless stream ofFailed to send peer connection infoandFailed to send response info. The offending peer isn't even dropped (addris discarded).This means any peer can permanently disable a node's networking with one invalid block (remote DoS), and any genuine consensus disagreement bricks the node instead of just rejecting that chain.
Fix
Classify reorg errors. A
Stateerror is caused by a peer's invalid block and must not be fatal: log a warning, drop the offending peer, and keep running. All other errors (db / env / net infrastructure) still propagate.reorg_to_tiponly commits its write txn on success, so on the error path the pre-reorg tip is left intact and continuing is safe.Related PR: LayerTwo-Labs/thunder-rust#102
Note: Both issues were reported by BTCapsule in drivechain telegram group: https://t.me/c/1378593808/234819