Skip to content

Commit

Permalink
[CORE-708] Explicitly log out delayed message when execution fails (#687
Browse files Browse the repository at this point in the history
)

* explicitly log out message when dispatch fails

* add e2e test case where delayed MsgCompleteBridge fails to execute

* nits
  • Loading branch information
teddyding authored Oct 24, 2023
1 parent a612627 commit 1f065b4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
10 changes: 10 additions & 0 deletions protocol/testutil/constants/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func init() {

var (
// Private
emptyCoin = sdk.Coin{
Denom: "adv4tnt",
Amount: sdkmath.NewInt(0),
}
coin = sdk.Coin{
Denom: "adv4tnt",
Amount: sdkmath.NewIntFromUint64(888),
Expand Down Expand Up @@ -66,6 +70,12 @@ var (
Coin: coin,
EthBlockHeight: 3,
}
BridgeEvent_Id4_Height0_EmptyCoin = types.BridgeEvent{
Id: 0,
Address: AliceAccAddress.String(),
Coin: emptyCoin,
EthBlockHeight: 0,
}
BridgeEvent_Id55_Height15 = types.BridgeEvent{
Id: 55,
Address: DaveAccAddress.String(),
Expand Down
17 changes: 17 additions & 0 deletions protocol/x/bridge/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ func TestBridge_Success(t *testing.T) {
blockTime: time.Now(),
expectNonEmptyBridgeTx: true,
},
"Success: 1 bridge event with 0 coin amount, delay 5 blocks": {
bridgeEvents: []bridgetypes.BridgeEvent{
constants.BridgeEvent_Id4_Height0_EmptyCoin,
},
proposeParams: bridgetypes.ProposeParams{
MaxBridgesPerBlock: 2,
ProposeDelayDuration: 0,
SkipRatePpm: 0, // do not skip proposing bridge events.
SkipIfBlockDelayedByDuration: time.Second * 10,
},
safetyParams: bridgetypes.SafetyParams{
IsDisabled: false,
DelayBlocks: 5,
},
blockTime: time.Now(),
expectNonEmptyBridgeTx: true,
},
"Success: 4 bridge events, delay 27 blocks": {
bridgeEvents: []bridgetypes.BridgeEvent{
constants.BridgeEvent_Id0_Height0,
Expand Down
12 changes: 11 additions & 1 deletion protocol/x/delaymsg/keeper/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@ 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", types.IdLogKey, id, constants.ErrorLogKey, err)
k.Logger(ctx).Error(
"failed to execute delayed message",
types.IdLogKey,
id,
constants.ErrorLogKey,
err,
types.MessageContentLogKey,
msg.String(),
types.MessageTypeUrlLogKey,
delayedMsg.Msg.TypeUrl,
)
}
}

Expand Down
5 changes: 0 additions & 5 deletions protocol/x/delaymsg/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,3 @@ const (
// NextDelayedMessageIdKey is the key to retrieve next delayed message id.
NextDelayedMessageIdKey = "NextDelayedMessageId"
)

// Log
const (
IdLogKey = "id"
)
8 changes: 8 additions & 0 deletions protocol/x/delaymsg/types/logs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package types

// Log
const (
IdLogKey = "id"
MessageContentLogKey = "message_content"
MessageTypeUrlLogKey = "message_type_url"
)

0 comments on commit 1f065b4

Please sign in to comment.