don't crush on p2p message handling panic (#4557)

* save

* save
This commit is contained in:
Alex Sharov 2022-06-28 10:19:57 +06:00 committed by GitHub
parent 5b42a6e8e8
commit 359ae889b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -630,8 +630,14 @@ func makeInboundMessage() *proto_sentry.InboundMessage {
return new(proto_sentry.InboundMessage) return new(proto_sentry.InboundMessage)
} }
func (cs *MultiClient) HandleInboundMessage(ctx context.Context, message *proto_sentry.InboundMessage, sentry direct.SentryClient) error { func (cs *MultiClient) HandleInboundMessage(ctx context.Context, message *proto_sentry.InboundMessage, sentry direct.SentryClient) (err error) {
err := cs.handleInboundMessage(ctx, message, sentry) defer func() {
if rec := recover(); rec != nil {
err = fmt.Errorf("%+v, msgID=%s, trace: %s", rec, message.Id.String(), dbg.Stack())
}
}() // avoid crash because Erigon's core does many things
err = cs.handleInboundMessage(ctx, message, sentry)
if (err != nil) && rlp.IsInvalidRLPError(err) { if (err != nil) && rlp.IsInvalidRLPError(err) {
log.Debug("Kick peer for invalid RLP", "err", err) log.Debug("Kick peer for invalid RLP", "err", err)