diff --git a/x/common/types/key_rollapp_packet.go b/x/common/types/key_rollapp_packet.go index 3adf6cad7..60976bf3c 100644 --- a/x/common/types/key_rollapp_packet.go +++ b/x/common/types/key_rollapp_packet.go @@ -22,15 +22,30 @@ var ( keySeparatorBytes = []byte("/") ) -// RollappPacketKey constructs a key for a specific RollappPacket -// status/rollappID/proofHeight/packetUID +// RollappPacketKey constructs a key for a specific RollappPacket of the form: +// status/rollappID/proofHeight/packetType/packetSourceChannel/packetSequence. +// +// In order to build a packet UID We need to take the source channel + packet + packet type as the packet UID +// otherwise we're not guaranteed with uniqueness as we could have: +// Same rollapp id, same status, same proof height same sequence (as it refers to the source chain) and same channel. +// Example would be, both rollapp and hub have channel-0 and we have at the same proof height of the rollapp +// AckPacket with sequence 1 (originated on the hub) and OnRecvPacket with sequence 1 (originated on the rollapp). +// Adding the packet type guarantees uniqueness as the type differentiate the source. func RollappPacketKey(rollappPacket *RollappPacket) []byte { + // Get the bytes rep srppPrefix := RollappPacketByStatusByRollappIDByProofHeightPrefix(rollappPacket.RollappId, rollappPacket.Status, rollappPacket.ProofHeight) + packetTypeBytes := []byte(rollappPacket.Type.String()) packetSequenceBytes := sdk.Uint64ToBigEndian(rollappPacket.Packet.Sequence) - packetDestinationChannelBytes := []byte(rollappPacket.Packet.DestinationChannel) - packetUIDBytes := append(packetDestinationChannelBytes, packetSequenceBytes...) + packetSourceChannelBytes := []byte(rollappPacket.Packet.SourceChannel) + // Construct the key result := append(srppPrefix, keySeparatorBytes...) - return append(result, packetUIDBytes...) + result = append(result, packetTypeBytes...) + result = append(result, keySeparatorBytes...) + result = append(result, packetSourceChannelBytes...) + result = append(result, keySeparatorBytes...) + result = append(result, packetSequenceBytes...) + + return result } // RollappPacketByStatusByRollappIDByProofHeightPrefix constructs a key prefix for a specific RollappPacket diff --git a/x/common/types/packet_uid.go b/x/common/types/packet_uid.go new file mode 100644 index 000000000..49da31ceb --- /dev/null +++ b/x/common/types/packet_uid.go @@ -0,0 +1,26 @@ +package types + +import fmt "fmt" + +// PacketUID is a unique identifier for an Rollapp IBC packet on the hub +type PacketUID struct { + Type RollappPacket_Type + RollappHubPort string + RollappHubChannel string + Sequence uint64 +} + +// NewPacketUID creates a new PacketUID with the provided details. +func NewPacketUID(packetType RollappPacket_Type, hubPort string, hubChannel string, sequence uint64) PacketUID { + return PacketUID{ + Type: packetType, + RollappHubPort: hubPort, + RollappHubChannel: hubChannel, + Sequence: sequence, + } +} + +// String returns a string representation of the PacketUID +func (p PacketUID) String() string { + return fmt.Sprintf("%s-%s-%s-%d", p.Type, p.RollappHubChannel, p.RollappHubPort, p.Sequence) +} diff --git a/x/delayedack/eibc.go b/x/delayedack/eibc.go index c197904f7..80d1114de 100644 --- a/x/delayedack/eibc.go +++ b/x/delayedack/eibc.go @@ -55,10 +55,10 @@ func (im IBCMiddleware) eIBCDemandOrderHandler(ctx sdk.Context, rollappPacket co } // Calculate the fee by multiplying the fee by the price var feeMultiplier sdk.Dec - if t == commontypes.RollappPacket_ON_TIMEOUT { + switch t { + case commontypes.RollappPacket_ON_TIMEOUT: feeMultiplier = im.keeper.TimeoutFee(ctx) - } - if t == commontypes.RollappPacket_ON_ACK { + case commontypes.RollappPacket_ON_ACK: feeMultiplier = im.keeper.ErrAckFee(ctx) } @@ -147,7 +147,8 @@ func (im IBCMiddleware) createDemandOrderFromIBCPacket(fungibleTokenPacketData t case commontypes.RollappPacket_ON_TIMEOUT: fallthrough case commontypes.RollappPacket_ON_ACK: - demandOrderDenom = fungibleTokenPacketData.Denom // It's what we tried to send + trace := transfertypes.ParseDenomTrace(fungibleTokenPacketData.Denom) + demandOrderDenom = trace.IBCDenom() demandOrderRecipient = fungibleTokenPacketData.Sender // and who tried to send it (refund because it failed) case commontypes.RollappPacket_ON_RECV: demandOrderDenom = im.getEIBCTransferDenom(*rollappPacket.Packet, fungibleTokenPacketData) diff --git a/x/delayedack/ibc_middleware.go b/x/delayedack/ibc_middleware.go index 750da2b7a..cd339ccbb 100644 --- a/x/delayedack/ibc_middleware.go +++ b/x/delayedack/ibc_middleware.go @@ -46,10 +46,11 @@ func (im IBCMiddleware) OnRecvPacket( if !im.keeper.IsRollappsEnabled(ctx) { return im.IBCModule.OnRecvPacket(ctx, packet, relayer) } - logger := ctx.Logger().With("module", "DelayedAckMiddleware") - rollappID, transferPacketData, err := im.ExtractRollappIDAndTransferPacket(ctx, packet) + rollappPortOnHub, rollappChannelOnHub := packet.DestinationPort, packet.DestinationChannel + + rollappID, transferPacketData, err := im.ExtractRollappIDAndTransferPacket(ctx, packet, rollappPortOnHub, rollappChannelOnHub) if err != nil { logger.Error("Failed to extract rollapp id from packet", "err", err) return channeltypes.NewErrorAcknowledgement(err) @@ -60,13 +61,13 @@ func (im IBCMiddleware) OnRecvPacket( return im.IBCModule.OnRecvPacket(ctx, packet, relayer) } - err = im.keeper.ValidateRollappId(ctx, rollappID, packet.GetDestPort(), packet.GetDestChannel()) + err = im.keeper.ValidateRollappId(ctx, rollappID, rollappPortOnHub, rollappChannelOnHub) if err != nil { logger.Error("Failed to validate rollappID", "rollappID", rollappID, "err", err) return channeltypes.NewErrorAcknowledgement(err) } - proofHeight, err := im.GetProofHeight(ctx, packet) + proofHeight, err := im.GetProofHeight(ctx, commontypes.RollappPacket_ON_RECV, rollappPortOnHub, rollappChannelOnHub, packet.Sequence) if err != nil { logger.Error("Failed to get proof height from packet", "err", err) return channeltypes.NewErrorAcknowledgement(err) @@ -116,13 +117,15 @@ func (im IBCMiddleware) OnAcknowledgementPacket( } logger := ctx.Logger().With("module", "DelayedAckMiddleware") + rollappPortOnHub, rollappChannelOnHub := packet.SourcePort, packet.SourceChannel + var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { logger.Error("Unmarshal acknowledgement", "err", err) return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unmarshal ICS-20 transfer packet acknowledgement: %v", err) } - rollappID, transferPacketData, err := im.ExtractRollappIDAndTransferPacket(ctx, packet) + rollappID, transferPacketData, err := im.ExtractRollappIDAndTransferPacket(ctx, packet, rollappPortOnHub, rollappChannelOnHub) if err != nil { logger.Error("Failed to extract rollapp id from channel", "err", err) return err @@ -132,13 +135,13 @@ func (im IBCMiddleware) OnAcknowledgementPacket( logger.Debug("Skipping IBC transfer OnAcknowledgementPacket for non-rollapp chain") return im.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) } - err = im.keeper.ValidateRollappId(ctx, rollappID, packet.GetDestPort(), packet.GetDestChannel()) + err = im.keeper.ValidateRollappId(ctx, rollappID, rollappPortOnHub, rollappChannelOnHub) if err != nil { logger.Error("Failed to validate rollappID", "rollappID", rollappID, "err", err) return err } - proofHeight, err := im.GetProofHeight(ctx, packet) + proofHeight, err := im.GetProofHeight(ctx, commontypes.RollappPacket_ON_ACK, rollappPortOnHub, rollappChannelOnHub, packet.Sequence) if err != nil { logger.Error("Failed to get proof height from packet", "err", err) return err @@ -200,7 +203,9 @@ func (im IBCMiddleware) OnTimeoutPacket( } logger := ctx.Logger().With("module", "DelayedAckMiddleware") - rollappID, transferPacketData, err := im.ExtractRollappIDAndTransferPacket(ctx, packet) + rollappPortOnHub, rollappChannelOnHub := packet.SourcePort, packet.SourceChannel + + rollappID, transferPacketData, err := im.ExtractRollappIDAndTransferPacket(ctx, packet, rollappPortOnHub, rollappChannelOnHub) if err != nil { logger.Error("Failed to extract rollapp id from channel", "err", err) return err @@ -211,13 +216,13 @@ func (im IBCMiddleware) OnTimeoutPacket( return im.IBCModule.OnTimeoutPacket(ctx, packet, relayer) } - err = im.keeper.ValidateRollappId(ctx, rollappID, packet.DestinationPort, packet.DestinationChannel) + err = im.keeper.ValidateRollappId(ctx, rollappID, rollappPortOnHub, rollappChannelOnHub) if err != nil { logger.Error("Failed to validate rollappID", "rollappID", rollappID, "err", err) return err } - proofHeight, err := im.GetProofHeight(ctx, packet) + proofHeight, err := im.GetProofHeight(ctx, commontypes.RollappPacket_ON_TIMEOUT, rollappPortOnHub, rollappChannelOnHub, packet.Sequence) if err != nil { logger.Error("Failed to get proof height from packet", "err", err) return err @@ -294,14 +299,14 @@ func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) } // ExtractRollappIDAndTransferPacket extracts the rollapp ID from the packet -func (im IBCMiddleware) ExtractRollappIDAndTransferPacket(ctx sdk.Context, packet channeltypes.Packet) (string, *transfertypes.FungibleTokenPacketData, error) { +func (im IBCMiddleware) ExtractRollappIDAndTransferPacket(ctx sdk.Context, packet channeltypes.Packet, rollappPortOnHub string, rollappChannelOnHub string) (string, *transfertypes.FungibleTokenPacketData, error) { // no-op if the packet is not a fungible token packet var data transfertypes.FungibleTokenPacketData if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { return "", nil, err } // Check if the packet is destined for a rollapp - chainID, err := im.keeper.ExtractChainIDFromChannel(ctx, packet.DestinationPort, packet.DestinationChannel) + chainID, err := im.keeper.ExtractChainIDFromChannel(ctx, rollappPortOnHub, rollappChannelOnHub) if err != nil { return "", &data, err } @@ -313,10 +318,10 @@ func (im IBCMiddleware) ExtractRollappIDAndTransferPacket(ctx sdk.Context, packe return "", &data, errorsmod.Wrapf(rollapptypes.ErrGenesisEventNotTriggered, "empty channel id: rollap id: %s", chainID) } // check if the channelID matches the rollappID's channelID - if rollapp.ChannelId != packet.GetDestChannel() { + if rollapp.ChannelId != rollappChannelOnHub { return "", &data, errorsmod.Wrapf( rollapptypes.ErrMismatchedChannelID, - "channel id mismatch: expect: %s: got: %s", rollapp.ChannelId, packet.GetDestChannel(), + "channel id mismatch: expect: %s: got: %s", rollapp.ChannelId, rollappChannelOnHub, ) } @@ -324,8 +329,10 @@ func (im IBCMiddleware) ExtractRollappIDAndTransferPacket(ctx sdk.Context, packe } // GetProofHeight returns the proof height of the packet -func (im IBCMiddleware) GetProofHeight(ctx sdk.Context, packet channeltypes.Packet) (uint64, error) { - packetId := channeltypes.NewPacketID(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) +func (im IBCMiddleware) GetProofHeight(ctx sdk.Context, packetType commontypes.RollappPacket_Type, + rollappPortOnHub string, rollappChannelOnHub string, sequence uint64, +) (uint64, error) { + packetId := commontypes.NewPacketUID(packetType, rollappPortOnHub, rollappChannelOnHub, sequence) height, ok := types.FromIBCProofContext(ctx, packetId) if ok { return height.RevisionHeight, nil diff --git a/x/delayedack/keeper/fraud.go b/x/delayedack/keeper/fraud.go index 509074d51..387429e59 100644 --- a/x/delayedack/keeper/fraud.go +++ b/x/delayedack/keeper/fraud.go @@ -35,7 +35,6 @@ func (k Keeper) HandleFraud(ctx sdk.Context, rollappID string, ibc porttypes.IBC logger.Error("failed to refund reverted packet", append(logContext, "error", err.Error())...) } } - // Update status to reverted _, err := k.UpdateRollappPacketWithStatus(ctx, rollappPacket, commontypes.Status_REVERTED) if err != nil { diff --git a/x/delayedack/keeper/keeper.go b/x/delayedack/keeper/keeper.go index 4f0af160d..fe3f9ee82 100644 --- a/x/delayedack/keeper/keeper.go +++ b/x/delayedack/keeper/keeper.go @@ -187,7 +187,7 @@ func (k *Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string } // ValidateRollappId checks that the rollapp id from the ibc connection matches the rollapp, checking the sequencer registered with the consensus state validator set -func (k *Keeper) ValidateRollappId(ctx sdk.Context, rollappID, portID, channelID string) error { +func (k *Keeper) ValidateRollappId(ctx sdk.Context, rollappID, rollappPortOnHub string, rollappChannelOnHub string) error { // Get the sequencer from the latest state info update and check the validator set hash // from the headers match with the sequencer for the rollappID // As the assumption the sequencer is honest we don't check the packet proof height. @@ -203,7 +203,7 @@ func (k *Keeper) ValidateRollappId(ctx sdk.Context, rollappID, portID, channelID // TODO (srene): We compare the validator set of the last consensus height, because it fails to get consensus for a different height, // but we should compare the validator set at the height of the last state info, because sequencer may have changed after that. // If the sequencer is changed, then the validation will fail till the new sequencer sends a new state info update. - tmConsensusState, err := k.getTmConsensusState(ctx, portID, channelID) + tmConsensusState, err := k.getTmConsensusState(ctx, rollappPortOnHub, rollappChannelOnHub) if err != nil { k.Logger(ctx).Error("error consensus state", err) return err diff --git a/x/delayedack/keeper/rollapp_packet.go b/x/delayedack/keeper/rollapp_packet.go index dd266e31b..b8e1c65c3 100644 --- a/x/delayedack/keeper/rollapp_packet.go +++ b/x/delayedack/keeper/rollapp_packet.go @@ -12,7 +12,7 @@ import ( // The key for the packet is generated using the rollappID, proofHeight and the packet itself. func (k Keeper) SetRollappPacket(ctx sdk.Context, rollappPacket commontypes.RollappPacket) error { logger := ctx.Logger() - logger.Debug("Saving rollapp packet", "rollappID", rollappPacket.RollappId, "channel", rollappPacket.Packet.DestinationChannel, + logger.Debug("Saving rollapp packet", "rollappID", rollappPacket.RollappId, "src channel", rollappPacket.Packet.SourceChannel, "sequence", rollappPacket.Packet.Sequence, "proofHeight", rollappPacket.ProofHeight, "type", rollappPacket.Type) store := ctx.KVStore(k.storeKey) rollappPacketKey := commontypes.RollappPacketKey(&rollappPacket) @@ -73,6 +73,7 @@ func (k Keeper) UpdateRollappPacketTransferAddress( case commontypes.RollappPacket_ON_ACK: sender = address } + // Create a new packet data with the updated recipient and sender newPacketData := transfertypes.NewFungibleTokenPacketData( transferPacketData.Denom, transferPacketData.Amount, diff --git a/x/delayedack/proof_height_ante.go b/x/delayedack/proof_height_ante.go index 5e2d37f39..7bc8da46f 100644 --- a/x/delayedack/proof_height_ante.go +++ b/x/delayedack/proof_height_ante.go @@ -5,6 +5,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" delayedacktypes "github.com/dymensionxyz/dymension/v3/x/delayedack/types" ) @@ -18,26 +19,40 @@ func (rrd IBCProofHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula for _, m := range tx.GetMsgs() { var ( height clienttypes.Height - packetId channeltypes.PacketId + packetId commontypes.PacketUID ) switch msg := m.(type) { case *channeltypes.MsgRecvPacket: height = msg.ProofHeight - packetId = channeltypes.NewPacketID(msg.Packet.GetDestPort(), msg.Packet.GetDestChannel(), msg.Packet.GetSequence()) + packetId = commontypes.NewPacketUID( + commontypes.RollappPacket_ON_RECV, + msg.Packet.DestinationPort, + msg.Packet.DestinationChannel, + msg.Packet.Sequence, + ) case *channeltypes.MsgAcknowledgement: height = msg.ProofHeight - packetId = channeltypes.NewPacketID(msg.Packet.GetDestPort(), msg.Packet.GetDestChannel(), msg.Packet.GetSequence()) + packetId = commontypes.NewPacketUID( + commontypes.RollappPacket_ON_ACK, + msg.Packet.SourcePort, + msg.Packet.SourceChannel, + msg.Packet.Sequence, + ) case *channeltypes.MsgTimeout: height = msg.ProofHeight - packetId = channeltypes.NewPacketID(msg.Packet.GetDestPort(), msg.Packet.GetDestChannel(), msg.Packet.GetSequence()) + packetId = commontypes.NewPacketUID( + commontypes.RollappPacket_ON_TIMEOUT, + msg.Packet.SourcePort, + msg.Packet.SourceChannel, + msg.Packet.Sequence, + ) default: continue } ctx = delayedacktypes.NewIBCProofContext(ctx, packetId, height) } - return next(ctx, tx, simulate) } diff --git a/x/delayedack/rollapp_hooks.go b/x/delayedack/rollapp_hooks.go index 46f86ede3..dc4f9acb9 100644 --- a/x/delayedack/rollapp_hooks.go +++ b/x/delayedack/rollapp_hooks.go @@ -59,25 +59,23 @@ func (im IBCMiddleware) finalizeRollappPacket( logger log.Logger, rollappPacket commontypes.RollappPacket, ) (err error) { - logger.Debug("Finalizing IBC rollapp packet", + logContext := []interface{}{ "rollappID", rollappID, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel(), - "type", rollappPacket.Type) + "sequence", rollappPacket.Packet.Sequence, + "source channel", rollappPacket.Packet.SourceChannel, + "destination channel", rollappPacket.Packet.DestinationChannel, + "type", rollappPacket.Type, + } switch rollappPacket.Type { case commontypes.RollappPacket_ON_RECV: - err = osmoutils.ApplyFuncIfNoError(ctx, im.onRecvPacket(rollappPacket, logger)) + err = osmoutils.ApplyFuncIfNoError(ctx, im.onRecvPacket(rollappPacket, logger, logContext)) case commontypes.RollappPacket_ON_ACK: - err = osmoutils.ApplyFuncIfNoError(ctx, im.onAckPacket(rollappPacket, logger)) + err = osmoutils.ApplyFuncIfNoError(ctx, im.onAckPacket(rollappPacket, logger, logContext)) case commontypes.RollappPacket_ON_TIMEOUT: - err = osmoutils.ApplyFuncIfNoError(ctx, im.onTimeoutPacket(rollappPacket, logger)) + err = osmoutils.ApplyFuncIfNoError(ctx, im.onTimeoutPacket(rollappPacket, logger, logContext)) default: - logger.Error("Unknown rollapp packet type", - "rollappID", rollappID, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel(), - "type", rollappPacket.Type) + logger.Error("Unknown rollapp packet type", logContext...) } // Update the packet with the error if err != nil { @@ -86,31 +84,21 @@ func (im IBCMiddleware) finalizeRollappPacket( // Update status to finalized rollappPacket, err = im.keeper.UpdateRollappPacketWithStatus(ctx, rollappPacket, commontypes.Status_FINALIZED) if err != nil { - logger.Error("Error finalizing IBC rollapp packet", - "rollappID", rollappID, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel(), - "type", rollappPacket.Type, - "error", err.Error()) + // If we failed finalizing the packet we return an error to abort the end blocker otherwise it's + // invariant breaking + return fmt.Errorf("Error finalizing IBC rollapp packet: %w", err) } return } -func (im IBCMiddleware) onRecvPacket(rollappPacket commontypes.RollappPacket, logger log.Logger) wrappedFunc { +func (im IBCMiddleware) onRecvPacket(rollappPacket commontypes.RollappPacket, logger log.Logger, logContext []interface{}) wrappedFunc { return func(ctx sdk.Context) (err error) { defer func() { if err != nil { - logger.Error("writing acknowledgement", - "rollappID", rollappPacket.RollappId, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel(), - "error", err.Error()) + logger.Error("writing acknowledgement", append(logContext, "error", err.Error())...) } }() - logger.Debug("Calling OnRecvPacket", - "rollappID", rollappPacket.RollappId, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel()) + logger.Debug("Calling OnRecvPacket", logContext...) ack := im.IBCModule.OnRecvPacket(ctx, *rollappPacket.Packet, rollappPacket.Relayer) // If async, return @@ -137,12 +125,9 @@ func (im IBCMiddleware) onRecvPacket(rollappPacket commontypes.RollappPacket, lo } } -func (im IBCMiddleware) onAckPacket(rollappPacket commontypes.RollappPacket, logger log.Logger) wrappedFunc { +func (im IBCMiddleware) onAckPacket(rollappPacket commontypes.RollappPacket, logger log.Logger, logContext []interface{}) wrappedFunc { return func(ctx sdk.Context) (err error) { - logger.Debug("Calling OnAcknowledgementPacket", - "rollappID", rollappPacket.RollappId, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel()) + logger.Debug("Calling OnAcknowledgementPacket", logContext...) err = im.IBCModule.OnAcknowledgementPacket( ctx, @@ -151,30 +136,19 @@ func (im IBCMiddleware) onAckPacket(rollappPacket commontypes.RollappPacket, log rollappPacket.Relayer, ) if err != nil { - logger.Error("calling OnAcknowledgementPacket", - "rollappID", rollappPacket.RollappId, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel(), - "error", err.Error()) + logger.Error("calling OnAcknowledgementPacket", append(logContext, "error", err.Error())...) } return } } -func (im IBCMiddleware) onTimeoutPacket(rollappPacket commontypes.RollappPacket, logger log.Logger) wrappedFunc { +func (im IBCMiddleware) onTimeoutPacket(rollappPacket commontypes.RollappPacket, logger log.Logger, logContext []interface{}) wrappedFunc { return func(ctx sdk.Context) (err error) { - logger.Debug("Calling OnTimeoutPacket", - "rollappID", rollappPacket.RollappId, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel()) + logger.Debug("Calling OnTimeoutPacket", logContext...) err = im.IBCModule.OnTimeoutPacket(ctx, *rollappPacket.Packet, rollappPacket.Relayer) if err != nil { - logger.Error("calling OnTimeoutPacket", - "rollappID", rollappPacket.RollappId, - "sequence", rollappPacket.Packet.GetSequence(), - "destination channel", rollappPacket.Packet.GetDestChannel(), - "error", err.Error()) + logger.Error("calling OnTimeoutPacket", append(logContext, "error", err.Error())...) } return } diff --git a/x/delayedack/types/proof_height_context.go b/x/delayedack/types/proof_height_context.go index 1ade51aa9..387881ee5 100644 --- a/x/delayedack/types/proof_height_context.go +++ b/x/delayedack/types/proof_height_context.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" ) const ( @@ -14,12 +14,12 @@ const ( proofHeightCtxKey = "ibc_proof_height" ) -func NewIBCProofContext(ctx sdk.Context, packetId channeltypes.PacketId, height clienttypes.Height) sdk.Context { +func NewIBCProofContext(ctx sdk.Context, packetId commontypes.PacketUID, height clienttypes.Height) sdk.Context { key := fmt.Sprintf("%s_%s", proofHeightCtxKey, packetId.String()) return ctx.WithValue(key, height) } -func FromIBCProofContext(ctx sdk.Context, packetId channeltypes.PacketId) (clienttypes.Height, bool) { +func FromIBCProofContext(ctx sdk.Context, packetId commontypes.PacketUID) (clienttypes.Height, bool) { key := fmt.Sprintf("%s_%s", proofHeightCtxKey, packetId.String()) u, ok := ctx.Value(key).(clienttypes.Height) return u, ok