From 5d68a8e490e7fe7d1ec70d2698e85ecc5f3ddf4b Mon Sep 17 00:00:00 2001 From: bznein Date: Thu, 10 Oct 2024 14:49:52 +0100 Subject: [PATCH 1/4] Add OnAcknowledgmentPacket to IBCModule V2 Interface --- modules/core/api/module.go | 12 ++++++++++-- testing/mock/v2/ibc_app.go | 7 ++++--- testing/mock/v2/ibc_module.go | 14 ++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/core/api/module.go b/modules/core/api/module.go index f15dfad6611..e33e638946c 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -31,8 +31,6 @@ type IBCModule interface { relayer sdk.AccAddress, ) channeltypesv2.RecvPacketResult - // OnAcknowledgementPacket - // OnTimeoutPacket is executed when a packet has timed out on the receiving chain. OnTimeoutPacket( ctx context.Context, @@ -41,4 +39,14 @@ type IBCModule interface { data channeltypesv2.PacketData, relayer sdk.AccAddress, ) error + + // OnAcknowledgementPacket is executed when a packet gets acknowledged + OnAcknowledgementPacket( + ctx context.Context, + sourceID string, + destinationID string, + data channeltypesv2.PacketData, + acknowldgement []byte, + relayer sdk.AccAddress, + ) error } diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index ddf4c67f115..05dfd01f597 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -9,7 +9,8 @@ import ( ) type IBCApp struct { - OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error - OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult - OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error + OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error + OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error + OnAcknowledgementPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowldgement []byte, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 0e948daa471..901695dc525 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -49,14 +49,12 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinati } } -// -// func (im IBCModule) OnAcknowledgementPacket() error { -// if im.IBCApp.OnAcknowledgementPacket != nil { -// return im.IBCApp.OnAcknowledgementPacket(...) -// } -// return nil -// } -// +func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowldgement []byte, relayer sdk.AccAddress) error { + if im.IBCApp.OnAcknowledgementPacket != nil { + return im.IBCApp.OnAcknowledgementPacket(ctx, sourceID, destinationID, data, acknowldgement, relayer) + } + return nil +} func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { if im.IBCApp.OnTimeoutPacket != nil { From f57e7b16a05e2c690344d2d5d9f4eb9a29542700 Mon Sep 17 00:00:00 2001 From: bznein Date: Thu, 10 Oct 2024 14:52:12 +0100 Subject: [PATCH 2/4] chore: fix typo --- modules/core/api/module.go | 2 +- testing/mock/v2/ibc_app.go | 2 +- testing/mock/v2/ibc_module.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/api/module.go b/modules/core/api/module.go index e33e638946c..8346d291663 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -46,7 +46,7 @@ type IBCModule interface { sourceID string, destinationID string, data channeltypesv2.PacketData, - acknowldgement []byte, + acknowledgement []byte, relayer sdk.AccAddress, ) error } diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index 05dfd01f597..21948faab3e 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -12,5 +12,5 @@ type IBCApp struct { OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error - OnAcknowledgementPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowldgement []byte, relayer sdk.AccAddress) error + OnAcknowledgementPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 901695dc525..cb797c592bc 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -49,9 +49,9 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinati } } -func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowldgement []byte, relayer sdk.AccAddress) error { +func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { if im.IBCApp.OnAcknowledgementPacket != nil { - return im.IBCApp.OnAcknowledgementPacket(ctx, sourceID, destinationID, data, acknowldgement, relayer) + return im.IBCApp.OnAcknowledgementPacket(ctx, sourceID, destinationID, data, acknowledgement, relayer) } return nil } From 8c7eb302e744073380c047be2a1d4f96d28dc7bc Mon Sep 17 00:00:00 2001 From: bznein Date: Mon, 14 Oct 2024 11:35:59 +0100 Subject: [PATCH 3/4] chore: PR feedback --- modules/core/api/module.go | 16 ++++++++-------- testing/mock/v2/ibc_app.go | 8 ++++---- testing/mock/v2/ibc_module.go | 16 ++++++++-------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/core/api/module.go b/modules/core/api/module.go index 8346d291663..077dc65e35e 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -16,8 +16,8 @@ type IBCModule interface { // for this specific application. OnSendPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress, @@ -25,8 +25,8 @@ type IBCModule interface { OnRecvPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress, ) channeltypesv2.RecvPacketResult @@ -34,8 +34,8 @@ type IBCModule interface { // OnTimeoutPacket is executed when a packet has timed out on the receiving chain. OnTimeoutPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress, ) error @@ -43,8 +43,8 @@ type IBCModule interface { // OnAcknowledgementPacket is executed when a packet gets acknowledged OnAcknowledgementPacket( ctx context.Context, - sourceID string, - destinationID string, + sourceChannel string, + destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress, diff --git a/testing/mock/v2/ibc_app.go b/testing/mock/v2/ibc_app.go index 21948faab3e..74c6ca7c543 100644 --- a/testing/mock/v2/ibc_app.go +++ b/testing/mock/v2/ibc_app.go @@ -9,8 +9,8 @@ import ( ) type IBCApp struct { - OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error - OnRecvPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult - OnTimeoutPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error - OnAcknowledgementPacket func(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error + OnSendPacket func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error + OnRecvPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult + OnTimeoutPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error + OnAcknowledgementPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index cb797c592bc..871b870bba4 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -32,16 +32,16 @@ func NewIBCModule() IBCModule { } } -func (im IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { +func (im IBCModule) OnSendPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error { if im.IBCApp.OnSendPacket != nil { - return im.IBCApp.OnSendPacket(ctx, sourceID, destinationID, sequence, data, signer) + return im.IBCApp.OnSendPacket(ctx, sourceChannel, destinationChannel, sequence, data, signer) } return nil } -func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { +func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { if im.IBCApp.OnRecvPacket != nil { - return im.IBCApp.OnRecvPacket(ctx, sourceID, destinationID, data, relayer) + return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, data, relayer) } return channeltypesv2.RecvPacketResult{ Status: channeltypesv2.PacketStatus_Success, @@ -49,16 +49,16 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, sourceID string, destinati } } -func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { +func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, acknowledgement []byte, relayer sdk.AccAddress) error { if im.IBCApp.OnAcknowledgementPacket != nil { - return im.IBCApp.OnAcknowledgementPacket(ctx, sourceID, destinationID, data, acknowledgement, relayer) + return im.IBCApp.OnAcknowledgementPacket(ctx, sourceChannel, destinationChannel, data, acknowledgement, relayer) } return nil } -func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceID string, destinationID string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { +func (im IBCModule) OnTimeoutPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.PacketData, relayer sdk.AccAddress) error { if im.IBCApp.OnTimeoutPacket != nil { - return im.IBCApp.OnTimeoutPacket(ctx, sourceID, destinationID, data, relayer) + return im.IBCApp.OnTimeoutPacket(ctx, sourceChannel, destinationChannel, data, relayer) } return nil } From 45339126f3168f4f03642abd60cf1603d721d685 Mon Sep 17 00:00:00 2001 From: bznein Date: Mon, 14 Oct 2024 11:43:39 +0100 Subject: [PATCH 4/4] chore: fix wrong merge conflict resolution --- modules/core/api/module.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/core/api/module.go b/modules/core/api/module.go index 86f30edcce4..077dc65e35e 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -49,14 +49,4 @@ type IBCModule interface { acknowledgement []byte, relayer sdk.AccAddress, ) error - - // OnAcknowledgementPacket is executed when a packet gets acknowledged - OnAcknowledgementPacket( - ctx context.Context, - sourceID string, - destinationID string, - data channeltypesv2.PacketData, - acknowledgement []byte, - relayer sdk.AccAddress, - ) error }