Skip to content

Commit

Permalink
fix(relayer): handling message received events should compare message…
Browse files Browse the repository at this point in the history
… dest chain with indexer source chain (#16537)

Co-authored-by: Roger <[email protected]>
  • Loading branch information
cyberhorsey and RogerLamTd committed Mar 27, 2024
1 parent 406cf1a commit 5c84e16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/relayer/indexer/handle_message_received_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ func (i *Indexer) handleMessageReceivedEvent(
"txHash", event.Raw.TxHash.Hex(),
)

// if the destinatio chain doesnt match, we dont process it in this indexer.
if new(big.Int).SetUint64(event.Message.DestChainId).Cmp(i.destChainId) != 0 {
// if the destination doesnt match our source chain, we dont want to handle this event.
if new(big.Int).SetUint64(event.Message.DestChainId).Cmp(i.srcChainId) != 0 {
slog.Info("skipping event, wrong chainID",
"messageDestChainID",
event.Message.DestChainId,
"indexerDestChainID",
i.destChainId.Uint64(),
"indexerSrcChainID",
i.srcChainId.Uint64(),
)

return nil
Expand Down
10 changes: 5 additions & 5 deletions packages/relayer/watchdog/watchdog.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,30 +285,30 @@ func (w *Watchdog) checkMessage(ctx context.Context, msg queue.Message) error {
}

// check if the source chain sent this message
sent, err := w.srcBridge.IsMessageSent(nil, msgBody.Event.Message)
sent, err := w.destBridge.IsMessageSent(nil, msgBody.Event.Message)
if err != nil {
return errors.Wrap(err, "w.srcBridge.IsMessageSent")
return errors.Wrap(err, "w.destBridge.IsMessageSent")
}

// if so, do nothing, acknowledge message
if sent {
slog.Info("source bridge did send this message. returning early",
slog.Info("dest bridge did send this message. returning early",
"msgHash", common.BytesToHash(msgBody.Event.MsgHash[:]).Hex(),
"sent", sent,
)

return nil
}

data, err := encoding.BridgeABI.Pack("processMessage", [][32]byte{msgBody.Event.MsgHash}, true)
data, err := encoding.BridgeABI.Pack("suspendMessages", [][32]byte{msgBody.Event.MsgHash}, true)
if err != nil {
return errors.Wrap(err, "encoding.BridgeABI.Pack")
}

candidate := txmgr.TxCandidate{
TxData: data,
Blobs: nil,
To: &w.cfg.DestBridgeAddress,
To: &w.cfg.SrcBridgeAddress,
}

receipt, err := w.txmgr.Send(ctx, candidate)
Expand Down

0 comments on commit 5c84e16

Please sign in to comment.