From 359ae889b801ad27843c25aed12282abe7efaf89 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Tue, 28 Jun 2022 10:19:57 +0600 Subject: [PATCH] don't crush on p2p message handling panic (#4557) * save * save --- cmd/sentry/sentry/sentry_multi_client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/sentry/sentry/sentry_multi_client.go b/cmd/sentry/sentry/sentry_multi_client.go index efa5f9c87..1359398c4 100644 --- a/cmd/sentry/sentry/sentry_multi_client.go +++ b/cmd/sentry/sentry/sentry_multi_client.go @@ -630,8 +630,14 @@ func makeInboundMessage() *proto_sentry.InboundMessage { return new(proto_sentry.InboundMessage) } -func (cs *MultiClient) HandleInboundMessage(ctx context.Context, message *proto_sentry.InboundMessage, sentry direct.SentryClient) error { - err := cs.handleInboundMessage(ctx, message, sentry) +func (cs *MultiClient) HandleInboundMessage(ctx context.Context, message *proto_sentry.InboundMessage, sentry direct.SentryClient) (err error) { + 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) { log.Debug("Kick peer for invalid RLP", "err", err)