From f61d6cd6a8dd758219fa17990856393e1252b447 Mon Sep 17 00:00:00 2001 From: Carlton N Hanna Date: Wed, 28 Feb 2024 14:57:41 -0700 Subject: [PATCH] todo async-icq --- app/app.go | 53 +++++------ app/sim_test.go | 21 ++--- app/upgrades.go | 8 +- go.mod | 2 +- go.sum | 2 + x/oracle/keeper/relay.go | 167 +++++++++++++++++----------------- x/oracle/keeper/relay_test.go | 80 ++++++++-------- x/oracle/module/module_ibc.go | 5 +- x/oracle/types/keys.go | 4 +- 9 files changed, 165 insertions(+), 177 deletions(-) diff --git a/app/app.go b/app/app.go index 8751c3963d..0d567cf44f 100644 --- a/app/app.go +++ b/app/app.go @@ -34,9 +34,10 @@ import ( upgradekeeper "cosmossdk.io/x/upgrade/keeper" upgradetypes "cosmossdk.io/x/upgrade/types" - // icq "github.com/cosmos/ibc-apps/modules/async-icq/v7" // TODO[1760]: async-icq - // icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper" // TODO[1760]: async-icq - // icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" // TODO[1760]: async-icq + icq "github.com/cosmos/ibc-apps/modules/async-icq/v8" + icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v8/keeper" + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" + // "github.com/cosmos/cosmos-sdk/x/quarantine" // TODO[1760]: quarantine // quarantinekeeper "github.com/cosmos/cosmos-sdk/x/quarantine/keeper" // TODO[1760]: quarantine // quarantinemodule "github.com/cosmos/cosmos-sdk/x/quarantine/module" // TODO[1760]: quarantine @@ -214,7 +215,7 @@ var ( ibc.AppModuleBasic{}, ibctransfer.AppModuleBasic{}, ica.AppModuleBasic{}, - // icq.AppModuleBasic{}, // TODO[1760]: async-icq + icq.AppModuleBasic{}, ibchooks.AppModuleBasic{}, ibcratelimitmodule.AppModuleBasic{}, @@ -309,11 +310,11 @@ type App struct { TriggerKeeper triggerkeeper.Keeper OracleKeeper oraclekeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - IBCHooksKeeper *ibchookskeeper.Keeper - ICAHostKeeper *icahostkeeper.Keeper - TransferKeeper *ibctransferkeeper.Keeper - // ICQKeeper icqkeeper.Keeper // TODO[1760]: async-icq + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + IBCHooksKeeper *ibchookskeeper.Keeper + ICAHostKeeper *icahostkeeper.Keeper + TransferKeeper *ibctransferkeeper.Keeper + ICQKeeper icqkeeper.Keeper RateLimitingKeeper *ibcratelimitkeeper.Keeper MarkerKeeper markerkeeper.Keeper @@ -391,7 +392,7 @@ func New( // ibchost.StoreKey, // TODO[1760]: ibc-host ibctransfertypes.StoreKey, icahosttypes.StoreKey, - // icqtypes.StoreKey, // TODO[1760]: async-icq + icqtypes.StoreKey, ibchookstypes.StoreKey, ibcratelimit.StoreKey, @@ -444,7 +445,7 @@ func New( scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) - // scopedICQKeeper := app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName) // TODO[1760]: async-icq + scopedICQKeeper := app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName) scopedOracleKeeper := app.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName) // capability keeper must be sealed after scope to module registrations are completed. @@ -600,17 +601,17 @@ func New( app.AccountKeeper, scopedICAHostKeeper, pioMessageRouter, govAuthority, ) app.ICAHostKeeper = &icaHostKeeper + // TODO[1760]: ica-host // icaModule := ica.NewAppModule(nil, app.ICAHostKeeper) // icaHostIBCModule := icahost.NewIBCModule(*app.ICAHostKeeper) - // TODO[1760]: async-icq - // app.ICQKeeper = icqkeeper.NewKeeper( - // appCodec, keys[icqtypes.StoreKey], app.GetSubspace(icqtypes.ModuleName), - // app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, - // scopedICQKeeper, app.BaseApp.GRPCQueryRouter(), - //) - // icqModule := icq.NewAppModule(app.ICQKeeper) - // icqIBCModule := icq.NewIBCModule(app.ICQKeeper) + app.ICQKeeper = icqkeeper.NewKeeper( + appCodec, keys[icqtypes.StoreKey], + app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, + scopedICQKeeper, app.BaseApp.GRPCQueryRouter(), govAuthority, + ) + icqModule := icq.NewAppModule(app.ICQKeeper, app.GetSubspace(icqtypes.ModuleName)) + icqIBCModule := icq.NewIBCModule(app.ICQKeeper) // Init CosmWasm module wasmDir := filepath.Join(homePath, "data", "wasm") @@ -728,7 +729,7 @@ func New( AddRoute(ibctransfertypes.ModuleName, app.TransferStack). AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)). // AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). // TODO[1760]: ica-host - // AddRoute(icqtypes.ModuleName, icqIBCModule). // TODO[1760]: async-icq + AddRoute(icqtypes.ModuleName, icqIBCModule). AddRoute(oracletypes.ModuleName, oracleModule) app.IBCKeeper.SetRouter(ibcRouter) @@ -789,7 +790,7 @@ func New( ibcratelimitmodule.NewAppModule(appCodec, *app.RateLimitingKeeper, app.AccountKeeper, app.BankKeeper), ibchooks.NewAppModule(app.AccountKeeper, *app.IBCHooksKeeper), ibctransfer.NewAppModule(*app.TransferKeeper), - // icqModule, // TODO[1760]: async-icq + icqModule, // icaModule, // TODO[1760]: ica-host ) @@ -847,7 +848,7 @@ func New( ibcratelimit.ModuleName, ibchookstypes.ModuleName, ibctransfertypes.ModuleName, - // icqtypes.ModuleName, // TODO[1760]: async-icq + icqtypes.ModuleName, nametypes.ModuleName, vestingtypes.ModuleName, // quarantine.ModuleName, // TODO[1760]: quarantine @@ -878,7 +879,7 @@ func New( ibcratelimit.ModuleName, ibchookstypes.ModuleName, ibctransfertypes.ModuleName, - // icqtypes.ModuleName, // TODO[1760]: async-icq + icqtypes.ModuleName, msgfeestypes.ModuleName, wasm.ModuleName, slashingtypes.ModuleName, @@ -930,7 +931,7 @@ func New( // ibchost.ModuleName, // TODO[1760]: ibc-host ibctransfertypes.ModuleName, - // icqtypes.ModuleName, // TODO[1760]: async-icq + icqtypes.ModuleName, icatypes.ModuleName, ibcratelimit.ModuleName, ibchookstypes.ModuleName, @@ -973,7 +974,7 @@ func New( ibcratelimit.ModuleName, ibchookstypes.ModuleName, icatypes.ModuleName, - // icqtypes.ModuleName, // TODO[1760]: async-icq + icqtypes.ModuleName, wasm.ModuleName, attributetypes.ModuleName, @@ -1115,7 +1116,7 @@ func New( app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper - // app.ScopedICQKeeper = scopedICQKeeper // TODO[1760]: async-icq + app.ScopedICQKeeper = scopedICQKeeper app.ScopedICAHostKeeper = scopedICAHostKeeper return app diff --git a/app/sim_test.go b/app/sim_test.go index ee921dea17..c40ff33d44 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -24,7 +24,7 @@ import ( storetypes "cosmossdk.io/store/types" evidencetypes "cosmossdk.io/x/evidence/types" - // icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" // TODO[1760]: async-icq + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" // "github.com/cosmos/cosmos-sdk/x/quarantine" // TODO[1760]: quarantine // "github.com/cosmos/cosmos-sdk/x/sanction" // TODO[1760]: sanction @@ -107,16 +107,15 @@ func appStateWithICQ(appState json.RawMessage, cdc codec.JSONCodec) json.RawMess if err != nil { panic(fmt.Sprintf("error unmarshalling appstate: %v", err)) } - // TODO[1760]: async-icq - // icqGenJSON, icqGenFound := rawState[icqtypes.ModuleName] - // if !icqGenFound || len(icqGenJSON) == 0 { - // icqGenState := icqtypes.DefaultGenesis() - // rawState[icqtypes.ModuleName] = cdc.MustMarshalJSON(icqGenState) - // appState, err = json.Marshal(rawState) - // if err != nil { - // panic(fmt.Sprintf("error marshalling appstate: %v", err)) - // } - // } + icqGenJSON, icqGenFound := rawState[icqtypes.ModuleName] + if !icqGenFound || len(icqGenJSON) == 0 { + icqGenState := icqtypes.DefaultGenesis() + rawState[icqtypes.ModuleName] = cdc.MustMarshalJSON(icqGenState) + appState, err = json.Marshal(rawState) + if err != nil { + panic(fmt.Sprintf("error marshalling appstate: %v", err)) + } + } return appState } diff --git a/app/upgrades.go b/app/upgrades.go index 171081948c..4202cdd8d1 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -9,7 +9,7 @@ import ( storetypes "cosmossdk.io/store/types" upgradetypes "cosmossdk.io/x/upgrade/types" - // icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" // TODO[1760]: async-icq + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -124,7 +124,7 @@ var upgrades = map[string]appUpgrade{ return vm, nil }, - Added: []string{ /* icqtypes.ModuleName, // TODO[1760]: async-icq */ oracletypes.ModuleName, ibchookstypes.StoreKey, hold.ModuleName, exchange.ModuleName}, + Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.StoreKey, hold.ModuleName, exchange.ModuleName}, }, "saffron-rc2": { // upgrade for v1.17.0-rc2 Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { @@ -174,7 +174,7 @@ var upgrades = map[string]appUpgrade{ return vm, nil }, - Added: []string{ /* icqtypes.ModuleName, // TODO[1760]: async-icq */ oracletypes.ModuleName, ibchookstypes.StoreKey, hold.ModuleName, exchange.ModuleName}, + Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.StoreKey, hold.ModuleName, exchange.ModuleName}, }, "tourmaline-rc1": { // upgrade for v1.18.0-rc1 Added: []string{ibcratelimit.ModuleName}, @@ -421,7 +421,7 @@ func setAccountDataNameRecord(ctx sdk.Context, accountK attributetypes.AccountKe // TODO: Remove with the saffron handlers. func setupICQ(ctx sdk.Context, app *App) { ctx.Logger().Info("Updating ICQ params") - // app.ICQKeeper.SetParams(ctx, icqtypes.NewParams(true, []string{"/provenance.oracle.v1.Query/Oracle"})) // TODO[1760]: async-icq + app.ICQKeeper.SetParams(ctx, icqtypes.NewParams(true, []string{"/provenance.oracle.v1.Query/Oracle"})) ctx.Logger().Info("Done updating ICQ params") } diff --git a/go.mod b/go.mod index d276295713..161d2eb71f 100644 --- a/go.mod +++ b/go.mod @@ -21,8 +21,8 @@ require ( github.com/cosmos/cosmos-sdk v0.50.4 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.4.11 + github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0 github.com/cosmos/ibc-go/modules/capability v1.0.0 - // github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1 // TODO[1760]: async-icq: Need a v0.50 compatible version. github.com/cosmos/ibc-go/v8 v8.0.0 // github.com/cosmos/rosetta v0.50.2 // TODO[1760]: rosetta github.com/ghodss/yaml v1.0.0 diff --git a/go.sum b/go.sum index 189b798d08..1bc5b26492 100644 --- a/go.sum +++ b/go.sum @@ -368,6 +368,8 @@ github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= github.com/cosmos/iavl v1.0.1 h1:D+mYbcRO2wptYzOM1Hxl9cpmmHU1ZEt9T2Wv5nZTeUw= github.com/cosmos/iavl v1.0.1/go.mod h1:8xIUkgVvwvVrBu81scdPty+/Dx9GqwHnAvXz4cwF7RY= +github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0 h1:nKP2+Rzlz2iyvTosY5mvP+aEBPe06oaDl3G7xLGBpNI= +github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0/go.mod h1:D3Q380FpWRFtmUQWLosPxachi6w24Og2t5u/Tww5wtY= github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= github.com/cosmos/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg= diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index d965a80411..b12897fcbf 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -7,7 +7,7 @@ import ( cerrs "cosmossdk.io/errors" - // icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" // TODO[1760]: async-icq + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -32,62 +32,58 @@ func (k Keeper) SendQuery( if !found { return 0, cerrs.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) } - _ = sourceChannelEnd // TODO[1760]: async-icq - - // TODO[1760]: async-icq - // destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() - // destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() - // - // data, err := icqtypes.SerializeCosmosQuery(reqs) - // if err != nil { - // return 0, cerrs.Wrap(err, "could not serialize reqs into cosmos query") - // } - // icqPacketData := icqtypes.InterchainQueryPacketData{ - // Data: data, - // } - // - // return k.createOutgoingPacket(ctx, sourcePort, sourceChannel, destinationPort, destinationChannel, chanCap, icqPacketData, timeoutTimestamp) - return 0, cerrs.Wrapf(sdkerrors.ErrNotSupported, "not yet updated") + + destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() + destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() + + data, err := icqtypes.SerializeCosmosQuery(reqs) + if err != nil { + return 0, cerrs.Wrap(err, "could not serialize reqs into cosmos query") + } + icqPacketData := icqtypes.InterchainQueryPacketData{ + Data: data, + } + + return k.createOutgoingPacket(ctx, sourcePort, sourceChannel, destinationPort, destinationChannel, chanCap, icqPacketData, timeoutTimestamp) } -// TODO[1760]: async-icq -// func (k Keeper) createOutgoingPacket( -// ctx sdk.Context, -// sourcePort, -// sourceChannel, -// destinationPort, -// destinationChannel string, -// chanCap *capabilitytypes.Capability, -// icqPacketData icqtypes.InterchainQueryPacketData, -// timeoutTimestamp uint64, -// ) (uint64, error) { -// if err := icqPacketData.ValidateBasic(); err != nil { -// return 0, cerrs.Wrap(err, "invalid interchain query packet data") -// } -// -// // get the next sequence -// sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) -// if !found { -// return 0, cerrs.Wrapf(channeltypes.ErrSequenceSendNotFound, "failed to retrieve next sequence send for channel %s on port %s", sourceChannel, sourcePort) -// } -// -// packet := channeltypes.NewPacket( -// icqPacketData.GetBytes(), -// sequence, -// sourcePort, -// sourceChannel, -// destinationPort, -// destinationChannel, -// clienttypes.ZeroHeight(), -// timeoutTimestamp, -// ) -// -// if _, err := k.ics4Wrapper.SendPacket(ctx, chanCap, packet.SourcePort, packet.SourceChannel, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.Data); err != nil { -// return 0, err -// } -// -// return packet.Sequence, nil -// } +func (k Keeper) createOutgoingPacket( + ctx sdk.Context, + sourcePort, + sourceChannel, + destinationPort, + destinationChannel string, + chanCap *capabilitytypes.Capability, + icqPacketData icqtypes.InterchainQueryPacketData, + timeoutTimestamp uint64, +) (uint64, error) { + if err := icqPacketData.ValidateBasic(); err != nil { + return 0, cerrs.Wrap(err, "invalid interchain query packet data") + } + + // get the next sequence + sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) + if !found { + return 0, cerrs.Wrapf(channeltypes.ErrSequenceSendNotFound, "failed to retrieve next sequence send for channel %s on port %s", sourceChannel, sourcePort) + } + + packet := channeltypes.NewPacket( + icqPacketData.GetBytes(), + sequence, + sourcePort, + sourceChannel, + destinationPort, + destinationChannel, + clienttypes.ZeroHeight(), + timeoutTimestamp, + ) + + if _, err := k.ics4Wrapper.SendPacket(ctx, chanCap, packet.SourcePort, packet.SourceChannel, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.Data); err != nil { + return 0, err + } + + return packet.Sequence, nil +} // OnAcknowledgementPacket reacts to an Acknowledgement packet. func (k Keeper) OnAcknowledgementPacket( @@ -97,37 +93,36 @@ func (k Keeper) OnAcknowledgementPacket( ) error { switch resp := ack.Response.(type) { case *channeltypes.Acknowledgement_Result: - // TODO[1760]: async-icq - // var ackData icqtypes.InterchainQueryPacketAck - // if err := icqtypes.ModuleCdc.UnmarshalJSON(resp.Result, &ackData); err != nil { - // return cerrs.Wrap(err, "failed to unmarshal interchain query packet ack") - // } - // resps, err := icqtypes.DeserializeCosmosResponse(ackData.Data) - // if err != nil { - // return cerrs.Wrap(err, "could not deserialize data to cosmos response") - // } - // - // if len(resps) < 1 { - // return cerrs.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") - // } - // - // var r types.QueryOracleResponse - // if err = k.cdc.Unmarshal(resps[0].Value, &r); err != nil { - // return cerrs.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) - // } - // - // err = ctx.EventManager().EmitTypedEvent(&types.EventOracleQuerySuccess{ - // SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), - // Result: string(resp.Result), - // Channel: modulePacket.DestinationChannel, - // }) - // - // k.Logger(ctx).Info("interchain query ack response", "sequence", modulePacket.Sequence, "response", r) - // - // if err != nil { - // k.Logger(ctx).Error("interchain query ack response was unable to emit event", "sequence", modulePacket.Sequence, "error", err) - // return err - // } + var ackData icqtypes.InterchainQueryPacketAck + if err := icqtypes.ModuleCdc.UnmarshalJSON(resp.Result, &ackData); err != nil { + return cerrs.Wrap(err, "failed to unmarshal interchain query packet ack") + } + resps, err := icqtypes.DeserializeCosmosResponse(ackData.Data) + if err != nil { + return cerrs.Wrap(err, "could not deserialize data to cosmos response") + } + + if len(resps) < 1 { + return cerrs.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") + } + + var r types.QueryOracleResponse + if err = k.cdc.Unmarshal(resps[0].Value, &r); err != nil { + return cerrs.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) + } + + err = ctx.EventManager().EmitTypedEvent(&types.EventOracleQuerySuccess{ + SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), + Result: string(resp.Result), + Channel: modulePacket.DestinationChannel, + }) + + k.Logger(ctx).Info("interchain query ack response", "sequence", modulePacket.Sequence, "response", r) + + if err != nil { + k.Logger(ctx).Error("interchain query ack response was unable to emit event", "sequence", modulePacket.Sequence, "error", err) + return err + } return cerrs.Wrapf(sdkerrors.ErrNotSupported, "not yet updated") case *channeltypes.Acknowledgement_Error: err := ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryError{ diff --git a/x/oracle/keeper/relay_test.go b/x/oracle/keeper/relay_test.go index c80628f7a3..875cf0b81c 100644 --- a/x/oracle/keeper/relay_test.go +++ b/x/oracle/keeper/relay_test.go @@ -10,7 +10,7 @@ import ( cerrs "cosmossdk.io/errors" - // icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" // TODO[1760]: async-icq + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" "github.com/cosmos/cosmos-sdk/codec" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -152,56 +152,48 @@ func (s *KeeperTestSuite) TestOnTimeoutPacket() { } func createICQResponse(cdc codec.Codec, response string) []byte { - // TODO[1760]: async-icq - // oracleResponse := types.QueryOracleResponse{ - // Data: []byte("{}"), - // } - // value, _ := cdc.Marshal(&oracleResponse) - // bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{{ - // Value: value, - // }}) - // - // icqPacket := icqtypes.InterchainQueryPacketAck{ - // Data: bytes, - // } - // icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) - // return icqBytes - return []byte("not yet updated") + oracleResponse := types.QueryOracleResponse{ + Data: []byte("{}"), + } + value, _ := cdc.Marshal(&oracleResponse) + bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{{ + Value: value, + }}) + + icqPacket := icqtypes.InterchainQueryPacketAck{ + Data: bytes, + } + icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) + return icqBytes } func createInvalidICQPacketAck() []byte { - // TODO[1760]: async-icq - // icqPacket := icqtypes.InterchainQueryPacketAck{ - // Data: []byte("abc"), - // } - // icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) - // return icqBytes - return []byte("not yet updated") + icqPacket := icqtypes.InterchainQueryPacketAck{ + Data: []byte("abc"), + } + icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) + return icqBytes } func createEmptyICQPacketAck() []byte { - // TODO[1760]: async-icq - // bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{}) - // - // icqPacket := icqtypes.InterchainQueryPacketAck{ - // Data: bytes, - // } - // - // icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) - // return icqBytes - return []byte("not yet updated") + bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{}) + + icqPacket := icqtypes.InterchainQueryPacketAck{ + Data: bytes, + } + + icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) + return icqBytes } func createInvalidCosmosResponse() []byte { - // TODO[1760]: async-icq - // bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{{ - // Value: []byte("baddata"), - // }}) - // - // icqPacket := icqtypes.InterchainQueryPacketAck{ - // Data: bytes, - // } - // icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) - // return icqBytes - return []byte("not yet updated") + bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{{ + Value: []byte("baddata"), + }}) + + icqPacket := icqtypes.InterchainQueryPacketAck{ + Data: bytes, + } + icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) + return icqBytes } diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index f20dae0c18..7cab0de1a1 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -3,7 +3,7 @@ package oracle import ( cerrs "cosmossdk.io/errors" - // icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" // TODO[1760]: async-icq + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -128,8 +128,7 @@ func (am AppModule) OnRecvPacket( _ channeltypes.Packet, _ sdk.AccAddress, ) ibcexported.Acknowledgement { - // return channeltypes.NewErrorAcknowledgement(cerrs.Wrapf(icqtypes.ErrInvalidChannelFlow, "oracle module can not receive packets")) // TODO[1760]: async-icq - return channeltypes.NewErrorAcknowledgement(cerrs.Wrapf(sdkerrors.ErrNotSupported, "not yet updated")) + return channeltypes.NewErrorAcknowledgement(cerrs.Wrapf(icqtypes.ErrInvalidChannelFlow, "oracle module can not receive packets")) } // OnAcknowledgementPacket implements the IBCModule interface diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 9f6161dd2e..0c2a13b89a 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -1,6 +1,6 @@ package types -// import icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" // TODO[1760]: async-icq +import icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" const ( // ModuleName defines the module name @@ -13,7 +13,7 @@ const ( MemStoreKey = "mem_interquery" // Version defines the current version the IBC module supports - Version = "icq-1" // icqtypes.Version // TODO[1760]: async-icq + Version = icqtypes.Version // PortID is the default port id that module binds to PortID = "oracle"