Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Jun 27, 2023
1 parent fcb1ff4 commit 30b2c4d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions x/ccv/provider/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,12 @@ func (am AppModule) OnRecvPacket(
ack ibcexported.Acknowledgement
consumerPacket ccv.ConsumerPacketData
)
// unmarshall consumer packet
// unmarshal consumer packet
if err := ccv.ModuleCdc.UnmarshalJSON(packet.GetData(), &consumerPacket); err != nil {
errAck := channeltypes.NewErrorAcknowledgement(fmt.Errorf("cannot unmarshal CCV packet data"))
errMsg := "cannot unmarshal CCV packet data from JSON"
// errMsg thrown out by IBC core, hence we log instead
ctx.Logger().Error(errMsg, "err", err)
errAck := channeltypes.NewErrorAcknowledgement(fmt.Errorf(errMsg))
ack = &errAck
} else {
// TODO: call ValidateBasic method on consumer packet data
Expand All @@ -194,7 +197,11 @@ func (am AppModule) OnRecvPacket(
// handle SlashPacket
ack = am.keeper.OnRecvSlashPacket(ctx, packet, *consumerPacket.GetSlashPacketData())
default:
errAck := channeltypes.NewErrorAcknowledgement(fmt.Errorf("invalid consumer packet type: %q", consumerPacket.Type))
errMsg := fmt.Sprintf("invalid consumer packet type: %q, valid types are: %q, %q",
consumerPacket.Type, ccv.VscMaturedPacket, ccv.SlashPacket)
// errMsg thrown out by IBC core, hence we log instead
ctx.Logger().Error(errMsg)
errAck := channeltypes.NewErrorAcknowledgement(fmt.Errorf(errMsg))
ack = &errAck
}
}
Expand Down

0 comments on commit 30b2c4d

Please sign in to comment.