From 47fd8106e648651fdde2fdc87a8f71fbdf5f6f41 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Wed, 19 Jun 2024 13:41:13 -0700 Subject: [PATCH] fix(relayer): nil check (#17625) Co-authored-by: d1onys1us <13951458+d1onys1us@users.noreply.github.com> --- _typos.toml | 1 + packages/relayer/indexer/save_event_to_db.go | 5 +++++ packages/relayer/processor/process_message.go | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/_typos.toml b/_typos.toml index 0dd112e46c1..f2944533a6f 100644 --- a/_typos.toml +++ b/_typos.toml @@ -17,6 +17,7 @@ extend-exclude = [ "packages/protocol/contracts/automata-attestation/**", "packages/protocol/contracts/thirdparty/**", "packages/protocol/contracts/compiled/**", + "packages/protocol/deployments/**", # TODO: fix typos and remove these "packages/taiko-client/**", ] diff --git a/packages/relayer/indexer/save_event_to_db.go b/packages/relayer/indexer/save_event_to_db.go index 674c0df0567..6a672250645 100644 --- a/packages/relayer/indexer/save_event_to_db.go +++ b/packages/relayer/indexer/save_event_to_db.go @@ -26,6 +26,11 @@ func (i *Indexer) saveEventToDB( return 0, errors.Wrap(err, "relayer.DecodeMessageData") } + if eventType == relayer.EventTypeSendETH { + canonicalToken = nil + amount = eventValue + } + // check if we have an existing event already. this is mostly likely only true // in the case of us crawling past blocks. existingEvent, err := i.eventRepo.FirstByEventAndMsgHash( diff --git a/packages/relayer/processor/process_message.go b/packages/relayer/processor/process_message.go index 6022b80ca87..b36c3b2a7a4 100644 --- a/packages/relayer/processor/process_message.go +++ b/packages/relayer/processor/process_message.go @@ -69,6 +69,12 @@ func (p *Processor) processMessage( return false, 0, errors.Wrap(err, "json.Unmarshal") } + if msgBody.Event == nil { + slog.Warn("empty msgBody", "id", msgBody.ID) + + return false, 0, errors.New("empty message body") + } + slog.Info("message received", "srcTxHash", msgBody.Event.Raw.TxHash.Hex()) // check if we already processing this hash