mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
[NOD-1042] Ignore very high orphans (#761)
* [NOD-530] Remove coinbase inputs and add blue score to payload * [NOD-1042] Ignore very high orphans * [NOD-1042] Add ban score to an orphan with malformed blue score * [NOD-1042] Fix log
This commit is contained in:
parent
d4c9fdf6ac
commit
0744e8ebc0
@ -532,6 +532,25 @@ func (sm *SyncManager) handleBlockMsg(bmsg *blockMsg) {
|
||||
}
|
||||
|
||||
if isOrphan {
|
||||
blueScore, err := bmsg.block.BlueScore()
|
||||
if err != nil {
|
||||
log.Errorf("Received an orphan block %s with malformed blue score from %s. Disconnecting...",
|
||||
blockHash, peer)
|
||||
peer.AddBanScoreAndPushRejectMsg(wire.CmdBlock, wire.RejectInvalid, blockHash,
|
||||
peerpkg.BanScoreMalformedBlueScoreInOrphan, 0,
|
||||
fmt.Sprintf("Received an orphan block %s with malformed blue score", blockHash))
|
||||
return
|
||||
}
|
||||
|
||||
const maxOrphanBlueScoreDiff = 10000
|
||||
selectedTipBlueScore := sm.dag.SelectedTipBlueScore()
|
||||
if blueScore > selectedTipBlueScore+maxOrphanBlueScoreDiff {
|
||||
log.Infof("Orphan block %s has blue score %d and the selected tip blue score is "+
|
||||
"%d. Ignoring orphans with a blue score difference from the selected tip greater than %d",
|
||||
blockHash, blueScore, selectedTipBlueScore, maxOrphanBlueScoreDiff)
|
||||
return
|
||||
}
|
||||
|
||||
// Request the parents for the orphan block from the peer that sent it.
|
||||
missingAncestors, err := sm.dag.GetOrphanMissingAncestorHashes(blockHash)
|
||||
if err != nil {
|
||||
|
@ -2,9 +2,10 @@ package peer
|
||||
|
||||
// Ban scores for misbehaving nodes
|
||||
const (
|
||||
BanScoreUnrequestedBlock = 100
|
||||
BanScoreInvalidBlock = 100
|
||||
BanScoreInvalidInvBlock = 100
|
||||
BanScoreUnrequestedBlock = 100
|
||||
BanScoreInvalidBlock = 100
|
||||
BanScoreInvalidInvBlock = 100
|
||||
BanScoreMalformedBlueScoreInOrphan = 100
|
||||
|
||||
BanScoreUnrequestedSelectedTip = 20
|
||||
BanScoreUnrequestedTx = 20
|
||||
|
Loading…
x
Reference in New Issue
Block a user