Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent Explorer Nodes from Adding Future Blocks #4845

Merged
merged 4 commits into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion node/harmony/node_explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ func (node *Node) explorerMessageHandler(ctx context.Context, msg *msg_pb.Messag
Msg("[Explorer] onCommitted unable to parse msg")
return err
}

// If a future block is received, it logs a warning and discards the block
// TODO: can be done with isRightBlockNumAndViewID(recvMsg)
if current := node.Blockchain().CurrentBlock().NumberU64(); recvMsg.BlockNum != current+1 {
utils.Logger().Debug().
Uint64("Received BlockNum", recvMsg.BlockNum).
Uint64("Current Block Number", current).
Msg("[Explorer] received a future block on COMMIT phase")
return nil
}
aggSig, mask, err := node.Consensus.ReadSignatureBitmapPayload(
recvMsg.Payload, 0,
)
Expand Down Expand Up @@ -88,6 +96,15 @@ func (node *Node) explorerMessageHandler(ctx context.Context, msg *msg_pb.Messag
utils.Logger().Error().Err(err).Msg("[Explorer] Unable to parse Prepared msg")
return err
}
// If a future block is received, it logs a warning and discards the block
// TODO: can be done with isRightBlockNumAndViewID(recvMsg)
if current := node.Blockchain().CurrentBlock().NumberU64(); recvMsg.BlockNum != current+1 {
utils.Logger().Debug().
Uint64("Received BlockNum", recvMsg.BlockNum).
Uint64("Current Block Number", current).
Msg("[Explorer] received a future block on PREPARE phase")
return nil
}
block, blockObj := recvMsg.Block, &types.Block{}
if err := rlp.DecodeBytes(block, blockObj); err != nil {
utils.Logger().Error().Err(err).Msg("explorer could not rlp decode block")
Expand Down