Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Sep 8, 2023
1 parent 3526d03 commit 03267da
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions messages/teleporter/message_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (m *messageManager) ShouldSendMessage(warpMessageInfo *vmtypes.WarpMessageI
m.logger.Info(
"Relayer EOA not allowed to deliver this message.",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", warpMessageInfo.WarpUnsignedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
)
return false, nil
Expand All @@ -126,6 +127,7 @@ func (m *messageManager) ShouldSendMessage(warpMessageInfo *vmtypes.WarpMessageI
m.logger.Error(
"Failed to check if message has been delivered to destination chain.",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", warpMessageInfo.WarpUnsignedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
zap.Error(err),
)
Expand Down Expand Up @@ -157,7 +159,10 @@ func (m *messageManager) messageDelivered(
// Check if the message has already been delivered to the destination chain
client, ok := destinationClient.Client().(ethclient.Client)
if !ok {
m.logger.Error("Destination client is not an Ethereum client.")
m.logger.Error(
"Destination client is not an Ethereum client.",
zap.String("destinationChainID", destinationChainID.String()),
)
return false, errors.New("destination client is not an Ethereum client")
}

Expand All @@ -166,7 +171,11 @@ func (m *messageManager) messageDelivered(
MessageID: teleporterMessage.MessageID,
})
if err != nil {
m.logger.Error("Failed packing messageReceived call data.")
m.logger.Error(
"Failed packing messageReceived call data.",
zap.String("destinationChainID", destinationChainID.String()),
zap.Error(err),
)
return false, err
}
protocolAddress := common.BytesToAddress(m.protocolAddress[:])
Expand All @@ -180,12 +189,18 @@ func (m *messageManager) messageDelivered(
m.logger.Error(
"Failed calling messageReceived method on destination chain.",
zap.String("destinationChainID", destinationChainID.String()),
zap.Error(err),
)
return false, err
}
// check the contract call result
delivered, err := unpackMessageReceivedResult(result)
if err != nil {
m.logger.Error(
"Failed unpacking messageReceived result.",
zap.String("destinationChainID", destinationChainID.String()),
zap.Error(err),
)
return false, err
}
if delivered {
Expand All @@ -205,13 +220,15 @@ func (m *messageManager) SendMessage(signedMessage *warp.Message, parsedVmPayloa
if !ok {
m.logger.Debug(
"Teleporter message to send not in cache. Extracting from signed warp message.",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
)
var err error
teleporterMessage, err = unpackTeleporterMessage(parsedVmPayload)
if err != nil {
m.logger.Error(
"Failed unpacking teleporter message.",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
)
return err
Expand All @@ -221,21 +238,26 @@ func (m *messageManager) SendMessage(signedMessage *warp.Message, parsedVmPayloa
m.logger.Info(
"Sending message to destination chain",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
)
numSigners, err := signedMessage.Signature.NumSigners()
if err != nil {
m.logger.Error(
"Failed to get number of signers",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
)
return err
}
gasLimit, err := CalculateReceiveMessageGasLimit(numSigners, teleporterMessage.RequiredGasLimit)
if err != nil {
m.logger.Error(
"Gas limit required overflowed uint64 max. not relaying message",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
)
return err
}
Expand All @@ -246,7 +268,9 @@ func (m *messageManager) SendMessage(signedMessage *warp.Message, parsedVmPayloa
if err != nil {
m.logger.Error(
"Failed packing receiveCrossChainMessage call data",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
)
return err
}
Expand All @@ -260,15 +284,17 @@ func (m *messageManager) SendMessage(signedMessage *warp.Message, parsedVmPayloa
if err != nil {
m.logger.Error(
"Failed to send tx.",
zap.String("warpMessageID", signedMessage.ID().String()),
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
zap.Error(err),
)
return err
}
m.logger.Info(
"Sent message to destination chain",
zap.String("destinationChainID", destinationChainID.String()),
zap.String("warpMessageID", signedMessage.ID().String()),
zap.String("teleporterMessageID", teleporterMessage.MessageID.String()),
)
return nil
Expand Down

0 comments on commit 03267da

Please sign in to comment.