Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry picking remaining PRs for v14.x #3928

Merged
merged 7 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/CosmWasm/wasmd v0.30.0
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/cosmos/cosmos-sdk v0.46.7
github.com/cosmos/cosmos-sdk v0.45.11
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v4 v4.2.0
github.com/gogo/protobuf v1.3.3
Expand All @@ -17,9 +17,9 @@ require (
github.com/mattn/go-sqlite3 v1.14.16
github.com/ory/dockertest/v3 v3.9.1
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3
github.com/osmosis-labs/osmosis/osmomath v0.0.2
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230101095308-fa4e70e17dbf
github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230106110532-e17f2f459464
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230106095152-4f77cc5e42af
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230106110415-61e4300ada92
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.0
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -853,12 +853,12 @@ github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e h1:A3by
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e/go.mod h1:rud0OaBIuq3+qOqtwT4SR7Q7iSzRp7w41fjninTjfnQ=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:YlmchqTmlwdWSmrRmXKR+PcU96ntOd8u10vTaTZdcNY=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI=
github.com/osmosis-labs/osmosis/osmomath v0.0.2 h1:8vTobkYfoRTCJCie+jE7gzXvqUUfoPI4NSvTskoci50=
github.com/osmosis-labs/osmosis/osmomath v0.0.2/go.mod h1:IpoXO7lvmfsBFfQzaqovs541hpqtrnM+GJSZDi/TZtc=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf h1:FZOlrTSaf/YWokt3+tSSZpcu6zu3dXLhsvhJWkHeBxU=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf/go.mod h1:T7CCZKYhKWASnv5mRE8u3m0gst3NZ/sU16Brjmv4UPw=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230101095308-fa4e70e17dbf h1:qcDUVsM6BNuGJ3dfGs3onOPzR0donLgXznqv60HRk+8=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230101095308-fa4e70e17dbf/go.mod h1:5zNisZDypMTW32EABSuWI/EacHC48590PpSO9QwFzCg=
github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230106110532-e17f2f459464 h1:2562qeTuCCb1IQBcbKjQgVD+cpPxVMzi//Dr/1uQbGc=
github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230106110532-e17f2f459464/go.mod h1:KrzYoNtnWUH75rj1XAsSR4nymlHFU7jeVOx7/1KMe0k=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230106095152-4f77cc5e42af h1:/UyyIUTH2FZaN7xULcA2SQ6+bKD9fsau4PJkYWMir3g=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230106095152-4f77cc5e42af/go.mod h1:K4de+n3DtLdueen98dOzaRXZvqMd8JvigL8O1xW445o=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230106110415-61e4300ada92 h1:aXAru0jzeTjrSmFEcqIXUI23yaE0RqpwKg04HK1sYcs=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230106110415-61e4300ada92/go.mod h1:UyXr/YYabkU+pQ85RDjUMJe2kbffcnOHWlk3NSfWA34=
github.com/osmosis-labs/wasmd v0.29.2-0.20221222131554-7c8ea36a6e30 h1:6uMi7HhPSwvKKU7j5NqljseFTEz4I7qHr+IPnnn42Ck=
github.com/osmosis-labs/wasmd v0.29.2-0.20221222131554-7c8ea36a6e30/go.mod h1:5fDYJyMXBq6u2iuHqqOTYiZ5NitIOeIW5k7qEXqbwJE=
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
Expand Down
4 changes: 3 additions & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,9 @@ github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xA
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE=
github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs=
github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230106110532-e17f2f459464/go.mod h1:KrzYoNtnWUH75rj1XAsSR4nymlHFU7jeVOx7/1KMe0k=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230105183030-bccf5202f260/go.mod h1:K4de+n3DtLdueen98dOzaRXZvqMd8JvigL8O1xW445o=
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI=
github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI=
github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
Expand Down Expand Up @@ -542,5 +543,6 @@ google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
pgregory.net/rapid v0.5.3/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
2 changes: 1 addition & 1 deletion osmomath/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/osmosis-labs/osmosis/osmomath
go 1.18

require (
github.com/cosmos/cosmos-sdk v0.46.7
github.com/cosmos/cosmos-sdk v0.45.1
github.com/stretchr/testify v1.8.1
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions osmoutils/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/osmosis-labs/osmosis/osmoutils
go 1.18

require (
github.com/cosmos/cosmos-sdk v0.46.7
github.com/cosmos/cosmos-sdk v0.45.10
github.com/cosmos/iavl v0.19.4
github.com/cosmos/ibc-go/v3 v3.4.0
github.com/cosmos/ibc-go/v4 v4.2.0
github.com/gogo/protobuf v1.3.3
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions osmoutils/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok=
github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-go/v3 v3.4.0 h1:ha3cqEG36pqMWqA1D+kxDWBTZXpeFMd/aZIQF7I0xro=
github.com/cosmos/ibc-go/v3 v3.4.0/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA=
github.com/cosmos/ibc-go/v4 v4.2.0 h1:Fx/kKq/uvawrAxk6ZrQ6sEIgffLRU5Cs/AUnvpPBrHI=
github.com/cosmos/ibc-go/v4 v4.2.0/go.mod h1:57qWScDtfCx3FOMLYmBIKPbOLE6xiVhrgxHAQmbWYXM=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
Expand Down
29 changes: 17 additions & 12 deletions osmoutils/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ package osmoutils

import (
"encoding/json"

sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
)

// NewStringErrorAcknowledgement returns a new instance of Acknowledgement using an Acknowledgement_Error
// type in the Response field. These errors differ from the IBC errors in that we use custom error strings.
// NOTE: Acknowledgements are written into state and thus, changes made to error strings included in packet acknowledgements
// risk an app hash divergence when nodes in a network are running different patch versions of software.
func NewStringErrorAcknowledgement(err string) channeltypes.Acknowledgement {
// ToDo: Do we want to do this or do we want to use the IBC errors and emit the string?

return channeltypes.Acknowledgement{
Response: &channeltypes.Acknowledgement_Error{
Error: err,
},
// NewEmitErrorAcknowledgement creates a new error acknowledgement after having emitted an event with the
// details of the error.
func NewEmitErrorAcknowledgement(ctx sdk.Context, err error, errorContexts ...string) channeltypes.Acknowledgement {
attributes := make([]sdk.Attribute, len(errorContexts)+1)
attributes[0] = sdk.NewAttribute("error", err.Error())
for i, s := range errorContexts {
attributes[i+1] = sdk.NewAttribute("error-context", s)
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
"ibc-acknowledgement-error",
attributes...,
),
})

return channeltypes.NewErrorAcknowledgement(err)
}

// MustExtractDenomFromPacketOnRecv takes a packet with a valid ICS20 token data in the Data field and returns the
Expand Down
Binary file modified tests/ibc-hooks/bytecode/counter.wasm
Binary file not shown.
Binary file modified tests/ibc-hooks/bytecode/crosschain_swaps.wasm
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/ibc-hooks/testutils/contracts/counter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ pub mod execute {
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> Result<Response, ContractError> {
match msg {
SudoMsg::ReceiveAck {
SudoMsg::IBCLifecycleComplete(IBCLifecycleComplete::IBCAck {
channel: _,
sequence: _,
ack: _,
success,
} => sudo::receive_ack(deps, env.contract.address, success),
SudoMsg::IBCTimeout {
}) => sudo::receive_ack(deps, env.contract.address, success),
SudoMsg::IBCLifecycleComplete(IBCLifecycleComplete::IBCTimeout {
channel: _,
sequence: _,
} => sudo::ibc_timeout(deps, env.contract.address),
}) => sudo::ibc_timeout(deps, env.contract.address),
}
}

Expand Down
23 changes: 20 additions & 3 deletions tests/ibc-hooks/testutils/contracts/counter/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,30 @@ pub struct GetTotalFundsResponse {
}

#[cw_serde]
pub enum SudoMsg {
ReceiveAck {
#[serde(rename = "ibc_lifecycle_complete")]
pub enum IBCLifecycleComplete {
#[serde(rename = "ibc_ack")]
IBCAck {
/// The source channel (osmosis side) of the IBC packet
channel: String,
/// The sequence number that the packet was sent with
sequence: u64,
/// String encoded version of the ack as seen by OnAcknowledgementPacket(..)
ack: String,
/// Weather an ack is a success of failure according to the transfer spec
success: bool,
},
#[serde(rename = "ibc_timeout")]
IBCTimeout { channel: String, sequence: u64 },
IBCTimeout {
/// The source channel (osmosis side) of the IBC packet
channel: String,
/// The sequence number that the packet was sent with
sequence: u64,
},
}

#[cw_serde]
pub enum SudoMsg {
#[serde(rename = "ibc_lifecycle_complete")]
IBCLifecycleComplete(IBCLifecycleComplete),
}
Binary file modified x/ibc-hooks/bytecode/crosschain_swaps.wasm
Binary file not shown.
Binary file modified x/ibc-hooks/bytecode/swaprouter.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions x/ibc-hooks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go 1.18

require (
github.com/CosmWasm/wasmd v0.29.2
github.com/cosmos/cosmos-sdk v0.46.7
github.com/cosmos/cosmos-sdk v0.45.11
github.com/cosmos/ibc-go/v4 v4.2.0
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230106095152-4f77cc5e42af
github.com/spf13/cobra v1.6.1
github.com/tendermint/tendermint v0.34.24
)
Expand Down
4 changes: 2 additions & 2 deletions x/ibc-hooks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh
github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e h1:A3byMZpvq21iI7yWJUNdHw0nf8jVAbVUsWY9twnXSXE=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e/go.mod h1:rud0OaBIuq3+qOqtwT4SR7Q7iSzRp7w41fjninTjfnQ=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf h1:FZOlrTSaf/YWokt3+tSSZpcu6zu3dXLhsvhJWkHeBxU=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf/go.mod h1:T7CCZKYhKWASnv5mRE8u3m0gst3NZ/sU16Brjmv4UPw=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230106095152-4f77cc5e42af h1:/UyyIUTH2FZaN7xULcA2SQ6+bKD9fsau4PJkYWMir3g=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230106095152-4f77cc5e42af/go.mod h1:K4de+n3DtLdueen98dOzaRXZvqMd8JvigL8O1xW445o=
github.com/osmosis-labs/wasmd v0.29.2-0.20221222131554-7c8ea36a6e30 h1:6uMi7HhPSwvKKU7j5NqljseFTEz4I7qHr+IPnnn42Ck=
github.com/osmosis-labs/wasmd v0.29.2-0.20221222131554-7c8ea36a6e30/go.mod h1:5fDYJyMXBq6u2iuHqqOTYiZ5NitIOeIW5k7qEXqbwJE=
github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE=
Expand Down
11 changes: 9 additions & 2 deletions x/ibc-hooks/types/errors.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package types

import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

var (
ErrBadPacketMetadataMsg = "cannot unmarshal metadata: '%v'. %s"
ErrBadMetadataFormatMsg = "wasm metadata not properly formatted for: '%v'. %s"
ErrBadExecutionMsg = "cannot execute contract: %v"
ErrBadResponse = "cannot create response: %v"

ErrMsgValidation = sdkerrors.Register("wasm-hooks", 2, "error in wasmhook message validation")
ErrMarshaling = sdkerrors.Register("wasm-hooks", 3, "cannot marshal the ICS20 packet")
ErrInvalidPacket = sdkerrors.Register("wasm-hooks", 4, "invalid packet data")
ErrBadResponse = sdkerrors.Register("wasm-hooks", 5, "cannot create response")
ErrWasmError = sdkerrors.Register("wasm-hooks", 6, "wasm error")
ErrBadSender = sdkerrors.Register("wasm-hooks", 7, "bad sender")
)
18 changes: 9 additions & 9 deletions x/ibc-hooks/wasm_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ func (h WasmHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packe
return im.App.OnRecvPacket(ctx, packet, relayer)
}
if err != nil {
return osmoutils.NewStringErrorAcknowledgement(err.Error())
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrMsgValidation, err.Error())
}
if msgBytes == nil || contractAddr == nil { // This should never happen
return osmoutils.NewStringErrorAcknowledgement("error in wasmhook message validation")
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrMsgValidation)
}

// The funds sent on this packet need to be transferred to the wasm hooks module address/
// For this, we override the ICS20 packet's Receiver (essentially hijacking the funds for the module)
// and execute the underlying OnRecvPacket() call (which should eventually land on the transfer app's
// relay.go and send the sunds to the module.
// relay.go and send the funds to the module.
//
// If that succeeds, we make the contract call
data.Receiver = WasmHookModuleAccountAddr.String()
bz, err := json.Marshal(data)
if err != nil {
return osmoutils.NewStringErrorAcknowledgement(fmt.Sprintf("cannot marshal the ICS20 packet: %s", err.Error()))
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrMarshaling, err.Error())
}
packet.Data = bz

Expand All @@ -89,7 +89,7 @@ func (h WasmHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packe
if !ok {
// This should never happen, as it should've been caught in the underlaying call to OnRecvPacket,
// but returning here for completeness
return osmoutils.NewStringErrorAcknowledgement("Invalid packet data: Amount is not an int")
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrInvalidPacket, "Amount is not an int")
}

// The packet's denom is the denom in the sender chain. This needs to be converted to the local denom.
Expand All @@ -104,13 +104,13 @@ func (h WasmHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packe
}
response, err := h.execWasmMsg(ctx, &execMsg)
if err != nil {
return osmoutils.NewStringErrorAcknowledgement(err.Error())
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrWasmError, err.Error())
}

fullAck := ContractAck{ContractResult: response.Data, IbcAck: ack.Acknowledgement()}
bz, err = json.Marshal(fullAck)
if err != nil {
return osmoutils.NewStringErrorAcknowledgement(fmt.Sprintf(types.ErrBadResponse, err.Error()))
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrBadResponse, err.Error())
}

return channeltypes.NewResultAcknowledgement(bz)
Expand Down Expand Up @@ -321,7 +321,7 @@ func (h WasmHooks) OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdk.Con
}

sudoMsg := []byte(fmt.Sprintf(
`{"receive_ack": {"channel": "%s", "sequence": %d, "ack": %s, "success": %s}}`,
`{"ibc_lifecycle_complete": {"ibc_ack": {"channel": "%s", "sequence": %d, "ack": %s, "success": %s}}}`,
packet.SourceChannel, packet.Sequence, ackAsJson, success))
_, err = h.ContractKeeper.Sudo(ctx, contractAddr, sudoMsg)
if err != nil {
Expand Down Expand Up @@ -356,7 +356,7 @@ func (h WasmHooks) OnTimeoutPacketOverride(im IBCMiddleware, ctx sdk.Context, pa
}

sudoMsg := []byte(fmt.Sprintf(
`{"ibc_timeout": {"channel": "%s", "sequence": %d}}`,
`{"ibc_lifecycle_complete": {"ibc_timeout": {"channel": "%s", "sequence": %d}}}`,
packet.SourceChannel, packet.Sequence))
_, err = h.ContractKeeper.Sudo(ctx, contractAddr, sudoMsg)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions x/ibc-rate-limit/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
Expand Down Expand Up @@ -140,7 +138,7 @@ func (suite *MiddlewareTestSuite) TestInvalidReceiver() {
_, ack, _ := suite.FullSendBToA(msg)
suite.Require().Contains(string(ack), "error",
"acknowledgment is not an error")
suite.Require().Contains(string(ack), sdkerrors.ErrInvalidAddress.Error(),
suite.Require().Contains(string(ack), fmt.Sprintf("ABCI code: %d", types.ErrBadMessage.ABCICode()),
"acknowledgment error is not of the right type")
}

Expand Down Expand Up @@ -214,7 +212,7 @@ func (suite *MiddlewareTestSuite) AssertReceive(success bool, msg sdk.Msg) (stri
} else {
suite.Require().Contains(string(ack), "error",
"acknowledgment is not an error")
suite.Require().Contains(string(ack), types.ErrRateLimitExceeded.Error(),
suite.Require().Contains(string(ack), fmt.Sprintf("ABCI code: %d", types.ErrRateLimitExceeded.ABCICode()),
"acknowledgment error is not of the right type")
}
return ack, err
Expand Down
6 changes: 3 additions & 3 deletions x/ibc-rate-limit/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (im *IBCModule) OnRecvPacket(
relayer sdk.AccAddress,
) exported.Acknowledgement {
if err := ValidateReceiverAddress(packet); err != nil {
return osmoutils.NewStringErrorAcknowledgement(err.Error())
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrBadMessage, err.Error())
}

contract := im.ics4Middleware.GetParams(ctx)
Expand All @@ -137,10 +137,10 @@ func (im *IBCModule) OnRecvPacket(
err := CheckAndUpdateRateLimits(ctx, im.ics4Middleware.ContractKeeper, "recv_packet", contract, packet)
if err != nil {
if strings.Contains(err.Error(), "rate limit exceeded") {
return osmoutils.NewStringErrorAcknowledgement(types.ErrRateLimitExceeded.Error())
return osmoutils.NewEmitErrorAcknowledgement(ctx, types.ErrRateLimitExceeded)
}
fullError := sdkerrors.Wrap(types.ErrContractError, err.Error())
return osmoutils.NewStringErrorAcknowledgement(fullError.Error())
return osmoutils.NewEmitErrorAcknowledgement(ctx, fullError)
}

// if this returns an Acknowledgement that isn't successful, all state changes are discarded
Expand Down