From 764889c471b4b9f9a2869fa62265c64067894bb9 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Fri, 8 Mar 2024 16:51:49 +0100 Subject: [PATCH] Use improved ibc callbacks wiring --- app/app.go | 12 ++++++++---- tests/e2e/ibc_callbacks_test.go | 6 ++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/app.go b/app/app.go index 36702b726c..33fd637d24 100644 --- a/app/app.go +++ b/app/app.go @@ -665,10 +665,13 @@ func NewWasmApp( // see https://medium.com/the-interchain-foundation/ibc-go-v6-changes-to-interchain-accounts-and-how-it-impacts-your-chain-806c185300d7 var noAuthzModule porttypes.IBCModule icaControllerStack = icacontroller.NewIBCMiddleware(noAuthzModule, app.ICAControllerKeeper) - icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) + // app.ICAAuthModule = icaControllerStack.(ibcmock.IBCModule) + icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper) icaControllerStack = ibccallbacks.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper, wasmStackIBCHandler, MaxIBCCallbackGas) + icaICS4Wrapper := icaControllerStack.(porttypes.ICS4Wrapper) + icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) // Since the callbacks middleware itself is an ics4wrapper, it needs to be passed to the ica controller keeper - app.ICAControllerKeeper.WithICS4Wrapper(icaControllerStack.(porttypes.ICS4Wrapper)) + app.ICAControllerKeeper.WithICS4Wrapper(icaICS4Wrapper) // RecvPacket, message that originates from core IBC and goes down to app, the flow is: // channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket @@ -679,10 +682,11 @@ func NewWasmApp( // Create Transfer Stack var transferStack porttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) - transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) transferStack = ibccallbacks.NewIBCMiddleware(transferStack, app.IBCFeeKeeper, wasmStackIBCHandler, MaxIBCCallbackGas) + transferICS4Wrapper := transferStack.(porttypes.ICS4Wrapper) + transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) // Since the callbacks middleware itself is an ics4wrapper, it needs to be passed to the ica controller keeper - app.TransferKeeper.WithICS4Wrapper(transferStack.(porttypes.ICS4Wrapper)) + app.TransferKeeper.WithICS4Wrapper(transferICS4Wrapper) // Create static IBC router, add app routes, then set and seal it ibcRouter := porttypes.NewRouter(). diff --git a/tests/e2e/ibc_callbacks_test.go b/tests/e2e/ibc_callbacks_test.go index 3383ead295..3aa000a6d3 100644 --- a/tests/e2e/ibc_callbacks_test.go +++ b/tests/e2e/ibc_callbacks_test.go @@ -97,10 +97,8 @@ func TestIBCCallbacks(t *testing.T) { assert.Len(t, response.IBCAckCallbacks, 1) assert.Empty(t, response.IBCTimeoutCallbacks) - var ack ibcfee.IncentivizedAcknowledgement - err = json.Unmarshal(response.IBCAckCallbacks[0].Acknowledgement.Data, &ack) - require.NoError(t, err) - assert.Equal(t, []byte(`{"result":"AQ=="}`), ack.AppAcknowledgement) // ics20 success ack + // and the ack result should be the ics20 success ack + assert.Equal(t, []byte(`{"result":"AQ=="}`), response.IBCAckCallbacks[0].Acknowledgement.Data) // now the same, but with a timeout: contractMsg.TimeoutSeconds = 1