Skip to content

Commit

Permalink
propagate log context from relayer to signature-aggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
iansuvak committed Feb 21, 2025
1 parent 06d0cb6 commit ab53376
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 43 deletions.
5 changes: 5 additions & 0 deletions messages/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ava-labs/avalanchego/vms/platformvm/warp"
"github.com/ava-labs/icm-services/vms"
"github.com/ethereum/go-ethereum/common"
"go.uber.org/zap"
)

// MessageManager is specific to each message protocol. The interface handles choosing which messages to send
Expand All @@ -30,6 +31,10 @@ type MessageHandler interface {
// returns the transaction hash if the transaction is successful.
SendMessage(signedMessage *warp.Message, destinationClient vms.DestinationClient) (common.Hash, error)

// GetLogContext returns extra fields to be set in the logger
// when passing it along to the signature aggregator
GetLogContext(destinationClient vms.DestinationClient) []zap.Field

// GetMessageRoutingInfo returns the source chain ID, origin sender address,
// destination chain ID, and destination address.
GetMessageRoutingInfo() (
Expand Down
4 changes: 4 additions & 0 deletions messages/off-chain-registry/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,7 @@ func (m *messageHandler) GetMessageRoutingInfo() (
m.factory.registryAddress,
nil
}

func (m *messageHandler) GetLogContext(destinationClient vms.DestinationClient) []zap.Field {
return []zap.Field{zap.String("unsignedWarpMessageID", m.unsignedMessage.ID().String())}
}
14 changes: 14 additions & 0 deletions messages/teleporter/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,20 @@ func (m *messageHandler) SendMessage(
return txHash, nil
}

func (m *messageHandler) GetLogContext(destinationClient vms.DestinationClient) []zap.Field {
destinationBlockchainID := destinationClient.DestinationBlockchainID()
teleporterMessageID, _ := teleporterUtils.CalculateMessageID(
m.factory.protocolAddress,
m.unsignedMessage.SourceChainID,
destinationBlockchainID,
m.teleporterMessage.MessageNonce,
)
return []zap.Field{
zap.String("unsignedWarpMessageID", m.unsignedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessageID.String()),
}
}

func (m *messageHandler) waitForReceipt(
signedMessage *warp.Message,
destinationClient vms.DestinationClient,
Expand Down
3 changes: 3 additions & 0 deletions relayer/application_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/logging"
avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp"

"github.com/ava-labs/icm-services/database"
"github.com/ava-labs/icm-services/messages"
"github.com/ava-labs/icm-services/peers"
Expand Down Expand Up @@ -205,7 +206,9 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co

// sourceWarpSignatureClient is nil iff the source blockchain is configured to fetch signatures via AppRequest
if r.sourceWarpSignatureClient == nil {
logContext := handler.GetLogContext(r.destinationClient)
signedMessage, err = r.signatureAggregator.CreateSignedMessage(
r.logger.With(logContext...),
unsignedMessage,
nil,
r.signingSubnetID,
Expand Down
Loading

0 comments on commit ab53376

Please sign in to comment.