Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(relayer): handling message received events should compare message dest chain with indexer source chain #16537

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading