From 2f541524a99752f2524ffcbd48f31d21f8a3b03a Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Tue, 3 Oct 2023 22:58:05 +0000 Subject: [PATCH] add primary network anycast todos --- messages/block_hash_publisher/message_manager.go | 2 ++ relayer/message_relayer.go | 4 ---- relayer/relayer.go | 7 +++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/messages/block_hash_publisher/message_manager.go b/messages/block_hash_publisher/message_manager.go index 6e61acef..27268074 100644 --- a/messages/block_hash_publisher/message_manager.go +++ b/messages/block_hash_publisher/message_manager.go @@ -109,6 +109,7 @@ func NewMessageManager( // ShouldSendMessage returns true if the message should be sent to ANY of the configured destination chains // This saves us from having to aggregate signatures in that case. Decisions about which destination chains to send to are made in SendMessage func (m *messageManager) ShouldSendMessage(warpMessageInfo *vmtypes.WarpMessageInfo, _ ids.ID) (bool, error) { + // TODO: Handle the primary network case. If it's the primary network, only check the passed in destinationChainID for _, destination := range m.destinations { if destination.shouldSend(warpMessageInfo.BlockTimestamp, warpMessageInfo.BlockNumber) { return true, nil @@ -118,6 +119,7 @@ func (m *messageManager) ShouldSendMessage(warpMessageInfo *vmtypes.WarpMessageI } func (m *messageManager) SendMessage(signedMessage *warp.Message, warpMessageInfo *vmtypes.WarpMessageInfo, _ ids.ID) error { + // TODO: Handle the primary network case. If it's the primary network, only send to the passed in destinationChainID m.logger.Info( "DEBUG SENDING", zap.String("destinationInfo", fmt.Sprintf("%#v", m.destinations)), diff --git a/relayer/message_relayer.go b/relayer/message_relayer.go index 09a52b51..755f275a 100644 --- a/relayer/message_relayer.go +++ b/relayer/message_relayer.go @@ -77,10 +77,6 @@ func newMessageRelayer( } func (r *messageRelayer) relayMessage(requestID uint32, messageManager messages.MessageManager) error { - // TODONOW: destinationChainID may be nil/empty, in which case it is an anycast message -> set by subscriber - // ShouldSendMessage makes decisions based ONLY on the message contents, not the relayer config. - // This means that it won't make any decisions about anycase messages based on the relayer config. - // SendMessage handles sending anycast messages to the correct destination chain, based on the relayer config shouldSend, err := messageManager.ShouldSendMessage(r.warpMessageInfo, r.destinationChainID) if err != nil { r.logger.Error( diff --git a/relayer/relayer.go b/relayer/relayer.go index badeacf0..87f9cc2f 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -72,6 +72,7 @@ func NewRelayer( messageManagers := make(map[common.Hash]messages.MessageManager) for address, config := range sourceSubnetInfo.MessageContracts { addressHash := common.HexToHash(address) + // TODO: To handle the primary network case, the messageManager needs to know if its source subnet is the primary network messageManager, err := messages.NewMessageManager(logger, addressHash, config, destinationClients) if err != nil { logger.Error( @@ -206,6 +207,12 @@ func (r *Relayer) RelayMessage(warpMessageInfo *vmtypes.WarpMessageInfo, metrics return nil } + // TODO: To handle anycasting for the primary network, we need to call newMessageRelayer in a loop for each of the + // configured destinations. We can get the configured destinations from messageManage. + // This is necessary because in the primary network case, each destination will have a different aggregate signature. + // For anycasting from any other network, we only need to create a single aggregate signature, so we fan out in + // messageManager instead. + // Create and run the message relayer to attempt to deliver the message to the destination chain messageRelayer := newMessageRelayer(r.logger, metrics, r, warpMessageInfo, warpMessageInfo.DestinationChainID, r.responseChan, messageCreator) if err != nil {