From aaa02c29852dbcecb18998c159550b27ba285602 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Wed, 28 May 2025 16:22:15 +0200 Subject: [PATCH] feat: add field in callbacks data for custom calldata (#8353) Co-authored-by: Gjermund Garaba (cherry picked from commit 7d579b91ac6b55db8e7f57567c9e7cf549f6e479) --- modules/apps/callbacks/ibc_middleware_test.go | 58 +++++- modules/apps/callbacks/types/callbacks.go | 78 ++++++-- .../apps/callbacks/types/callbacks_test.go | 171 +++++++++++++++++- modules/apps/callbacks/types/errors.go | 1 + modules/apps/callbacks/types/export_test.go | 4 +- modules/apps/callbacks/types/keys.go | 2 + .../apps/callbacks/v2/ibc_middleware_test.go | 8 +- 7 files changed, 289 insertions(+), 33 deletions(-) diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index 4aa7f87bb92..d5fec7be54d 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -94,6 +94,7 @@ func (s *CallbacksTestSuite) TestWithICS4Wrapper() { func (s *CallbacksTestSuite) TestSendPacket() { var packetData transfertypes.FungibleTokenPacketData + var callbackExecuted bool testCases := []struct { name string @@ -127,7 +128,7 @@ func (s *CallbacksTestSuite) TestSendPacket() { }, "none", // improperly formatted callback data should result in no callback execution false, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: ics4Wrapper SendPacket call fails", @@ -165,6 +166,46 @@ func (s *CallbacksTestSuite) TestSendPacket() { false, errorsmod.Wrapf(types.ErrCallbackOutOfGas, "ibc %s callback out of gas", types.CallbackTypeSendPacket), }, + { + "failure: callback address invalid", + func() { + packetData.Memo = fmt.Sprintf(`{"src_callback": {"address":%d}}`, 50) + callbackExecuted = false // callback should not be executed + }, + types.CallbackTypeSendPacket, + false, + types.ErrInvalidCallbackData, + }, + { + "failure: callback gas limit invalid", + func() { + packetData.Memo = fmt.Sprintf(`{"src_callback": {"address":"%s", "gas_limit":%d}}`, simapp.SuccessContract, 50) + callbackExecuted = false // callback should not be executed + }, + types.CallbackTypeSendPacket, + false, + types.ErrInvalidCallbackData, + }, + { + "failure: callback calldata invalid", + func() { + packetData.Memo = fmt.Sprintf(`{"src_callback": {"address":"%s", "gas_limit":"%d", "calldata":%d}}`, simapp.SuccessContract, 50, 50) + callbackExecuted = false // callback should not be executed + }, + types.CallbackTypeSendPacket, + false, + types.ErrInvalidCallbackData, + }, + { + "failure: callback calldata hex invalid", + func() { + packetData.Memo = fmt.Sprintf(`{"src_callback": {"address":"%s", "gas_limit":"%d", "calldata":"%s"}}`, simapp.SuccessContract, 50, "calldata") + callbackExecuted = false // callback should not be executed + }, + types.CallbackTypeSendPacket, + false, + types.ErrInvalidCallbackData, + }, } for _, tc := range testCases { @@ -180,6 +221,7 @@ func (s *CallbacksTestSuite) TestSendPacket() { ibctesting.TestAccAddress, fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, simapp.SuccessContract), ) + callbackExecuted = true tc.malleate() @@ -214,11 +256,13 @@ func (s *CallbacksTestSuite) TestSendPacket() { default: sendPacket() - s.Require().ErrorIs(err, tc.expValue.(error)) + s.Require().ErrorIs(tc.expValue.(error), err) s.Require().Equal(uint64(0), seq) } - s.AssertHasExecutedExpectedCallback(tc.callbackType, expPass) + if callbackExecuted { + s.AssertHasExecutedExpectedCallback(tc.callbackType, expPass) + } }) } } @@ -279,7 +323,7 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { packet.Data = packetData.GetBytes() }, noExecution, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: callback execution reach out of gas, but sufficient gas provided by relayer", @@ -449,7 +493,7 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { packet.Data = packetData.GetBytes() }, noExecution, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: callback execution reach out of gas, but sufficient gas provided by relayer", @@ -624,7 +668,7 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { packet.Data = packetData.GetBytes() }, noExecution, - channeltypes.NewErrorAcknowledgement(types.ErrCallbackAddressNotFound), + channeltypes.NewErrorAcknowledgement(types.ErrInvalidCallbackData), }, { "failure: callback execution reach out of gas, but sufficient gas provided by relayer", @@ -782,7 +826,7 @@ func (s *CallbacksTestSuite) TestWriteAcknowledgement() { packet.Data = packetData.GetBytes() }, "none", // improperly formatted callback data should result in no callback execution - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: ics4Wrapper WriteAcknowledgement call fails", diff --git a/modules/apps/callbacks/types/callbacks.go b/modules/apps/callbacks/types/callbacks.go index edb7b1e7ba1..0d7b07fe21a 100644 --- a/modules/apps/callbacks/types/callbacks.go +++ b/modules/apps/callbacks/types/callbacks.go @@ -1,11 +1,14 @@ package types import ( + "encoding/hex" "strconv" "strings" sdk "github.com/cosmos/cosmos-sdk/types" + errorsmod "cosmossdk.io/errors" + channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" "github.com/cosmos/ibc-go/v10/modules/core/api" @@ -74,6 +77,9 @@ type CallbackData struct { CommitGasLimit uint64 // ApplicationVersion is the base application version. ApplicationVersion string + // Calldata is the calldata to be passed to the callback actor. + // This may be empty but if it is not empty, it should be the calldata sent to the callback actor. + Calldata []byte } // GetSourceCallbackData parses the packet data and returns the source callback data. @@ -129,9 +135,9 @@ func GetCallbackData( } // get the callback address from the callback data - callbackAddress := getCallbackAddress(callbackData) - if strings.TrimSpace(callbackAddress) == "" { - return CallbackData{}, true, ErrCallbackAddressNotFound + callbackAddress, err := getCallbackAddress(callbackData) + if err != nil || strings.TrimSpace(callbackAddress) == "" { + return CallbackData{}, true, ErrInvalidCallbackData } // retrieve packet sender from packet data if possible and if needed @@ -144,7 +150,15 @@ func GetCallbackData( } // get the gas limit from the callback data - executionGasLimit, commitGasLimit := computeExecAndCommitGasLimit(callbackData, remainingGas, maxGas) + executionGasLimit, commitGasLimit, err := computeExecAndCommitGasLimit(callbackData, remainingGas, maxGas) + if err != nil { + return CallbackData{}, true, err + } + + callData, err := getCalldata(callbackData) + if err != nil { + return CallbackData{}, true, err + } return CallbackData{ CallbackAddress: callbackAddress, @@ -152,12 +166,16 @@ func GetCallbackData( SenderAddress: packetSender, CommitGasLimit: commitGasLimit, ApplicationVersion: version, + Calldata: callData, }, true, nil } -func computeExecAndCommitGasLimit(callbackData map[string]any, remainingGas, maxGas uint64) (uint64, uint64) { +func computeExecAndCommitGasLimit(callbackData map[string]any, remainingGas, maxGas uint64) (uint64, uint64, error) { // get the gas limit from the callback data - commitGasLimit := getUserDefinedGasLimit(callbackData) + commitGasLimit, err := getUserDefinedGasLimit(callbackData) + if err != nil { + return 0, 0, err + } // ensure user defined gas limit does not exceed the max gas limit if commitGasLimit == 0 || commitGasLimit > maxGas { @@ -168,7 +186,7 @@ func computeExecAndCommitGasLimit(callbackData map[string]any, remainingGas, max // in this case, the callback execution may be retried upon failure executionGasLimit := min(remainingGas, commitGasLimit) - return executionGasLimit, commitGasLimit + return executionGasLimit, commitGasLimit, nil } // getUserDefinedGasLimit returns the custom gas limit provided for callbacks if it is @@ -179,19 +197,26 @@ func computeExecAndCommitGasLimit(callbackData map[string]any, remainingGas, max // { "{callbackKey}": { ... , "gas_limit": {stringForCallback} } // // Note: the user defined gas limit must be set as a string and not a json number. -func getUserDefinedGasLimit(callbackData map[string]any) uint64 { +func getUserDefinedGasLimit(callbackData map[string]any) (uint64, error) { // the gas limit must be specified as a string and not a json number - gasLimit, ok := callbackData[UserDefinedGasLimitKey].(string) + gasLimit, ok := callbackData[UserDefinedGasLimitKey] if !ok { - return 0 + return 0, nil + } + gasLimitStr, ok := gasLimit.(string) + if !ok { + return 0, errorsmod.Wrapf(ErrInvalidCallbackData, "gas limit [%v] must be a string", gasLimit) + } + if gasLimitStr == "" { + return 0, nil } - userGas, err := strconv.ParseUint(gasLimit, 10, 64) + userGas, err := strconv.ParseUint(gasLimitStr, 10, 64) if err != nil { - return 0 + return 0, errorsmod.Wrapf(ErrInvalidCallbackData, "gas limit must be a valid uint64: %s", err) } - return userGas + return userGas, nil } // getCallbackAddress returns the callback address if it is specified in the callback data. @@ -203,13 +228,34 @@ func getUserDefinedGasLimit(callbackData map[string]any) uint64 { // // ADR-8 middleware should callback on the returned address if it is a PacketActor // (i.e. smart contract that accepts IBC callbacks). -func getCallbackAddress(callbackData map[string]any) string { +func getCallbackAddress(callbackData map[string]any) (string, error) { callbackAddress, ok := callbackData[CallbackAddressKey].(string) if !ok { - return "" + return "", errorsmod.Wrapf(ErrInvalidCallbackData, "callback address must be a string") } - return callbackAddress + return callbackAddress, nil +} + +// getCalldata returns the calldata if it is specified in the callback data. +func getCalldata(callbackData map[string]any) ([]byte, error) { + calldataAny, ok := callbackData[CalldataKey] + if !ok { + return nil, nil + } + calldataStr, ok := calldataAny.(string) + if !ok { + return nil, errorsmod.Wrapf(ErrInvalidCallbackData, "calldata must be a string") + } + if calldataStr == "" { + return nil, nil + } + + calldata, err := hex.DecodeString(calldataStr) + if err != nil { + return nil, errorsmod.Wrapf(ErrInvalidCallbackData, "calldata must be a valid hex string: %s", err) + } + return calldata, nil } // AllowRetry returns true if the callback execution gas limit is less than the commit gas limit. diff --git a/modules/apps/callbacks/types/callbacks_test.go b/modules/apps/callbacks/types/callbacks_test.go index d8ac06d5c46..e4dc13bd6b2 100644 --- a/modules/apps/callbacks/types/callbacks_test.go +++ b/modules/apps/callbacks/types/callbacks_test.go @@ -228,6 +228,79 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { true, nil, }, + { + "success: source callback with calldata", + func() { + remainingGas = 2_000_000 + version = transfertypes.V1 + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "calldata": "%x"}}`, sender, []byte("calldata")), + } + }, + types.CallbackData{ + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, + Calldata: []byte("calldata"), + }, + true, + nil, + }, + { + "success: source callback with empty calldata", + func() { + remainingGas = 2_000_000 + version = transfertypes.V1 + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "calldata": ""}}`, sender), + } + }, + types.CallbackData{ + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, + Calldata: nil, + }, + true, + nil, + }, + { + "success: dest callback with calldata", + func() { + callbackKey = types.DestinationCallbackKey + remainingGas = 2_000_000 + version = transfertypes.V1 + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"dest_callback": {"address": "%s", "calldata": "%x"}}`, sender, []byte("calldata")), + } + }, + types.CallbackData{ + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, + Calldata: []byte("calldata"), + }, + true, + nil, + }, { "failure: packet data does not implement PacketDataProvider", func() { @@ -267,7 +340,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { }, types.CallbackData{}, true, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: space address", @@ -283,7 +356,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { }, types.CallbackData{}, true, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { @@ -343,6 +416,57 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { false, types.ErrNotPacketDataProvider, }, + { + "failure: invalid gasLimit", + func() { + remainingGas = 2_000_000 + version = transfertypes.V1 + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "gas_limit": "invalid"}}`, sender), + } + }, + types.CallbackData{}, + true, + types.ErrInvalidCallbackData, + }, + { + "failure: invalid calldata", + func() { + remainingGas = 2_000_000 + version = transfertypes.V1 + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "calldata": "invalid"}}`, sender), + } + }, + types.CallbackData{}, + true, + types.ErrInvalidCallbackData, + }, + { + "failure: invalid calldata is number", + func() { + remainingGas = 2_000_000 + version = transfertypes.V1 + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "calldata": 10}}`, sender), + } + }, + types.CallbackData{}, + true, + types.ErrInvalidCallbackData, + }, } for _, tc := range testCases { @@ -365,6 +489,12 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { expAllowRetry := tc.expCallbackData.ExecutionGasLimit < tc.expCallbackData.CommitGasLimit s.Require().Equal(expAllowRetry, callbackData.AllowRetry(), tc.name) + + // check if the callback calldata is correctly unmarshalled + if len(tc.expCallbackData.Calldata) > 0 { + s.Require().Equal([]byte("calldata"), callbackData.Calldata, tc.name) + } + } else { s.Require().ErrorIs(err, tc.expError, tc.name) } @@ -496,6 +626,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { name string packetData ibcexported.PacketDataProvider expAddress string + expError error }{ { "success: memo has callbacks in json struct and properly formatted src_callback_address which does not match packet sender", @@ -507,6 +638,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, receiver), }, receiver, + nil, }, { "success: valid src_callback address specified in memo that matches sender", @@ -518,6 +650,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, sender), }, sender, + nil, }, { "failure: memo is empty", @@ -529,6 +662,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: "", }, "", + nil, }, { "failure: memo is not json string", @@ -540,6 +674,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: "memo", }, "", + nil, }, { "failure: memo has empty src_callback object", @@ -551,6 +686,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: `{"src_callback": {}}`, }, "", + types.ErrInvalidCallbackData, }, { "failure: memo does not have callbacks in json struct", @@ -562,6 +698,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: `{"Key": 10}`, }, "", + nil, }, { "failure: memo has src_callback in json struct but does not have address key", @@ -573,6 +710,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: `{"src_callback": {"Key": 10}}`, }, "", + types.ErrInvalidCallbackData, }, { "failure: memo has src_callback in json struct but does not have string value for address key", @@ -584,6 +722,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { Memo: `{"src_callback": {"address": 10}}`, }, "", + types.ErrInvalidCallbackData, }, } @@ -591,7 +730,15 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { s.Run(tc.name, func() { callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]any) s.Require().Equal(ok, callbackData != nil) - s.Require().Equal(tc.expAddress, types.GetCallbackAddress(callbackData), tc.name) + if ok { + address, err := types.GetCallbackAddress(callbackData) + if tc.expError != nil { + s.Require().ErrorIs(err, tc.expError, tc.name) + } else { + s.Require().NoError(err, tc.name) + s.Require().Equal(tc.expAddress, address, tc.name) + } + } }) } } @@ -606,6 +753,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { name string packetData ibcexported.PacketDataProvider expUserGas uint64 + expError error }{ { "success: memo is empty", @@ -617,6 +765,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: "", }, 0, + nil, }, { "success: memo has user defined gas limit", @@ -628,6 +777,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `{"src_callback": {"gas_limit": "100"}}`, }, 100, + nil, }, { "success: user defined gas limit is zero", @@ -639,6 +789,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `{"src_callback": {"gas_limit": "0"}}`, }, 0, + nil, }, { "failure: memo has empty src_callback object", @@ -650,6 +801,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `{"src_callback": {}}`, }, 0, + nil, }, { "failure: memo has user defined gas limit as json number", @@ -661,6 +813,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `{"src_callback": {"gas_limit": 100}}`, }, 0, + types.ErrInvalidCallbackData, }, { "failure: memo has user defined gas limit as negative", @@ -672,6 +825,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `{"src_callback": {"gas_limit": "-100"}}`, }, 0, + types.ErrInvalidCallbackData, }, { "failure: memo has user defined gas limit as string", @@ -683,6 +837,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `{"src_callback": {"gas_limit": "invalid"}}`, }, 0, + types.ErrInvalidCallbackData, }, { "failure: memo has user defined gas limit as empty string", @@ -694,6 +849,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `{"src_callback": {"gas_limit": ""}}`, }, 0, + nil, }, { "failure: malformed memo", @@ -705,6 +861,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { Memo: `invalid`, }, 0, + nil, }, } @@ -712,7 +869,13 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { s.Run(tc.name, func() { callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]any) s.Require().Equal(ok, callbackData != nil) - s.Require().Equal(tc.expUserGas, types.GetUserDefinedGasLimit(callbackData), tc.name) + userGas, err := types.GetUserDefinedGasLimit(callbackData) + if tc.expError != nil { + s.Require().ErrorIs(err, tc.expError, tc.name) + } else { + s.Require().NoError(err, tc.name) + s.Require().Equal(tc.expUserGas, userGas, tc.name) + } }) } } diff --git a/modules/apps/callbacks/types/errors.go b/modules/apps/callbacks/types/errors.go index df2d2ef2938..07d5a5c9ef5 100644 --- a/modules/apps/callbacks/types/errors.go +++ b/modules/apps/callbacks/types/errors.go @@ -11,4 +11,5 @@ var ( ErrCallbackAddressNotFound = errorsmod.Register(ModuleName, 5, "callback address not found in packet data") ErrCallbackOutOfGas = errorsmod.Register(ModuleName, 6, "callback out of gas") ErrCallbackPanic = errorsmod.Register(ModuleName, 7, "callback panic") + ErrInvalidCallbackData = errorsmod.Register(ModuleName, 8, "invalid callback data") ) diff --git a/modules/apps/callbacks/types/export_test.go b/modules/apps/callbacks/types/export_test.go index 382ff6e6231..e55fdf3c854 100644 --- a/modules/apps/callbacks/types/export_test.go +++ b/modules/apps/callbacks/types/export_test.go @@ -5,11 +5,11 @@ package types */ // GetCallbackAddress is a wrapper around getCallbackAddress to allow the function to be directly called in tests. -func GetCallbackAddress(callbackData map[string]any) string { +func GetCallbackAddress(callbackData map[string]any) (string, error) { return getCallbackAddress(callbackData) } // GetUserDefinedGasLimit is a wrapper around getUserDefinedGasLimit to allow the function to be directly called in tests. -func GetUserDefinedGasLimit(callbackData map[string]any) uint64 { +func GetUserDefinedGasLimit(callbackData map[string]any) (uint64, error) { return getUserDefinedGasLimit(callbackData) } diff --git a/modules/apps/callbacks/types/keys.go b/modules/apps/callbacks/types/keys.go index d07613cc466..9ab3f5c323c 100644 --- a/modules/apps/callbacks/types/keys.go +++ b/modules/apps/callbacks/types/keys.go @@ -28,4 +28,6 @@ const ( // The expected format for ICS20 and ICS27 memo field is as follows: // { "{callbackKey}": { ... , "gas_limit": {stringForCallback} } UserDefinedGasLimitKey = "gas_limit" + // CalldataKey is the key used to store the calldata in the callback packet data. + CalldataKey = "calldata" ) diff --git a/modules/apps/callbacks/v2/ibc_middleware_test.go b/modules/apps/callbacks/v2/ibc_middleware_test.go index 417e4052f79..fe436fe3f2f 100644 --- a/modules/apps/callbacks/v2/ibc_middleware_test.go +++ b/modules/apps/callbacks/v2/ibc_middleware_test.go @@ -132,7 +132,7 @@ func (s *CallbacksTestSuite) TestSendPacket() { }, "none", // improperly formatted callback data should result in no callback execution false, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: callback execution fails", @@ -274,7 +274,7 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { packetData.Memo = `{"src_callback": {"address": ""}}` }, noExecution, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: callback execution reach out of gas, but sufficient gas provided by relayer", @@ -433,7 +433,7 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { packetData.Memo = `{"src_callback": {"address": ""}}` }, noExecution, - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: callback execution reach out of gas, but sufficient gas provided by relayer", @@ -758,7 +758,7 @@ func (s *CallbacksTestSuite) TestWriteAcknowledgement() { packetData.Memo = `{"dest_callback": {"address": ""}}` }, "none", // improperly formatted callback data should result in no callback execution - types.ErrCallbackAddressNotFound, + types.ErrInvalidCallbackData, }, { "failure: ics4Wrapper WriteAcknowledgement call fails",