mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
parent
b22e0e4628
commit
d8aa5d2d86
@ -306,8 +306,15 @@ func RecvMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = handleInboundMessage(ctx, req, sentry); err != nil {
|
if err = handleInboundMessage(ctx, req, sentry); err != nil {
|
||||||
if rlp.IsDecodeError(err) {
|
if rlp.IsInvalidRLPError(err) {
|
||||||
log.Debug("[RecvMessage] Handling incoming message", "error", err)
|
log.Debug("[RecvMessage] Kick peer for invalid RLP", "error", err)
|
||||||
|
outreq := proto_sentry.PenalizePeerRequest{
|
||||||
|
PeerId: req.PeerId,
|
||||||
|
Penalty: proto_sentry.PenaltyKind_Kick, // TODO: Extend penalty kinds
|
||||||
|
}
|
||||||
|
if _, err1 := sentry.PenalizePeer(ctx, &outreq, &grpc.EmptyCallOption{}); err1 != nil {
|
||||||
|
log.Error("Could not send penalty", "err", err1)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Warn("[RecvMessage] Handling incoming message", "error", err)
|
log.Warn("[RecvMessage] Handling incoming message", "error", err)
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsDecodeError(err error) bool {
|
func IsInvalidRLPError(err error) bool {
|
||||||
return errors.Is(err, ErrExpectedString) ||
|
return errors.Is(err, ErrExpectedString) ||
|
||||||
errors.Is(err, ErrExpectedList) ||
|
errors.Is(err, ErrExpectedList) ||
|
||||||
errors.Is(err, ErrCanonInt) ||
|
errors.Is(err, ErrCanonInt) ||
|
||||||
@ -70,7 +70,17 @@ func IsDecodeError(err error) bool {
|
|||||||
errors.Is(err, ErrValueTooLarge) ||
|
errors.Is(err, ErrValueTooLarge) ||
|
||||||
errors.Is(err, ErrMoreThanOneValue) ||
|
errors.Is(err, ErrMoreThanOneValue) ||
|
||||||
errors.Is(err, ErrWrongTxTypePrefix) ||
|
errors.Is(err, ErrWrongTxTypePrefix) ||
|
||||||
errors.Is(err, ErrUnknownTxTypePrefix)
|
errors.Is(err, ErrUnknownTxTypePrefix) ||
|
||||||
|
// internal errors
|
||||||
|
errors.Is(err, errNotInList) ||
|
||||||
|
errors.Is(err, errNotAtEOL) ||
|
||||||
|
errors.Is(err, errUintOverflow) ||
|
||||||
|
// stream errors
|
||||||
|
strings.Contains(err.Error(), "rlp: input list has too many elements") ||
|
||||||
|
strings.Contains(err.Error(), "rlp: expected input string or byte") ||
|
||||||
|
strings.Contains(err.Error(), "rlp: expected input list") ||
|
||||||
|
strings.Contains(err.Error(), "rlp: non-canonical size information") ||
|
||||||
|
strings.Contains(err.Error(), "rlp: non-canonical integer (leading zero bytes)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder is implemented by types that require custom RLP decoding rules or need to decode
|
// Decoder is implemented by types that require custom RLP decoding rules or need to decode
|
||||||
|
Loading…
Reference in New Issue
Block a user