Skip to content

Commit

Permalink
[CORE-648] fix delaymsg error logging (#568)
Browse files Browse the repository at this point in the history
* fix delaymsg error logging

* define log keys
  • Loading branch information
tqin7 authored Oct 11, 2023
1 parent 05da3b2 commit 0a98a8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions protocol/x/delaymsg/keeper/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants"
"github.com/dydxprotocol/v4-chain/protocol/lib"
"github.com/dydxprotocol/v4-chain/protocol/lib/abci"
"github.com/dydxprotocol/v4-chain/protocol/x/delaymsg/types"
Expand Down Expand Up @@ -29,13 +30,13 @@ func DispatchMessagesForBlock(k types.DelayMsgKeeper, ctx sdk.Context) {
for _, id := range blockMessageIds.Ids {
delayedMsg, found := k.GetMessage(ctx, id)
if !found {
k.Logger(ctx).Error("delayed message %v not found", id)
k.Logger(ctx).Error("delayed message not found", types.IdLogKey, id)
continue
}

msg, err := delayedMsg.GetMessage()
if err != nil {
k.Logger(ctx).Error("failed to decode delayed message with id %v: %v", id, err)
k.Logger(ctx).Error("failed to decode delayed message", types.IdLogKey, id, constants.ErrorLogKey, err)
continue
}

Expand All @@ -49,7 +50,7 @@ func DispatchMessagesForBlock(k types.DelayMsgKeeper, ctx sdk.Context) {
events = append(events, res.GetEvents()...)
return nil
}); err != nil {
k.Logger(ctx).Error("failed to execute delayed message with id %v: %v", id, err)
k.Logger(ctx).Error("failed to execute delayed message", types.IdLogKey, id, constants.ErrorLogKey, err)
}
}

Expand All @@ -58,7 +59,7 @@ func DispatchMessagesForBlock(k types.DelayMsgKeeper, ctx sdk.Context) {

for _, id := range blockMessageIds.Ids {
if err := k.DeleteMessage(ctx, id); err != nil {
k.Logger(ctx).Error("failed to delete delayed message: %w", err)
k.Logger(ctx).Error("failed to delete delayed message", types.IdLogKey, id, constants.ErrorLogKey, err)
}
}
}
5 changes: 5 additions & 0 deletions protocol/x/delaymsg/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ const (
// NumDelayedMessagesKey is the prefix to retrieve the number of DelayedMessages.
NumDelayedMessagesKey = "NumMsgs"
)

// Log
const (
IdLogKey = "id"
)

0 comments on commit 0a98a8d

Please sign in to comment.