From b9b70d440d4219292b3b8d7de39ff7264e539df7 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 27 Jul 2023 12:16:40 -0400 Subject: [PATCH 01/96] Added protos for oracle module. --- docs/proto-docs.md | 284 +++++++++++++++++++++++ proto/provenance/oracle/v1/event.proto | 13 ++ proto/provenance/oracle/v1/genesis.proto | 17 ++ proto/provenance/oracle/v1/query.proto | 82 +++++++ proto/provenance/oracle/v1/tx.proto | 29 +++ 5 files changed, 425 insertions(+) create mode 100644 proto/provenance/oracle/v1/event.proto create mode 100644 proto/provenance/oracle/v1/genesis.proto create mode 100644 proto/provenance/oracle/v1/query.proto create mode 100644 proto/provenance/oracle/v1/tx.proto diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 839c5ae6f5..fa4fe34dfd 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -430,6 +430,30 @@ - [Msg](#provenance.name.v1.Msg) +- [provenance/oracle/v1/event.proto](#provenance/oracle/v1/event.proto) + - [EventOracleQueryResponse](#provenance.oracle.v1.EventOracleQueryResponse) + +- [provenance/oracle/v1/genesis.proto](#provenance/oracle/v1/genesis.proto) + - [GenesisState](#provenance.oracle.v1.GenesisState) + +- [provenance/oracle/v1/query.proto](#provenance/oracle/v1/query.proto) + - [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) + - [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) + - [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) + - [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) + - [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) + - [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) + - [QueryOracleResult](#provenance.oracle.v1.QueryOracleResult) + - [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) + + - [Query](#provenance.oracle.v1.Query) + +- [provenance/oracle/v1/tx.proto](#provenance/oracle/v1/tx.proto) + - [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) + - [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) + + - [Msg](#provenance.oracle.v1.Msg) + - [provenance/reward/v1/reward.proto](#provenance/reward/v1/reward.proto) - [ActionCounter](#provenance.reward.v1.ActionCounter) - [ActionDelegate](#provenance.reward.v1.ActionDelegate) @@ -6644,6 +6668,266 @@ Msg defines the bank Msg service. + +

Top

+ +## provenance/oracle/v1/event.proto + + + + + +### EventOracleQueryResponse +EventOracleQueryResponse is an event for when the chain receives a response from an oracle query + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query_id` | [string](#string) | | query_id is a unique identifier of the query | + + + + + + + + + + + + + + + + +

Top

+ +## provenance/oracle/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the oracle module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query_id` | [uint64](#uint64) | | Query id is the next auto incremented id to be assigned to the next query | + + + + + + + + + + + + + + + + +

Top

+ +## provenance/oracle/v1/query.proto + + + + + +### QueryContractAddressRequest +QueryContractAddressRequest queries for the Trigger with an identifier of id. + + + + + + + + +### QueryContractAddressResponse +QueryContractAddressResponse contains the address of the oracle's contract. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | The address of the oracle's contract | + + + + + + + + +### QueryOracleContractRequest +QueryOracleContractRequest queries the oracle's smart contract + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query` | [bytes](#bytes) | | Query contains the query data passed to the contract. | + + + + + + + + +### QueryOracleContractResponse +QueryOracleContractResponse contains the result of the query to the oracle's smart contract + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `data` | [bytes](#bytes) | | Data contains the json data returned from the smart contract. | + + + + + + + + +### QueryOracleRequest +QueryOracleRequest queries an Oracle on another chain + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query` | [bytes](#bytes) | | Query contains the query data passed to the oracle. | +| `source_port` | [string](#string) | | Source port is the source port to the oracle. | +| `source_channel` | [string](#string) | | Source channel is the channel to the oracle. | + + + + + + + + +### QueryOracleResponse +QueryOracleResponse contains the id of the oracle query. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query_id` | [uint64](#uint64) | | The id that uniquely identifies the query. | + + + + + + + + +### QueryOracleResult +QueryOracleResult attempts to obtain the result of the oracle query. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query_id` | [uint64](#uint64) | | The id of the query to get the result from | + + + + + + + + +### QueryOracleResultResponse +QueryOracleResult contains the result of the oracle query. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `data` | [bytes](#bytes) | | Data contains the json data returned from the smart contract. | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service for oracle module. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ContractAddress` | [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) | [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) | ContractAddress returns the address of the oracle's contract | GET|/provenance/oracle/v1/contract_address| +| `Oracle` | [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) | [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) | Oracle sends an icq to an oracle on another chain | GET|/provenance/oracle/v1/oracle| +| `OracleContract` | [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) | [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) | OracleContract sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle_contract| +| `OracleResult` | [QueryOracleResult](#provenance.oracle.v1.QueryOracleResult) | [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) | OracleResult returns the address of the oracle's contract | GET|/provenance/oracle/v1/oracle_result| + + + + + + +

Top

+ +## provenance/oracle/v1/tx.proto + + + + + +### MsgUpdateOracleRequest +MsgUpdateOracleRequest is the request type for updating an oracle's contract address + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | The address of the oracle's contract | +| `authority` | [string](#string) | | The signing authorities for the request | + + + + + + + + +### MsgUpdateOracleResponse +MsgUpdateOracleResponse is the response type for updating the oracle. + + + + + + + + + + + + + + +### Msg +Msg + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `UpdateOracle` | [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) | [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) | UpdateOracle is the RPC endpoint for updating the oracle | | + + + + +

Top

diff --git a/proto/provenance/oracle/v1/event.proto b/proto/provenance/oracle/v1/event.proto new file mode 100644 index 0000000000..e7fb76edb0 --- /dev/null +++ b/proto/provenance/oracle/v1/event.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package provenance.oracle.v1; + +option go_package = "github.com/provenance-io/provenance/x/oracle/types"; + +option java_package = "io.provenance.oracle.v1"; +option java_multiple_files = true; + +// EventOracleQueryResponse is an event for when the chain receives a response from an oracle query +message EventOracleQueryResponse { + // query_id is a unique identifier of the query + string query_id = 1; +} \ No newline at end of file diff --git a/proto/provenance/oracle/v1/genesis.proto b/proto/provenance/oracle/v1/genesis.proto new file mode 100644 index 0000000000..42f143c807 --- /dev/null +++ b/proto/provenance/oracle/v1/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package provenance.oracle.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/provenance-io/provenance/x/oracle/types"; +option java_package = "io.provenance.oracle.v1"; +option java_multiple_files = true; + +// GenesisState defines the oracle module's genesis state. +message GenesisState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // Query id is the next auto incremented id to be assigned to the next query + uint64 query_id = 1; +} \ No newline at end of file diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto new file mode 100644 index 0000000000..b3051a7dae --- /dev/null +++ b/proto/provenance/oracle/v1/query.proto @@ -0,0 +1,82 @@ +syntax = "proto3"; +package provenance.oracle.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/provenance-io/provenance/x/oracle/types"; +option java_package = "io.provenance.oracle.v1"; +option java_multiple_files = true; + +// Query defines the gRPC querier service for oracle module. +service Query { + // ContractAddress returns the address of the oracle's contract + rpc ContractAddress(QueryContractAddressRequest) returns (QueryContractAddressResponse) { + option (google.api.http).get = "/provenance/oracle/v1/contract_address"; + } + + // Oracle sends an icq to an oracle on another chain + rpc Oracle(QueryOracleRequest) returns (QueryOracleResponse) { + option (google.api.http).get = "/provenance/oracle/v1/oracle"; + } + + // OracleContract sends a query to the oracle's contract + rpc OracleContract(QueryOracleContractRequest) returns (QueryOracleContractResponse) { + option (google.api.http).get = "/provenance/oracle/v1/oracle_contract"; + } + + // OracleResult returns the address of the oracle's contract + rpc OracleResult(QueryOracleResult) returns (QueryOracleResultResponse) { + option (google.api.http).get = "/provenance/oracle/v1/oracle_result"; + } +} + +// QueryContractAddressRequest queries for the Trigger with an identifier of id. +message QueryContractAddressRequest {} + +// QueryContractAddressResponse contains the address of the oracle's contract. +message QueryContractAddressResponse { + // The address of the oracle's contract + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// QueryOracleRequest queries an Oracle on another chain +message QueryOracleRequest { + // Query contains the query data passed to the oracle. + bytes query = 1 [(gogoproto.casttype) = "RawContractMessage"]; + // Source port is the source port to the oracle. + string source_port = 2; + // Source channel is the channel to the oracle. + string source_channel = 3; +} + +// QueryOracleResponse contains the id of the oracle query. +message QueryOracleResponse { + // The id that uniquely identifies the query. + uint64 query_id = 1; +} + +// QueryOracleContractRequest queries the oracle's smart contract +message QueryOracleContractRequest { + // Query contains the query data passed to the contract. + bytes query = 1 [(gogoproto.casttype) = "RawContractMessage"]; +} + +// QueryOracleContractResponse contains the result of the query to the oracle's smart contract +message QueryOracleContractResponse { + // Data contains the json data returned from the smart contract. + bytes data = 1 [(gogoproto.casttype) = "RawContractMessage"]; +} + +// QueryOracleResult attempts to obtain the result of the oracle query. +message QueryOracleResult { + // The id of the query to get the result from + uint64 query_id = 1; +} + +// QueryOracleResult contains the result of the oracle query. +message QueryOracleResultResponse { + // Data contains the json data returned from the smart contract. + bytes data = 2 [(gogoproto.casttype) = "RawContractMessage"]; +} \ No newline at end of file diff --git a/proto/provenance/oracle/v1/tx.proto b/proto/provenance/oracle/v1/tx.proto new file mode 100644 index 0000000000..ead8c80580 --- /dev/null +++ b/proto/provenance/oracle/v1/tx.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package provenance.oracle.v1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/provenance-io/provenance/x/oracle/types"; +option java_package = "io.provenance.oracle.v1"; +option java_multiple_files = true; + +// Msg +service Msg { + // UpdateOracle is the RPC endpoint for updating the oracle + rpc UpdateOracle(MsgUpdateOracleRequest) returns (MsgUpdateOracleResponse); +} + +// MsgUpdateOracleRequest is the request type for updating an oracle's contract address +message MsgUpdateOracleRequest { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + // The address of the oracle's contract + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // The signing authorities for the request + string authority = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// MsgUpdateOracleResponse is the response type for updating the oracle. +message MsgUpdateOracleResponse {} \ No newline at end of file From d76d082e5394a6584c4c1c7ecf8ebf4d3a3c5c35 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 27 Jul 2023 14:39:23 -0400 Subject: [PATCH 02/96] Added simple implementation for the oracle module. No logic, tests, or simulation have been completed yet. --- docs/proto-docs.md | 10 +- proto/provenance/oracle/v1/query.proto | 14 +- x/oracle/client/cli/query.go | 19 + x/oracle/client/cli/tx.go | 23 + x/oracle/keeper/genesis.go | 18 + x/oracle/keeper/keeper.go | 30 + x/oracle/keeper/msg_server.go | 26 + x/oracle/keeper/query_server.go | 27 + x/oracle/module/module.go | 189 +++ x/oracle/simulation/genesis.go | 1 + x/oracle/spec/README.md | 0 x/oracle/types/codec.go | 20 + x/oracle/types/event.pb.go | 318 +++++ x/oracle/types/genesis.go | 24 + x/oracle/types/genesis.pb.go | 299 ++++ x/oracle/types/keys.go | 6 + x/oracle/types/query.pb.go | 1780 ++++++++++++++++++++++++ x/oracle/types/query.pb.gw.go | 388 ++++++ x/oracle/types/tx.pb.go | 614 ++++++++ 19 files changed, 3794 insertions(+), 12 deletions(-) create mode 100644 x/oracle/client/cli/query.go create mode 100644 x/oracle/client/cli/tx.go create mode 100644 x/oracle/keeper/genesis.go create mode 100644 x/oracle/keeper/keeper.go create mode 100644 x/oracle/keeper/msg_server.go create mode 100644 x/oracle/keeper/query_server.go create mode 100644 x/oracle/module/module.go create mode 100644 x/oracle/simulation/genesis.go create mode 100644 x/oracle/spec/README.md create mode 100644 x/oracle/types/codec.go create mode 100644 x/oracle/types/event.pb.go create mode 100644 x/oracle/types/genesis.go create mode 100644 x/oracle/types/genesis.pb.go create mode 100644 x/oracle/types/keys.go create mode 100644 x/oracle/types/query.pb.go create mode 100644 x/oracle/types/query.pb.gw.go create mode 100644 x/oracle/types/tx.pb.go diff --git a/docs/proto-docs.md b/docs/proto-docs.md index fa4fe34dfd..d2a7547b1a 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -443,7 +443,7 @@ - [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) - [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) - [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) - - [QueryOracleResult](#provenance.oracle.v1.QueryOracleResult) + - [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) - [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) - [Query](#provenance.oracle.v1.Query) @@ -6824,10 +6824,10 @@ QueryOracleResponse contains the id of the oracle query. - + -### QueryOracleResult -QueryOracleResult attempts to obtain the result of the oracle query. +### QueryOracleResultRequest +QueryOracleResultRequest attempts to obtain the result of the oracle query. | Field | Type | Label | Description | @@ -6870,7 +6870,7 @@ Query defines the gRPC querier service for oracle module. | `ContractAddress` | [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) | [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) | ContractAddress returns the address of the oracle's contract | GET|/provenance/oracle/v1/contract_address| | `Oracle` | [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) | [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) | Oracle sends an icq to an oracle on another chain | GET|/provenance/oracle/v1/oracle| | `OracleContract` | [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) | [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) | OracleContract sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle_contract| -| `OracleResult` | [QueryOracleResult](#provenance.oracle.v1.QueryOracleResult) | [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) | OracleResult returns the address of the oracle's contract | GET|/provenance/oracle/v1/oracle_result| +| `OracleResult` | [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) | [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) | OracleResult returns the address of the oracle's contract | GET|/provenance/oracle/v1/oracle_result| diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index b3051a7dae..13a7d7bbd2 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -27,7 +27,7 @@ service Query { } // OracleResult returns the address of the oracle's contract - rpc OracleResult(QueryOracleResult) returns (QueryOracleResultResponse) { + rpc OracleResult(QueryOracleResultRequest) returns (QueryOracleResultResponse) { option (google.api.http).get = "/provenance/oracle/v1/oracle_result"; } } @@ -44,7 +44,7 @@ message QueryContractAddressResponse { // QueryOracleRequest queries an Oracle on another chain message QueryOracleRequest { // Query contains the query data passed to the oracle. - bytes query = 1 [(gogoproto.casttype) = "RawContractMessage"]; + bytes query = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; // Source port is the source port to the oracle. string source_port = 2; // Source channel is the channel to the oracle. @@ -60,17 +60,17 @@ message QueryOracleResponse { // QueryOracleContractRequest queries the oracle's smart contract message QueryOracleContractRequest { // Query contains the query data passed to the contract. - bytes query = 1 [(gogoproto.casttype) = "RawContractMessage"]; + bytes query = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; } // QueryOracleContractResponse contains the result of the query to the oracle's smart contract message QueryOracleContractResponse { // Data contains the json data returned from the smart contract. - bytes data = 1 [(gogoproto.casttype) = "RawContractMessage"]; + bytes data = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; } -// QueryOracleResult attempts to obtain the result of the oracle query. -message QueryOracleResult { +// QueryOracleResultRequest attempts to obtain the result of the oracle query. +message QueryOracleResultRequest { // The id of the query to get the result from uint64 query_id = 1; } @@ -78,5 +78,5 @@ message QueryOracleResult { // QueryOracleResult contains the result of the oracle query. message QueryOracleResultResponse { // Data contains the json data returned from the smart contract. - bytes data = 2 [(gogoproto.casttype) = "RawContractMessage"]; + bytes data = 2 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; } \ No newline at end of file diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go new file mode 100644 index 0000000000..c3527ecca9 --- /dev/null +++ b/x/oracle/client/cli/query.go @@ -0,0 +1,19 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/provenance-io/provenance/x/oracle/types" + "github.com/spf13/cobra" +) + +func GetQueryCmd() *cobra.Command { + queryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the triggers module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + queryCmd.AddCommand() + return queryCmd +} diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go new file mode 100644 index 0000000000..c60e1d6258 --- /dev/null +++ b/x/oracle/client/cli/tx.go @@ -0,0 +1,23 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/provenance-io/provenance/x/oracle/types" + "github.com/spf13/cobra" +) + +// NewTxCmd is the top-level command for trigger CLI transactions. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Aliases: []string{"t"}, + Short: "Transaction commands for the trigger module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand() + + return txCmd +} diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go new file mode 100644 index 0000000000..ee91326c16 --- /dev/null +++ b/x/oracle/keeper/genesis.go @@ -0,0 +1,18 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" +) + +// ExportGenesis returns a GenesisState for a given context. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return types.NewGenesisState(1) +} + +// InitGenesis new trigger genesis +func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { + if err := data.Validate(); err != nil { + panic(err) + } +} diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go new file mode 100644 index 0000000000..791ea8477e --- /dev/null +++ b/x/oracle/keeper/keeper.go @@ -0,0 +1,30 @@ +package keeper + +import ( + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/provenance-io/provenance/x/oracle/types" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec +} + +func NewKeeper( + cdc codec.BinaryCodec, + key storetypes.StoreKey, +) Keeper { + return Keeper{ + storeKey: key, + cdc: cdc, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go new file mode 100644 index 0000000000..f45a5c8e31 --- /dev/null +++ b/x/oracle/keeper/msg_server.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "context" + + "github.com/provenance-io/provenance/x/oracle/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the account MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +// UpdateOracle changes the oracle's address to the provided one +func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracleRequest) (*types.MsgUpdateOracleResponse, error) { + //ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.MsgUpdateOracleResponse{}, nil +} diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go new file mode 100644 index 0000000000..910e548ef1 --- /dev/null +++ b/x/oracle/keeper/query_server.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + "github.com/provenance-io/provenance/x/oracle/types" +) + +var _ types.QueryServer = Keeper{} + +// QueryAddress returns the address of the oracle's contract +func (k Keeper) ContractAddress(ctx context.Context, req *types.QueryContractAddressRequest) (*types.QueryContractAddressResponse, error) { + return &types.QueryContractAddressResponse{}, nil +} + +// Oracle sends an ICQ to an oracle +func (k Keeper) Oracle(ctx context.Context, req *types.QueryOracleRequest) (*types.QueryOracleResponse, error) { + return &types.QueryOracleResponse{}, nil +} + +func (k Keeper) OracleContract(ctx context.Context, req *types.QueryOracleContractRequest) (*types.QueryOracleContractResponse, error) { + return &types.QueryOracleContractResponse{}, nil +} + +func (k Keeper) OracleResult(ctx context.Context, req *types.QueryOracleResult) (*types.QueryOracleResultResponse, error) { + return &types.QueryOracleResultResponse{}, nil +} diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go new file mode 100644 index 0000000000..79c53f1607 --- /dev/null +++ b/x/oracle/module/module.go @@ -0,0 +1,189 @@ +package oracle + +import ( + "context" + "encoding/json" + "math/rand" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/provenance-io/provenance/x/oracle/client/cli" + "github.com/provenance-io/provenance/x/oracle/keeper" + "github.com/provenance-io/provenance/x/oracle/types" + "github.com/spf13/cobra" + + cerrs "cosmossdk.io/errors" + sdkclient "github.com/cosmos/cosmos-sdk/client" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + abci "github.com/tendermint/tendermint/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +// AppModuleBasic defines the basic application module used by the trigger module. +type AppModuleBasic struct { + cdc codec.Codec +} + +// Name returns the trigger module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the trigger module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { +} + +// RegisterInterfaces registers the trigger module's interface types +func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the trigger +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the trigger module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ sdkclient.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return cerrs.Wrapf(err, "failed to unmarshal %q genesis state", types.ModuleName) + } + + return data.Validate() +} + +// RegisterRESTRoutes registers the REST routes for the trigger module. +// Deprecated: RegisterRESTRoutes is deprecated. +func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the trigger module. +func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetQueryCmd returns the cli query commands for the trigger module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// GetTxCmd returns the transaction commands for the trigger module +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +// AppModule implements the sdk.AppModule interface +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + } +} + +// GenerateGenesisState creates a randomized GenState of the trigger module. +func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { + // simulation.RandomizedGenState(simState) +} + +// ProposalContents returns content functions used to simulate governance proposals. +func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + // currently no gov proposals exist + return nil +} + +// RandomizedParams returns randomized module parameters for param change proposals. +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + // currently no module params exist + return nil +} + +// RegisterStoreDecoder registers a func to decode each module's defined types from their corresponding store key +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { + //sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) +} + +// WeightedOperations returns simulation operations (i.e msgs) with their respective weight +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} + /*return simulation.WeightedOperations( + simState.AppParams, simState.Cdc, am.keeper, am.accountKeeper, am.bankKeeper, + )*/ +} + +// Name returns the trigger module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants does nothing, there are no invariants to enforce +func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// Deprecated: Route returns the message routing key for the trigger module. +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// QuerierRoute returns the route we respond to for abci queries +func (AppModule) QuerierRoute() string { return "" } + +// LegacyQuerierHandler returns the trigger module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil +} + +// InitGenesis performs genesis initialization for the trigger module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + am.keeper.InitGenesis(ctx, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the trigger +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock is the `BeginBlocker` function run at the beginning of each block to +// process trigger module updates. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +} + +// EndBlock The `EndBlocker` abci call is ran at the end of each block. The `EventManager` is monitored +// and `Qualifying Actions` are deduced from newly created events and prior internal state. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go new file mode 100644 index 0000000000..02eddda2ba --- /dev/null +++ b/x/oracle/simulation/genesis.go @@ -0,0 +1 @@ +package simulation diff --git a/x/oracle/spec/README.md b/x/oracle/spec/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go new file mode 100644 index 0000000000..d66b7e13f5 --- /dev/null +++ b/x/oracle/types/codec.go @@ -0,0 +1,20 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ignoring RegisterLegacyAminoCodec registers all the necessary types and interfaces for the +// double check +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgUpdateOracleRequest{}, + ) +} + +var ( + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/oracle/types/event.pb.go b/x/oracle/types/event.pb.go new file mode 100644 index 0000000000..f74abc358b --- /dev/null +++ b/x/oracle/types/event.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: provenance/oracle/v1/event.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// EventOracleQueryResponse is an event for when the chain receives a response from an oracle query +type EventOracleQueryResponse struct { + // query_id is a unique identifier of the query + QueryId string `protobuf:"bytes,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` +} + +func (m *EventOracleQueryResponse) Reset() { *m = EventOracleQueryResponse{} } +func (m *EventOracleQueryResponse) String() string { return proto.CompactTextString(m) } +func (*EventOracleQueryResponse) ProtoMessage() {} +func (*EventOracleQueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e98d10c8454ad24d, []int{0} +} +func (m *EventOracleQueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventOracleQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventOracleQueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventOracleQueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventOracleQueryResponse.Merge(m, src) +} +func (m *EventOracleQueryResponse) XXX_Size() int { + return m.Size() +} +func (m *EventOracleQueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EventOracleQueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_EventOracleQueryResponse proto.InternalMessageInfo + +func (m *EventOracleQueryResponse) GetQueryId() string { + if m != nil { + return m.QueryId + } + return "" +} + +func init() { + proto.RegisterType((*EventOracleQueryResponse)(nil), "provenance.oracle.v1.EventOracleQueryResponse") +} + +func init() { proto.RegisterFile("provenance/oracle/v1/event.proto", fileDescriptor_e98d10c8454ad24d) } + +var fileDescriptor_e98d10c8454ad24d = []byte{ + // 184 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x28, 0xca, 0x2f, + 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, + 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, + 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x54, 0x32, 0xe5, 0x92, 0x70, 0x05, 0x29, 0xf2, 0x07, 0x8b, + 0x04, 0x96, 0xa6, 0x16, 0x55, 0x06, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x49, 0x72, + 0x71, 0x14, 0x82, 0x04, 0xe2, 0x33, 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xd8, 0xc1, + 0x7c, 0xcf, 0x14, 0xa7, 0xf4, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, + 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0xe0, 0x12, + 0xcf, 0xcc, 0xd7, 0xc3, 0x66, 0x53, 0x00, 0x63, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, + 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x42, 0x89, 0x6e, 0x66, 0x3e, 0x12, 0x4f, 0xbf, 0x02, 0xe6, 0xfc, + 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xe3, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xa5, 0x30, 0xb5, 0xdf, 0xe0, 0x00, 0x00, 0x00, +} + +func (m *EventOracleQueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventOracleQueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventOracleQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.QueryId) > 0 { + i -= len(m.QueryId) + copy(dAtA[i:], m.QueryId) + i = encodeVarintEvent(dAtA, i, uint64(len(m.QueryId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { + offset -= sovEvent(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventOracleQueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.QueryId) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func sovEvent(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvent(x uint64) (n int) { + return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventOracleQueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventOracleQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventOracleQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.QueryId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvent(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEvent + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvent + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvent + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go new file mode 100644 index 0000000000..8b3b95a8bd --- /dev/null +++ b/x/oracle/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import fmt "fmt" + +func NewGenesisState(queryID uint64) *GenesisState { + return &GenesisState{ + QueryId: queryID, + } +} + +// DefaultGenesis returns the default trigger genesis state +func DefaultGenesis() *GenesisState { + return NewGenesisState(1) +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + if gs.QueryId == 0 { + return fmt.Errorf("invalid query id") + } + + return nil +} diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go new file mode 100644 index 0000000000..6ee62679c2 --- /dev/null +++ b/x/oracle/types/genesis.pb.go @@ -0,0 +1,299 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: provenance/oracle/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the oracle module's genesis state. +type GenesisState struct { + // Query id is the next auto incremented id to be assigned to the next query + QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_f8d8aecd974cfd80, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "provenance.oracle.v1.GenesisState") +} + +func init() { + proto.RegisterFile("provenance/oracle/v1/genesis.proto", fileDescriptor_f8d8aecd974cfd80) +} + +var fileDescriptor_f8d8aecd974cfd80 = []byte{ + // 200 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0x28, 0xca, 0x2f, + 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, + 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x41, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, + 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0x95, 0x8c, 0xb9, 0x78, 0xdc, 0x21, 0x9a, 0x83, 0x4b, 0x12, 0x4b, + 0x52, 0x85, 0x24, 0xb9, 0x38, 0x0a, 0x4b, 0x53, 0x8b, 0x2a, 0xe3, 0x33, 0x53, 0x24, 0x18, 0x15, + 0x18, 0x35, 0x58, 0x82, 0xd8, 0xc1, 0x7c, 0xcf, 0x14, 0x2b, 0x8e, 0x8e, 0x05, 0xf2, 0x0c, 0x2f, + 0x16, 0xc8, 0x33, 0x38, 0xa5, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, + 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x03, 0x97, + 0x78, 0x26, 0xd8, 0x60, 0x0c, 0xdb, 0x03, 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, + 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, 0x4a, 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0x30, 0x4f, + 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x1d, 0x69, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, + 0xaa, 0x5e, 0xd7, 0x0d, 0xf6, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.QueryId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.QueryId != 0 { + n += 1 + sovGenesis(uint64(m.QueryId)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + } + m.QueryId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go new file mode 100644 index 0000000000..29e2b851a8 --- /dev/null +++ b/x/oracle/types/keys.go @@ -0,0 +1,6 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "oracle" +) diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go new file mode 100644 index 0000000000..0988d716af --- /dev/null +++ b/x/oracle/types/query.pb.go @@ -0,0 +1,1780 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: provenance/oracle/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryContractAddressRequest queries for the Trigger with an identifier of id. +type QueryContractAddressRequest struct { +} + +func (m *QueryContractAddressRequest) Reset() { *m = QueryContractAddressRequest{} } +func (m *QueryContractAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryContractAddressRequest) ProtoMessage() {} +func (*QueryContractAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{0} +} +func (m *QueryContractAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryContractAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractAddressRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryContractAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractAddressRequest.Merge(m, src) +} +func (m *QueryContractAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryContractAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractAddressRequest proto.InternalMessageInfo + +// QueryContractAddressResponse contains the address of the oracle's contract. +type QueryContractAddressResponse struct { + // The address of the oracle's contract + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryContractAddressResponse) Reset() { *m = QueryContractAddressResponse{} } +func (m *QueryContractAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryContractAddressResponse) ProtoMessage() {} +func (*QueryContractAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{1} +} +func (m *QueryContractAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryContractAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryContractAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractAddressResponse.Merge(m, src) +} +func (m *QueryContractAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryContractAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractAddressResponse proto.InternalMessageInfo + +func (m *QueryContractAddressResponse) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// QueryOracleRequest queries an Oracle on another chain +type QueryOracleRequest struct { + // Query contains the query data passed to the oracle. + Query github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=query,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"query,omitempty"` + // Source port is the source port to the oracle. + SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` + // Source channel is the channel to the oracle. + SourceChannel string `protobuf:"bytes,3,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` +} + +func (m *QueryOracleRequest) Reset() { *m = QueryOracleRequest{} } +func (m *QueryOracleRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOracleRequest) ProtoMessage() {} +func (*QueryOracleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{2} +} +func (m *QueryOracleRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOracleRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryOracleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleRequest.Merge(m, src) +} +func (m *QueryOracleRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryOracleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOracleRequest proto.InternalMessageInfo + +func (m *QueryOracleRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { + if m != nil { + return m.Query + } + return nil +} + +func (m *QueryOracleRequest) GetSourcePort() string { + if m != nil { + return m.SourcePort + } + return "" +} + +func (m *QueryOracleRequest) GetSourceChannel() string { + if m != nil { + return m.SourceChannel + } + return "" +} + +// QueryOracleResponse contains the id of the oracle query. +type QueryOracleResponse struct { + // The id that uniquely identifies the query. + QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` +} + +func (m *QueryOracleResponse) Reset() { *m = QueryOracleResponse{} } +func (m *QueryOracleResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOracleResponse) ProtoMessage() {} +func (*QueryOracleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{3} +} +func (m *QueryOracleResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOracleResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryOracleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleResponse.Merge(m, src) +} +func (m *QueryOracleResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryOracleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOracleResponse proto.InternalMessageInfo + +func (m *QueryOracleResponse) GetQueryId() uint64 { + if m != nil { + return m.QueryId + } + return 0 +} + +// QueryOracleContractRequest queries the oracle's smart contract +type QueryOracleContractRequest struct { + // Query contains the query data passed to the contract. + Query github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=query,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"query,omitempty"` +} + +func (m *QueryOracleContractRequest) Reset() { *m = QueryOracleContractRequest{} } +func (m *QueryOracleContractRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOracleContractRequest) ProtoMessage() {} +func (*QueryOracleContractRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{4} +} +func (m *QueryOracleContractRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOracleContractRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOracleContractRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryOracleContractRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleContractRequest.Merge(m, src) +} +func (m *QueryOracleContractRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryOracleContractRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleContractRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOracleContractRequest proto.InternalMessageInfo + +func (m *QueryOracleContractRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { + if m != nil { + return m.Query + } + return nil +} + +// QueryOracleContractResponse contains the result of the query to the oracle's smart contract +type QueryOracleContractResponse struct { + // Data contains the json data returned from the smart contract. + Data github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=data,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"data,omitempty"` +} + +func (m *QueryOracleContractResponse) Reset() { *m = QueryOracleContractResponse{} } +func (m *QueryOracleContractResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOracleContractResponse) ProtoMessage() {} +func (*QueryOracleContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{5} +} +func (m *QueryOracleContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOracleContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOracleContractResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryOracleContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleContractResponse.Merge(m, src) +} +func (m *QueryOracleContractResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryOracleContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOracleContractResponse proto.InternalMessageInfo + +func (m *QueryOracleContractResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { + if m != nil { + return m.Data + } + return nil +} + +// QueryOracleResultRequest attempts to obtain the result of the oracle query. +type QueryOracleResultRequest struct { + // The id of the query to get the result from + QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` +} + +func (m *QueryOracleResultRequest) Reset() { *m = QueryOracleResultRequest{} } +func (m *QueryOracleResultRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOracleResultRequest) ProtoMessage() {} +func (*QueryOracleResultRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{6} +} +func (m *QueryOracleResultRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOracleResultRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOracleResultRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryOracleResultRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleResultRequest.Merge(m, src) +} +func (m *QueryOracleResultRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryOracleResultRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleResultRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOracleResultRequest proto.InternalMessageInfo + +func (m *QueryOracleResultRequest) GetQueryId() uint64 { + if m != nil { + return m.QueryId + } + return 0 +} + +// QueryOracleResult contains the result of the oracle query. +type QueryOracleResultResponse struct { + // Data contains the json data returned from the smart contract. + Data github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,2,opt,name=data,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"data,omitempty"` +} + +func (m *QueryOracleResultResponse) Reset() { *m = QueryOracleResultResponse{} } +func (m *QueryOracleResultResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOracleResultResponse) ProtoMessage() {} +func (*QueryOracleResultResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{7} +} +func (m *QueryOracleResultResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOracleResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOracleResultResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryOracleResultResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleResultResponse.Merge(m, src) +} +func (m *QueryOracleResultResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryOracleResultResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleResultResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOracleResultResponse proto.InternalMessageInfo + +func (m *QueryOracleResultResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { + if m != nil { + return m.Data + } + return nil +} + +func init() { + proto.RegisterType((*QueryContractAddressRequest)(nil), "provenance.oracle.v1.QueryContractAddressRequest") + proto.RegisterType((*QueryContractAddressResponse)(nil), "provenance.oracle.v1.QueryContractAddressResponse") + proto.RegisterType((*QueryOracleRequest)(nil), "provenance.oracle.v1.QueryOracleRequest") + proto.RegisterType((*QueryOracleResponse)(nil), "provenance.oracle.v1.QueryOracleResponse") + proto.RegisterType((*QueryOracleContractRequest)(nil), "provenance.oracle.v1.QueryOracleContractRequest") + proto.RegisterType((*QueryOracleContractResponse)(nil), "provenance.oracle.v1.QueryOracleContractResponse") + proto.RegisterType((*QueryOracleResultRequest)(nil), "provenance.oracle.v1.QueryOracleResultRequest") + proto.RegisterType((*QueryOracleResultResponse)(nil), "provenance.oracle.v1.QueryOracleResultResponse") +} + +func init() { proto.RegisterFile("provenance/oracle/v1/query.proto", fileDescriptor_169907f611744c57) } + +var fileDescriptor_169907f611744c57 = []byte{ + // 591 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xbf, 0x6f, 0x13, 0x31, + 0x14, 0xc7, 0xeb, 0xd2, 0x1f, 0x60, 0x4a, 0x91, 0x4c, 0x24, 0x92, 0x23, 0x5c, 0xab, 0x83, 0x40, + 0x10, 0xca, 0xb9, 0x09, 0x62, 0x60, 0x60, 0x20, 0x99, 0x18, 0x10, 0xed, 0x75, 0x40, 0x62, 0x89, + 0xdc, 0x3b, 0xeb, 0x7a, 0x52, 0x62, 0x5f, 0x6c, 0x27, 0x6d, 0x57, 0xf8, 0x07, 0x90, 0x58, 0x19, + 0x19, 0x58, 0x91, 0xf8, 0x23, 0x18, 0x2b, 0x58, 0x98, 0x10, 0x4a, 0xf8, 0x2b, 0x18, 0x10, 0x8a, + 0xed, 0x90, 0x1f, 0x3a, 0x85, 0x54, 0x2a, 0x53, 0xee, 0xec, 0xef, 0x7b, 0xdf, 0xcf, 0x7b, 0x79, + 0xef, 0xe0, 0x76, 0x2a, 0x78, 0x8f, 0x32, 0xc2, 0x42, 0x8a, 0xb9, 0x20, 0x61, 0x8b, 0xe2, 0x5e, + 0x15, 0x77, 0xba, 0x54, 0x9c, 0xf8, 0xa9, 0xe0, 0x8a, 0xa3, 0xdc, 0x58, 0xe1, 0x1b, 0x85, 0xdf, + 0xab, 0x3a, 0xb9, 0x98, 0xc7, 0x5c, 0x0b, 0xf0, 0xf0, 0xc9, 0x68, 0x9d, 0x62, 0xcc, 0x79, 0xdc, + 0xa2, 0x98, 0xa4, 0x09, 0x26, 0x8c, 0x71, 0x45, 0x54, 0xc2, 0x99, 0xb4, 0xb7, 0x85, 0x90, 0xcb, + 0x36, 0x97, 0x4d, 0x13, 0x66, 0x5e, 0xcc, 0x95, 0x77, 0x13, 0xde, 0xd8, 0x1b, 0x7a, 0x36, 0x38, + 0x53, 0x82, 0x84, 0xea, 0x49, 0x14, 0x09, 0x2a, 0x65, 0x40, 0x3b, 0x5d, 0x2a, 0x95, 0x17, 0xc0, + 0x62, 0xf6, 0xb5, 0x4c, 0x39, 0x93, 0x14, 0xd5, 0xe0, 0x3a, 0x31, 0x47, 0x79, 0xb0, 0x0d, 0xca, + 0x97, 0xea, 0xf9, 0x2f, 0x9f, 0x2a, 0x39, 0xeb, 0x60, 0xc5, 0xfb, 0x4a, 0x24, 0x2c, 0x0e, 0x46, + 0x42, 0xef, 0x23, 0x80, 0x48, 0x27, 0x7d, 0xae, 0x8b, 0xb2, 0x56, 0x68, 0x1f, 0xae, 0xea, 0xea, + 0x75, 0xa2, 0x8d, 0xfa, 0xe3, 0x5f, 0xdf, 0xb7, 0x1e, 0xc5, 0x89, 0x3a, 0xec, 0x1e, 0xf8, 0x21, + 0x6f, 0xe3, 0x06, 0x97, 0xed, 0x17, 0x44, 0xb6, 0xf1, 0x11, 0x91, 0xed, 0x08, 0x1f, 0xeb, 0x5f, + 0xac, 0x4e, 0x52, 0x2a, 0xfd, 0x80, 0x1c, 0x8d, 0x00, 0x9f, 0x51, 0x29, 0x49, 0x4c, 0x03, 0x93, + 0x0b, 0x6d, 0xc1, 0xcb, 0x92, 0x77, 0x45, 0x48, 0x9b, 0x29, 0x17, 0x2a, 0xbf, 0x3c, 0x64, 0x0c, + 0xa0, 0x39, 0xda, 0xe5, 0x42, 0xa1, 0x12, 0xdc, 0xb4, 0x82, 0xf0, 0x90, 0x30, 0x46, 0x5b, 0xf9, + 0x0b, 0x5a, 0x73, 0xc5, 0x9c, 0x36, 0xcc, 0xa1, 0xb7, 0x03, 0xaf, 0x4d, 0x21, 0xdb, 0xf2, 0x0b, + 0xf0, 0xa2, 0xf6, 0x69, 0x26, 0x91, 0xc6, 0x5e, 0x09, 0xd6, 0xf5, 0xfb, 0xd3, 0xc8, 0xeb, 0x40, + 0x67, 0x22, 0x62, 0x84, 0xf7, 0x3f, 0x8b, 0xf5, 0x52, 0xfb, 0x5f, 0xce, 0x5a, 0x5a, 0xd8, 0x3d, + 0xb8, 0x12, 0x11, 0x45, 0xce, 0xc7, 0x52, 0xa7, 0xf2, 0x1e, 0xc2, 0xfc, 0x74, 0x5b, 0xba, 0xad, + 0xbf, 0x25, 0xce, 0xe9, 0x0d, 0x83, 0x85, 0x8c, 0xb0, 0x19, 0xcc, 0xe5, 0x73, 0xc3, 0xac, 0xfd, + 0x5e, 0x81, 0xab, 0xda, 0x10, 0x7d, 0x00, 0xf0, 0xea, 0xcc, 0x2c, 0xa3, 0xaa, 0x9f, 0xb5, 0x68, + 0xfe, 0x9c, 0xb5, 0x70, 0x6a, 0x67, 0x09, 0x31, 0x75, 0x79, 0xfe, 0xab, 0xaf, 0x3f, 0xdf, 0x2e, + 0x97, 0xd1, 0x1d, 0x9c, 0xb9, 0xf9, 0xa1, 0x0d, 0x6b, 0xda, 0x35, 0x41, 0xaf, 0x01, 0x5c, 0x33, + 0x0d, 0x42, 0xe5, 0x39, 0x76, 0x53, 0x4b, 0xe4, 0xdc, 0x5b, 0x40, 0x69, 0x79, 0x6e, 0x6b, 0x1e, + 0x17, 0x15, 0xb3, 0x79, 0xcc, 0x13, 0x7a, 0x0f, 0xe0, 0xe6, 0xf4, 0x3c, 0xa1, 0x9d, 0x7f, 0x7a, + 0xcc, 0x4c, 0xbb, 0x53, 0x3d, 0x43, 0x84, 0xa5, 0xab, 0x68, 0xba, 0xbb, 0xa8, 0x34, 0x8f, 0xae, + 0x39, 0x6a, 0x1a, 0x7a, 0x07, 0xe0, 0xc6, 0xe4, 0x34, 0x21, 0x7f, 0x91, 0x46, 0x8c, 0xa7, 0xd5, + 0xc1, 0x0b, 0xeb, 0x2d, 0xe0, 0x7d, 0x0d, 0x58, 0x42, 0xb7, 0xe6, 0x02, 0x0a, 0x1d, 0x54, 0x8f, + 0x3f, 0xf7, 0x5d, 0x70, 0xda, 0x77, 0xc1, 0x8f, 0xbe, 0x0b, 0xde, 0x0c, 0xdc, 0xa5, 0xd3, 0x81, + 0xbb, 0xf4, 0x6d, 0xe0, 0x2e, 0xc1, 0xeb, 0x09, 0xcf, 0x74, 0xde, 0x05, 0x2f, 0x6b, 0x13, 0x63, + 0x3f, 0x96, 0x54, 0x12, 0x3e, 0xe9, 0x78, 0x3c, 0xf2, 0xd4, 0x2b, 0x70, 0xb0, 0xa6, 0xbf, 0xea, + 0x0f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x29, 0x91, 0xe8, 0x44, 0x5e, 0x06, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // ContractAddress returns the address of the oracle's contract + ContractAddress(ctx context.Context, in *QueryContractAddressRequest, opts ...grpc.CallOption) (*QueryContractAddressResponse, error) + // Oracle sends an icq to an oracle on another chain + Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) + // OracleContract sends a query to the oracle's contract + OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) + // OracleResult returns the address of the oracle's contract + OracleResult(ctx context.Context, in *QueryOracleResultRequest, opts ...grpc.CallOption) (*QueryOracleResultResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) ContractAddress(ctx context.Context, in *QueryContractAddressRequest, opts ...grpc.CallOption) (*QueryContractAddressResponse, error) { + out := new(QueryContractAddressResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/ContractAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) { + out := new(QueryOracleResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/Oracle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) { + out := new(QueryOracleContractResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/OracleContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) OracleResult(ctx context.Context, in *QueryOracleResultRequest, opts ...grpc.CallOption) (*QueryOracleResultResponse, error) { + out := new(QueryOracleResultResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/OracleResult", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // ContractAddress returns the address of the oracle's contract + ContractAddress(context.Context, *QueryContractAddressRequest) (*QueryContractAddressResponse, error) + // Oracle sends an icq to an oracle on another chain + Oracle(context.Context, *QueryOracleRequest) (*QueryOracleResponse, error) + // OracleContract sends a query to the oracle's contract + OracleContract(context.Context, *QueryOracleContractRequest) (*QueryOracleContractResponse, error) + // OracleResult returns the address of the oracle's contract + OracleResult(context.Context, *QueryOracleResultRequest) (*QueryOracleResultResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) ContractAddress(ctx context.Context, req *QueryContractAddressRequest) (*QueryContractAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ContractAddress not implemented") +} +func (*UnimplementedQueryServer) Oracle(ctx context.Context, req *QueryOracleRequest) (*QueryOracleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Oracle not implemented") +} +func (*UnimplementedQueryServer) OracleContract(ctx context.Context, req *QueryOracleContractRequest) (*QueryOracleContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OracleContract not implemented") +} +func (*UnimplementedQueryServer) OracleResult(ctx context.Context, req *QueryOracleResultRequest) (*QueryOracleResultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OracleResult not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_ContractAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryContractAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ContractAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Query/ContractAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ContractAddress(ctx, req.(*QueryContractAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Oracle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOracleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Oracle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Query/Oracle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Oracle(ctx, req.(*QueryOracleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_OracleContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOracleContractRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).OracleContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Query/OracleContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).OracleContract(ctx, req.(*QueryOracleContractRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_OracleResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOracleResultRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).OracleResult(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Query/OracleResult", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).OracleResult(ctx, req.(*QueryOracleResultRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "provenance.oracle.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ContractAddress", + Handler: _Query_ContractAddress_Handler, + }, + { + MethodName: "Oracle", + Handler: _Query_Oracle_Handler, + }, + { + MethodName: "OracleContract", + Handler: _Query_OracleContract_Handler, + }, + { + MethodName: "OracleResult", + Handler: _Query_OracleResult_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "provenance/oracle/v1/query.proto", +} + +func (m *QueryContractAddressRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryContractAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryContractAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryContractAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryOracleRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryOracleRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0x12 + } + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryOracleResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryOracleResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryOracleContractRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryOracleContractRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOracleContractRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryOracleContractResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryOracleContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOracleContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryOracleResultRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryOracleResultRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOracleResultRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryOracleResultResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryOracleResultResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOracleResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryContractAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryContractAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryOracleRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Query) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.SourceChannel) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryOracleResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.QueryId != 0 { + n += 1 + sovQuery(uint64(m.QueryId)) + } + return n +} + +func (m *QueryOracleContractRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Query) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryOracleContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryOracleResultRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.QueryId != 0 { + n += 1 + sovQuery(uint64(m.QueryId)) + } + return n +} + +func (m *QueryOracleResultResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryContractAddressRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryContractAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryContractAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryContractAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryOracleRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryOracleRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) + if m.Query == nil { + m.Query = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourcePort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryOracleResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryOracleResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOracleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + } + m.QueryId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryOracleContractRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryOracleContractRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOracleContractRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) + if m.Query == nil { + m.Query = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryOracleContractResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryOracleContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOracleContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryOracleResultRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryOracleResultRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOracleResultRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + } + m.QueryId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryOracleResultResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryOracleResultResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOracleResultResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go new file mode 100644 index 0000000000..21c594d9f2 --- /dev/null +++ b/x/oracle/types/query.pb.gw.go @@ -0,0 +1,388 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: provenance/oracle/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_Query_ContractAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractAddressRequest + var metadata runtime.ServerMetadata + + msg, err := client.ContractAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ContractAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractAddressRequest + var metadata runtime.ServerMetadata + + msg, err := server.ContractAddress(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Oracle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Oracle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Oracle_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Oracle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Oracle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Oracle_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Oracle(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_OracleContract_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_OracleContract_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleContractRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.OracleContract(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_OracleContract_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleContractRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.OracleContract(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_OracleResult_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_OracleResult_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleResultRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleResult_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.OracleResult(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_OracleResult_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleResultRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleResult_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.OracleResult(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_ContractAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ContractAddress_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ContractAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Oracle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Oracle_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Oracle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_OracleContract_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_OracleContract_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_OracleContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_OracleResult_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_OracleResult_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_OracleResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_ContractAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ContractAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ContractAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Oracle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Oracle_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Oracle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_OracleContract_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_OracleContract_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_OracleContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_OracleResult_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_OracleResult_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_OracleResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_ContractAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "contract_address"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Oracle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"provenance", "oracle", "v1"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_OracleContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_contract"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_OracleResult_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_result"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_ContractAddress_0 = runtime.ForwardResponseMessage + + forward_Query_Oracle_0 = runtime.ForwardResponseMessage + + forward_Query_OracleContract_0 = runtime.ForwardResponseMessage + + forward_Query_OracleResult_0 = runtime.ForwardResponseMessage +) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go new file mode 100644 index 0000000000..39b1dfaae6 --- /dev/null +++ b/x/oracle/types/tx.pb.go @@ -0,0 +1,614 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: provenance/oracle/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUpdateOracleRequest is the request type for updating an oracle's contract address +type MsgUpdateOracleRequest struct { + // The address of the oracle's contract + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // The signing authorities for the request + Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (m *MsgUpdateOracleRequest) Reset() { *m = MsgUpdateOracleRequest{} } +func (m *MsgUpdateOracleRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateOracleRequest) ProtoMessage() {} +func (*MsgUpdateOracleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_66a39dda41c6a784, []int{0} +} +func (m *MsgUpdateOracleRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateOracleRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateOracleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateOracleRequest.Merge(m, src) +} +func (m *MsgUpdateOracleRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateOracleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateOracleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateOracleRequest proto.InternalMessageInfo + +func (m *MsgUpdateOracleRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgUpdateOracleRequest) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +// MsgUpdateOracleResponse is the response type for updating the oracle. +type MsgUpdateOracleResponse struct { +} + +func (m *MsgUpdateOracleResponse) Reset() { *m = MsgUpdateOracleResponse{} } +func (m *MsgUpdateOracleResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateOracleResponse) ProtoMessage() {} +func (*MsgUpdateOracleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_66a39dda41c6a784, []int{1} +} +func (m *MsgUpdateOracleResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateOracleResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateOracleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateOracleResponse.Merge(m, src) +} +func (m *MsgUpdateOracleResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateOracleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateOracleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateOracleResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateOracleRequest)(nil), "provenance.oracle.v1.MsgUpdateOracleRequest") + proto.RegisterType((*MsgUpdateOracleResponse)(nil), "provenance.oracle.v1.MsgUpdateOracleResponse") +} + +func init() { proto.RegisterFile("provenance/oracle/v1/tx.proto", fileDescriptor_66a39dda41c6a784) } + +var fileDescriptor_66a39dda41c6a784 = []byte{ + // 295 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x28, 0xca, 0x2f, + 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, + 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0x48, 0xeb, 0x41, 0xa4, + 0xf5, 0xca, 0x0c, 0xa5, 0x24, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xe3, 0xc1, 0x6a, 0xf4, 0x21, + 0x1c, 0x88, 0x06, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x88, 0x38, 0x88, 0x05, 0x11, 0x55, 0xea, + 0x63, 0xe4, 0x12, 0xf3, 0x2d, 0x4e, 0x0f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xf5, 0x07, 0x9b, 0x13, + 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x22, 0x64, 0xc4, 0xc5, 0x9e, 0x98, 0x92, 0x52, 0x94, 0x5a, + 0x5c, 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0x71, 0x69, 0x8b, 0xae, 0x08, 0xd4, 0x4c, + 0x47, 0x88, 0x4c, 0x70, 0x49, 0x51, 0x66, 0x5e, 0x7a, 0x10, 0x4c, 0xa1, 0x90, 0x19, 0x17, 0x67, + 0x62, 0x69, 0x49, 0x46, 0x7e, 0x51, 0x66, 0x49, 0xa5, 0x04, 0x13, 0x01, 0x5d, 0x08, 0xa5, 0x56, + 0x1c, 0x33, 0x16, 0xc8, 0x33, 0xbe, 0x58, 0x20, 0xcf, 0xa8, 0x24, 0xc9, 0x25, 0x8e, 0xe1, 0x9e, + 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa3, 0x22, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x6c, 0x2e, + 0x1e, 0x64, 0x69, 0x21, 0x1d, 0x3d, 0x6c, 0x41, 0xa1, 0x87, 0xdd, 0x57, 0x52, 0xba, 0x44, 0xaa, + 0x86, 0xd8, 0xe9, 0x94, 0x7e, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, + 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, 0xe2, + 0x99, 0xf9, 0x58, 0x8d, 0x0a, 0x60, 0x8c, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, + 0xce, 0xcf, 0xd5, 0x47, 0x28, 0xd1, 0xcd, 0xcc, 0x47, 0xe2, 0xe9, 0x57, 0xc0, 0x62, 0xb5, 0xa4, + 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x1f, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x09, + 0xc3, 0xcb, 0xba, 0xf7, 0x01, 0x00, 0x00, +} + +func (this *MsgUpdateOracleRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgUpdateOracleRequest) + if !ok { + that2, ok := that.(MsgUpdateOracleRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if this.Authority != that1.Authority { + return false + } + return true +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // UpdateOracle is the RPC endpoint for updating the oracle + UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest, opts ...grpc.CallOption) (*MsgUpdateOracleResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest, opts ...grpc.CallOption) (*MsgUpdateOracleResponse, error) { + out := new(MsgUpdateOracleResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Msg/UpdateOracle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UpdateOracle is the RPC endpoint for updating the oracle + UpdateOracle(context.Context, *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateOracle(ctx context.Context, req *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateOracle not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateOracle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateOracleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateOracle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Msg/UpdateOracle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateOracle(ctx, req.(*MsgUpdateOracleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "provenance.oracle.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateOracle", + Handler: _Msg_UpdateOracle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "provenance/oracle/v1/tx.proto", +} + +func (m *MsgUpdateOracleRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateOracleRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateOracleResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateOracleResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateOracleRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateOracleResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateOracleRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateOracleRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateOracleResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateOracleResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateOracleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From f05b400b57932871bc08c0484e02ec81544138b9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 27 Jul 2023 14:46:30 -0400 Subject: [PATCH 03/96] Fixed signature of OracleResult. --- x/oracle/keeper/query_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 910e548ef1..febcbf3e54 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -22,6 +22,6 @@ func (k Keeper) OracleContract(ctx context.Context, req *types.QueryOracleContra return &types.QueryOracleContractResponse{}, nil } -func (k Keeper) OracleResult(ctx context.Context, req *types.QueryOracleResult) (*types.QueryOracleResultResponse, error) { +func (k Keeper) OracleResult(ctx context.Context, req *types.QueryOracleResultRequest) (*types.QueryOracleResultResponse, error) { return &types.QueryOracleResultResponse{}, nil } From b01c9af2dd7bdb30e928d5549b8b03c092b97cc6 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 27 Jul 2023 16:05:22 -0400 Subject: [PATCH 04/96] Added async-icq to provenance. Still need to hook up oracle module, and then integrate the two. --- app/app.go | 25 ++++++++++++++++++++++++- go.mod | 1 + go.sum | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 456889b7db..d3ae3a4f45 100644 --- a/app/app.go +++ b/app/app.go @@ -117,6 +117,9 @@ import ( porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host" ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper" + icq "github.com/strangelove-ventures/async-icq/v6" + icqkeeper "github.com/strangelove-ventures/async-icq/v6/keeper" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" appparams "github.com/provenance-io/provenance/app/params" "github.com/provenance-io/provenance/internal/antewrapper" @@ -200,6 +203,7 @@ var ( ibc.AppModuleBasic{}, transfer.AppModuleBasic{}, ica.AppModuleBasic{}, + icq.AppModuleBasic{}, marker.AppModuleBasic{}, attribute.AppModuleBasic{}, @@ -289,6 +293,7 @@ type App struct { IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly ICAHostKeeper icahostkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper + ICQKeeper icqkeeper.Keeper MarkerKeeper markerkeeper.Keeper MetadataKeeper metadatakeeper.Keeper @@ -300,6 +305,7 @@ type App struct { ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + ScopedICQKeeper capabilitykeeper.ScopedKeeper // the module manager mm *module.Manager @@ -353,6 +359,7 @@ func New( ibchost.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, + icqtypes.StoreKey, metadatatypes.StoreKey, markertypes.StoreKey, @@ -398,6 +405,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) // capability keeper must be sealed after scope to module registrations are completed. app.CapabilityKeeper.Seal() @@ -495,6 +503,14 @@ func New( icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper) icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) + app.ICQKeeper = icqkeeper.NewKeeper( + appCodec, keys[icqtypes.StoreKey], app.GetSubspace(icqtypes.ModuleName), + app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + scopedICQKeeper, app.BaseApp, + ) + icqModule := icq.NewAppModule(app.ICQKeeper) + icqIBCModule := icq.NewIBCModule(app.ICQKeeper) + // Init CosmWasm module wasmDir := filepath.Join(homePath, "data", "wasm") @@ -581,7 +597,8 @@ func New( ibcRouter := porttypes.NewRouter() ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule). AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)). - AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). + AddRoute(icqtypes.ModuleName, icqIBCModule) app.IBCKeeper.SetRouter(ibcRouter) // Create evidence Keeper for to register the IBC light client misbehavior evidence route @@ -636,6 +653,7 @@ func New( // IBC ibc.NewAppModule(app.IBCKeeper), transferModule, + icqModule, icaModule, ) @@ -672,6 +690,7 @@ func New( metadatatypes.ModuleName, wasm.ModuleName, ibctransfertypes.ModuleName, + icqtypes.ModuleName, nametypes.ModuleName, vestingtypes.ModuleName, quarantine.ModuleName, @@ -697,6 +716,7 @@ func New( genutiltypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, + icqtypes.ModuleName, msgfeestypes.ModuleName, wasm.ModuleName, slashingtypes.ModuleName, @@ -744,6 +764,7 @@ func New( ibchost.ModuleName, ibctransfertypes.ModuleName, + icqtypes.ModuleName, icatypes.ModuleName, // wasm after ibc transfer wasm.ModuleName, @@ -910,6 +931,7 @@ func New( app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper + app.ScopedICQKeeper = scopedICQKeeper app.ScopedICAHostKeeper = scopedICAHostKeeper return app @@ -1113,6 +1135,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(icqtypes.ModuleName) return paramsKeeper } diff --git a/go.mod b/go.mod index 9c0e9437d9..b1c88d0ca0 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 + github.com/strangelove-ventures/async-icq/v6 v6.0.0-rc0 github.com/stretchr/testify v1.8.4 github.com/tendermint/tendermint v0.34.28 github.com/tendermint/tm-db v0.6.7 diff --git a/go.sum b/go.sum index b503c44ec2..06cb67a56d 100644 --- a/go.sum +++ b/go.sum @@ -1077,6 +1077,8 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/strangelove-ventures/async-icq/v6 v6.0.0-rc0 h1:gh0/GEH0LGSyQIuCpMVaA8f9GnkeiKqxNY8p8Z+4460= +github.com/strangelove-ventures/async-icq/v6 v6.0.0-rc0/go.mod h1:6jtElXZFjBeT00/mEnyiUif6YKN7pxmeorBpLOMidd8= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= From 9a3a53451ebb4077ad6534ff9d02ea5c98d5b9c2 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 27 Jul 2023 16:24:41 -0400 Subject: [PATCH 05/96] Added the oracle module app.go --- app/app.go | 15 +++++++++++++++ x/oracle/types/keys.go | 3 +++ 2 files changed, 18 insertions(+) diff --git a/app/app.go b/app/app.go index d3ae3a4f45..2645c3c97f 100644 --- a/app/app.go +++ b/app/app.go @@ -149,6 +149,9 @@ import ( namekeeper "github.com/provenance-io/provenance/x/name/keeper" nametypes "github.com/provenance-io/provenance/x/name/types" namewasm "github.com/provenance-io/provenance/x/name/wasm" + oraclekeeper "github.com/provenance-io/provenance/x/oracle/keeper" + oraclemodule "github.com/provenance-io/provenance/x/oracle/module" + oracletypes "github.com/provenance-io/provenance/x/oracle/types" rewardkeeper "github.com/provenance-io/provenance/x/reward/keeper" rewardmodule "github.com/provenance-io/provenance/x/reward/module" rewardtypes "github.com/provenance-io/provenance/x/reward/types" @@ -213,6 +216,7 @@ var ( msgfeesmodule.AppModuleBasic{}, rewardmodule.AppModuleBasic{}, triggermodule.AppModuleBasic{}, + oraclemodule.AppModuleBasic{}, ) // module account permissions @@ -232,6 +236,7 @@ var ( wasm.ModuleName: {authtypes.Burner}, rewardtypes.ModuleName: nil, triggertypes.ModuleName: nil, + oracletypes.ModuleName: nil, } ) @@ -289,6 +294,7 @@ type App struct { QuarantineKeeper quarantinekeeper.Keeper SanctionKeeper sanctionkeeper.Keeper 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 ICAHostKeeper icahostkeeper.Keeper @@ -371,6 +377,7 @@ func New( quarantine.StoreKey, sanction.StoreKey, triggertypes.StoreKey, + oracletypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -495,6 +502,7 @@ func New( return pioMsgFeesRouter.Handler(msg) }) app.TriggerKeeper = triggerkeeper.NewKeeper(appCodec, keys[triggertypes.StoreKey], app.MsgServiceRouter()) + app.OracleKeeper = oraclekeeper.NewKeeper(appCodec, keys[oracletypes.StoreKey]) app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, @@ -649,6 +657,7 @@ func New( wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper), triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper), + oraclemodule.NewAppModule(appCodec, app.OracleKeeper), // IBC ibc.NewAppModule(app.IBCKeeper), @@ -688,6 +697,7 @@ func New( paramstypes.ModuleName, msgfeestypes.ModuleName, metadatatypes.ModuleName, + oracletypes.ModuleName, wasm.ModuleName, ibctransfertypes.ModuleName, icqtypes.ModuleName, @@ -712,6 +722,7 @@ func New( distrtypes.ModuleName, authz.ModuleName, metadatatypes.ModuleName, + oracletypes.ModuleName, nametypes.ModuleName, genutiltypes.ModuleName, ibchost.ModuleName, @@ -770,6 +781,7 @@ func New( wasm.ModuleName, rewardtypes.ModuleName, triggertypes.ModuleName, + oracletypes.ModuleName, // no-ops paramstypes.ModuleName, @@ -809,6 +821,7 @@ func New( nametypes.ModuleName, rewardtypes.ModuleName, triggertypes.ModuleName, + oracletypes.ModuleName, // Last due to v0.44 issue: https://github.com/cosmos/cosmos-sdk/issues/10591 authtypes.ModuleName, @@ -843,6 +856,7 @@ func New( msgfeesmodule.NewAppModule(appCodec, app.MsgFeesKeeper, app.interfaceRegistry), rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper), triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper), + oraclemodule.NewAppModule(appCodec, app.OracleKeeper), provwasm.NewWrapper(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper), ibc.NewAppModule(app.IBCKeeper), @@ -1131,6 +1145,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(wasm.ModuleName) paramsKeeper.Subspace(rewardtypes.ModuleName) paramsKeeper.Subspace(triggertypes.ModuleName) + paramsKeeper.Subspace(oracletypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 29e2b851a8..81580b64ac 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -3,4 +3,7 @@ package types const ( // ModuleName defines the module name ModuleName = "oracle" + + // StoreKey is string representation of the store key for marker + StoreKey = ModuleName ) From 2b97f265bb13844e7a637450570d991101a0dd72 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 27 Jul 2023 16:32:50 -0400 Subject: [PATCH 06/96] Added empty Msg interface implementation for UpdateOracle. --- x/oracle/types/msgs.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 x/oracle/types/msgs.go diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go new file mode 100644 index 0000000000..2abe47417e --- /dev/null +++ b/x/oracle/types/msgs.go @@ -0,0 +1,17 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgUpdateOracleRequest{} + +// GetSigners indicates that the message must have been signed by the parent. +func (msg MsgUpdateOracleRequest) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(msg.Authority)} +} + +// ValidateBasic runs stateless validation checks on the message. +func (msg MsgUpdateOracleRequest) ValidateBasic() error { + return nil +} From 210cb1dee49c0cc84f50a9831a9189af0505432b Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 28 Jul 2023 10:42:49 -0400 Subject: [PATCH 07/96] Added ICQKeeper to OracleKeeper. Made the QueryOracle request a transaction. --- app/app.go | 2 +- docs/proto-docs.md | 70 ++-- go.mod | 4 +- go.sum | 8 +- proto/provenance/oracle/v1/query.proto | 21 - proto/provenance/oracle/v1/tx.proto | 18 + x/oracle/keeper/keeper.go | 15 +- x/oracle/keeper/msg_server.go | 5 +- x/oracle/keeper/query.go | 130 ++++++ x/oracle/keeper/query_server.go | 5 - x/oracle/types/codec.go | 1 + x/oracle/types/query.pb.go | 551 ++----------------------- x/oracle/types/query.pb.gw.go | 80 ---- x/oracle/types/tx.pb.go | 527 ++++++++++++++++++++++- 14 files changed, 749 insertions(+), 688 deletions(-) create mode 100644 x/oracle/keeper/query.go diff --git a/app/app.go b/app/app.go index 2645c3c97f..821506ef1f 100644 --- a/app/app.go +++ b/app/app.go @@ -502,7 +502,6 @@ func New( return pioMsgFeesRouter.Handler(msg) }) app.TriggerKeeper = triggerkeeper.NewKeeper(appCodec, keys[triggertypes.StoreKey], app.MsgServiceRouter()) - app.OracleKeeper = oraclekeeper.NewKeeper(appCodec, keys[oracletypes.StoreKey]) app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, @@ -518,6 +517,7 @@ func New( ) icqModule := icq.NewAppModule(app.ICQKeeper) icqIBCModule := icq.NewIBCModule(app.ICQKeeper) + app.OracleKeeper = oraclekeeper.NewKeeper(appCodec, keys[oracletypes.StoreKey], app.ICQKeeper) // Init CosmWasm module wasmDir := filepath.Join(homePath, "data", "wasm") diff --git a/docs/proto-docs.md b/docs/proto-docs.md index d2a7547b1a..6bbca98241 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -441,14 +441,14 @@ - [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) - [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) - [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) - - [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) - - [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) - [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) - [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) - [Query](#provenance.oracle.v1.Query) - [provenance/oracle/v1/tx.proto](#provenance/oracle/v1/tx.proto) + - [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) + - [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) - [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) - [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) @@ -6792,38 +6792,6 @@ QueryOracleContractResponse contains the result of the query to the oracle's sma - - -### QueryOracleRequest -QueryOracleRequest queries an Oracle on another chain - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `query` | [bytes](#bytes) | | Query contains the query data passed to the oracle. | -| `source_port` | [string](#string) | | Source port is the source port to the oracle. | -| `source_channel` | [string](#string) | | Source channel is the channel to the oracle. | - - - - - - - - -### QueryOracleResponse -QueryOracleResponse contains the id of the oracle query. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `query_id` | [uint64](#uint64) | | The id that uniquely identifies the query. | - - - - - - ### QueryOracleResultRequest @@ -6868,7 +6836,6 @@ Query defines the gRPC querier service for oracle module. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `ContractAddress` | [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) | [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) | ContractAddress returns the address of the oracle's contract | GET|/provenance/oracle/v1/contract_address| -| `Oracle` | [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) | [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) | Oracle sends an icq to an oracle on another chain | GET|/provenance/oracle/v1/oracle| | `OracleContract` | [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) | [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) | OracleContract sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle_contract| | `OracleResult` | [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) | [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) | OracleResult returns the address of the oracle's contract | GET|/provenance/oracle/v1/oracle_result| @@ -6883,6 +6850,38 @@ Query defines the gRPC querier service for oracle module. + + +### MsgQueryOracleRequest +MsgQueryOracleRequest queries an Oracle on another chain + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query` | [bytes](#bytes) | | Query contains the query data passed to the oracle. | +| `source_port` | [string](#string) | | Source port is the source port to the oracle. | +| `source_channel` | [string](#string) | | Source channel is the channel to the oracle. | + + + + + + + + +### MsgQueryOracleResponse +MsgQueryOracleResponse contains the id of the oracle query. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `query_id` | [uint64](#uint64) | | The id that uniquely identifies the query. | + + + + + + ### MsgUpdateOracleRequest @@ -6923,6 +6922,7 @@ Msg | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `UpdateOracle` | [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) | [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) | UpdateOracle is the RPC endpoint for updating the oracle | | +| `QueryOracle` | [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) | [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) | QueryOracle sends an icq to an oracle on another chain | | diff --git a/go.mod b/go.mod index b1c88d0ca0..9181213bd2 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,8 @@ require ( github.com/tendermint/tm-db v0.6.7 golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0 golang.org/x/text v0.11.0 - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 + google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e + google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 google.golang.org/grpc v1.56.2 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 @@ -165,6 +166,7 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.122.0 // indirect google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20230629202037-9506855d4529 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect diff --git a/go.sum b/go.sum index 06cb67a56d..43c7743ac0 100644 --- a/go.sum +++ b/go.sum @@ -1743,8 +1743,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto v0.0.0-20230629202037-9506855d4529 h1:9JucMWR7sPvCxUFd6UsOUNmA5kCcWOfORaT3tpAsKQs= +google.golang.org/genproto v0.0.0-20230629202037-9506855d4529/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64= +google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e h1:AZX1ra8YbFMSb7+1pI8S9v4rrgRR7jU1FmuFSSjTVcQ= +google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 h1:2FZP5XuJY9zQyGM5N0rtovnoXjiMUEIUMvw0m9wlpLc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:8mL13HKkDa+IuJ8yruA3ci0q+0vsUz4m//+ottjwS5o= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index 13a7d7bbd2..da3b7c3019 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -16,11 +16,6 @@ service Query { option (google.api.http).get = "/provenance/oracle/v1/contract_address"; } - // Oracle sends an icq to an oracle on another chain - rpc Oracle(QueryOracleRequest) returns (QueryOracleResponse) { - option (google.api.http).get = "/provenance/oracle/v1/oracle"; - } - // OracleContract sends a query to the oracle's contract rpc OracleContract(QueryOracleContractRequest) returns (QueryOracleContractResponse) { option (google.api.http).get = "/provenance/oracle/v1/oracle_contract"; @@ -41,22 +36,6 @@ message QueryContractAddressResponse { string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -// QueryOracleRequest queries an Oracle on another chain -message QueryOracleRequest { - // Query contains the query data passed to the oracle. - bytes query = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; - // Source port is the source port to the oracle. - string source_port = 2; - // Source channel is the channel to the oracle. - string source_channel = 3; -} - -// QueryOracleResponse contains the id of the oracle query. -message QueryOracleResponse { - // The id that uniquely identifies the query. - uint64 query_id = 1; -} - // QueryOracleContractRequest queries the oracle's smart contract message QueryOracleContractRequest { // Query contains the query data passed to the contract. diff --git a/proto/provenance/oracle/v1/tx.proto b/proto/provenance/oracle/v1/tx.proto index ead8c80580..7db4ad08b3 100644 --- a/proto/provenance/oracle/v1/tx.proto +++ b/proto/provenance/oracle/v1/tx.proto @@ -12,6 +12,24 @@ option java_multiple_files = true; service Msg { // UpdateOracle is the RPC endpoint for updating the oracle rpc UpdateOracle(MsgUpdateOracleRequest) returns (MsgUpdateOracleResponse); + // QueryOracle sends an icq to an oracle on another chain + rpc QueryOracle(MsgQueryOracleRequest) returns (MsgQueryOracleResponse); +} + +// MsgQueryOracleRequest queries an Oracle on another chain +message MsgQueryOracleRequest { + // Query contains the query data passed to the oracle. + bytes query = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; + // Source port is the source port to the oracle. + string source_port = 2; + // Source channel is the channel to the oracle. + string source_channel = 3; +} + +// MsgQueryOracleResponse contains the id of the oracle query. +message MsgQueryOracleResponse { + // The id that uniquely identifies the query. + uint64 query_id = 1; } // MsgUpdateOracleRequest is the request type for updating an oracle's contract address diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 791ea8477e..6bd2e7bca4 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -4,24 +4,27 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" - "github.com/provenance-io/provenance/x/oracle/types" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" + icq "github.com/strangelove-ventures/async-icq/v6/keeper" ) type Keeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + icqKeeper icq.Keeper } func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, + icqKeeper icq.Keeper, ) Keeper { return Keeper{ - storeKey: key, - cdc: cdc, + storeKey: key, + cdc: cdc, + icqKeeper: icqKeeper, } } diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index f45a5c8e31..93eddbd78e 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -21,6 +21,9 @@ var _ types.MsgServer = msgServer{} // UpdateOracle changes the oracle's address to the provided one func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracleRequest) (*types.MsgUpdateOracleResponse, error) { //ctx := sdk.UnwrapSDKContext(goCtx) - return &types.MsgUpdateOracleResponse{}, nil } + +func (s msgServer) QueryOracle(goCtx context.Context, msg *types.MsgQueryOracleRequest) (*types.MsgQueryOracleResponse, error) { + return &types.MsgQueryOracleResponse{}, nil +} diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go new file mode 100644 index 0000000000..b1a7e41af6 --- /dev/null +++ b/x/oracle/keeper/query.go @@ -0,0 +1,130 @@ +package keeper + +/*import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/quasar-finance/interchain-query-demo/x/interquery/types" + + icqtypes "github.com/cosmos/ibc-go/v3/modules/apps/icq/types" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +func (k Keeper) SendQuery( + ctx sdk.Context, + sourcePort, + sourceChannel string, + chanCap *capabilitytypes.Capability, + reqs []abci.RequestQuery, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, +) (uint64, error) { + sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) + if !found { + return 0, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) + } + + destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() + destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() + + data, err := icqtypes.SerializeCosmosQuery(reqs) + if err != nil { + return 0, sdkerrors.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) +} + +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, sdkerrors.Wrap(err, "invalid interchain query packet data") + } + + // get the next sequence + sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) + if !found { + return 0, sdkerrors.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); err != nil { + return 0, err + } + + return packet.Sequence, nil +} + +func (k Keeper) OnAcknowledgementPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + ack channeltypes.Acknowledgement, +) error { + switch resp := ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + var ackData icqtypes.InterchainQueryPacketAck + if err := icqtypes.ModuleCdc.UnmarshalJSON(resp.Result, &ackData); err != nil { + return sdkerrors.Wrap(err, "failed to unmarshal interchain query packet ack") + } + resps, err := icqtypes.DeserializeCosmosResponse(ackData.Data) + if err != nil { + return sdkerrors.Wrap(err, "could not deserialize data to cosmos response") + } + + if len(resps) < 1 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") + } + + var r banktypes.QueryAllBalancesResponse + if err := k.cdc.Unmarshal(resps[0].Value, &r); err != nil { + return sdkerrors.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) + } + + k.SetQueryResponse(ctx, modulePacket.Sequence, r) + k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeQueryResult, + sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), + ), + ) + + k.Logger(ctx).Info("interchain query response", "sequence", modulePacket.Sequence, "response", r) + case *channeltypes.Acknowledgement_Error: + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeQueryResult, + sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), + ), + ) + + k.Logger(ctx).Error("interchain query response", "sequence", modulePacket.Sequence, "error", resp.Error) + } + return nil +} +*/ diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index febcbf3e54..61a6ea641a 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -13,11 +13,6 @@ func (k Keeper) ContractAddress(ctx context.Context, req *types.QueryContractAdd return &types.QueryContractAddressResponse{}, nil } -// Oracle sends an ICQ to an oracle -func (k Keeper) Oracle(ctx context.Context, req *types.QueryOracleRequest) (*types.QueryOracleResponse, error) { - return &types.QueryOracleResponse{}, nil -} - func (k Keeper) OracleContract(ctx context.Context, req *types.QueryOracleContractRequest) (*types.QueryOracleContractResponse, error) { return &types.QueryOracleContractResponse{}, nil } diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index d66b7e13f5..10e25f709b 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -12,6 +12,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgUpdateOracleRequest{}, + &MsgQueryOracleRequest{}, ) } diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 0988d716af..d78e8a7770 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -114,116 +114,6 @@ func (m *QueryContractAddressResponse) GetAddress() string { return "" } -// QueryOracleRequest queries an Oracle on another chain -type QueryOracleRequest struct { - // Query contains the query data passed to the oracle. - Query github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=query,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"query,omitempty"` - // Source port is the source port to the oracle. - SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` - // Source channel is the channel to the oracle. - SourceChannel string `protobuf:"bytes,3,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` -} - -func (m *QueryOracleRequest) Reset() { *m = QueryOracleRequest{} } -func (m *QueryOracleRequest) String() string { return proto.CompactTextString(m) } -func (*QueryOracleRequest) ProtoMessage() {} -func (*QueryOracleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{2} -} -func (m *QueryOracleRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryOracleRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryOracleRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOracleRequest.Merge(m, src) -} -func (m *QueryOracleRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryOracleRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOracleRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryOracleRequest proto.InternalMessageInfo - -func (m *QueryOracleRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { - if m != nil { - return m.Query - } - return nil -} - -func (m *QueryOracleRequest) GetSourcePort() string { - if m != nil { - return m.SourcePort - } - return "" -} - -func (m *QueryOracleRequest) GetSourceChannel() string { - if m != nil { - return m.SourceChannel - } - return "" -} - -// QueryOracleResponse contains the id of the oracle query. -type QueryOracleResponse struct { - // The id that uniquely identifies the query. - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` -} - -func (m *QueryOracleResponse) Reset() { *m = QueryOracleResponse{} } -func (m *QueryOracleResponse) String() string { return proto.CompactTextString(m) } -func (*QueryOracleResponse) ProtoMessage() {} -func (*QueryOracleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{3} -} -func (m *QueryOracleResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryOracleResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryOracleResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOracleResponse.Merge(m, src) -} -func (m *QueryOracleResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryOracleResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOracleResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryOracleResponse proto.InternalMessageInfo - -func (m *QueryOracleResponse) GetQueryId() uint64 { - if m != nil { - return m.QueryId - } - return 0 -} - // QueryOracleContractRequest queries the oracle's smart contract type QueryOracleContractRequest struct { // Query contains the query data passed to the contract. @@ -234,7 +124,7 @@ func (m *QueryOracleContractRequest) Reset() { *m = QueryOracleContractR func (m *QueryOracleContractRequest) String() string { return proto.CompactTextString(m) } func (*QueryOracleContractRequest) ProtoMessage() {} func (*QueryOracleContractRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{4} + return fileDescriptor_169907f611744c57, []int{2} } func (m *QueryOracleContractRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +170,7 @@ func (m *QueryOracleContractResponse) Reset() { *m = QueryOracleContract func (m *QueryOracleContractResponse) String() string { return proto.CompactTextString(m) } func (*QueryOracleContractResponse) ProtoMessage() {} func (*QueryOracleContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{5} + return fileDescriptor_169907f611744c57, []int{3} } func (m *QueryOracleContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,7 +216,7 @@ func (m *QueryOracleResultRequest) Reset() { *m = QueryOracleResultReque func (m *QueryOracleResultRequest) String() string { return proto.CompactTextString(m) } func (*QueryOracleResultRequest) ProtoMessage() {} func (*QueryOracleResultRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{6} + return fileDescriptor_169907f611744c57, []int{4} } func (m *QueryOracleResultRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -372,7 +262,7 @@ func (m *QueryOracleResultResponse) Reset() { *m = QueryOracleResultResp func (m *QueryOracleResultResponse) String() string { return proto.CompactTextString(m) } func (*QueryOracleResultResponse) ProtoMessage() {} func (*QueryOracleResultResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{7} + return fileDescriptor_169907f611744c57, []int{5} } func (m *QueryOracleResultResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -411,8 +301,6 @@ func (m *QueryOracleResultResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_t func init() { proto.RegisterType((*QueryContractAddressRequest)(nil), "provenance.oracle.v1.QueryContractAddressRequest") proto.RegisterType((*QueryContractAddressResponse)(nil), "provenance.oracle.v1.QueryContractAddressResponse") - proto.RegisterType((*QueryOracleRequest)(nil), "provenance.oracle.v1.QueryOracleRequest") - proto.RegisterType((*QueryOracleResponse)(nil), "provenance.oracle.v1.QueryOracleResponse") proto.RegisterType((*QueryOracleContractRequest)(nil), "provenance.oracle.v1.QueryOracleContractRequest") proto.RegisterType((*QueryOracleContractResponse)(nil), "provenance.oracle.v1.QueryOracleContractResponse") proto.RegisterType((*QueryOracleResultRequest)(nil), "provenance.oracle.v1.QueryOracleResultRequest") @@ -422,44 +310,39 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/query.proto", fileDescriptor_169907f611744c57) } var fileDescriptor_169907f611744c57 = []byte{ - // 591 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xbf, 0x6f, 0x13, 0x31, - 0x14, 0xc7, 0xeb, 0xd2, 0x1f, 0x60, 0x4a, 0x91, 0x4c, 0x24, 0x92, 0x23, 0x5c, 0xab, 0x83, 0x40, - 0x10, 0xca, 0xb9, 0x09, 0x62, 0x60, 0x60, 0x20, 0x99, 0x18, 0x10, 0xed, 0x75, 0x40, 0x62, 0x89, - 0xdc, 0x3b, 0xeb, 0x7a, 0x52, 0x62, 0x5f, 0x6c, 0x27, 0x6d, 0x57, 0xf8, 0x07, 0x90, 0x58, 0x19, - 0x19, 0x58, 0x91, 0xf8, 0x23, 0x18, 0x2b, 0x58, 0x98, 0x10, 0x4a, 0xf8, 0x2b, 0x18, 0x10, 0x8a, - 0xed, 0x90, 0x1f, 0x3a, 0x85, 0x54, 0x2a, 0x53, 0xee, 0xec, 0xef, 0x7b, 0xdf, 0xcf, 0x7b, 0x79, - 0xef, 0xe0, 0x76, 0x2a, 0x78, 0x8f, 0x32, 0xc2, 0x42, 0x8a, 0xb9, 0x20, 0x61, 0x8b, 0xe2, 0x5e, - 0x15, 0x77, 0xba, 0x54, 0x9c, 0xf8, 0xa9, 0xe0, 0x8a, 0xa3, 0xdc, 0x58, 0xe1, 0x1b, 0x85, 0xdf, - 0xab, 0x3a, 0xb9, 0x98, 0xc7, 0x5c, 0x0b, 0xf0, 0xf0, 0xc9, 0x68, 0x9d, 0x62, 0xcc, 0x79, 0xdc, - 0xa2, 0x98, 0xa4, 0x09, 0x26, 0x8c, 0x71, 0x45, 0x54, 0xc2, 0x99, 0xb4, 0xb7, 0x85, 0x90, 0xcb, - 0x36, 0x97, 0x4d, 0x13, 0x66, 0x5e, 0xcc, 0x95, 0x77, 0x13, 0xde, 0xd8, 0x1b, 0x7a, 0x36, 0x38, - 0x53, 0x82, 0x84, 0xea, 0x49, 0x14, 0x09, 0x2a, 0x65, 0x40, 0x3b, 0x5d, 0x2a, 0x95, 0x17, 0xc0, - 0x62, 0xf6, 0xb5, 0x4c, 0x39, 0x93, 0x14, 0xd5, 0xe0, 0x3a, 0x31, 0x47, 0x79, 0xb0, 0x0d, 0xca, - 0x97, 0xea, 0xf9, 0x2f, 0x9f, 0x2a, 0x39, 0xeb, 0x60, 0xc5, 0xfb, 0x4a, 0x24, 0x2c, 0x0e, 0x46, - 0x42, 0xef, 0x23, 0x80, 0x48, 0x27, 0x7d, 0xae, 0x8b, 0xb2, 0x56, 0x68, 0x1f, 0xae, 0xea, 0xea, - 0x75, 0xa2, 0x8d, 0xfa, 0xe3, 0x5f, 0xdf, 0xb7, 0x1e, 0xc5, 0x89, 0x3a, 0xec, 0x1e, 0xf8, 0x21, - 0x6f, 0xe3, 0x06, 0x97, 0xed, 0x17, 0x44, 0xb6, 0xf1, 0x11, 0x91, 0xed, 0x08, 0x1f, 0xeb, 0x5f, - 0xac, 0x4e, 0x52, 0x2a, 0xfd, 0x80, 0x1c, 0x8d, 0x00, 0x9f, 0x51, 0x29, 0x49, 0x4c, 0x03, 0x93, - 0x0b, 0x6d, 0xc1, 0xcb, 0x92, 0x77, 0x45, 0x48, 0x9b, 0x29, 0x17, 0x2a, 0xbf, 0x3c, 0x64, 0x0c, - 0xa0, 0x39, 0xda, 0xe5, 0x42, 0xa1, 0x12, 0xdc, 0xb4, 0x82, 0xf0, 0x90, 0x30, 0x46, 0x5b, 0xf9, - 0x0b, 0x5a, 0x73, 0xc5, 0x9c, 0x36, 0xcc, 0xa1, 0xb7, 0x03, 0xaf, 0x4d, 0x21, 0xdb, 0xf2, 0x0b, - 0xf0, 0xa2, 0xf6, 0x69, 0x26, 0x91, 0xc6, 0x5e, 0x09, 0xd6, 0xf5, 0xfb, 0xd3, 0xc8, 0xeb, 0x40, - 0x67, 0x22, 0x62, 0x84, 0xf7, 0x3f, 0x8b, 0xf5, 0x52, 0xfb, 0x5f, 0xce, 0x5a, 0x5a, 0xd8, 0x3d, - 0xb8, 0x12, 0x11, 0x45, 0xce, 0xc7, 0x52, 0xa7, 0xf2, 0x1e, 0xc2, 0xfc, 0x74, 0x5b, 0xba, 0xad, - 0xbf, 0x25, 0xce, 0xe9, 0x0d, 0x83, 0x85, 0x8c, 0xb0, 0x19, 0xcc, 0xe5, 0x73, 0xc3, 0xac, 0xfd, - 0x5e, 0x81, 0xab, 0xda, 0x10, 0x7d, 0x00, 0xf0, 0xea, 0xcc, 0x2c, 0xa3, 0xaa, 0x9f, 0xb5, 0x68, - 0xfe, 0x9c, 0xb5, 0x70, 0x6a, 0x67, 0x09, 0x31, 0x75, 0x79, 0xfe, 0xab, 0xaf, 0x3f, 0xdf, 0x2e, - 0x97, 0xd1, 0x1d, 0x9c, 0xb9, 0xf9, 0xa1, 0x0d, 0x6b, 0xda, 0x35, 0x41, 0xaf, 0x01, 0x5c, 0x33, - 0x0d, 0x42, 0xe5, 0x39, 0x76, 0x53, 0x4b, 0xe4, 0xdc, 0x5b, 0x40, 0x69, 0x79, 0x6e, 0x6b, 0x1e, - 0x17, 0x15, 0xb3, 0x79, 0xcc, 0x13, 0x7a, 0x0f, 0xe0, 0xe6, 0xf4, 0x3c, 0xa1, 0x9d, 0x7f, 0x7a, - 0xcc, 0x4c, 0xbb, 0x53, 0x3d, 0x43, 0x84, 0xa5, 0xab, 0x68, 0xba, 0xbb, 0xa8, 0x34, 0x8f, 0xae, - 0x39, 0x6a, 0x1a, 0x7a, 0x07, 0xe0, 0xc6, 0xe4, 0x34, 0x21, 0x7f, 0x91, 0x46, 0x8c, 0xa7, 0xd5, - 0xc1, 0x0b, 0xeb, 0x2d, 0xe0, 0x7d, 0x0d, 0x58, 0x42, 0xb7, 0xe6, 0x02, 0x0a, 0x1d, 0x54, 0x8f, - 0x3f, 0xf7, 0x5d, 0x70, 0xda, 0x77, 0xc1, 0x8f, 0xbe, 0x0b, 0xde, 0x0c, 0xdc, 0xa5, 0xd3, 0x81, - 0xbb, 0xf4, 0x6d, 0xe0, 0x2e, 0xc1, 0xeb, 0x09, 0xcf, 0x74, 0xde, 0x05, 0x2f, 0x6b, 0x13, 0x63, - 0x3f, 0x96, 0x54, 0x12, 0x3e, 0xe9, 0x78, 0x3c, 0xf2, 0xd4, 0x2b, 0x70, 0xb0, 0xa6, 0xbf, 0xea, - 0x0f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x29, 0x91, 0xe8, 0x44, 0x5e, 0x06, 0x00, 0x00, + // 507 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0xeb, 0xb1, 0x31, 0xb0, 0x26, 0x90, 0xac, 0x4a, 0xb4, 0x61, 0x84, 0x29, 0x68, 0x30, + 0x09, 0xd5, 0xa6, 0x45, 0x1c, 0x38, 0x70, 0xa0, 0x3b, 0x71, 0x40, 0xb0, 0xec, 0x80, 0xc4, 0xa5, + 0xf2, 0x12, 0x2b, 0x44, 0x6a, 0xfc, 0xa5, 0xb1, 0xdb, 0x6d, 0x57, 0x9e, 0x00, 0x89, 0x2b, 0x47, + 0x0e, 0x3c, 0x00, 0x0f, 0xc1, 0x71, 0x82, 0x0b, 0x27, 0x84, 0x5a, 0x1e, 0x02, 0x71, 0x42, 0xb3, + 0x1d, 0x96, 0x55, 0x51, 0xd9, 0xa4, 0x9d, 0x6a, 0xd7, 0xff, 0xef, 0xfb, 0xfd, 0xbf, 0xf8, 0x9f, + 0xe0, 0x8d, 0xbc, 0x80, 0x89, 0x90, 0x5c, 0x46, 0x82, 0x41, 0xc1, 0xa3, 0xa1, 0x60, 0x93, 0x2e, + 0x1b, 0x8d, 0x45, 0x71, 0x48, 0xf3, 0x02, 0x34, 0x90, 0xe6, 0x89, 0x82, 0x5a, 0x05, 0x9d, 0x74, + 0xbd, 0x66, 0x02, 0x09, 0x18, 0x01, 0x3b, 0x5e, 0x59, 0xad, 0xb7, 0x9e, 0x00, 0x24, 0x43, 0xc1, + 0x78, 0x9e, 0x32, 0x2e, 0x25, 0x68, 0xae, 0x53, 0x90, 0xca, 0x9d, 0xb6, 0x23, 0x50, 0x19, 0xa8, + 0x81, 0x2d, 0xb3, 0x1b, 0x7b, 0x14, 0xdc, 0xc2, 0x37, 0x77, 0x8e, 0x99, 0xdb, 0x20, 0x75, 0xc1, + 0x23, 0xfd, 0x34, 0x8e, 0x0b, 0xa1, 0x54, 0x28, 0x46, 0x63, 0xa1, 0x74, 0x10, 0xe2, 0xf5, 0xfa, + 0x63, 0x95, 0x83, 0x54, 0x82, 0xf4, 0xf0, 0x2a, 0xb7, 0x7f, 0xb5, 0xd0, 0x06, 0xda, 0xba, 0xda, + 0x6f, 0x7d, 0xfd, 0xdc, 0x69, 0x3a, 0x82, 0x13, 0xef, 0xea, 0x22, 0x95, 0x49, 0x58, 0x0a, 0x83, + 0x11, 0xf6, 0x4c, 0xcf, 0x17, 0x66, 0xa6, 0xb2, 0xb3, 0x23, 0x92, 0x5d, 0xbc, 0x62, 0x1e, 0x82, + 0xe9, 0xb7, 0xd6, 0x7f, 0xf2, 0xe7, 0xc7, 0xed, 0xc7, 0x49, 0xaa, 0xdf, 0x8c, 0xf7, 0x68, 0x04, + 0x19, 0xdb, 0x06, 0x95, 0xbd, 0xe2, 0x2a, 0x63, 0xfb, 0x5c, 0x65, 0x31, 0x3b, 0x30, 0xbf, 0x4c, + 0x1f, 0xe6, 0x42, 0xd1, 0x90, 0xef, 0x97, 0xdd, 0x9e, 0x0b, 0xa5, 0x78, 0x22, 0x42, 0xdb, 0x2b, + 0xc8, 0xdd, 0x94, 0xf3, 0x48, 0x37, 0xc5, 0x0e, 0x5e, 0x8e, 0xb9, 0xe6, 0x17, 0x83, 0x34, 0xad, + 0x82, 0x47, 0xb8, 0x55, 0x21, 0x86, 0x42, 0x8d, 0x87, 0xff, 0x46, 0x6c, 0xe3, 0x2b, 0xc6, 0xd6, + 0x20, 0x8d, 0x0d, 0x72, 0x39, 0x5c, 0x35, 0xfb, 0x67, 0x71, 0x20, 0x71, 0xbb, 0xa6, 0x6c, 0xce, + 0xe6, 0xd2, 0x85, 0xd9, 0xec, 0xfd, 0xbe, 0x84, 0x57, 0x0c, 0x90, 0x7c, 0x42, 0xf8, 0xfa, 0xdc, + 0x2d, 0x93, 0x2e, 0xad, 0x8b, 0x20, 0x5d, 0x10, 0x18, 0xaf, 0x77, 0x9e, 0x12, 0x3b, 0x57, 0x40, + 0xdf, 0x7e, 0xfb, 0xf5, 0x7e, 0x69, 0x8b, 0xdc, 0x65, 0xb5, 0xef, 0x44, 0xe4, 0xca, 0x06, 0x2e, + 0x40, 0xe4, 0x23, 0xc2, 0xd7, 0x4e, 0xdf, 0x24, 0x79, 0xb0, 0x00, 0x5b, 0x9b, 0x33, 0xaf, 0x7b, + 0x8e, 0x0a, 0xe7, 0xb3, 0x63, 0x7c, 0xde, 0x23, 0x9b, 0xf5, 0x3e, 0xed, 0x6a, 0x50, 0xda, 0x25, + 0x1f, 0x10, 0x5e, 0xab, 0xde, 0x23, 0xa1, 0xff, 0x45, 0x9e, 0xca, 0x89, 0xc7, 0xce, 0xac, 0x77, + 0x06, 0xef, 0x1b, 0x83, 0x9b, 0xe4, 0xce, 0x42, 0x83, 0x85, 0x29, 0xea, 0x27, 0x5f, 0xa6, 0x3e, + 0x3a, 0x9a, 0xfa, 0xe8, 0xe7, 0xd4, 0x47, 0xef, 0x66, 0x7e, 0xe3, 0x68, 0xe6, 0x37, 0xbe, 0xcf, + 0xfc, 0x06, 0xbe, 0x91, 0x42, 0x2d, 0xf9, 0x25, 0x7a, 0xdd, 0xab, 0x04, 0xee, 0x44, 0xd2, 0x49, + 0xa1, 0x4a, 0x3c, 0x28, 0x99, 0x26, 0x7c, 0x7b, 0x97, 0xcd, 0x97, 0xe6, 0xe1, 0xdf, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xd7, 0x3f, 0xbc, 0x19, 0xf2, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -476,8 +359,6 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // ContractAddress returns the address of the oracle's contract ContractAddress(ctx context.Context, in *QueryContractAddressRequest, opts ...grpc.CallOption) (*QueryContractAddressResponse, error) - // Oracle sends an icq to an oracle on another chain - Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) // OracleContract sends a query to the oracle's contract OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) // OracleResult returns the address of the oracle's contract @@ -501,15 +382,6 @@ func (c *queryClient) ContractAddress(ctx context.Context, in *QueryContractAddr return out, nil } -func (c *queryClient) Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) { - out := new(QueryOracleResponse) - err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/Oracle", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) { out := new(QueryOracleContractResponse) err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/OracleContract", in, out, opts...) @@ -532,8 +404,6 @@ func (c *queryClient) OracleResult(ctx context.Context, in *QueryOracleResultReq type QueryServer interface { // ContractAddress returns the address of the oracle's contract ContractAddress(context.Context, *QueryContractAddressRequest) (*QueryContractAddressResponse, error) - // Oracle sends an icq to an oracle on another chain - Oracle(context.Context, *QueryOracleRequest) (*QueryOracleResponse, error) // OracleContract sends a query to the oracle's contract OracleContract(context.Context, *QueryOracleContractRequest) (*QueryOracleContractResponse, error) // OracleResult returns the address of the oracle's contract @@ -547,9 +417,6 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) ContractAddress(ctx context.Context, req *QueryContractAddressRequest) (*QueryContractAddressResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ContractAddress not implemented") } -func (*UnimplementedQueryServer) Oracle(ctx context.Context, req *QueryOracleRequest) (*QueryOracleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Oracle not implemented") -} func (*UnimplementedQueryServer) OracleContract(ctx context.Context, req *QueryOracleContractRequest) (*QueryOracleContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OracleContract not implemented") } @@ -579,24 +446,6 @@ func _Query_ContractAddress_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } -func _Query_Oracle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOracleRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Oracle(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/provenance.oracle.v1.Query/Oracle", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Oracle(ctx, req.(*QueryOracleRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_OracleContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryOracleContractRequest) if err := dec(in); err != nil { @@ -641,10 +490,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ContractAddress", Handler: _Query_ContractAddress_Handler, }, - { - MethodName: "Oracle", - Handler: _Query_Oracle_Handler, - }, { MethodName: "OracleContract", Handler: _Query_OracleContract_Handler, @@ -711,78 +556,6 @@ func (m *QueryContractAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryOracleRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryOracleRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SourceChannel) > 0 { - i -= len(m.SourceChannel) - copy(dAtA[i:], m.SourceChannel) - i = encodeVarintQuery(dAtA, i, uint64(len(m.SourceChannel))) - i-- - dAtA[i] = 0x1a - } - if len(m.SourcePort) > 0 { - i -= len(m.SourcePort) - copy(dAtA[i:], m.SourcePort) - i = encodeVarintQuery(dAtA, i, uint64(len(m.SourcePort))) - i-- - dAtA[i] = 0x12 - } - if len(m.Query) > 0 { - i -= len(m.Query) - copy(dAtA[i:], m.Query) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Query))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryOracleResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryOracleResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QueryId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QueryId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *QueryOracleContractRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -934,39 +707,6 @@ func (m *QueryContractAddressResponse) Size() (n int) { return n } -func (m *QueryOracleRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Query) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.SourcePort) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.SourceChannel) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryOracleResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QueryId != 0 { - n += 1 + sovQuery(uint64(m.QueryId)) - } - return n -} - func (m *QueryOracleContractRequest) Size() (n int) { if m == nil { return 0 @@ -1156,223 +896,6 @@ func (m *QueryContractAddressResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOracleRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryOracleRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) - if m.Query == nil { - m.Query = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourcePort", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SourcePort = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SourceChannel = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryOracleResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryOracleResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOracleResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) - } - m.QueryId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryOracleContractRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 21c594d9f2..891be2f546 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -49,42 +49,6 @@ func local_request_Query_ContractAddress_0(ctx context.Context, marshaler runtim } -var ( - filter_Query_Oracle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Oracle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOracleRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Oracle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Oracle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Oracle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOracleRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Oracle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Oracle(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_OracleContract_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -183,26 +147,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_Oracle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Oracle_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Oracle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_OracleContract_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -304,26 +248,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_Oracle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Oracle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Oracle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_OracleContract_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -370,8 +294,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_ContractAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "contract_address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Oracle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"provenance", "oracle", "v1"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_OracleContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_contract"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_OracleResult_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_result"}, "", runtime.AssumeColonVerbOpt(false))) @@ -380,8 +302,6 @@ var ( var ( forward_Query_ContractAddress_0 = runtime.ForwardResponseMessage - forward_Query_Oracle_0 = runtime.ForwardResponseMessage - forward_Query_OracleContract_0 = runtime.ForwardResponseMessage forward_Query_OracleResult_0 = runtime.ForwardResponseMessage diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 39b1dfaae6..7e31e3430a 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -29,6 +30,116 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgQueryOracleRequest queries an Oracle on another chain +type MsgQueryOracleRequest struct { + // Query contains the query data passed to the oracle. + Query github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=query,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"query,omitempty"` + // Source port is the source port to the oracle. + SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` + // Source channel is the channel to the oracle. + SourceChannel string `protobuf:"bytes,3,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` +} + +func (m *MsgQueryOracleRequest) Reset() { *m = MsgQueryOracleRequest{} } +func (m *MsgQueryOracleRequest) String() string { return proto.CompactTextString(m) } +func (*MsgQueryOracleRequest) ProtoMessage() {} +func (*MsgQueryOracleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_66a39dda41c6a784, []int{0} +} +func (m *MsgQueryOracleRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgQueryOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgQueryOracleRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgQueryOracleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgQueryOracleRequest.Merge(m, src) +} +func (m *MsgQueryOracleRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgQueryOracleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgQueryOracleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgQueryOracleRequest proto.InternalMessageInfo + +func (m *MsgQueryOracleRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { + if m != nil { + return m.Query + } + return nil +} + +func (m *MsgQueryOracleRequest) GetSourcePort() string { + if m != nil { + return m.SourcePort + } + return "" +} + +func (m *MsgQueryOracleRequest) GetSourceChannel() string { + if m != nil { + return m.SourceChannel + } + return "" +} + +// MsgQueryOracleResponse contains the id of the oracle query. +type MsgQueryOracleResponse struct { + // The id that uniquely identifies the query. + QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` +} + +func (m *MsgQueryOracleResponse) Reset() { *m = MsgQueryOracleResponse{} } +func (m *MsgQueryOracleResponse) String() string { return proto.CompactTextString(m) } +func (*MsgQueryOracleResponse) ProtoMessage() {} +func (*MsgQueryOracleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_66a39dda41c6a784, []int{1} +} +func (m *MsgQueryOracleResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgQueryOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgQueryOracleResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgQueryOracleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgQueryOracleResponse.Merge(m, src) +} +func (m *MsgQueryOracleResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgQueryOracleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgQueryOracleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgQueryOracleResponse proto.InternalMessageInfo + +func (m *MsgQueryOracleResponse) GetQueryId() uint64 { + if m != nil { + return m.QueryId + } + return 0 +} + // MsgUpdateOracleRequest is the request type for updating an oracle's contract address type MsgUpdateOracleRequest struct { // The address of the oracle's contract @@ -41,7 +152,7 @@ func (m *MsgUpdateOracleRequest) Reset() { *m = MsgUpdateOracleRequest{} func (m *MsgUpdateOracleRequest) String() string { return proto.CompactTextString(m) } func (*MsgUpdateOracleRequest) ProtoMessage() {} func (*MsgUpdateOracleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{0} + return fileDescriptor_66a39dda41c6a784, []int{2} } func (m *MsgUpdateOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -92,7 +203,7 @@ func (m *MsgUpdateOracleResponse) Reset() { *m = MsgUpdateOracleResponse func (m *MsgUpdateOracleResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateOracleResponse) ProtoMessage() {} func (*MsgUpdateOracleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{1} + return fileDescriptor_66a39dda41c6a784, []int{3} } func (m *MsgUpdateOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -122,6 +233,8 @@ func (m *MsgUpdateOracleResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateOracleResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgQueryOracleRequest)(nil), "provenance.oracle.v1.MsgQueryOracleRequest") + proto.RegisterType((*MsgQueryOracleResponse)(nil), "provenance.oracle.v1.MsgQueryOracleResponse") proto.RegisterType((*MsgUpdateOracleRequest)(nil), "provenance.oracle.v1.MsgUpdateOracleRequest") proto.RegisterType((*MsgUpdateOracleResponse)(nil), "provenance.oracle.v1.MsgUpdateOracleResponse") } @@ -129,26 +242,36 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/tx.proto", fileDescriptor_66a39dda41c6a784) } var fileDescriptor_66a39dda41c6a784 = []byte{ - // 295 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x28, 0xca, 0x2f, - 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, - 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0x48, 0xeb, 0x41, 0xa4, - 0xf5, 0xca, 0x0c, 0xa5, 0x24, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xe3, 0xc1, 0x6a, 0xf4, 0x21, - 0x1c, 0x88, 0x06, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x88, 0x38, 0x88, 0x05, 0x11, 0x55, 0xea, - 0x63, 0xe4, 0x12, 0xf3, 0x2d, 0x4e, 0x0f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xf5, 0x07, 0x9b, 0x13, - 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x22, 0x64, 0xc4, 0xc5, 0x9e, 0x98, 0x92, 0x52, 0x94, 0x5a, - 0x5c, 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0x71, 0x69, 0x8b, 0xae, 0x08, 0xd4, 0x4c, - 0x47, 0x88, 0x4c, 0x70, 0x49, 0x51, 0x66, 0x5e, 0x7a, 0x10, 0x4c, 0xa1, 0x90, 0x19, 0x17, 0x67, - 0x62, 0x69, 0x49, 0x46, 0x7e, 0x51, 0x66, 0x49, 0xa5, 0x04, 0x13, 0x01, 0x5d, 0x08, 0xa5, 0x56, - 0x1c, 0x33, 0x16, 0xc8, 0x33, 0xbe, 0x58, 0x20, 0xcf, 0xa8, 0x24, 0xc9, 0x25, 0x8e, 0xe1, 0x9e, - 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa3, 0x22, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x6c, 0x2e, - 0x1e, 0x64, 0x69, 0x21, 0x1d, 0x3d, 0x6c, 0x41, 0xa1, 0x87, 0xdd, 0x57, 0x52, 0xba, 0x44, 0xaa, - 0x86, 0xd8, 0xe9, 0x94, 0x7e, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, - 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, 0xe2, - 0x99, 0xf9, 0x58, 0x8d, 0x0a, 0x60, 0x8c, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, - 0xce, 0xcf, 0xd5, 0x47, 0x28, 0xd1, 0xcd, 0xcc, 0x47, 0xe2, 0xe9, 0x57, 0xc0, 0x62, 0xb5, 0xa4, - 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x1f, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x09, - 0xc3, 0xcb, 0xba, 0xf7, 0x01, 0x00, 0x00, + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x4f, 0x6b, 0x13, 0x41, + 0x14, 0xcf, 0x58, 0xb5, 0xcd, 0xb4, 0x7a, 0x18, 0xa2, 0x4d, 0x02, 0x6e, 0x4a, 0x40, 0x28, 0xd8, + 0xec, 0xd0, 0x14, 0x04, 0x05, 0x0f, 0x26, 0x27, 0x0f, 0xc1, 0xba, 0x45, 0x04, 0x2f, 0x61, 0xba, + 0x3b, 0xcc, 0x2e, 0x76, 0xf7, 0x6d, 0xe7, 0xcd, 0xa6, 0xc9, 0x97, 0x10, 0x8f, 0x1e, 0xfb, 0x21, + 0xfa, 0x21, 0x3c, 0x16, 0x4f, 0x1e, 0x44, 0x24, 0xb9, 0xf8, 0x19, 0x3c, 0x49, 0x67, 0x52, 0xb2, + 0xda, 0x58, 0x7a, 0xda, 0x7d, 0xbf, 0xf7, 0xfb, 0xbd, 0x7f, 0xfb, 0x5b, 0xfa, 0x28, 0xd7, 0x30, + 0x92, 0x99, 0xc8, 0x42, 0xc9, 0x41, 0x8b, 0xf0, 0x48, 0xf2, 0xd1, 0x2e, 0x37, 0x63, 0x3f, 0xd7, + 0x60, 0x80, 0xd5, 0x16, 0x69, 0xdf, 0xa5, 0xfd, 0xd1, 0x6e, 0xb3, 0x11, 0x02, 0xa6, 0x80, 0x43, + 0xcb, 0xe1, 0x2e, 0x70, 0x82, 0x66, 0x4d, 0x81, 0x02, 0x87, 0x5f, 0xbc, 0x39, 0xb4, 0x7d, 0x46, + 0xe8, 0x83, 0x01, 0xaa, 0x37, 0x85, 0xd4, 0x93, 0xd7, 0xb6, 0x4c, 0x20, 0x8f, 0x0b, 0x89, 0x86, + 0x1d, 0xd0, 0x3b, 0xc7, 0x17, 0x68, 0x9d, 0x6c, 0x91, 0xed, 0x8d, 0xde, 0x8b, 0xdf, 0x3f, 0x5a, + 0xcf, 0x54, 0x62, 0xe2, 0xe2, 0xd0, 0x0f, 0x21, 0xe5, 0x7d, 0xc0, 0xf4, 0x9d, 0xc0, 0x94, 0x9f, + 0x08, 0x4c, 0x23, 0x3e, 0xb6, 0x4f, 0x6e, 0x26, 0xb9, 0x44, 0x3f, 0x10, 0x27, 0x7d, 0xc8, 0x8c, + 0x16, 0xa1, 0x19, 0x48, 0x44, 0xa1, 0x64, 0xe0, 0x6a, 0xb1, 0x16, 0x5d, 0x47, 0x28, 0x74, 0x28, + 0x87, 0x39, 0x68, 0x53, 0xbf, 0xb5, 0x45, 0xb6, 0xab, 0x01, 0x75, 0xd0, 0x3e, 0x68, 0xc3, 0x1e, + 0xd3, 0xfb, 0x73, 0x42, 0x18, 0x8b, 0x2c, 0x93, 0x47, 0xf5, 0x15, 0xcb, 0xb9, 0xe7, 0xd0, 0xbe, + 0x03, 0xdb, 0x7b, 0xf4, 0xe1, 0xbf, 0x53, 0x63, 0x0e, 0x19, 0x4a, 0xd6, 0xa0, 0x6b, 0xb6, 0xd5, + 0x30, 0x89, 0xec, 0xe4, 0xb7, 0x83, 0x55, 0x1b, 0xbf, 0x8a, 0xda, 0x1f, 0x89, 0x55, 0xbd, 0xcd, + 0x23, 0x61, 0xe4, 0xdf, 0xcb, 0x76, 0xe9, 0xaa, 0x88, 0x22, 0x2d, 0x11, 0xad, 0xa8, 0xda, 0xab, + 0x7f, 0x3d, 0xeb, 0xd4, 0xe6, 0xf7, 0x7b, 0xe9, 0x32, 0x07, 0x46, 0x27, 0x99, 0x0a, 0x2e, 0x89, + 0xec, 0x29, 0xad, 0x8a, 0xc2, 0xc4, 0xa0, 0x13, 0x33, 0x71, 0x9b, 0x5c, 0xa3, 0x5a, 0x50, 0x9f, + 0xaf, 0x7d, 0x3e, 0x6d, 0x91, 0x5f, 0xa7, 0x2d, 0xd2, 0x6e, 0xd0, 0xcd, 0x2b, 0xf3, 0xb8, 0x35, + 0xba, 0xdf, 0x09, 0x5d, 0x19, 0xa0, 0x62, 0x1f, 0xe8, 0x46, 0x39, 0xcf, 0x76, 0xfc, 0x65, 0xdf, + 0xdd, 0x5f, 0xbe, 0x56, 0xb3, 0x73, 0x43, 0xf6, 0xfc, 0x76, 0x31, 0x5d, 0x2f, 0x9d, 0x94, 0x3d, + 0xf9, 0xaf, 0xfa, 0xaa, 0x5d, 0x9a, 0x3b, 0x37, 0x23, 0xbb, 0x4e, 0x3d, 0xf5, 0x65, 0xea, 0x91, + 0xf3, 0xa9, 0x47, 0x7e, 0x4e, 0x3d, 0xf2, 0x69, 0xe6, 0x55, 0xce, 0x67, 0x5e, 0xe5, 0xdb, 0xcc, + 0xab, 0xd0, 0xcd, 0x04, 0x96, 0x56, 0xda, 0x27, 0xef, 0xbb, 0x25, 0xfb, 0x2d, 0x28, 0x9d, 0x04, + 0x4a, 0x11, 0x1f, 0x5f, 0xfe, 0x2c, 0xd6, 0x8a, 0x87, 0x77, 0xad, 0xcd, 0xf7, 0xfe, 0x04, 0x00, + 0x00, 0xff, 0xff, 0xa7, 0x1d, 0x74, 0xfb, 0x4e, 0x03, 0x00, 0x00, } func (this *MsgUpdateOracleRequest) Equal(that interface{}) bool { @@ -193,6 +316,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // UpdateOracle is the RPC endpoint for updating the oracle UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest, opts ...grpc.CallOption) (*MsgUpdateOracleResponse, error) + // QueryOracle sends an icq to an oracle on another chain + QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, opts ...grpc.CallOption) (*MsgQueryOracleResponse, error) } type msgClient struct { @@ -212,10 +337,21 @@ func (c *msgClient) UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest return out, nil } +func (c *msgClient) QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, opts ...grpc.CallOption) (*MsgQueryOracleResponse, error) { + out := new(MsgQueryOracleResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Msg/QueryOracle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateOracle is the RPC endpoint for updating the oracle UpdateOracle(context.Context, *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) + // QueryOracle sends an icq to an oracle on another chain + QueryOracle(context.Context, *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -225,6 +361,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateOracle(ctx context.Context, req *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateOracle not implemented") } +func (*UnimplementedMsgServer) QueryOracle(ctx context.Context, req *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryOracle not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -248,6 +387,24 @@ func _Msg_UpdateOracle_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_QueryOracle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgQueryOracleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).QueryOracle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Msg/QueryOracle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).QueryOracle(ctx, req.(*MsgQueryOracleRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "provenance.oracle.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -256,11 +413,87 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateOracle", Handler: _Msg_UpdateOracle_Handler, }, + { + MethodName: "QueryOracle", + Handler: _Msg_QueryOracle_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/oracle/v1/tx.proto", } +func (m *MsgQueryOracleRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgQueryOracleRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgQueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0x12 + } + if len(m.Query) > 0 { + i -= len(m.Query) + copy(dAtA[i:], m.Query) + i = encodeVarintTx(dAtA, i, uint64(len(m.Query))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgQueryOracleResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgQueryOracleResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgQueryOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.QueryId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *MsgUpdateOracleRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -332,6 +565,39 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgQueryOracleRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Query) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SourceChannel) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgQueryOracleResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.QueryId != 0 { + n += 1 + sovTx(uint64(m.QueryId)) + } + return n +} + func (m *MsgUpdateOracleRequest) Size() (n int) { if m == nil { return 0 @@ -364,6 +630,223 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgQueryOracleRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgQueryOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) + if m.Query == nil { + m.Query = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourcePort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgQueryOracleResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgQueryOracleResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgQueryOracleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + } + m.QueryId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgUpdateOracleRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 457dae2001d7870d17cda308deaa59a7e87e6e26 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 28 Jul 2023 16:22:42 -0400 Subject: [PATCH 08/96] Added some more stuff from the example ICQ Controller created by Quasar. Haven't gotten to the ibc or query part yet. Still need to verify if everything is needed and why. --- app/app.go | 15 +- docs/proto-docs.md | 31 +++ proto/provenance/oracle/v1/genesis.proto | 5 + proto/provenance/oracle/v1/params.proto | 14 ++ x/oracle/keeper/genesis.go | 8 +- x/oracle/keeper/keeper.go | 83 ++++++- x/oracle/keeper/params.go | 16 ++ x/oracle/keeper/query.go | 6 +- x/oracle/types/expected_keepers.go | 32 +++ x/oracle/types/genesis.go | 18 +- x/oracle/types/genesis.pb.go | 116 +++++++++- x/oracle/types/keys.go | 22 ++ x/oracle/types/params.go | 39 ++++ x/oracle/types/params.pb.go | 265 +++++++++++++++++++++++ 14 files changed, 640 insertions(+), 30 deletions(-) create mode 100644 proto/provenance/oracle/v1/params.proto create mode 100644 x/oracle/keeper/params.go create mode 100644 x/oracle/types/expected_keepers.go create mode 100644 x/oracle/types/params.go create mode 100644 x/oracle/types/params.pb.go diff --git a/app/app.go b/app/app.go index 821506ef1f..2a77a06fc3 100644 --- a/app/app.go +++ b/app/app.go @@ -312,6 +312,7 @@ type App struct { ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper ScopedICQKeeper capabilitykeeper.ScopedKeeper + ScopedOracleKeeper capabilitykeeper.ScopedKeeper // the module manager mm *module.Manager @@ -517,7 +518,19 @@ func New( ) icqModule := icq.NewAppModule(app.ICQKeeper) icqIBCModule := icq.NewIBCModule(app.ICQKeeper) - app.OracleKeeper = oraclekeeper.NewKeeper(appCodec, keys[oracletypes.StoreKey], app.ICQKeeper) + + scopedOracleKeeper := app.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName) + app.ScopedOracleKeeper = scopedOracleKeeper + app.OracleKeeper = *oraclekeeper.NewKeeper( + appCodec, + keys[oracletypes.StoreKey], + keys[oracletypes.MemStoreKey], + app.GetSubspace(icqtypes.ModuleName), + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + scopedOracleKeeper, + ) // Init CosmWasm module wasmDir := filepath.Join(homePath, "data", "wasm") diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 6bbca98241..61b814d1e2 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -433,6 +433,9 @@ - [provenance/oracle/v1/event.proto](#provenance/oracle/v1/event.proto) - [EventOracleQueryResponse](#provenance.oracle.v1.EventOracleQueryResponse) +- [provenance/oracle/v1/params.proto](#provenance/oracle/v1/params.proto) + - [Params](#provenance.oracle.v1.Params) + - [provenance/oracle/v1/genesis.proto](#provenance/oracle/v1/genesis.proto) - [GenesisState](#provenance.oracle.v1.GenesisState) @@ -6689,6 +6692,32 @@ EventOracleQueryResponse is an event for when the chain receives a response from + + + + + + + + + + + +

Top

+ +## provenance/oracle/v1/params.proto + + + + + +### Params +Params defines the parameters for the module. + + + + + @@ -6715,6 +6744,8 @@ GenesisState defines the oracle module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `query_id` | [uint64](#uint64) | | Query id is the next auto incremented id to be assigned to the next query | +| `params` | [Params](#provenance.oracle.v1.Params) | | Params | +| `port_id` | [string](#string) | | The port to assign to the module | diff --git a/proto/provenance/oracle/v1/genesis.proto b/proto/provenance/oracle/v1/genesis.proto index 42f143c807..b03e7700b3 100644 --- a/proto/provenance/oracle/v1/genesis.proto +++ b/proto/provenance/oracle/v1/genesis.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package provenance.oracle.v1; import "gogoproto/gogo.proto"; +import "provenance/oracle/v1/params.proto"; option go_package = "github.com/provenance-io/provenance/x/oracle/types"; option java_package = "io.provenance.oracle.v1"; @@ -14,4 +15,8 @@ message GenesisState { // Query id is the next auto incremented id to be assigned to the next query uint64 query_id = 1; + // Params + Params params = 2 [(gogoproto.nullable) = false]; + // The port to assign to the module + string port_id = 3; } \ No newline at end of file diff --git a/proto/provenance/oracle/v1/params.proto b/proto/provenance/oracle/v1/params.proto new file mode 100644 index 0000000000..edb16fe947 --- /dev/null +++ b/proto/provenance/oracle/v1/params.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package provenance.oracle.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/provenance-io/provenance/x/oracle/types"; + +option java_package = "io.provenance.oracle.v1"; +option java_multiple_files = true; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; +} \ No newline at end of file diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index ee91326c16..f469e9f2d2 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -11,8 +11,12 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { } // InitGenesis new trigger genesis -func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { - if err := data.Validate(); err != nil { +func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { + k.SetPort(ctx, genState.PortId) + + if err := genState.Validate(); err != nil { panic(err) } + + k.SetParams(ctx, genState.Params) } diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 6bd2e7bca4..d50d43ecd6 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -6,28 +6,89 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" "github.com/provenance-io/provenance/x/oracle/types" - icq "github.com/strangelove-ventures/async-icq/v6/keeper" + + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) type Keeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec - icqKeeper icq.Keeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + + ics4Wrapper types.ICS4Wrapper + channelKeeper types.ChannelKeeper + portKeeper types.PortKeeper + scopedKeeper capabilitykeeper.ScopedKeeper } func NewKeeper( cdc codec.BinaryCodec, - key storetypes.StoreKey, - icqKeeper icq.Keeper, -) Keeper { - return Keeper{ - storeKey: key, - cdc: cdc, - icqKeeper: icqKeeper, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + ics4Wrapper types.ICS4Wrapper, + channelKeeper types.ChannelKeeper, + portKeeper types.PortKeeper, + scopedKeeper capabilitykeeper.ScopedKeeper, +) *Keeper { + + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + storeKey: storeKey, + cdc: cdc, + memKey: memKey, + paramstore: ps, + + ics4Wrapper: ics4Wrapper, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + scopedKeeper: scopedKeeper, } } func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } + +// BindPort stores the provided portID and binds to it, returning the associated capability +func (k Keeper) BindPort(ctx sdk.Context, portID string) error { + cap := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, cap, host.PortPath(portID)) +} + +// IsBound checks if the interchain query already bound to the desired port +func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { + _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) + return ok +} + +// GetPort returns the portID for the transfer module. Used in ExportGenesis +func (k Keeper) GetPort(ctx sdk.Context) string { + store := ctx.KVStore(k.storeKey) + return string(store.Get(types.PortKey)) +} + +// SetPort sets the portID for the transfer module. Used in InitGenesis +func (k Keeper) SetPort(ctx sdk.Context, portID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.PortKey, []byte(portID)) +} + +// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function +func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { + return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) +} + +// ClaimCapability wraps the scopedKeeper's ClaimCapability function +func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, cap, name) +} diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go new file mode 100644 index 0000000000..8af6500235 --- /dev/null +++ b/x/oracle/keeper/params.go @@ -0,0 +1,16 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams() +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go index b1a7e41af6..9808fbd47f 100644 --- a/x/oracle/keeper/query.go +++ b/x/oracle/keeper/query.go @@ -7,9 +7,9 @@ package keeper capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/quasar-finance/interchain-query-demo/x/interquery/types" - icqtypes "github.com/cosmos/ibc-go/v3/modules/apps/icq/types" - clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + icqtypes "github.com/cosmos/ibc-go/v6/modules/apps/icq/types" + clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" abci "github.com/tendermint/tendermint/abci/types" ) diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go new file mode 100644 index 0000000000..66b6fc73da --- /dev/null +++ b/x/oracle/types/expected_keepers.go @@ -0,0 +1,32 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" +) + +// ICS4Wrapper defines the expected ICS4Wrapper for middleware +type ICS4Wrapper interface { + SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + data []byte, + ) (sequence uint64, err error) +} + +type ChannelKeeper interface { + GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) +} + +// PortKeeper defines the expected IBC port keeper +type PortKeeper interface { + BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability + IsBound(ctx sdk.Context, portID string) bool +} diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 8b3b95a8bd..a82d0344a2 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -1,6 +1,10 @@ package types -import fmt "fmt" +import ( + fmt "fmt" + + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" +) func NewGenesisState(queryID uint64) *GenesisState { return &GenesisState{ @@ -10,7 +14,11 @@ func NewGenesisState(queryID uint64) *GenesisState { // DefaultGenesis returns the default trigger genesis state func DefaultGenesis() *GenesisState { - return NewGenesisState(1) + return &GenesisState{ + PortId: PortID, + Params: DefaultParams(), + QueryId: 1, + } } // Validate performs basic genesis state validation returning an error upon any @@ -20,5 +28,9 @@ func (gs GenesisState) Validate() error { return fmt.Errorf("invalid query id") } - return nil + if err := host.PortIdentifierValidator(gs.PortId); err != nil { + return err + } + + return gs.Params.Validate() } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index 6ee62679c2..ea8f6b9a5c 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -27,6 +27,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // Query id is the next auto incremented id to be assigned to the next query QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` + // Params + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` + // The port to assign to the module + PortId string `protobuf:"bytes,3,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -71,20 +75,24 @@ func init() { } var fileDescriptor_f8d8aecd974cfd80 = []byte{ - // 200 bytes of a gzipped FileDescriptorProto + // 263 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, - 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0x95, 0x8c, 0xb9, 0x78, 0xdc, 0x21, 0x9a, 0x83, 0x4b, 0x12, 0x4b, - 0x52, 0x85, 0x24, 0xb9, 0x38, 0x0a, 0x4b, 0x53, 0x8b, 0x2a, 0xe3, 0x33, 0x53, 0x24, 0x18, 0x15, - 0x18, 0x35, 0x58, 0x82, 0xd8, 0xc1, 0x7c, 0xcf, 0x14, 0x2b, 0x8e, 0x8e, 0x05, 0xf2, 0x0c, 0x2f, - 0x16, 0xc8, 0x33, 0x38, 0xa5, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, - 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x03, 0x97, - 0x78, 0x26, 0xd8, 0x60, 0x0c, 0xdb, 0x03, 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, - 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, 0x4a, 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0x30, 0x4f, - 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x1d, 0x69, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0xaa, 0x5e, 0xd7, 0x0d, 0xf6, 0x00, 0x00, 0x00, + 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0xa5, 0x14, 0xb1, 0x9a, 0x57, 0x90, 0x58, 0x94, 0x98, 0x0b, 0x35, + 0x4e, 0xa9, 0x83, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x41, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, 0x24, + 0x17, 0x47, 0x61, 0x69, 0x6a, 0x51, 0x65, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4b, + 0x10, 0x3b, 0x98, 0xef, 0x99, 0x22, 0x64, 0xc5, 0xc5, 0x06, 0xd1, 0x2b, 0xc1, 0xa4, 0xc0, 0xa8, + 0xc1, 0x6d, 0x24, 0xa3, 0x87, 0xcd, 0x2d, 0x7a, 0x01, 0x60, 0x35, 0x4e, 0x2c, 0x27, 0xee, 0xc9, + 0x33, 0x04, 0x41, 0x75, 0x08, 0x89, 0x73, 0xb1, 0x17, 0xe4, 0x17, 0x95, 0x80, 0x4c, 0x65, 0x56, + 0x60, 0xd4, 0xe0, 0x0c, 0x62, 0x03, 0x71, 0x3d, 0x53, 0xac, 0x38, 0x3a, 0x16, 0xc8, 0x33, 0xbc, + 0x58, 0x20, 0xcf, 0xe0, 0x94, 0x7e, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, + 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, + 0xe2, 0x99, 0xf9, 0x58, 0xad, 0x0a, 0x60, 0x8c, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, + 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x28, 0xd1, 0xcd, 0xcc, 0x47, 0xe2, 0xe9, 0x57, 0xc0, 0x7c, 0x5f, + 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, 0xba, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xea, + 0xc2, 0x2b, 0xf1, 0x6f, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -107,6 +115,23 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if m.QueryId != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.QueryId)) i-- @@ -135,6 +160,12 @@ func (m *GenesisState) Size() (n int) { if m.QueryId != 0 { n += 1 + sovGenesis(uint64(m.QueryId)) } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -192,6 +223,71 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 81580b64ac..22873d0f14 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -1,9 +1,31 @@ package types +import ( + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" +) + const ( // ModuleName defines the module name ModuleName = "oracle" // StoreKey is string representation of the store key for marker StoreKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_interquery" + + // Version defines the current version the IBC module supports + Version = icqtypes.Version + + // PortID is the default port id that module binds to + PortID = "oracle" +) + +var ( + // PortKey defines the key to store the port ID in store + PortKey = KeyPrefix("oracle-port-") ) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go new file mode 100644 index 0000000000..357196ad6a --- /dev/null +++ b/x/oracle/types/params.go @@ -0,0 +1,39 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/oracle/types/params.pb.go b/x/oracle/types/params.pb.go new file mode 100644 index 0000000000..c50a7a6feb --- /dev/null +++ b/x/oracle/types/params.pb.go @@ -0,0 +1,265 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: provenance/oracle/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_8b65391c48f11fe8, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "provenance.oracle.v1.Params") +} + +func init() { proto.RegisterFile("provenance/oracle/v1/params.proto", fileDescriptor_8b65391c48f11fe8) } + +var fileDescriptor_8b65391c48f11fe8 = []byte{ + // 166 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0x28, 0xca, 0x2f, + 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, + 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, + 0x28, 0xd1, 0x83, 0x28, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, + 0x07, 0xb1, 0x20, 0x6a, 0x95, 0xf8, 0xb8, 0xd8, 0x02, 0xc0, 0x7a, 0xad, 0x58, 0x66, 0x2c, 0x90, + 0x67, 0x70, 0x4a, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, + 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, 0xf1, 0x4c, + 0xb0, 0x1e, 0x0c, 0x83, 0x03, 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, + 0xf3, 0x73, 0xf5, 0x11, 0x4a, 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0x30, 0xe7, 0x96, 0x54, + 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xed, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x59, + 0xfc, 0x5f, 0xd0, 0x00, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) From 204767ef3bb7603455883945f5cf8bfd0fc20695 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 31 Jul 2023 13:58:41 -0400 Subject: [PATCH 09/96] Added some more functions from quasar and got the setup to build and run. Still needs to be tested and verified that icq works. --- app/app.go | 3 +- docs/proto-docs.md | 1 + proto/provenance/oracle/v1/tx.proto | 2 + x/oracle/keeper/queries.go | 62 ++++++++++ x/oracle/keeper/relay.go | 129 ++++++++++++++++++++ x/oracle/module/module_ibc.go | 176 ++++++++++++++++++++++++++++ x/oracle/types/errors.go | 11 ++ x/oracle/types/events_ibc.go | 13 ++ x/oracle/types/msgs.go | 10 ++ x/oracle/types/queries.go | 30 +++++ x/oracle/types/tx.pb.go | 113 +++++++++++++----- 11 files changed, 519 insertions(+), 31 deletions(-) create mode 100644 x/oracle/keeper/queries.go create mode 100644 x/oracle/keeper/relay.go create mode 100644 x/oracle/module/module_ibc.go create mode 100644 x/oracle/types/errors.go create mode 100644 x/oracle/types/events_ibc.go create mode 100644 x/oracle/types/queries.go diff --git a/app/app.go b/app/app.go index 2a77a06fc3..408368d9e9 100644 --- a/app/app.go +++ b/app/app.go @@ -414,6 +414,7 @@ func New( scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) scopedICQKeeper := app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName) + scopedOracleKeeper := app.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName) // capability keeper must be sealed after scope to module registrations are completed. app.CapabilityKeeper.Seal() @@ -519,7 +520,6 @@ func New( icqModule := icq.NewAppModule(app.ICQKeeper) icqIBCModule := icq.NewIBCModule(app.ICQKeeper) - scopedOracleKeeper := app.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName) app.ScopedOracleKeeper = scopedOracleKeeper app.OracleKeeper = *oraclekeeper.NewKeeper( appCodec, @@ -825,6 +825,7 @@ func New( sanction.ModuleName, icatypes.ModuleName, + icqtypes.ModuleName, wasm.ModuleName, attributetypes.ModuleName, diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 61b814d1e2..228430587c 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -6892,6 +6892,7 @@ MsgQueryOracleRequest queries an Oracle on another chain | `query` | [bytes](#bytes) | | Query contains the query data passed to the oracle. | | `source_port` | [string](#string) | | Source port is the source port to the oracle. | | `source_channel` | [string](#string) | | Source channel is the channel to the oracle. | +| `authority` | [string](#string) | | The signing authority for the request | diff --git a/proto/provenance/oracle/v1/tx.proto b/proto/provenance/oracle/v1/tx.proto index 7db4ad08b3..0f7e3b0d82 100644 --- a/proto/provenance/oracle/v1/tx.proto +++ b/proto/provenance/oracle/v1/tx.proto @@ -24,6 +24,8 @@ message MsgQueryOracleRequest { string source_port = 2; // Source channel is the channel to the oracle. string source_channel = 3; + // The signing authority for the request + string authority = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // MsgQueryOracleResponse contains the id of the oracle query. diff --git a/x/oracle/keeper/queries.go b/x/oracle/keeper/queries.go new file mode 100644 index 0000000000..c8e7d7afa5 --- /dev/null +++ b/x/oracle/keeper/queries.go @@ -0,0 +1,62 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + gogotypes "github.com/gogo/protobuf/types" + "github.com/provenance-io/provenance/x/oracle/types" +) + +// SetQueryRequest saves the query request +func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req banktypes.QueryAllBalancesRequest) { + store := ctx.KVStore(k.storeKey) + store.Set(types.QueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) +} + +// GetQueryRequest returns the query request by packet sequence +func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (banktypes.QueryAllBalancesRequest, error) { + bz := ctx.KVStore(k.storeKey).Get(types.QueryRequestStoreKey(packetSequence)) + if bz == nil { + return banktypes.QueryAllBalancesRequest{}, sdkerrors.Wrapf(types.ErrSample, + "GetQueryRequest: Result for packet sequence %d is not available.", packetSequence, + ) + } + var req banktypes.QueryAllBalancesRequest + k.cdc.MustUnmarshal(bz, &req) + return req, nil +} + +// SetQueryResponse saves the query response +func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp banktypes.QueryAllBalancesResponse) { + store := ctx.KVStore(k.storeKey) + store.Set(types.QueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) +} + +// GetQueryResponse returns the query response by packet sequence +func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (banktypes.QueryAllBalancesResponse, error) { + bz := ctx.KVStore(k.storeKey).Get(types.QueryResponseStoreKey(packetSequence)) + if bz == nil { + return banktypes.QueryAllBalancesResponse{}, sdkerrors.Wrapf(types.ErrSample, + "GetQueryResponse: Result for packet sequence %d is not available.", packetSequence, + ) + } + var resp banktypes.QueryAllBalancesResponse + k.cdc.MustUnmarshal(bz, &resp) + return resp, nil +} + +// GetLastQueryPacketSeq return the id from the last query request +func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { + bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.LastQueryPacketSeqKey)) + uintV := gogotypes.UInt64Value{} + k.cdc.MustUnmarshalLengthPrefixed(bz, &uintV) + return uintV.GetValue() +} + +// SetLastQueryPacketSeq saves the id from the last query request +func (k Keeper) SetLastQueryPacketSeq(ctx sdk.Context, packetSequence uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyPrefix(types.LastQueryPacketSeqKey), + k.cdc.MustMarshalLengthPrefixed(&gogotypes.UInt64Value{Value: packetSequence})) +} diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go new file mode 100644 index 0000000000..3123bdbdaf --- /dev/null +++ b/x/oracle/keeper/relay.go @@ -0,0 +1,129 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/provenance-io/provenance/x/oracle/types" + + clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +func (k Keeper) SendQuery( + ctx sdk.Context, + sourcePort, + sourceChannel string, + chanCap *capabilitytypes.Capability, + reqs []abci.RequestQuery, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, +) (uint64, error) { + sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) + if !found { + return 0, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) + } + + destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() + destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() + + data, err := icqtypes.SerializeCosmosQuery(reqs) + if err != nil { + return 0, sdkerrors.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) +} + +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, sdkerrors.Wrap(err, "invalid interchain query packet data") + } + + // get the next sequence + sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) + if !found { + return 0, sdkerrors.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) OnAcknowledgementPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + ack channeltypes.Acknowledgement, +) error { + switch resp := ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + var ackData icqtypes.InterchainQueryPacketAck + if err := icqtypes.ModuleCdc.UnmarshalJSON(resp.Result, &ackData); err != nil { + return sdkerrors.Wrap(err, "failed to unmarshal interchain query packet ack") + } + resps, err := icqtypes.DeserializeCosmosResponse(ackData.Data) + if err != nil { + return sdkerrors.Wrap(err, "could not deserialize data to cosmos response") + } + + if len(resps) < 1 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") + } + + var r banktypes.QueryAllBalancesResponse + if err := k.cdc.Unmarshal(resps[0].Value, &r); err != nil { + return sdkerrors.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) + } + + k.SetQueryResponse(ctx, modulePacket.Sequence, r) + k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeQueryResult, + sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), + ), + ) + + k.Logger(ctx).Info("interchain query response", "sequence", modulePacket.Sequence, "response", r) + case *channeltypes.Acknowledgement_Error: + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeQueryResult, + sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), + ), + ) + + k.Logger(ctx).Error("interchain query response", "sequence", modulePacket.Sequence, "error", resp.Error) + } + return nil +} diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go new file mode 100644 index 0000000000..33b3ba1e76 --- /dev/null +++ b/x/oracle/module/module_ibc.go @@ -0,0 +1,176 @@ +package oracle + +import ( + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported" + "github.com/provenance-io/provenance/x/oracle/types" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" +) + +// OnChanOpenInit implements the IBCModule interface +func (am AppModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) error { + + // Require portID is the portID module is bound to + boundPort := am.keeper.GetPort(ctx) + if boundPort != portID { + return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + } + + if version != types.Version { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) + } + + // Claim channel capability passed back by IBC module + if err := am.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return err + } + + return nil +} + +// OnChanOpenTry implements the IBCModule interface +func (am AppModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + + // Require portID is the portID module is bound to + boundPort := am.keeper.GetPort(ctx) + if boundPort != portID { + return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + } + + if counterpartyVersion != types.Version { + return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", counterpartyVersion, types.Version) + } + + // Module may have already claimed capability in OnChanOpenInit in the case of crossing hellos + // (ie chainA and chainB both call ChanOpenInit before one of them calls ChanOpenTry) + // If module can already authenticate the capability then module already owns it so we don't need to claim + // Otherwise, module does not have channel capability and we must claim it from IBC + if !am.keeper.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) { + // Only claim channel capability passed back by IBC module if we do not already own it + if err := am.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + } + + return types.Version, nil +} + +// OnChanOpenAck implements the IBCModule interface +func (am AppModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyChannelID string, + counterpartyVersion string, +) error { + if counterpartyVersion != types.Version { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version) + } + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (am AppModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnChanCloseInit implements the IBCModule interface +func (am AppModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // Disallow user-initiated channel closing for channels + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (am AppModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface +func (am AppModule) OnRecvPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrapf(icqtypes.ErrInvalidChannelFlow, "inter-query module can not receive packets")) +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (am AppModule) OnAcknowledgementPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + var ack channeltypes.Acknowledgement + if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet acknowledgement: %v", err) + } + + return am.keeper.OnAcknowledgementPacket(ctx, modulePacket, ack) +} + +// OnTimeoutPacket implements the IBCModule interface +func (am AppModule) OnTimeoutPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + relayer sdk.AccAddress, +) error { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeTimeout, + sdk.NewAttribute(types.AttributeKeySequence, strconv.FormatUint(modulePacket.Sequence, 10)), + ), + ) + + am.keeper.Logger(ctx).Error("Packet timeout", "sequence", modulePacket.Sequence) + + return nil +} + +func (am AppModule) NegotiateAppVersion( + ctx sdk.Context, + order channeltypes.Order, + connectionID string, + portID string, + counterparty channeltypes.Counterparty, + proposedVersion string, +) (version string, err error) { + return proposedVersion, nil +} diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go new file mode 100644 index 0000000000..762d42f1e5 --- /dev/null +++ b/x/oracle/types/errors.go @@ -0,0 +1,11 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrInvalidPacketTimeout = sdkerrors.Register(ModuleName, 1500, "invalid packet timeout") + ErrInvalidVersion = sdkerrors.Register(ModuleName, 1501, "invalid version") +) diff --git a/x/oracle/types/events_ibc.go b/x/oracle/types/events_ibc.go new file mode 100644 index 0000000000..d3c7fc73f6 --- /dev/null +++ b/x/oracle/types/events_ibc.go @@ -0,0 +1,13 @@ +package types + +// IBC events +const ( + EventTypeQueryResult = "query_result" + EventTypeTimeout = "timeout" + // this line is used by starport scaffolding # ibc/packet/event + + AttributeKeyAckSuccess = "success" + AttributeKeyAck = "acknowledgement" + AttributeKeyAckError = "error" + AttributeKeySequence = "sequence" +) diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 2abe47417e..910391d655 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -15,3 +15,13 @@ func (msg MsgUpdateOracleRequest) GetSigners() []sdk.AccAddress { func (msg MsgUpdateOracleRequest) ValidateBasic() error { return nil } + +// GetSigners indicates that the message must have been signed by the parent. +func (msg MsgQueryOracleRequest) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(msg.Authority)} +} + +// ValidateBasic runs stateless validation checks on the message. +func (msg MsgQueryOracleRequest) ValidateBasic() error { + return nil +} diff --git a/x/oracle/types/queries.go b/x/oracle/types/queries.go new file mode 100644 index 0000000000..52288fa615 --- /dev/null +++ b/x/oracle/types/queries.go @@ -0,0 +1,30 @@ +package types + +import "encoding/binary" + +var ( + // QueryResponseStoreKeyPrefix is a prefix for storing request + QueryRequestStoreKeyPrefix = "coin_rates_request" + + // QueryResponseStoreKeyPrefix is a prefix for storing result + QueryResponseStoreKeyPrefix = "coin_rates_response" + + // LastQueryPacketSeqKey is the key for the last packet sequence + LastQueryPacketSeqKey = "coin_rates_last_id" +) + +// QueryRequestStoreKey is a function to generate key for each result in store +func QueryRequestStoreKey(packetSequence uint64) []byte { + return append(KeyPrefix(QueryRequestStoreKeyPrefix), uint64ToBytes(packetSequence)...) +} + +// QueryResponseStoreKey is a function to generate key for each result in store +func QueryResponseStoreKey(packetSequence uint64) []byte { + return append(KeyPrefix(QueryResponseStoreKeyPrefix), uint64ToBytes(packetSequence)...) +} + +func uint64ToBytes(num uint64) []byte { + result := make([]byte, 8) + binary.BigEndian.PutUint64(result, uint64(num)) + return result +} diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 7e31e3430a..87e38e7079 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -38,6 +38,8 @@ type MsgQueryOracleRequest struct { SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` // Source channel is the channel to the oracle. SourceChannel string `protobuf:"bytes,3,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` + // The signing authority for the request + Authority string `protobuf:"bytes,4,opt,name=authority,proto3" json:"authority,omitempty"` } func (m *MsgQueryOracleRequest) Reset() { *m = MsgQueryOracleRequest{} } @@ -94,6 +96,13 @@ func (m *MsgQueryOracleRequest) GetSourceChannel() string { return "" } +func (m *MsgQueryOracleRequest) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + // MsgQueryOracleResponse contains the id of the oracle query. type MsgQueryOracleResponse struct { // The id that uniquely identifies the query. @@ -242,36 +251,37 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/tx.proto", fileDescriptor_66a39dda41c6a784) } var fileDescriptor_66a39dda41c6a784 = []byte{ - // 459 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x4f, 0x6b, 0x13, 0x41, - 0x14, 0xcf, 0x58, 0xb5, 0xcd, 0xb4, 0x7a, 0x18, 0xa2, 0x4d, 0x02, 0x6e, 0x4a, 0x40, 0x28, 0xd8, - 0xec, 0xd0, 0x14, 0x04, 0x05, 0x0f, 0x26, 0x27, 0x0f, 0xc1, 0xba, 0x45, 0x04, 0x2f, 0x61, 0xba, - 0x3b, 0xcc, 0x2e, 0x76, 0xf7, 0x6d, 0xe7, 0xcd, 0xa6, 0xc9, 0x97, 0x10, 0x8f, 0x1e, 0xfb, 0x21, - 0xfa, 0x21, 0x3c, 0x16, 0x4f, 0x1e, 0x44, 0x24, 0xb9, 0xf8, 0x19, 0x3c, 0x49, 0x67, 0x52, 0xb2, - 0xda, 0x58, 0x7a, 0xda, 0x7d, 0xbf, 0xf7, 0xfb, 0xbd, 0x7f, 0xfb, 0x5b, 0xfa, 0x28, 0xd7, 0x30, - 0x92, 0x99, 0xc8, 0x42, 0xc9, 0x41, 0x8b, 0xf0, 0x48, 0xf2, 0xd1, 0x2e, 0x37, 0x63, 0x3f, 0xd7, - 0x60, 0x80, 0xd5, 0x16, 0x69, 0xdf, 0xa5, 0xfd, 0xd1, 0x6e, 0xb3, 0x11, 0x02, 0xa6, 0x80, 0x43, - 0xcb, 0xe1, 0x2e, 0x70, 0x82, 0x66, 0x4d, 0x81, 0x02, 0x87, 0x5f, 0xbc, 0x39, 0xb4, 0x7d, 0x46, - 0xe8, 0x83, 0x01, 0xaa, 0x37, 0x85, 0xd4, 0x93, 0xd7, 0xb6, 0x4c, 0x20, 0x8f, 0x0b, 0x89, 0x86, - 0x1d, 0xd0, 0x3b, 0xc7, 0x17, 0x68, 0x9d, 0x6c, 0x91, 0xed, 0x8d, 0xde, 0x8b, 0xdf, 0x3f, 0x5a, - 0xcf, 0x54, 0x62, 0xe2, 0xe2, 0xd0, 0x0f, 0x21, 0xe5, 0x7d, 0xc0, 0xf4, 0x9d, 0xc0, 0x94, 0x9f, - 0x08, 0x4c, 0x23, 0x3e, 0xb6, 0x4f, 0x6e, 0x26, 0xb9, 0x44, 0x3f, 0x10, 0x27, 0x7d, 0xc8, 0x8c, - 0x16, 0xa1, 0x19, 0x48, 0x44, 0xa1, 0x64, 0xe0, 0x6a, 0xb1, 0x16, 0x5d, 0x47, 0x28, 0x74, 0x28, - 0x87, 0x39, 0x68, 0x53, 0xbf, 0xb5, 0x45, 0xb6, 0xab, 0x01, 0x75, 0xd0, 0x3e, 0x68, 0xc3, 0x1e, - 0xd3, 0xfb, 0x73, 0x42, 0x18, 0x8b, 0x2c, 0x93, 0x47, 0xf5, 0x15, 0xcb, 0xb9, 0xe7, 0xd0, 0xbe, - 0x03, 0xdb, 0x7b, 0xf4, 0xe1, 0xbf, 0x53, 0x63, 0x0e, 0x19, 0x4a, 0xd6, 0xa0, 0x6b, 0xb6, 0xd5, - 0x30, 0x89, 0xec, 0xe4, 0xb7, 0x83, 0x55, 0x1b, 0xbf, 0x8a, 0xda, 0x1f, 0x89, 0x55, 0xbd, 0xcd, - 0x23, 0x61, 0xe4, 0xdf, 0xcb, 0x76, 0xe9, 0xaa, 0x88, 0x22, 0x2d, 0x11, 0xad, 0xa8, 0xda, 0xab, - 0x7f, 0x3d, 0xeb, 0xd4, 0xe6, 0xf7, 0x7b, 0xe9, 0x32, 0x07, 0x46, 0x27, 0x99, 0x0a, 0x2e, 0x89, - 0xec, 0x29, 0xad, 0x8a, 0xc2, 0xc4, 0xa0, 0x13, 0x33, 0x71, 0x9b, 0x5c, 0xa3, 0x5a, 0x50, 0x9f, - 0xaf, 0x7d, 0x3e, 0x6d, 0x91, 0x5f, 0xa7, 0x2d, 0xd2, 0x6e, 0xd0, 0xcd, 0x2b, 0xf3, 0xb8, 0x35, - 0xba, 0xdf, 0x09, 0x5d, 0x19, 0xa0, 0x62, 0x1f, 0xe8, 0x46, 0x39, 0xcf, 0x76, 0xfc, 0x65, 0xdf, - 0xdd, 0x5f, 0xbe, 0x56, 0xb3, 0x73, 0x43, 0xf6, 0xfc, 0x76, 0x31, 0x5d, 0x2f, 0x9d, 0x94, 0x3d, - 0xf9, 0xaf, 0xfa, 0xaa, 0x5d, 0x9a, 0x3b, 0x37, 0x23, 0xbb, 0x4e, 0x3d, 0xf5, 0x65, 0xea, 0x91, - 0xf3, 0xa9, 0x47, 0x7e, 0x4e, 0x3d, 0xf2, 0x69, 0xe6, 0x55, 0xce, 0x67, 0x5e, 0xe5, 0xdb, 0xcc, - 0xab, 0xd0, 0xcd, 0x04, 0x96, 0x56, 0xda, 0x27, 0xef, 0xbb, 0x25, 0xfb, 0x2d, 0x28, 0x9d, 0x04, - 0x4a, 0x11, 0x1f, 0x5f, 0xfe, 0x2c, 0xd6, 0x8a, 0x87, 0x77, 0xad, 0xcd, 0xf7, 0xfe, 0x04, 0x00, - 0x00, 0xff, 0xff, 0xa7, 0x1d, 0x74, 0xfb, 0x4e, 0x03, 0x00, 0x00, + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0xb4, 0xd5, 0xb6, 0xd3, 0xea, 0x61, 0x88, 0x76, 0x13, 0x70, 0x53, 0x02, 0x42, 0xc1, + 0x66, 0x87, 0xa6, 0x20, 0x28, 0x78, 0x30, 0x39, 0x79, 0x08, 0xd6, 0x2d, 0x22, 0x78, 0x09, 0xd3, + 0xdd, 0x61, 0xb2, 0xd8, 0xdd, 0xb7, 0x9d, 0x37, 0x9b, 0x26, 0x7f, 0x42, 0x3c, 0x7a, 0xec, 0x8f, + 0xf0, 0x47, 0x78, 0x2c, 0x9e, 0x3c, 0x88, 0x48, 0x72, 0xf1, 0xe0, 0x2f, 0xf0, 0x24, 0x99, 0x49, + 0x49, 0x6a, 0xa3, 0xe4, 0xb4, 0xfb, 0xbe, 0xf7, 0xbd, 0x37, 0xdf, 0xf7, 0x78, 0x8f, 0x3e, 0xc8, + 0x35, 0xf4, 0x65, 0x26, 0xb2, 0x48, 0x72, 0xd0, 0x22, 0x3a, 0x95, 0xbc, 0x7f, 0xc0, 0xcd, 0x20, + 0xc8, 0x35, 0x18, 0x60, 0xe5, 0x59, 0x3a, 0x70, 0xe9, 0xa0, 0x7f, 0x50, 0xad, 0x44, 0x80, 0x29, + 0x60, 0xd7, 0x72, 0xb8, 0x0b, 0x5c, 0x41, 0xb5, 0xac, 0x40, 0x81, 0xc3, 0x27, 0x7f, 0x0e, 0xad, + 0xff, 0x22, 0xf4, 0x5e, 0x07, 0xd5, 0xab, 0x42, 0xea, 0xe1, 0x4b, 0xdb, 0x26, 0x94, 0x67, 0x85, + 0x44, 0xc3, 0x8e, 0xe9, 0xad, 0xb3, 0x09, 0xea, 0x91, 0x5d, 0xb2, 0xb7, 0xdd, 0x7a, 0xf6, 0xfb, + 0x7b, 0xed, 0x89, 0x4a, 0x4c, 0xaf, 0x38, 0x09, 0x22, 0x48, 0x79, 0x1b, 0x30, 0x7d, 0x23, 0x30, + 0xe5, 0xe7, 0x02, 0xd3, 0x98, 0x0f, 0xec, 0x97, 0x9b, 0x61, 0x2e, 0x31, 0x08, 0xc5, 0x79, 0x1b, + 0x32, 0xa3, 0x45, 0x64, 0x3a, 0x12, 0x51, 0x28, 0x19, 0xba, 0x5e, 0xac, 0x46, 0xb7, 0x10, 0x0a, + 0x1d, 0xc9, 0x6e, 0x0e, 0xda, 0x78, 0x2b, 0xbb, 0x64, 0x6f, 0x33, 0xa4, 0x0e, 0x3a, 0x02, 0x6d, + 0xd8, 0x43, 0x7a, 0x77, 0x4a, 0x88, 0x7a, 0x22, 0xcb, 0xe4, 0xa9, 0xb7, 0x6a, 0x39, 0x77, 0x1c, + 0xda, 0x76, 0x20, 0x7b, 0x4c, 0x37, 0x45, 0x61, 0x7a, 0xa0, 0x13, 0x33, 0xf4, 0xd6, 0x26, 0x8c, + 0x96, 0xf7, 0xe5, 0x53, 0xa3, 0x3c, 0x75, 0xfc, 0x3c, 0x8e, 0xb5, 0x44, 0x3c, 0x36, 0x3a, 0xc9, + 0x54, 0x38, 0xa3, 0xd6, 0x0f, 0xe9, 0xfd, 0xbf, 0xdd, 0x62, 0x0e, 0x19, 0x4a, 0x56, 0xa1, 0x1b, + 0x56, 0x62, 0x37, 0x89, 0xad, 0xe3, 0xb5, 0x70, 0xdd, 0xc6, 0x2f, 0xe2, 0xfa, 0x7b, 0x62, 0xab, + 0x5e, 0xe7, 0xb1, 0x30, 0xf2, 0xfa, 0x90, 0x9a, 0x74, 0x5d, 0xb8, 0xb7, 0x6c, 0xd1, 0xff, 0x54, + 0x5c, 0x11, 0xaf, 0x6b, 0x5f, 0x59, 0x5a, 0xfb, 0xd3, 0x8d, 0x8f, 0x17, 0x35, 0xf2, 0xf3, 0xa2, + 0x46, 0xea, 0x15, 0xba, 0x73, 0x43, 0x8f, 0xb3, 0xd1, 0xfc, 0x46, 0xe8, 0x6a, 0x07, 0x15, 0x7b, + 0x47, 0xb7, 0xe7, 0xf3, 0x6c, 0x3f, 0x58, 0xb4, 0x2f, 0xc1, 0x62, 0x5b, 0xd5, 0xc6, 0x92, 0xec, + 0xe9, 0xec, 0x7a, 0x74, 0x6b, 0x6e, 0xa4, 0xec, 0xd1, 0x3f, 0xab, 0x6f, 0xae, 0x59, 0x75, 0x7f, + 0x39, 0xb2, 0x7b, 0xa9, 0xa5, 0x3e, 0x8f, 0x7c, 0x72, 0x39, 0xf2, 0xc9, 0x8f, 0x91, 0x4f, 0x3e, + 0x8c, 0xfd, 0xd2, 0xe5, 0xd8, 0x2f, 0x7d, 0x1d, 0xfb, 0x25, 0xba, 0x93, 0xc0, 0xc2, 0x4e, 0x47, + 0xe4, 0x6d, 0x73, 0x6e, 0x6d, 0x67, 0x94, 0x46, 0x02, 0x73, 0x11, 0x1f, 0x5c, 0x1d, 0x99, 0x5d, + 0xe1, 0x93, 0xdb, 0xf6, 0x3c, 0x0e, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x68, 0x60, 0x46, + 0x86, 0x03, 0x00, 0x00, } func (this *MsgUpdateOracleRequest) Equal(that interface{}) bool { @@ -442,6 +452,13 @@ func (m *MsgQueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x22 + } if len(m.SourceChannel) > 0 { i -= len(m.SourceChannel) copy(dAtA[i:], m.SourceChannel) @@ -583,6 +600,10 @@ func (m *MsgQueryOracleRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -757,6 +778,38 @@ func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { } m.SourceChannel = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 32faa3e72d2c58fee8edb49da9d55852e48cae5e Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 1 Aug 2023 15:02:22 -0400 Subject: [PATCH 10/96] I successfully hooked up interchain queries. I just need to tailor it for our needs and add the transaction to the whitelist. --- app/app.go | 6 +- docs/proto-docs.md | 70 +++ proto/provenance/oracle/v1/query.proto | 14 + proto/provenance/oracle/v1/tx.proto | 15 + x/oracle/client/cli/query.go | 47 +- x/oracle/client/cli/tx.go | 45 +- x/oracle/keeper/genesis.go | 12 +- x/oracle/keeper/msg_server.go | 42 ++ x/oracle/keeper/query_server.go | 35 ++ x/oracle/module/module_ibc.go | 10 +- x/oracle/types/codec.go | 8 + x/oracle/types/genesis.go | 10 +- x/oracle/types/msgs.go | 29 +- x/oracle/types/query.pb.go | 510 +++++++++++++++++++-- x/oracle/types/query.pb.gw.go | 80 ++++ x/oracle/types/tx.pb.go | 604 +++++++++++++++++++++++-- 16 files changed, 1444 insertions(+), 93 deletions(-) diff --git a/app/app.go b/app/app.go index 408368d9e9..4ee461d586 100644 --- a/app/app.go +++ b/app/app.go @@ -531,6 +531,7 @@ func New( &app.IBCKeeper.PortKeeper, scopedOracleKeeper, ) + oracleModule := oraclemodule.NewAppModule(appCodec, app.OracleKeeper) // Init CosmWasm module wasmDir := filepath.Join(homePath, "data", "wasm") @@ -619,7 +620,8 @@ func New( ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule). AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)). AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(icqtypes.ModuleName, icqIBCModule) + AddRoute(icqtypes.ModuleName, icqIBCModule). + AddRoute(oracletypes.ModuleName, oracleModule) app.IBCKeeper.SetRouter(ibcRouter) // Create evidence Keeper for to register the IBC light client misbehavior evidence route @@ -670,7 +672,7 @@ func New( wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper), triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper), - oraclemodule.NewAppModule(appCodec, app.OracleKeeper), + oracleModule, // IBC ibc.NewAppModule(app.IBCKeeper), diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 228430587c..0e57580221 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -446,12 +446,16 @@ - [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) - [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) - [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) + - [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) + - [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) - [Query](#provenance.oracle.v1.Query) - [provenance/oracle/v1/tx.proto](#provenance/oracle/v1/tx.proto) - [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) - [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) + - [MsgSendQueryAllBalances](#provenance.oracle.v1.MsgSendQueryAllBalances) + - [MsgSendQueryAllBalancesResponse](#provenance.oracle.v1.MsgSendQueryAllBalancesResponse) - [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) - [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) @@ -6852,6 +6856,37 @@ QueryOracleResult contains the result of the oracle query. + + + +### QueryQueryStateRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sequence` | [uint64](#uint64) | | | + + + + + + + + +### QueryQueryStateResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `request` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `response` | [google.protobuf.Any](#google.protobuf.Any) | | | + + + + + @@ -6869,6 +6904,7 @@ Query defines the gRPC querier service for oracle module. | `ContractAddress` | [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) | [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) | ContractAddress returns the address of the oracle's contract | GET|/provenance/oracle/v1/contract_address| | `OracleContract` | [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) | [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) | OracleContract sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle_contract| | `OracleResult` | [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) | [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) | OracleResult returns the address of the oracle's contract | GET|/provenance/oracle/v1/oracle_result| +| `QueryState` | [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) | [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) | | GET|/quasar-finance/interchainquerydemo/interquery/query_state| @@ -6914,6 +6950,39 @@ MsgQueryOracleResponse contains the id of the oracle query. + + +### MsgSendQueryAllBalances + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `creator` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `address` | [string](#string) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | | + + + + + + + + +### MsgSendQueryAllBalancesResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sequence` | [uint64](#uint64) | | | + + + + + + ### MsgUpdateOracleRequest @@ -6955,6 +7024,7 @@ Msg | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `UpdateOracle` | [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) | [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) | UpdateOracle is the RPC endpoint for updating the oracle | | | `QueryOracle` | [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) | [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) | QueryOracle sends an icq to an oracle on another chain | | +| `SendQueryAllBalances` | [MsgSendQueryAllBalances](#provenance.oracle.v1.MsgSendQueryAllBalances) | [MsgSendQueryAllBalancesResponse](#provenance.oracle.v1.MsgSendQueryAllBalancesResponse) | | | diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index da3b7c3019..edb0504a60 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -4,6 +4,7 @@ package provenance.oracle.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos_proto/cosmos.proto"; +import "google/protobuf/any.proto"; option go_package = "github.com/provenance-io/provenance/x/oracle/types"; option java_package = "io.provenance.oracle.v1"; @@ -25,6 +26,19 @@ service Query { rpc OracleResult(QueryOracleResultRequest) returns (QueryOracleResultResponse) { option (google.api.http).get = "/provenance/oracle/v1/oracle_result"; } + + rpc QueryState(QueryQueryStateRequest) returns (QueryQueryStateResponse) { + option (google.api.http).get = "/quasar-finance/interchainquerydemo/interquery/query_state"; + } +} + +message QueryQueryStateRequest { + uint64 sequence = 1; +} + +message QueryQueryStateResponse { + google.protobuf.Any request = 1 [(gogoproto.nullable) = false]; + google.protobuf.Any response = 2 [(gogoproto.nullable) = true]; } // QueryContractAddressRequest queries for the Trigger with an identifier of id. diff --git a/proto/provenance/oracle/v1/tx.proto b/proto/provenance/oracle/v1/tx.proto index 0f7e3b0d82..f059cec162 100644 --- a/proto/provenance/oracle/v1/tx.proto +++ b/proto/provenance/oracle/v1/tx.proto @@ -3,6 +3,8 @@ package provenance.oracle.v1; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/protobuf/any.proto"; option go_package = "github.com/provenance-io/provenance/x/oracle/types"; option java_package = "io.provenance.oracle.v1"; @@ -14,6 +16,19 @@ service Msg { rpc UpdateOracle(MsgUpdateOracleRequest) returns (MsgUpdateOracleResponse); // QueryOracle sends an icq to an oracle on another chain rpc QueryOracle(MsgQueryOracleRequest) returns (MsgQueryOracleResponse); + + rpc SendQueryAllBalances(MsgSendQueryAllBalances) returns (MsgSendQueryAllBalancesResponse); +} + +message MsgSendQueryAllBalances { + string creator = 1; + string channel_id = 2; + string address = 3; + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +message MsgSendQueryAllBalancesResponse { + uint64 sequence = 1; } // MsgQueryOracleRequest queries an Oracle on another chain diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index c3527ecca9..e3008f1560 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -1,7 +1,12 @@ package cli import ( + "context" + "fmt" + "strconv" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/provenance-io/provenance/x/oracle/types" "github.com/spf13/cobra" ) @@ -14,6 +19,46 @@ func GetQueryCmd() *cobra.Command { SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } - queryCmd.AddCommand() + queryCmd.AddCommand( + CmdQueryState(), + ) return queryCmd } + +var _ = strconv.Itoa(0) + +func CmdQueryState() *cobra.Command { + cmd := &cobra.Command{ + Use: "query-state [sequence]", + Short: "Returns the request and response of an ICQ query given the packet sequence", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + sequence, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("invalid sequence: %w", err) + } + params := &types.QueryQueryStateRequest{ + Sequence: sequence, + } + + res, err := queryClient.QueryState(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index c60e1d6258..bc3a729439 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -1,7 +1,11 @@ package cli import ( + "strconv" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" "github.com/provenance-io/provenance/x/oracle/types" "github.com/spf13/cobra" ) @@ -17,7 +21,46 @@ func NewTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand() + txCmd.AddCommand( + CmdSendQueryAllBalances(), + ) return txCmd } + +var _ = strconv.Itoa(0) + +func CmdSendQueryAllBalances() *cobra.Command { + cmd := &cobra.Command{ + Use: "send-query-all-balances [channel-id] [address]", + Short: "Query the balances of an account on the remote chain via ICQ", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + msg := types.NewMsgSendQueryAllBalances( + clientCtx.GetFromAddress().String(), + args[0], // channel id + args[1], // address + pageReq, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "send query all balances") + + return cmd +} diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index f469e9f2d2..2167b94572 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -7,16 +7,22 @@ import ( // ExportGenesis returns a GenesisState for a given context. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - return types.NewGenesisState(1) + return types.DefaultGenesis() } // InitGenesis new trigger genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { - k.SetPort(ctx, genState.PortId) - if err := genState.Validate(); err != nil { panic(err) } + k.SetPort(ctx, genState.PortId) + if !k.IsBound(ctx, genState.PortId) { + err := k.BindPort(ctx, genState.PortId) + if err != nil { + panic("could not claim port capability: " + err.Error()) + } + } + k.SetParams(ctx, genState.Params) } diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 93eddbd78e..cac5fe3e2e 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -2,8 +2,16 @@ package keeper import ( "context" + "time" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" "github.com/provenance-io/provenance/x/oracle/types" + abcitypes "github.com/tendermint/tendermint/abci/types" ) type msgServer struct { @@ -27,3 +35,37 @@ func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracl func (s msgServer) QueryOracle(goCtx context.Context, msg *types.MsgQueryOracleRequest) (*types.MsgQueryOracleResponse, error) { return &types.MsgQueryOracleResponse{}, nil } + +func (k msgServer) SendQueryAllBalances(goCtx context.Context, msg *types.MsgSendQueryAllBalances) (*types.MsgSendQueryAllBalancesResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(k.GetPort(ctx), msg.ChannelId)) + if !found { + return nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + } + + q := banktypes.QueryAllBalancesRequest{ + Address: msg.Address, + Pagination: msg.Pagination, + } + reqs := []abcitypes.RequestQuery{ + { + Path: "/cosmos.bank.v1beta1.Query/AllBalances", + Data: k.cdc.MustMarshal(&q), + }, + } + + // timeoutTimestamp set to max value with the unsigned bit shifted to sastisfy hermes timestamp conversion + // it is the responsibility of the auth module developer to ensure an appropriate timeout timestamp + timeoutTimestamp := ctx.BlockTime().Add(time.Minute).UnixNano() + seq, err := k.SendQuery(ctx, types.PortID, msg.ChannelId, chanCap, reqs, clienttypes.ZeroHeight(), uint64(timeoutTimestamp)) + if err != nil { + return nil, err + } + + k.SetQueryRequest(ctx, seq, q) + + return &types.MsgSendQueryAllBalancesResponse{ + Sequence: seq, + }, nil +} diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 61a6ea641a..c0e60d24d6 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -3,7 +3,11 @@ package keeper import ( "context" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/provenance-io/provenance/x/oracle/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) var _ types.QueryServer = Keeper{} @@ -20,3 +24,34 @@ func (k Keeper) OracleContract(ctx context.Context, req *types.QueryOracleContra func (k Keeper) OracleResult(ctx context.Context, req *types.QueryOracleResultRequest) (*types.QueryOracleResultResponse, error) { return &types.QueryOracleResultResponse{}, nil } + +func (k Keeper) QueryState(goCtx context.Context, req *types.QueryQueryStateRequest) (*types.QueryQueryStateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + qreq, err := k.GetQueryRequest(ctx, req.Sequence) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + var anyQResp *cdctypes.Any + qresp, err := k.GetQueryResponse(ctx, req.Sequence) + if err == nil { + anyQResp, err = cdctypes.NewAnyWithValue(&qresp) + if err != nil { + panic(err) + } + } + + anyQReq, err := cdctypes.NewAnyWithValue(&qreq) + if err != nil { + panic(err) + } + return &types.QueryQueryStateResponse{ + Request: *anyQReq, + Response: anyQResp, + }, nil +} diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index 33b3ba1e76..e516724e9d 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -24,24 +24,24 @@ func (am AppModule) OnChanOpenInit( chanCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string, -) error { +) (string, error) { // Require portID is the portID module is bound to boundPort := am.keeper.GetPort(ctx) if boundPort != portID { - return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } if version != types.Version { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) + return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) } // Claim channel capability passed back by IBC module if err := am.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { - return err + return "", err } - return nil + return version, nil } // OnChanOpenTry implements the IBCModule interface diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 10e25f709b..6d45290830 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -4,6 +4,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/gogo/protobuf/proto" ) // ignoring RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -13,6 +15,12 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { (*sdk.Msg)(nil), &MsgUpdateOracleRequest{}, &MsgQueryOracleRequest{}, + &MsgSendQueryAllBalances{}, + ) + + registry.RegisterImplementations((*proto.Message)(nil), + &banktypes.QueryAllBalancesRequest{}, + &banktypes.QueryAllBalancesResponse{}, ) } diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index a82d0344a2..4d8ff7ff84 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -6,19 +6,17 @@ import ( host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -func NewGenesisState(queryID uint64) *GenesisState { +func NewGenesisState(port string, params Params, queryID uint64) *GenesisState { return &GenesisState{ + PortId: port, + Params: params, QueryId: queryID, } } // DefaultGenesis returns the default trigger genesis state func DefaultGenesis() *GenesisState { - return &GenesisState{ - PortId: PortID, - Params: DefaultParams(), - QueryId: 1, - } + return NewGenesisState(PortID, DefaultParams(), 1) } // Validate performs basic genesis state validation returning an error upon any diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 910391d655..55d166db13 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -2,9 +2,36 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + query "github.com/cosmos/cosmos-sdk/types/query" ) -var _ sdk.Msg = &MsgUpdateOracleRequest{} +var _, _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgQueryOracleRequest{}, &MsgSendQueryAllBalances{} + +func NewMsgSendQueryAllBalances(creator, channelId string, addr string, page *query.PageRequest) *MsgSendQueryAllBalances { + return &MsgSendQueryAllBalances{ + Creator: creator, + ChannelId: channelId, + Address: addr, + Pagination: page, + } +} + +func (msg *MsgSendQueryAllBalances) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgSendQueryAllBalances) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} // GetSigners indicates that the message must have been signed by the parent. func (msg MsgUpdateOracleRequest) GetSigners() []sdk.AccAddress { diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index d78e8a7770..6ebe0f8204 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -8,6 +8,7 @@ import ( fmt "fmt" github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -31,6 +32,102 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type QueryQueryStateRequest struct { + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *QueryQueryStateRequest) Reset() { *m = QueryQueryStateRequest{} } +func (m *QueryQueryStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryQueryStateRequest) ProtoMessage() {} +func (*QueryQueryStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{0} +} +func (m *QueryQueryStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryQueryStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryQueryStateRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryQueryStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryQueryStateRequest.Merge(m, src) +} +func (m *QueryQueryStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryQueryStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryQueryStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryQueryStateRequest proto.InternalMessageInfo + +func (m *QueryQueryStateRequest) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +type QueryQueryStateResponse struct { + Request types.Any `protobuf:"bytes,1,opt,name=request,proto3" json:"request"` + Response *types.Any `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` +} + +func (m *QueryQueryStateResponse) Reset() { *m = QueryQueryStateResponse{} } +func (m *QueryQueryStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryQueryStateResponse) ProtoMessage() {} +func (*QueryQueryStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_169907f611744c57, []int{1} +} +func (m *QueryQueryStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryQueryStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryQueryStateResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryQueryStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryQueryStateResponse.Merge(m, src) +} +func (m *QueryQueryStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryQueryStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryQueryStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryQueryStateResponse proto.InternalMessageInfo + +func (m *QueryQueryStateResponse) GetRequest() types.Any { + if m != nil { + return m.Request + } + return types.Any{} +} + +func (m *QueryQueryStateResponse) GetResponse() *types.Any { + if m != nil { + return m.Response + } + return nil +} + // QueryContractAddressRequest queries for the Trigger with an identifier of id. type QueryContractAddressRequest struct { } @@ -39,7 +136,7 @@ func (m *QueryContractAddressRequest) Reset() { *m = QueryContractAddres func (m *QueryContractAddressRequest) String() string { return proto.CompactTextString(m) } func (*QueryContractAddressRequest) ProtoMessage() {} func (*QueryContractAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{0} + return fileDescriptor_169907f611744c57, []int{2} } func (m *QueryContractAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,7 +175,7 @@ func (m *QueryContractAddressResponse) Reset() { *m = QueryContractAddre func (m *QueryContractAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryContractAddressResponse) ProtoMessage() {} func (*QueryContractAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{1} + return fileDescriptor_169907f611744c57, []int{3} } func (m *QueryContractAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -124,7 +221,7 @@ func (m *QueryOracleContractRequest) Reset() { *m = QueryOracleContractR func (m *QueryOracleContractRequest) String() string { return proto.CompactTextString(m) } func (*QueryOracleContractRequest) ProtoMessage() {} func (*QueryOracleContractRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{2} + return fileDescriptor_169907f611744c57, []int{4} } func (m *QueryOracleContractRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -170,7 +267,7 @@ func (m *QueryOracleContractResponse) Reset() { *m = QueryOracleContract func (m *QueryOracleContractResponse) String() string { return proto.CompactTextString(m) } func (*QueryOracleContractResponse) ProtoMessage() {} func (*QueryOracleContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{3} + return fileDescriptor_169907f611744c57, []int{5} } func (m *QueryOracleContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -216,7 +313,7 @@ func (m *QueryOracleResultRequest) Reset() { *m = QueryOracleResultReque func (m *QueryOracleResultRequest) String() string { return proto.CompactTextString(m) } func (*QueryOracleResultRequest) ProtoMessage() {} func (*QueryOracleResultRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{4} + return fileDescriptor_169907f611744c57, []int{6} } func (m *QueryOracleResultRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -262,7 +359,7 @@ func (m *QueryOracleResultResponse) Reset() { *m = QueryOracleResultResp func (m *QueryOracleResultResponse) String() string { return proto.CompactTextString(m) } func (*QueryOracleResultResponse) ProtoMessage() {} func (*QueryOracleResultResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{5} + return fileDescriptor_169907f611744c57, []int{7} } func (m *QueryOracleResultResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -299,6 +396,8 @@ func (m *QueryOracleResultResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_t } func init() { + proto.RegisterType((*QueryQueryStateRequest)(nil), "provenance.oracle.v1.QueryQueryStateRequest") + proto.RegisterType((*QueryQueryStateResponse)(nil), "provenance.oracle.v1.QueryQueryStateResponse") proto.RegisterType((*QueryContractAddressRequest)(nil), "provenance.oracle.v1.QueryContractAddressRequest") proto.RegisterType((*QueryContractAddressResponse)(nil), "provenance.oracle.v1.QueryContractAddressResponse") proto.RegisterType((*QueryOracleContractRequest)(nil), "provenance.oracle.v1.QueryOracleContractRequest") @@ -310,39 +409,48 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/query.proto", fileDescriptor_169907f611744c57) } var fileDescriptor_169907f611744c57 = []byte{ - // 507 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6e, 0xd3, 0x30, - 0x18, 0xc7, 0xeb, 0xb1, 0x31, 0xb0, 0x26, 0x90, 0xac, 0x4a, 0xb4, 0x61, 0x84, 0x29, 0x68, 0x30, - 0x09, 0xd5, 0xa6, 0x45, 0x1c, 0x38, 0x70, 0xa0, 0x3b, 0x71, 0x40, 0xb0, 0xec, 0x80, 0xc4, 0xa5, - 0xf2, 0x12, 0x2b, 0x44, 0x6a, 0xfc, 0xa5, 0xb1, 0xdb, 0x6d, 0x57, 0x9e, 0x00, 0x89, 0x2b, 0x47, - 0x0e, 0x3c, 0x00, 0x0f, 0xc1, 0x71, 0x82, 0x0b, 0x27, 0x84, 0x5a, 0x1e, 0x02, 0x71, 0x42, 0xb3, - 0x1d, 0x96, 0x55, 0x51, 0xd9, 0xa4, 0x9d, 0x6a, 0xd7, 0xff, 0xef, 0xfb, 0xfd, 0xbf, 0xf8, 0x9f, - 0xe0, 0x8d, 0xbc, 0x80, 0x89, 0x90, 0x5c, 0x46, 0x82, 0x41, 0xc1, 0xa3, 0xa1, 0x60, 0x93, 0x2e, - 0x1b, 0x8d, 0x45, 0x71, 0x48, 0xf3, 0x02, 0x34, 0x90, 0xe6, 0x89, 0x82, 0x5a, 0x05, 0x9d, 0x74, - 0xbd, 0x66, 0x02, 0x09, 0x18, 0x01, 0x3b, 0x5e, 0x59, 0xad, 0xb7, 0x9e, 0x00, 0x24, 0x43, 0xc1, - 0x78, 0x9e, 0x32, 0x2e, 0x25, 0x68, 0xae, 0x53, 0x90, 0xca, 0x9d, 0xb6, 0x23, 0x50, 0x19, 0xa8, - 0x81, 0x2d, 0xb3, 0x1b, 0x7b, 0x14, 0xdc, 0xc2, 0x37, 0x77, 0x8e, 0x99, 0xdb, 0x20, 0x75, 0xc1, - 0x23, 0xfd, 0x34, 0x8e, 0x0b, 0xa1, 0x54, 0x28, 0x46, 0x63, 0xa1, 0x74, 0x10, 0xe2, 0xf5, 0xfa, - 0x63, 0x95, 0x83, 0x54, 0x82, 0xf4, 0xf0, 0x2a, 0xb7, 0x7f, 0xb5, 0xd0, 0x06, 0xda, 0xba, 0xda, - 0x6f, 0x7d, 0xfd, 0xdc, 0x69, 0x3a, 0x82, 0x13, 0xef, 0xea, 0x22, 0x95, 0x49, 0x58, 0x0a, 0x83, - 0x11, 0xf6, 0x4c, 0xcf, 0x17, 0x66, 0xa6, 0xb2, 0xb3, 0x23, 0x92, 0x5d, 0xbc, 0x62, 0x1e, 0x82, - 0xe9, 0xb7, 0xd6, 0x7f, 0xf2, 0xe7, 0xc7, 0xed, 0xc7, 0x49, 0xaa, 0xdf, 0x8c, 0xf7, 0x68, 0x04, - 0x19, 0xdb, 0x06, 0x95, 0xbd, 0xe2, 0x2a, 0x63, 0xfb, 0x5c, 0x65, 0x31, 0x3b, 0x30, 0xbf, 0x4c, - 0x1f, 0xe6, 0x42, 0xd1, 0x90, 0xef, 0x97, 0xdd, 0x9e, 0x0b, 0xa5, 0x78, 0x22, 0x42, 0xdb, 0x2b, - 0xc8, 0xdd, 0x94, 0xf3, 0x48, 0x37, 0xc5, 0x0e, 0x5e, 0x8e, 0xb9, 0xe6, 0x17, 0x83, 0x34, 0xad, - 0x82, 0x47, 0xb8, 0x55, 0x21, 0x86, 0x42, 0x8d, 0x87, 0xff, 0x46, 0x6c, 0xe3, 0x2b, 0xc6, 0xd6, - 0x20, 0x8d, 0x0d, 0x72, 0x39, 0x5c, 0x35, 0xfb, 0x67, 0x71, 0x20, 0x71, 0xbb, 0xa6, 0x6c, 0xce, - 0xe6, 0xd2, 0x85, 0xd9, 0xec, 0xfd, 0xbe, 0x84, 0x57, 0x0c, 0x90, 0x7c, 0x42, 0xf8, 0xfa, 0xdc, - 0x2d, 0x93, 0x2e, 0xad, 0x8b, 0x20, 0x5d, 0x10, 0x18, 0xaf, 0x77, 0x9e, 0x12, 0x3b, 0x57, 0x40, - 0xdf, 0x7e, 0xfb, 0xf5, 0x7e, 0x69, 0x8b, 0xdc, 0x65, 0xb5, 0xef, 0x44, 0xe4, 0xca, 0x06, 0x2e, - 0x40, 0xe4, 0x23, 0xc2, 0xd7, 0x4e, 0xdf, 0x24, 0x79, 0xb0, 0x00, 0x5b, 0x9b, 0x33, 0xaf, 0x7b, - 0x8e, 0x0a, 0xe7, 0xb3, 0x63, 0x7c, 0xde, 0x23, 0x9b, 0xf5, 0x3e, 0xed, 0x6a, 0x50, 0xda, 0x25, - 0x1f, 0x10, 0x5e, 0xab, 0xde, 0x23, 0xa1, 0xff, 0x45, 0x9e, 0xca, 0x89, 0xc7, 0xce, 0xac, 0x77, - 0x06, 0xef, 0x1b, 0x83, 0x9b, 0xe4, 0xce, 0x42, 0x83, 0x85, 0x29, 0xea, 0x27, 0x5f, 0xa6, 0x3e, - 0x3a, 0x9a, 0xfa, 0xe8, 0xe7, 0xd4, 0x47, 0xef, 0x66, 0x7e, 0xe3, 0x68, 0xe6, 0x37, 0xbe, 0xcf, - 0xfc, 0x06, 0xbe, 0x91, 0x42, 0x2d, 0xf9, 0x25, 0x7a, 0xdd, 0xab, 0x04, 0xee, 0x44, 0xd2, 0x49, - 0xa1, 0x4a, 0x3c, 0x28, 0x99, 0x26, 0x7c, 0x7b, 0x97, 0xcd, 0x97, 0xe6, 0xe1, 0xdf, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xd7, 0x3f, 0xbc, 0x19, 0xf2, 0x04, 0x00, 0x00, + // 645 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x4f, 0x14, 0x31, + 0x14, 0xc7, 0xb7, 0x04, 0x04, 0x2b, 0xd1, 0xa4, 0xd9, 0xc8, 0x32, 0xe2, 0x42, 0xc6, 0xa0, 0x24, + 0xba, 0xad, 0xbb, 0xa2, 0x89, 0x46, 0x0f, 0x2c, 0x27, 0x0f, 0x46, 0x19, 0x0e, 0x26, 0x5e, 0x36, + 0x65, 0xa6, 0x0c, 0x93, 0x30, 0xed, 0x6c, 0xdb, 0xe1, 0xc7, 0xd5, 0x8b, 0x57, 0x13, 0xaf, 0x1e, + 0x3d, 0x70, 0xf1, 0xe6, 0x1f, 0xc1, 0x91, 0xe8, 0xc5, 0x13, 0x31, 0xe0, 0x5f, 0xe1, 0xc9, 0x6c, + 0xdb, 0x81, 0x05, 0x26, 0x0b, 0x24, 0x5c, 0x76, 0xdb, 0xe9, 0xf7, 0xbd, 0xef, 0xa7, 0xed, 0x7b, + 0x85, 0x33, 0x99, 0x14, 0x1b, 0x8c, 0x53, 0x1e, 0x32, 0x22, 0x24, 0x0d, 0xd7, 0x19, 0xd9, 0x68, + 0x92, 0x6e, 0xce, 0xe4, 0x36, 0xce, 0xa4, 0xd0, 0x02, 0x55, 0x8f, 0x15, 0xd8, 0x2a, 0xf0, 0x46, + 0xd3, 0xab, 0xc6, 0x22, 0x16, 0x46, 0x40, 0x7a, 0x23, 0xab, 0xf5, 0xa6, 0x62, 0x21, 0xe2, 0x75, + 0x46, 0x68, 0x96, 0x10, 0xca, 0xb9, 0xd0, 0x54, 0x27, 0x82, 0x2b, 0xb7, 0x3a, 0x19, 0x0a, 0x95, + 0x0a, 0xd5, 0xb1, 0x61, 0x76, 0x52, 0x2c, 0xb9, 0x40, 0x33, 0x5b, 0xc9, 0x57, 0x09, 0xe5, 0xce, + 0xdf, 0x9f, 0x87, 0xb7, 0x97, 0x7a, 0x38, 0xe6, 0x67, 0x59, 0x53, 0xcd, 0x02, 0xd6, 0xcd, 0x99, + 0xd2, 0xc8, 0x83, 0x63, 0xaa, 0x37, 0xe4, 0x21, 0xab, 0x81, 0x19, 0x30, 0x37, 0x1c, 0x1c, 0xcd, + 0xfd, 0x4f, 0x00, 0x4e, 0x9c, 0x09, 0x53, 0x99, 0xe0, 0x8a, 0xa1, 0x79, 0x38, 0x2a, 0x6d, 0x0a, + 0x13, 0x76, 0xa3, 0x55, 0xc5, 0xd6, 0x1e, 0x17, 0xf6, 0x78, 0x81, 0x6f, 0xb7, 0x87, 0x77, 0xf7, + 0xa7, 0x2b, 0x41, 0x21, 0x45, 0xcf, 0xe0, 0x98, 0x74, 0x19, 0x6a, 0x43, 0xe7, 0x84, 0x81, 0xe0, + 0x48, 0xeb, 0xdf, 0x85, 0x77, 0x0c, 0xc3, 0xa2, 0xe0, 0x5a, 0xd2, 0x50, 0x2f, 0x44, 0x91, 0x64, + 0x4a, 0xb9, 0x4d, 0xf8, 0x01, 0x9c, 0x2a, 0x5f, 0x76, 0xb0, 0x2d, 0x38, 0x4a, 0xed, 0x27, 0x03, + 0x7b, 0xbd, 0x5d, 0xfb, 0xf9, 0xa3, 0x51, 0x75, 0x87, 0xe7, 0xc4, 0xcb, 0x5a, 0x26, 0x3c, 0x0e, + 0x0a, 0xa1, 0xdf, 0x85, 0x9e, 0xc9, 0xf9, 0xd6, 0x5c, 0x57, 0x91, 0xb9, 0x38, 0xb6, 0x65, 0x38, + 0x62, 0xee, 0xd7, 0xe4, 0x1b, 0x6f, 0xbf, 0xfa, 0xb7, 0x3f, 0xfd, 0x3c, 0x4e, 0xf4, 0x5a, 0xbe, + 0x82, 0x43, 0x91, 0x92, 0x45, 0xa1, 0xd2, 0xf7, 0x54, 0xa5, 0x64, 0x93, 0xaa, 0x34, 0x22, 0x5b, + 0xe6, 0x9f, 0xe8, 0xed, 0x8c, 0x29, 0x1c, 0xd0, 0xcd, 0x22, 0xdb, 0x1b, 0xa6, 0x14, 0x8d, 0x59, + 0x60, 0x73, 0xf9, 0x99, 0xdb, 0xe5, 0x69, 0x4b, 0xb7, 0x8b, 0x25, 0x38, 0x1c, 0x51, 0x4d, 0xaf, + 0xc6, 0xd2, 0xa4, 0xf2, 0x9f, 0xc2, 0x5a, 0x9f, 0x63, 0xc0, 0x54, 0xbe, 0x7e, 0xb4, 0xc5, 0x49, + 0x38, 0x66, 0xb0, 0x3a, 0x49, 0xe4, 0x2a, 0x63, 0xd4, 0xcc, 0x5f, 0x47, 0x3e, 0x87, 0x93, 0x25, + 0x61, 0xa7, 0x30, 0x87, 0xae, 0x0c, 0xb3, 0xb5, 0x33, 0x02, 0x47, 0x8c, 0x21, 0xda, 0x01, 0xf0, + 0xd6, 0xa9, 0x5b, 0x46, 0x4d, 0x5c, 0xd6, 0x5d, 0x78, 0x40, 0xc1, 0x78, 0xad, 0xcb, 0x84, 0xb8, + 0x1a, 0xc4, 0x1f, 0x7f, 0xfd, 0xfd, 0x32, 0x34, 0x87, 0xee, 0x93, 0xd2, 0x76, 0x0f, 0x5d, 0x58, + 0xc7, 0x15, 0x10, 0xfa, 0x06, 0xe0, 0xcd, 0x93, 0x37, 0x89, 0x1e, 0x0f, 0xb0, 0x2d, 0xad, 0x33, + 0xaf, 0x79, 0x89, 0x08, 0xc7, 0xd9, 0x30, 0x9c, 0x0f, 0xd0, 0x6c, 0x39, 0xa7, 0x1d, 0x75, 0x0a, + 0x5c, 0xf4, 0x15, 0xc0, 0xf1, 0xfe, 0x7b, 0x44, 0xf8, 0x5c, 0xcb, 0x13, 0x75, 0xe2, 0x91, 0x0b, + 0xeb, 0x1d, 0xe0, 0x43, 0x03, 0x38, 0x8b, 0xee, 0x0d, 0x04, 0x94, 0x96, 0xe6, 0x3b, 0x80, 0xf0, + 0xf8, 0xf9, 0x41, 0x8f, 0x06, 0x98, 0x9d, 0x79, 0xdc, 0xbc, 0xc6, 0x05, 0xd5, 0x0e, 0xac, 0x6d, + 0xc0, 0x5e, 0xa2, 0x17, 0xa4, 0x9b, 0x53, 0x45, 0x65, 0x63, 0x35, 0xb1, 0x70, 0x09, 0xd7, 0x4c, + 0x86, 0x6b, 0x34, 0xe1, 0xa6, 0x03, 0x22, 0x96, 0x0a, 0xfb, 0xcd, 0x4c, 0xed, 0x4b, 0xdf, 0x51, + 0xbd, 0x5c, 0xed, 0x78, 0xf7, 0xa0, 0x0e, 0xf6, 0x0e, 0xea, 0xe0, 0xcf, 0x41, 0x1d, 0x7c, 0x3e, + 0xac, 0x57, 0xf6, 0x0e, 0xeb, 0x95, 0xdf, 0x87, 0xf5, 0x0a, 0x9c, 0x48, 0x44, 0x29, 0xce, 0x3b, + 0xf0, 0xa1, 0xd5, 0xd7, 0x20, 0xc7, 0x92, 0x46, 0x22, 0xfa, 0x4f, 0x68, 0xab, 0x38, 0x23, 0xd3, + 0x2c, 0x2b, 0xd7, 0xcc, 0x83, 0xf9, 0xe4, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0x51, 0xaf, + 0x92, 0x7d, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -363,6 +471,7 @@ type QueryClient interface { OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) // OracleResult returns the address of the oracle's contract OracleResult(ctx context.Context, in *QueryOracleResultRequest, opts ...grpc.CallOption) (*QueryOracleResultResponse, error) + QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) } type queryClient struct { @@ -400,6 +509,15 @@ func (c *queryClient) OracleResult(ctx context.Context, in *QueryOracleResultReq return out, nil } +func (c *queryClient) QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) { + out := new(QueryQueryStateResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/QueryState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // ContractAddress returns the address of the oracle's contract @@ -408,6 +526,7 @@ type QueryServer interface { OracleContract(context.Context, *QueryOracleContractRequest) (*QueryOracleContractResponse, error) // OracleResult returns the address of the oracle's contract OracleResult(context.Context, *QueryOracleResultRequest) (*QueryOracleResultResponse, error) + QueryState(context.Context, *QueryQueryStateRequest) (*QueryQueryStateResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -423,6 +542,9 @@ func (*UnimplementedQueryServer) OracleContract(ctx context.Context, req *QueryO func (*UnimplementedQueryServer) OracleResult(ctx context.Context, req *QueryOracleResultRequest) (*QueryOracleResultResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OracleResult not implemented") } +func (*UnimplementedQueryServer) QueryState(ctx context.Context, req *QueryQueryStateRequest) (*QueryQueryStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryState not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -482,6 +604,24 @@ func _Query_OracleResult_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Query_QueryState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryQueryStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Query/QueryState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryState(ctx, req.(*QueryQueryStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "provenance.oracle.v1.Query", HandlerType: (*QueryServer)(nil), @@ -498,11 +638,88 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "OracleResult", Handler: _Query_OracleResult_Handler, }, + { + MethodName: "QueryState", + Handler: _Query_QueryState_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/oracle/v1/query.proto", } +func (m *QueryQueryStateRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryQueryStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryQueryStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryQueryStateResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryQueryStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryQueryStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Response != nil { + { + size, err := m.Response.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Request.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *QueryContractAddressRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -685,6 +902,33 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QueryQueryStateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) + } + return n +} + +func (m *QueryQueryStateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Request.Size() + n += 1 + l + sovQuery(uint64(l)) + if m.Response != nil { + l = m.Response.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryContractAddressRequest) Size() (n int) { if m == nil { return 0 @@ -764,6 +1008,194 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryQueryStateRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryQueryStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryQueryStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryQueryStateResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryQueryStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryQueryStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Request.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Response == nil { + m.Response = &types.Any{} + } + if err := m.Response.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryContractAddressRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 891be2f546..602ad6edc2 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -121,6 +121,42 @@ func local_request_Query_OracleResult_0(ctx context.Context, marshaler runtime.M } +var ( + filter_Query_QueryState_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_QueryState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryQueryStateRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryState_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryQueryStateRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryState_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryState(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -187,6 +223,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryState_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -288,6 +344,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryState_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -297,6 +373,8 @@ var ( pattern_Query_OracleContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_contract"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_OracleResult_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_result"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"quasar-finance", "interchainquerydemo", "interquery", "query_state"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -305,4 +383,6 @@ var ( forward_Query_OracleContract_0 = runtime.ForwardResponseMessage forward_Query_OracleResult_0 = runtime.ForwardResponseMessage + + forward_Query_QueryState_0 = runtime.ForwardResponseMessage ) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 87e38e7079..1ab3990fbd 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -8,6 +8,8 @@ import ( fmt "fmt" github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -30,6 +32,118 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgSendQueryAllBalances struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,4,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *MsgSendQueryAllBalances) Reset() { *m = MsgSendQueryAllBalances{} } +func (m *MsgSendQueryAllBalances) String() string { return proto.CompactTextString(m) } +func (*MsgSendQueryAllBalances) ProtoMessage() {} +func (*MsgSendQueryAllBalances) Descriptor() ([]byte, []int) { + return fileDescriptor_66a39dda41c6a784, []int{0} +} +func (m *MsgSendQueryAllBalances) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendQueryAllBalances) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendQueryAllBalances.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSendQueryAllBalances) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendQueryAllBalances.Merge(m, src) +} +func (m *MsgSendQueryAllBalances) XXX_Size() int { + return m.Size() +} +func (m *MsgSendQueryAllBalances) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendQueryAllBalances.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendQueryAllBalances proto.InternalMessageInfo + +func (m *MsgSendQueryAllBalances) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgSendQueryAllBalances) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *MsgSendQueryAllBalances) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgSendQueryAllBalances) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type MsgSendQueryAllBalancesResponse struct { + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *MsgSendQueryAllBalancesResponse) Reset() { *m = MsgSendQueryAllBalancesResponse{} } +func (m *MsgSendQueryAllBalancesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSendQueryAllBalancesResponse) ProtoMessage() {} +func (*MsgSendQueryAllBalancesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_66a39dda41c6a784, []int{1} +} +func (m *MsgSendQueryAllBalancesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendQueryAllBalancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendQueryAllBalancesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSendQueryAllBalancesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendQueryAllBalancesResponse.Merge(m, src) +} +func (m *MsgSendQueryAllBalancesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSendQueryAllBalancesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendQueryAllBalancesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendQueryAllBalancesResponse proto.InternalMessageInfo + +func (m *MsgSendQueryAllBalancesResponse) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + // MsgQueryOracleRequest queries an Oracle on another chain type MsgQueryOracleRequest struct { // Query contains the query data passed to the oracle. @@ -46,7 +160,7 @@ func (m *MsgQueryOracleRequest) Reset() { *m = MsgQueryOracleRequest{} } func (m *MsgQueryOracleRequest) String() string { return proto.CompactTextString(m) } func (*MsgQueryOracleRequest) ProtoMessage() {} func (*MsgQueryOracleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{0} + return fileDescriptor_66a39dda41c6a784, []int{2} } func (m *MsgQueryOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -113,7 +227,7 @@ func (m *MsgQueryOracleResponse) Reset() { *m = MsgQueryOracleResponse{} func (m *MsgQueryOracleResponse) String() string { return proto.CompactTextString(m) } func (*MsgQueryOracleResponse) ProtoMessage() {} func (*MsgQueryOracleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{1} + return fileDescriptor_66a39dda41c6a784, []int{3} } func (m *MsgQueryOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -161,7 +275,7 @@ func (m *MsgUpdateOracleRequest) Reset() { *m = MsgUpdateOracleRequest{} func (m *MsgUpdateOracleRequest) String() string { return proto.CompactTextString(m) } func (*MsgUpdateOracleRequest) ProtoMessage() {} func (*MsgUpdateOracleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{2} + return fileDescriptor_66a39dda41c6a784, []int{4} } func (m *MsgUpdateOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,7 +326,7 @@ func (m *MsgUpdateOracleResponse) Reset() { *m = MsgUpdateOracleResponse func (m *MsgUpdateOracleResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateOracleResponse) ProtoMessage() {} func (*MsgUpdateOracleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{3} + return fileDescriptor_66a39dda41c6a784, []int{5} } func (m *MsgUpdateOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -242,6 +356,8 @@ func (m *MsgUpdateOracleResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateOracleResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgSendQueryAllBalances)(nil), "provenance.oracle.v1.MsgSendQueryAllBalances") + proto.RegisterType((*MsgSendQueryAllBalancesResponse)(nil), "provenance.oracle.v1.MsgSendQueryAllBalancesResponse") proto.RegisterType((*MsgQueryOracleRequest)(nil), "provenance.oracle.v1.MsgQueryOracleRequest") proto.RegisterType((*MsgQueryOracleResponse)(nil), "provenance.oracle.v1.MsgQueryOracleResponse") proto.RegisterType((*MsgUpdateOracleRequest)(nil), "provenance.oracle.v1.MsgUpdateOracleRequest") @@ -251,37 +367,47 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/tx.proto", fileDescriptor_66a39dda41c6a784) } var fileDescriptor_66a39dda41c6a784 = []byte{ - // 468 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xce, 0xb4, 0xd5, 0xb6, 0xd3, 0xea, 0x61, 0x88, 0x76, 0x13, 0x70, 0x53, 0x02, 0x42, 0xc1, - 0x66, 0x87, 0xa6, 0x20, 0x28, 0x78, 0x30, 0x39, 0x79, 0x08, 0xd6, 0x2d, 0x22, 0x78, 0x09, 0xd3, - 0xdd, 0x61, 0xb2, 0xd8, 0xdd, 0xb7, 0x9d, 0x37, 0x9b, 0x26, 0x7f, 0x42, 0x3c, 0x7a, 0xec, 0x8f, - 0xf0, 0x47, 0x78, 0x2c, 0x9e, 0x3c, 0x88, 0x48, 0x72, 0xf1, 0xe0, 0x2f, 0xf0, 0x24, 0x99, 0x49, - 0x49, 0x6a, 0xa3, 0xe4, 0xb4, 0xfb, 0xbe, 0xf7, 0xbd, 0x37, 0xdf, 0xf7, 0x78, 0x8f, 0x3e, 0xc8, - 0x35, 0xf4, 0x65, 0x26, 0xb2, 0x48, 0x72, 0xd0, 0x22, 0x3a, 0x95, 0xbc, 0x7f, 0xc0, 0xcd, 0x20, - 0xc8, 0x35, 0x18, 0x60, 0xe5, 0x59, 0x3a, 0x70, 0xe9, 0xa0, 0x7f, 0x50, 0xad, 0x44, 0x80, 0x29, - 0x60, 0xd7, 0x72, 0xb8, 0x0b, 0x5c, 0x41, 0xb5, 0xac, 0x40, 0x81, 0xc3, 0x27, 0x7f, 0x0e, 0xad, - 0xff, 0x22, 0xf4, 0x5e, 0x07, 0xd5, 0xab, 0x42, 0xea, 0xe1, 0x4b, 0xdb, 0x26, 0x94, 0x67, 0x85, - 0x44, 0xc3, 0x8e, 0xe9, 0xad, 0xb3, 0x09, 0xea, 0x91, 0x5d, 0xb2, 0xb7, 0xdd, 0x7a, 0xf6, 0xfb, - 0x7b, 0xed, 0x89, 0x4a, 0x4c, 0xaf, 0x38, 0x09, 0x22, 0x48, 0x79, 0x1b, 0x30, 0x7d, 0x23, 0x30, - 0xe5, 0xe7, 0x02, 0xd3, 0x98, 0x0f, 0xec, 0x97, 0x9b, 0x61, 0x2e, 0x31, 0x08, 0xc5, 0x79, 0x1b, - 0x32, 0xa3, 0x45, 0x64, 0x3a, 0x12, 0x51, 0x28, 0x19, 0xba, 0x5e, 0xac, 0x46, 0xb7, 0x10, 0x0a, - 0x1d, 0xc9, 0x6e, 0x0e, 0xda, 0x78, 0x2b, 0xbb, 0x64, 0x6f, 0x33, 0xa4, 0x0e, 0x3a, 0x02, 0x6d, - 0xd8, 0x43, 0x7a, 0x77, 0x4a, 0x88, 0x7a, 0x22, 0xcb, 0xe4, 0xa9, 0xb7, 0x6a, 0x39, 0x77, 0x1c, - 0xda, 0x76, 0x20, 0x7b, 0x4c, 0x37, 0x45, 0x61, 0x7a, 0xa0, 0x13, 0x33, 0xf4, 0xd6, 0x26, 0x8c, - 0x96, 0xf7, 0xe5, 0x53, 0xa3, 0x3c, 0x75, 0xfc, 0x3c, 0x8e, 0xb5, 0x44, 0x3c, 0x36, 0x3a, 0xc9, - 0x54, 0x38, 0xa3, 0xd6, 0x0f, 0xe9, 0xfd, 0xbf, 0xdd, 0x62, 0x0e, 0x19, 0x4a, 0x56, 0xa1, 0x1b, - 0x56, 0x62, 0x37, 0x89, 0xad, 0xe3, 0xb5, 0x70, 0xdd, 0xc6, 0x2f, 0xe2, 0xfa, 0x7b, 0x62, 0xab, - 0x5e, 0xe7, 0xb1, 0x30, 0xf2, 0xfa, 0x90, 0x9a, 0x74, 0x5d, 0xb8, 0xb7, 0x6c, 0xd1, 0xff, 0x54, - 0x5c, 0x11, 0xaf, 0x6b, 0x5f, 0x59, 0x5a, 0xfb, 0xd3, 0x8d, 0x8f, 0x17, 0x35, 0xf2, 0xf3, 0xa2, - 0x46, 0xea, 0x15, 0xba, 0x73, 0x43, 0x8f, 0xb3, 0xd1, 0xfc, 0x46, 0xe8, 0x6a, 0x07, 0x15, 0x7b, - 0x47, 0xb7, 0xe7, 0xf3, 0x6c, 0x3f, 0x58, 0xb4, 0x2f, 0xc1, 0x62, 0x5b, 0xd5, 0xc6, 0x92, 0xec, - 0xe9, 0xec, 0x7a, 0x74, 0x6b, 0x6e, 0xa4, 0xec, 0xd1, 0x3f, 0xab, 0x6f, 0xae, 0x59, 0x75, 0x7f, - 0x39, 0xb2, 0x7b, 0xa9, 0xa5, 0x3e, 0x8f, 0x7c, 0x72, 0x39, 0xf2, 0xc9, 0x8f, 0x91, 0x4f, 0x3e, - 0x8c, 0xfd, 0xd2, 0xe5, 0xd8, 0x2f, 0x7d, 0x1d, 0xfb, 0x25, 0xba, 0x93, 0xc0, 0xc2, 0x4e, 0x47, - 0xe4, 0x6d, 0x73, 0x6e, 0x6d, 0x67, 0x94, 0x46, 0x02, 0x73, 0x11, 0x1f, 0x5c, 0x1d, 0x99, 0x5d, - 0xe1, 0x93, 0xdb, 0xf6, 0x3c, 0x0e, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x68, 0x60, 0x46, - 0x86, 0x03, 0x00, 0x00, + // 625 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x41, 0x4f, 0x13, 0x41, + 0x14, 0x66, 0x00, 0x85, 0x0e, 0xe8, 0x61, 0x52, 0xa5, 0x6d, 0xc2, 0x96, 0x6c, 0xa2, 0x21, 0x0a, + 0x3b, 0x69, 0x89, 0x26, 0x9a, 0x70, 0xa0, 0x24, 0x26, 0x1c, 0x1a, 0x71, 0x89, 0x31, 0xf1, 0x42, + 0xa6, 0xbb, 0xe3, 0x74, 0xe3, 0x76, 0x66, 0x99, 0x99, 0x2d, 0x34, 0xf1, 0x37, 0x18, 0x8f, 0x1e, + 0xf9, 0x11, 0xfc, 0x08, 0x8f, 0xc4, 0x93, 0xf1, 0x60, 0x0c, 0x5c, 0x3c, 0xf8, 0x0b, 0x3c, 0x99, + 0x9d, 0x19, 0x68, 0xd1, 0x12, 0xeb, 0xa9, 0x7d, 0xef, 0x7d, 0xdf, 0xcc, 0xf7, 0xbe, 0xb7, 0x6f, + 0xe0, 0x72, 0x26, 0x45, 0x9f, 0x72, 0xc2, 0x23, 0x8a, 0x85, 0x24, 0x51, 0x4a, 0x71, 0xbf, 0x81, + 0xf5, 0x51, 0x90, 0x49, 0xa1, 0x05, 0x2a, 0x0f, 0xcb, 0x81, 0x2d, 0x07, 0xfd, 0x46, 0xad, 0x1a, + 0x09, 0xd5, 0x13, 0x6a, 0xdf, 0x60, 0xb0, 0x0d, 0x2c, 0xa1, 0x56, 0x66, 0x82, 0x09, 0x9b, 0x2f, + 0xfe, 0xb9, 0xec, 0x03, 0x8b, 0xc1, 0x1d, 0xa2, 0x28, 0x3e, 0xc8, 0xa9, 0x1c, 0xe0, 0x7e, 0xa3, + 0x43, 0x35, 0x69, 0xe0, 0x8c, 0xb0, 0x84, 0x13, 0x9d, 0x08, 0xee, 0xb0, 0x55, 0x26, 0x04, 0x4b, + 0x29, 0x36, 0x51, 0x27, 0x7f, 0x83, 0x09, 0x1f, 0xd8, 0x92, 0x7f, 0x02, 0xe0, 0x52, 0x5b, 0xb1, + 0x3d, 0xca, 0xe3, 0x17, 0xc5, 0x21, 0x5b, 0x69, 0xda, 0x22, 0x69, 0x21, 0x4e, 0xa1, 0x0a, 0x9c, + 0x8b, 0x24, 0x25, 0x5a, 0xc8, 0x0a, 0x58, 0x01, 0xab, 0xa5, 0xf0, 0x22, 0x44, 0xcb, 0x10, 0x46, + 0x5d, 0xc2, 0x39, 0x4d, 0xf7, 0x93, 0xb8, 0x32, 0x6d, 0x8a, 0x25, 0x97, 0xd9, 0x89, 0x0b, 0x22, + 0x89, 0x63, 0x49, 0x95, 0xaa, 0xcc, 0x58, 0xa2, 0x0b, 0xd1, 0x33, 0x08, 0x87, 0xea, 0x2a, 0xb3, + 0x2b, 0x60, 0x75, 0xa1, 0x79, 0x3f, 0x70, 0xed, 0x16, 0xad, 0x04, 0xa6, 0x95, 0xc0, 0xb5, 0x12, + 0xec, 0x12, 0x46, 0x43, 0x7a, 0x90, 0x53, 0xa5, 0xc3, 0x11, 0xa6, 0xbf, 0x09, 0xeb, 0xd7, 0xa8, + 0x0e, 0xa9, 0xca, 0x04, 0x57, 0x14, 0xd5, 0xe0, 0xbc, 0x2a, 0x98, 0x3c, 0xa2, 0x46, 0xfe, 0x6c, + 0x78, 0x19, 0xfb, 0x3f, 0x01, 0xbc, 0xd3, 0x56, 0xcc, 0x70, 0x9f, 0x9b, 0x19, 0xb8, 0x4b, 0xd0, + 0x1e, 0xbc, 0x61, 0x14, 0x18, 0xca, 0x62, 0x6b, 0xf3, 0xd7, 0xb7, 0xfa, 0x13, 0x96, 0xe8, 0x6e, + 0xde, 0x09, 0x22, 0xd1, 0xc3, 0xdb, 0x42, 0xf5, 0x5e, 0x11, 0xd5, 0xc3, 0x87, 0x44, 0xf5, 0x62, + 0x7c, 0x64, 0x7e, 0xb1, 0x1e, 0x64, 0x54, 0x05, 0x21, 0x39, 0xdc, 0x16, 0x5c, 0x4b, 0x12, 0xe9, + 0x36, 0x55, 0xaa, 0x50, 0x6e, 0xcf, 0x42, 0x75, 0xb8, 0xa0, 0x44, 0x2e, 0x23, 0xba, 0x9f, 0x09, + 0xa9, 0x9d, 0x5f, 0xd0, 0xa6, 0x76, 0x85, 0xd4, 0xe8, 0x1e, 0xbc, 0xed, 0x00, 0xce, 0x44, 0xe7, + 0xdb, 0x2d, 0x9b, 0xdd, 0xb6, 0x49, 0xf4, 0x18, 0x96, 0x48, 0xae, 0xbb, 0x42, 0x26, 0x7a, 0x60, + 0xcc, 0x2b, 0xb5, 0x2a, 0x9f, 0x4f, 0xd6, 0xcb, 0xce, 0xbf, 0x2d, 0x6b, 0xf2, 0x9e, 0x96, 0x09, + 0x67, 0xe1, 0x10, 0xea, 0x6f, 0xc0, 0xbb, 0x7f, 0x76, 0xeb, 0x4c, 0xaa, 0xc2, 0x79, 0x23, 0xb1, + 0x18, 0xa3, 0x35, 0x69, 0xce, 0xc4, 0x3b, 0xb1, 0xff, 0x1e, 0x18, 0xd6, 0xcb, 0x2c, 0x26, 0x9a, + 0x5e, 0x35, 0xa9, 0x39, 0x9c, 0x2f, 0xf8, 0x87, 0x8a, 0xcb, 0xc9, 0x5f, 0xd1, 0x3e, 0x3d, 0xb1, + 0xf6, 0xa7, 0xf3, 0x1f, 0x8f, 0xeb, 0xe0, 0xc7, 0x71, 0x1d, 0xf8, 0x55, 0xf3, 0xa5, 0x5e, 0xd5, + 0x63, 0xdb, 0x68, 0x7e, 0x9d, 0x86, 0x33, 0x6d, 0xc5, 0xd0, 0x5b, 0xb8, 0x38, 0x5a, 0x47, 0x6b, + 0xc1, 0xb8, 0x65, 0x0b, 0xc6, 0xb7, 0x55, 0x5b, 0x9f, 0x10, 0xed, 0xbc, 0xeb, 0xc2, 0x85, 0x11, + 0x4b, 0xd1, 0xc3, 0x6b, 0xd9, 0x7f, 0x7f, 0x66, 0xb5, 0xb5, 0xc9, 0xc0, 0xee, 0xa6, 0x77, 0xb0, + 0x3c, 0x76, 0x41, 0xaf, 0x17, 0x3c, 0x0e, 0x5e, 0x7b, 0xf4, 0x5f, 0xf0, 0x8b, 0xdb, 0x5b, 0xec, + 0xd3, 0x99, 0x07, 0x4e, 0xcf, 0x3c, 0xf0, 0xfd, 0xcc, 0x03, 0x1f, 0xce, 0xbd, 0xa9, 0xd3, 0x73, + 0x6f, 0xea, 0xcb, 0xb9, 0x37, 0x05, 0x97, 0x12, 0x31, 0xf6, 0xc8, 0x5d, 0xf0, 0xba, 0x39, 0xb2, + 0x34, 0x43, 0xc8, 0x7a, 0x22, 0x46, 0x22, 0x7c, 0x74, 0xf1, 0x3e, 0x9a, 0x05, 0xea, 0xdc, 0x34, + 0x4f, 0xd2, 0xc6, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xeb, 0xbf, 0x88, 0x41, 0x05, 0x00, + 0x00, } func (this *MsgUpdateOracleRequest) Equal(that interface{}) bool { @@ -328,6 +454,7 @@ type MsgClient interface { UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest, opts ...grpc.CallOption) (*MsgUpdateOracleResponse, error) // QueryOracle sends an icq to an oracle on another chain QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, opts ...grpc.CallOption) (*MsgQueryOracleResponse, error) + SendQueryAllBalances(ctx context.Context, in *MsgSendQueryAllBalances, opts ...grpc.CallOption) (*MsgSendQueryAllBalancesResponse, error) } type msgClient struct { @@ -356,12 +483,22 @@ func (c *msgClient) QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, return out, nil } +func (c *msgClient) SendQueryAllBalances(ctx context.Context, in *MsgSendQueryAllBalances, opts ...grpc.CallOption) (*MsgSendQueryAllBalancesResponse, error) { + out := new(MsgSendQueryAllBalancesResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Msg/SendQueryAllBalances", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateOracle is the RPC endpoint for updating the oracle UpdateOracle(context.Context, *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) // QueryOracle sends an icq to an oracle on another chain QueryOracle(context.Context, *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) + SendQueryAllBalances(context.Context, *MsgSendQueryAllBalances) (*MsgSendQueryAllBalancesResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -374,6 +511,9 @@ func (*UnimplementedMsgServer) UpdateOracle(ctx context.Context, req *MsgUpdateO func (*UnimplementedMsgServer) QueryOracle(ctx context.Context, req *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryOracle not implemented") } +func (*UnimplementedMsgServer) SendQueryAllBalances(ctx context.Context, req *MsgSendQueryAllBalances) (*MsgSendQueryAllBalancesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendQueryAllBalances not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -415,6 +555,24 @@ func _Msg_QueryOracle_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Msg_SendQueryAllBalances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSendQueryAllBalances) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SendQueryAllBalances(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.oracle.v1.Msg/SendQueryAllBalances", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SendQueryAllBalances(ctx, req.(*MsgSendQueryAllBalances)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "provenance.oracle.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -427,11 +585,99 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryOracle", Handler: _Msg_QueryOracle_Handler, }, + { + MethodName: "SendQueryAllBalances", + Handler: _Msg_SendQueryAllBalances_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/oracle/v1/tx.proto", } +func (m *MsgSendQueryAllBalances) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSendQueryAllBalances) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendQueryAllBalances) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSendQueryAllBalancesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSendQueryAllBalancesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendQueryAllBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *MsgQueryOracleRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -582,6 +828,43 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgSendQueryAllBalances) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSendQueryAllBalancesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovTx(uint64(m.Sequence)) + } + return n +} + func (m *MsgQueryOracleRequest) Size() (n int) { if m == nil { return 0 @@ -651,6 +934,257 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgSendQueryAllBalances) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSendQueryAllBalances: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendQueryAllBalances: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSendQueryAllBalancesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSendQueryAllBalancesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendQueryAllBalancesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 13b308b8987288abe49755554a2693218dee2302 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 2 Aug 2023 16:17:08 -0400 Subject: [PATCH 11/96] Disconnected example ICQ and started writing our own. Added some implementation to add a contract address for the oracle. Tested and verified that ICQ hits our custom query entrypoint. --- docs/proto-docs.md | 74 +-- proto/provenance/oracle/v1/query.proto | 17 - proto/provenance/oracle/v1/tx.proto | 23 +- x/oracle/client/cli/query.go | 31 ++ x/oracle/client/cli/tx.go | 100 +++- x/oracle/keeper/msg_server.go | 26 +- x/oracle/keeper/oracle.go | 24 + x/oracle/keeper/queries.go | 17 +- x/oracle/keeper/query_server.go | 19 +- x/oracle/keeper/relay.go | 3 +- x/oracle/types/codec.go | 1 - x/oracle/types/errors.go | 7 +- x/oracle/types/msgs.go | 32 +- x/oracle/types/queries.go | 8 + x/oracle/types/query.pb.go | 447 ++-------------- x/oracle/types/query.pb.gw.go | 80 --- x/oracle/types/tx.pb.go | 700 ++----------------------- 17 files changed, 299 insertions(+), 1310 deletions(-) create mode 100644 x/oracle/keeper/oracle.go diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 0e57580221..7b51ae2cc0 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -444,8 +444,6 @@ - [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) - [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) - [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) - - [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) - - [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) - [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) - [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) @@ -454,8 +452,6 @@ - [provenance/oracle/v1/tx.proto](#provenance/oracle/v1/tx.proto) - [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) - [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) - - [MsgSendQueryAllBalances](#provenance.oracle.v1.MsgSendQueryAllBalances) - - [MsgSendQueryAllBalancesResponse](#provenance.oracle.v1.MsgSendQueryAllBalancesResponse) - [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) - [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) @@ -6827,36 +6823,6 @@ QueryOracleContractResponse contains the result of the query to the oracle's sma - - -### QueryOracleResultRequest -QueryOracleResultRequest attempts to obtain the result of the oracle query. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `query_id` | [uint64](#uint64) | | The id of the query to get the result from | - - - - - - - - -### QueryOracleResultResponse -QueryOracleResult contains the result of the oracle query. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `data` | [bytes](#bytes) | | Data contains the json data returned from the smart contract. | - - - - - - ### QueryQueryStateRequest @@ -6903,7 +6869,6 @@ Query defines the gRPC querier service for oracle module. | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `ContractAddress` | [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) | [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) | ContractAddress returns the address of the oracle's contract | GET|/provenance/oracle/v1/contract_address| | `OracleContract` | [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) | [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) | OracleContract sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle_contract| -| `OracleResult` | [QueryOracleResultRequest](#provenance.oracle.v1.QueryOracleResultRequest) | [QueryOracleResultResponse](#provenance.oracle.v1.QueryOracleResultResponse) | OracleResult returns the address of the oracle's contract | GET|/provenance/oracle/v1/oracle_result| | `QueryState` | [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) | [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) | | GET|/quasar-finance/interchainquerydemo/interquery/query_state| @@ -6926,8 +6891,7 @@ MsgQueryOracleRequest queries an Oracle on another chain | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `query` | [bytes](#bytes) | | Query contains the query data passed to the oracle. | -| `source_port` | [string](#string) | | Source port is the source port to the oracle. | -| `source_channel` | [string](#string) | | Source channel is the channel to the oracle. | +| `channel` | [string](#string) | | Channel is the channel to the oracle. | | `authority` | [string](#string) | | The signing authority for the request | @@ -6943,40 +6907,7 @@ MsgQueryOracleResponse contains the id of the oracle query. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `query_id` | [uint64](#uint64) | | The id that uniquely identifies the query. | - - - - - - - - -### MsgSendQueryAllBalances - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `creator` | [string](#string) | | | -| `channel_id` | [string](#string) | | | -| `address` | [string](#string) | | | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | | - - - - - - - - -### MsgSendQueryAllBalancesResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `sequence` | [uint64](#uint64) | | | +| `sequence` | [uint64](#uint64) | | The sequence number that uniquely identifies the query. | @@ -7024,7 +6955,6 @@ Msg | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `UpdateOracle` | [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) | [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) | UpdateOracle is the RPC endpoint for updating the oracle | | | `QueryOracle` | [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) | [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) | QueryOracle sends an icq to an oracle on another chain | | -| `SendQueryAllBalances` | [MsgSendQueryAllBalances](#provenance.oracle.v1.MsgSendQueryAllBalances) | [MsgSendQueryAllBalancesResponse](#provenance.oracle.v1.MsgSendQueryAllBalancesResponse) | | | diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index edb0504a60..808b5fe980 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -22,11 +22,6 @@ service Query { option (google.api.http).get = "/provenance/oracle/v1/oracle_contract"; } - // OracleResult returns the address of the oracle's contract - rpc OracleResult(QueryOracleResultRequest) returns (QueryOracleResultResponse) { - option (google.api.http).get = "/provenance/oracle/v1/oracle_result"; - } - rpc QueryState(QueryQueryStateRequest) returns (QueryQueryStateResponse) { option (google.api.http).get = "/quasar-finance/interchainquerydemo/interquery/query_state"; } @@ -60,16 +55,4 @@ message QueryOracleContractRequest { message QueryOracleContractResponse { // Data contains the json data returned from the smart contract. bytes data = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; -} - -// QueryOracleResultRequest attempts to obtain the result of the oracle query. -message QueryOracleResultRequest { - // The id of the query to get the result from - uint64 query_id = 1; -} - -// QueryOracleResult contains the result of the oracle query. -message QueryOracleResultResponse { - // Data contains the json data returned from the smart contract. - bytes data = 2 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; } \ No newline at end of file diff --git a/proto/provenance/oracle/v1/tx.proto b/proto/provenance/oracle/v1/tx.proto index f059cec162..3ddcbe201e 100644 --- a/proto/provenance/oracle/v1/tx.proto +++ b/proto/provenance/oracle/v1/tx.proto @@ -16,37 +16,22 @@ service Msg { rpc UpdateOracle(MsgUpdateOracleRequest) returns (MsgUpdateOracleResponse); // QueryOracle sends an icq to an oracle on another chain rpc QueryOracle(MsgQueryOracleRequest) returns (MsgQueryOracleResponse); - - rpc SendQueryAllBalances(MsgSendQueryAllBalances) returns (MsgSendQueryAllBalancesResponse); -} - -message MsgSendQueryAllBalances { - string creator = 1; - string channel_id = 2; - string address = 3; - cosmos.base.query.v1beta1.PageRequest pagination = 4; -} - -message MsgSendQueryAllBalancesResponse { - uint64 sequence = 1; } // MsgQueryOracleRequest queries an Oracle on another chain message MsgQueryOracleRequest { // Query contains the query data passed to the oracle. bytes query = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; - // Source port is the source port to the oracle. - string source_port = 2; - // Source channel is the channel to the oracle. - string source_channel = 3; + // Channel is the channel to the oracle. + string channel = 3; // The signing authority for the request string authority = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // MsgQueryOracleResponse contains the id of the oracle query. message MsgQueryOracleResponse { - // The id that uniquely identifies the query. - uint64 query_id = 1; + // The sequence number that uniquely identifies the query. + uint64 sequence = 1; } // MsgUpdateOracleRequest is the request type for updating an oracle's contract address diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index e3008f1560..cde297e9a0 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -21,6 +21,7 @@ func GetQueryCmd() *cobra.Command { } queryCmd.AddCommand( CmdQueryState(), + CmdQueryContractAddress(), ) return queryCmd } @@ -62,3 +63,33 @@ func CmdQueryState() *cobra.Command { return cmd } + +func CmdQueryContractAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "contract-address", + Short: "Returns the address of the contract that the oracle is using", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryContractAddressRequest{} + + res, err := queryClient.ContractAddress(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index bc3a729439..6cd1e18287 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -1,6 +1,12 @@ package cli import ( + "encoding/base64" + "encoding/hex" + "encoding/json" + "errors" + "flag" + "fmt" "strconv" "github.com/cosmos/cosmos-sdk/client" @@ -22,7 +28,7 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - CmdSendQueryAllBalances(), + CmdOracleQuery(), ) return txCmd @@ -30,27 +36,57 @@ func NewTxCmd() *cobra.Command { var _ = strconv.Itoa(0) -func CmdSendQueryAllBalances() *cobra.Command { +func CmdOracleUpdate() *cobra.Command { cmd := &cobra.Command{ - Use: "send-query-all-balances [channel-id] [address]", - Short: "Query the balances of an account on the remote chain via ICQ", - Args: cobra.ExactArgs(2), + Use: "oracle-update [address]", + Short: "Update the local oracle's contract address", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - pageReq, err := client.ReadPageRequest(cmd.Flags()) + msg := types.NewMsgUpdateOracle( + clientCtx.GetFromAddress().String(), + args[0], + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdOracleQuery() *cobra.Command { + decoder := newArgDecoder(asciiDecodeString) + cmd := &cobra.Command{ + Use: "oracle-query [channel-id] [json]", + Short: "Query the oracle on the remote chain via ICQ", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - msg := types.NewMsgSendQueryAllBalances( + queryData, err := decoder.DecodeString(args[1]) + if err != nil { + return fmt.Errorf("decode query: %s", err) + } + if !json.Valid(queryData) { + return errors.New("query data must be json") + } + + msg := types.NewMsgQueryOracle( clientCtx.GetFromAddress().String(), - args[0], // channel id - args[1], // address - pageReq, + args[0], // channel id + queryData, // address ) if err := msg.ValidateBasic(); err != nil { return err @@ -60,7 +96,49 @@ func CmdSendQueryAllBalances() *cobra.Command { } flags.AddTxFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "send query all balances") return cmd } + +type argumentDecoder struct { + // dec is the default decoder + dec func(string) ([]byte, error) + asciiF, hexF, b64F bool +} + +func newArgDecoder(def func(string) ([]byte, error)) *argumentDecoder { + return &argumentDecoder{dec: def} +} + +func (a *argumentDecoder) RegisterFlags(f *flag.FlagSet, argName string) { + f.BoolVar(&a.asciiF, "ascii", false, "ascii encoded "+argName) + f.BoolVar(&a.hexF, "hex", false, "hex encoded "+argName) + f.BoolVar(&a.b64F, "b64", false, "base64 encoded "+argName) +} + +func (a *argumentDecoder) DecodeString(s string) ([]byte, error) { + found := -1 + for i, v := range []*bool{&a.asciiF, &a.hexF, &a.b64F} { + if !*v { + continue + } + if found != -1 { + return nil, errors.New("multiple decoding flags used") + } + found = i + } + switch found { + case 0: + return asciiDecodeString(s) + case 1: + return hex.DecodeString(s) + case 2: + return base64.StdEncoding.DecodeString(s) + default: + return a.dec(s) + } +} + +func asciiDecodeString(s string) ([]byte, error) { + return []byte(s), nil +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index cac5fe3e2e..be726e50a7 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" @@ -28,44 +27,39 @@ var _ types.MsgServer = msgServer{} // UpdateOracle changes the oracle's address to the provided one func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracleRequest) (*types.MsgUpdateOracleResponse, error) { - //ctx := sdk.UnwrapSDKContext(goCtx) + ctx := sdk.UnwrapSDKContext(goCtx) + s.Keeper.SetOracleContract(ctx, sdk.MustAccAddressFromBech32(msg.Address)) return &types.MsgUpdateOracleResponse{}, nil } -func (s msgServer) QueryOracle(goCtx context.Context, msg *types.MsgQueryOracleRequest) (*types.MsgQueryOracleResponse, error) { - return &types.MsgQueryOracleResponse{}, nil -} - -func (k msgServer) SendQueryAllBalances(goCtx context.Context, msg *types.MsgSendQueryAllBalances) (*types.MsgSendQueryAllBalancesResponse, error) { +func (k msgServer) QueryOracle(goCtx context.Context, msg *types.MsgQueryOracleRequest) (*types.MsgQueryOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(k.GetPort(ctx), msg.ChannelId)) + chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(k.GetPort(ctx), msg.Channel)) if !found { return nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") } - q := banktypes.QueryAllBalancesRequest{ - Address: msg.Address, - Pagination: msg.Pagination, + q := types.QueryOracleContractRequest{ + Query: msg.GetQuery(), } + reqs := []abcitypes.RequestQuery{ { - Path: "/cosmos.bank.v1beta1.Query/AllBalances", + Path: "/provenance.oracle.v1.Query/OracleContract", Data: k.cdc.MustMarshal(&q), }, } - // timeoutTimestamp set to max value with the unsigned bit shifted to sastisfy hermes timestamp conversion - // it is the responsibility of the auth module developer to ensure an appropriate timeout timestamp timeoutTimestamp := ctx.BlockTime().Add(time.Minute).UnixNano() - seq, err := k.SendQuery(ctx, types.PortID, msg.ChannelId, chanCap, reqs, clienttypes.ZeroHeight(), uint64(timeoutTimestamp)) + seq, err := k.SendQuery(ctx, types.PortID, msg.Channel, chanCap, reqs, clienttypes.ZeroHeight(), uint64(timeoutTimestamp)) if err != nil { return nil, err } k.SetQueryRequest(ctx, seq, q) - return &types.MsgSendQueryAllBalancesResponse{ + return &types.MsgQueryOracleResponse{ Sequence: seq, }, nil } diff --git a/x/oracle/keeper/oracle.go b/x/oracle/keeper/oracle.go new file mode 100644 index 0000000000..99f38aa581 --- /dev/null +++ b/x/oracle/keeper/oracle.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" +) + +// SetTrigger Sets the trigger in the store. +func (k Keeper) SetOracleContract(ctx sdk.Context, contract sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetContractStoreKey(), contract) +} + +// GetTrigger Gets a trigger from the store by id. +func (k Keeper) GetOracleContract(ctx sdk.Context) (acc sdk.AccAddress, err error) { + store := ctx.KVStore(k.storeKey) + key := types.GetContractStoreKey() + acc = store.Get(key) + if len(acc) == 0 { + return sdk.AccAddress{}, types.ErrContractAddressDoesNotExist + } + + return acc, err +} diff --git a/x/oracle/keeper/queries.go b/x/oracle/keeper/queries.go index c8e7d7afa5..7716cb07b3 100644 --- a/x/oracle/keeper/queries.go +++ b/x/oracle/keeper/queries.go @@ -3,45 +3,44 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" gogotypes "github.com/gogo/protobuf/types" "github.com/provenance-io/provenance/x/oracle/types" ) // SetQueryRequest saves the query request -func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req banktypes.QueryAllBalancesRequest) { +func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req types.QueryOracleContractRequest) { store := ctx.KVStore(k.storeKey) store.Set(types.QueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) } // GetQueryRequest returns the query request by packet sequence -func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (banktypes.QueryAllBalancesRequest, error) { +func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.QueryOracleContractRequest, error) { bz := ctx.KVStore(k.storeKey).Get(types.QueryRequestStoreKey(packetSequence)) if bz == nil { - return banktypes.QueryAllBalancesRequest{}, sdkerrors.Wrapf(types.ErrSample, + return types.QueryOracleContractRequest{}, sdkerrors.Wrapf(types.ErrSample, "GetQueryRequest: Result for packet sequence %d is not available.", packetSequence, ) } - var req banktypes.QueryAllBalancesRequest + var req types.QueryOracleContractRequest k.cdc.MustUnmarshal(bz, &req) return req, nil } // SetQueryResponse saves the query response -func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp banktypes.QueryAllBalancesResponse) { +func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp types.QueryOracleContractResponse) { store := ctx.KVStore(k.storeKey) store.Set(types.QueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) } // GetQueryResponse returns the query response by packet sequence -func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (banktypes.QueryAllBalancesResponse, error) { +func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types.QueryOracleContractResponse, error) { bz := ctx.KVStore(k.storeKey).Get(types.QueryResponseStoreKey(packetSequence)) if bz == nil { - return banktypes.QueryAllBalancesResponse{}, sdkerrors.Wrapf(types.ErrSample, + return types.QueryOracleContractResponse{}, sdkerrors.Wrapf(types.ErrSample, "GetQueryResponse: Result for packet sequence %d is not available.", packetSequence, ) } - var resp banktypes.QueryAllBalancesResponse + var resp types.QueryOracleContractResponse k.cdc.MustUnmarshal(bz, &resp) return resp, nil } diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index c0e60d24d6..ab1666d7e6 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -13,18 +13,25 @@ import ( var _ types.QueryServer = Keeper{} // QueryAddress returns the address of the oracle's contract -func (k Keeper) ContractAddress(ctx context.Context, req *types.QueryContractAddressRequest) (*types.QueryContractAddressResponse, error) { - return &types.QueryContractAddressResponse{}, nil +func (k Keeper) ContractAddress(goCtx context.Context, req *types.QueryContractAddressRequest) (*types.QueryContractAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + contract, err := k.GetOracleContract(ctx) + if err != nil { + return nil, err + } + + return &types.QueryContractAddressResponse{Address: contract.String()}, nil } func (k Keeper) OracleContract(ctx context.Context, req *types.QueryOracleContractRequest) (*types.QueryOracleContractResponse, error) { + // We do the logic here to actually send it to the oracle return &types.QueryOracleContractResponse{}, nil } -func (k Keeper) OracleResult(ctx context.Context, req *types.QueryOracleResultRequest) (*types.QueryOracleResultResponse, error) { - return &types.QueryOracleResultResponse{}, nil -} - func (k Keeper) QueryState(goCtx context.Context, req *types.QueryQueryStateRequest) (*types.QueryQueryStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index 3123bdbdaf..c674282b3b 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -3,7 +3,6 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/provenance-io/provenance/x/oracle/types" @@ -99,7 +98,7 @@ func (k Keeper) OnAcknowledgementPacket( return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") } - var r banktypes.QueryAllBalancesResponse + var r types.QueryOracleContractResponse if err := k.cdc.Unmarshal(resps[0].Value, &r); err != nil { return sdkerrors.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) } diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 6d45290830..ec0395c2bf 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -15,7 +15,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { (*sdk.Msg)(nil), &MsgUpdateOracleRequest{}, &MsgQueryOracleRequest{}, - &MsgSendQueryAllBalances{}, ) registry.RegisterImplementations((*proto.Message)(nil), diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index 762d42f1e5..e181e7e753 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -5,7 +5,8 @@ import ( ) var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") - ErrInvalidPacketTimeout = sdkerrors.Register(ModuleName, 1500, "invalid packet timeout") - ErrInvalidVersion = sdkerrors.Register(ModuleName, 1501, "invalid version") + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrInvalidPacketTimeout = sdkerrors.Register(ModuleName, 1500, "invalid packet timeout") + ErrInvalidVersion = sdkerrors.Register(ModuleName, 1501, "invalid version") + ErrContractAddressDoesNotExist = sdkerrors.Register(ModuleName, 1502, "missing contract address") ) diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 55d166db13..fc02e3e0bf 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -2,35 +2,23 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - query "github.com/cosmos/cosmos-sdk/types/query" ) -var _, _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgQueryOracleRequest{}, &MsgSendQueryAllBalances{} +var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgQueryOracleRequest{} -func NewMsgSendQueryAllBalances(creator, channelId string, addr string, page *query.PageRequest) *MsgSendQueryAllBalances { - return &MsgSendQueryAllBalances{ - Creator: creator, - ChannelId: channelId, - Address: addr, - Pagination: page, +func NewMsgQueryOracle(creator, channelId string, query []byte) *MsgQueryOracleRequest { + return &MsgQueryOracleRequest{ + Authority: creator, + Channel: channelId, + Query: query, } } -func (msg *MsgSendQueryAllBalances) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) +func NewMsgUpdateOracle(creator, addr string) *MsgUpdateOracleRequest { + return &MsgUpdateOracleRequest{ + Authority: creator, + Address: addr, } - return []sdk.AccAddress{creator} -} - -func (msg *MsgSendQueryAllBalances) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - return nil } // GetSigners indicates that the message must have been signed by the parent. diff --git a/x/oracle/types/queries.go b/x/oracle/types/queries.go index 52288fa615..a206fe089f 100644 --- a/x/oracle/types/queries.go +++ b/x/oracle/types/queries.go @@ -11,8 +11,16 @@ var ( // LastQueryPacketSeqKey is the key for the last packet sequence LastQueryPacketSeqKey = "coin_rates_last_id" + + // ContractStoreKey is the key for the oracle's contract address + ContractStoreKey = []byte{0x01} ) +// ContractStoreKey is a function to get the key for the oracle's contract in store +func GetContractStoreKey() []byte { + return []byte(ContractStoreKey) +} + // QueryRequestStoreKey is a function to generate key for each result in store func QueryRequestStoreKey(packetSequence uint64) []byte { return append(KeyPrefix(QueryRequestStoreKeyPrefix), uint64ToBytes(packetSequence)...) diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 6ebe0f8204..4c9c10c21d 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -303,98 +303,6 @@ func (m *QueryOracleContractResponse) GetData() github_com_CosmWasm_wasmd_x_wasm return nil } -// QueryOracleResultRequest attempts to obtain the result of the oracle query. -type QueryOracleResultRequest struct { - // The id of the query to get the result from - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` -} - -func (m *QueryOracleResultRequest) Reset() { *m = QueryOracleResultRequest{} } -func (m *QueryOracleResultRequest) String() string { return proto.CompactTextString(m) } -func (*QueryOracleResultRequest) ProtoMessage() {} -func (*QueryOracleResultRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{6} -} -func (m *QueryOracleResultRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryOracleResultRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryOracleResultRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryOracleResultRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOracleResultRequest.Merge(m, src) -} -func (m *QueryOracleResultRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryOracleResultRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOracleResultRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryOracleResultRequest proto.InternalMessageInfo - -func (m *QueryOracleResultRequest) GetQueryId() uint64 { - if m != nil { - return m.QueryId - } - return 0 -} - -// QueryOracleResult contains the result of the oracle query. -type QueryOracleResultResponse struct { - // Data contains the json data returned from the smart contract. - Data github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,2,opt,name=data,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"data,omitempty"` -} - -func (m *QueryOracleResultResponse) Reset() { *m = QueryOracleResultResponse{} } -func (m *QueryOracleResultResponse) String() string { return proto.CompactTextString(m) } -func (*QueryOracleResultResponse) ProtoMessage() {} -func (*QueryOracleResultResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{7} -} -func (m *QueryOracleResultResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryOracleResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryOracleResultResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryOracleResultResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOracleResultResponse.Merge(m, src) -} -func (m *QueryOracleResultResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryOracleResultResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOracleResultResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryOracleResultResponse proto.InternalMessageInfo - -func (m *QueryOracleResultResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { - if m != nil { - return m.Data - } - return nil -} - func init() { proto.RegisterType((*QueryQueryStateRequest)(nil), "provenance.oracle.v1.QueryQueryStateRequest") proto.RegisterType((*QueryQueryStateResponse)(nil), "provenance.oracle.v1.QueryQueryStateResponse") @@ -402,55 +310,48 @@ func init() { proto.RegisterType((*QueryContractAddressResponse)(nil), "provenance.oracle.v1.QueryContractAddressResponse") proto.RegisterType((*QueryOracleContractRequest)(nil), "provenance.oracle.v1.QueryOracleContractRequest") proto.RegisterType((*QueryOracleContractResponse)(nil), "provenance.oracle.v1.QueryOracleContractResponse") - proto.RegisterType((*QueryOracleResultRequest)(nil), "provenance.oracle.v1.QueryOracleResultRequest") - proto.RegisterType((*QueryOracleResultResponse)(nil), "provenance.oracle.v1.QueryOracleResultResponse") } func init() { proto.RegisterFile("provenance/oracle/v1/query.proto", fileDescriptor_169907f611744c57) } var fileDescriptor_169907f611744c57 = []byte{ - // 645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x4f, 0x14, 0x31, - 0x14, 0xc7, 0xb7, 0x04, 0x04, 0x2b, 0xd1, 0xa4, 0xd9, 0xc8, 0x32, 0xe2, 0x42, 0xc6, 0xa0, 0x24, - 0xba, 0xad, 0xbb, 0xa2, 0x89, 0x46, 0x0f, 0x2c, 0x27, 0x0f, 0x46, 0x19, 0x0e, 0x26, 0x5e, 0x36, - 0x65, 0xa6, 0x0c, 0x93, 0x30, 0xed, 0x6c, 0xdb, 0xe1, 0xc7, 0xd5, 0x8b, 0x57, 0x13, 0xaf, 0x1e, - 0x3d, 0x70, 0xf1, 0xe6, 0x1f, 0xc1, 0x91, 0xe8, 0xc5, 0x13, 0x31, 0xe0, 0x5f, 0xe1, 0xc9, 0x6c, - 0xdb, 0x81, 0x05, 0x26, 0x0b, 0x24, 0x5c, 0x76, 0xdb, 0xe9, 0xf7, 0xbd, 0xef, 0xa7, 0xed, 0x7b, - 0x85, 0x33, 0x99, 0x14, 0x1b, 0x8c, 0x53, 0x1e, 0x32, 0x22, 0x24, 0x0d, 0xd7, 0x19, 0xd9, 0x68, - 0x92, 0x6e, 0xce, 0xe4, 0x36, 0xce, 0xa4, 0xd0, 0x02, 0x55, 0x8f, 0x15, 0xd8, 0x2a, 0xf0, 0x46, - 0xd3, 0xab, 0xc6, 0x22, 0x16, 0x46, 0x40, 0x7a, 0x23, 0xab, 0xf5, 0xa6, 0x62, 0x21, 0xe2, 0x75, - 0x46, 0x68, 0x96, 0x10, 0xca, 0xb9, 0xd0, 0x54, 0x27, 0x82, 0x2b, 0xb7, 0x3a, 0x19, 0x0a, 0x95, - 0x0a, 0xd5, 0xb1, 0x61, 0x76, 0x52, 0x2c, 0xb9, 0x40, 0x33, 0x5b, 0xc9, 0x57, 0x09, 0xe5, 0xce, - 0xdf, 0x9f, 0x87, 0xb7, 0x97, 0x7a, 0x38, 0xe6, 0x67, 0x59, 0x53, 0xcd, 0x02, 0xd6, 0xcd, 0x99, - 0xd2, 0xc8, 0x83, 0x63, 0xaa, 0x37, 0xe4, 0x21, 0xab, 0x81, 0x19, 0x30, 0x37, 0x1c, 0x1c, 0xcd, - 0xfd, 0x4f, 0x00, 0x4e, 0x9c, 0x09, 0x53, 0x99, 0xe0, 0x8a, 0xa1, 0x79, 0x38, 0x2a, 0x6d, 0x0a, - 0x13, 0x76, 0xa3, 0x55, 0xc5, 0xd6, 0x1e, 0x17, 0xf6, 0x78, 0x81, 0x6f, 0xb7, 0x87, 0x77, 0xf7, - 0xa7, 0x2b, 0x41, 0x21, 0x45, 0xcf, 0xe0, 0x98, 0x74, 0x19, 0x6a, 0x43, 0xe7, 0x84, 0x81, 0xe0, - 0x48, 0xeb, 0xdf, 0x85, 0x77, 0x0c, 0xc3, 0xa2, 0xe0, 0x5a, 0xd2, 0x50, 0x2f, 0x44, 0x91, 0x64, - 0x4a, 0xb9, 0x4d, 0xf8, 0x01, 0x9c, 0x2a, 0x5f, 0x76, 0xb0, 0x2d, 0x38, 0x4a, 0xed, 0x27, 0x03, - 0x7b, 0xbd, 0x5d, 0xfb, 0xf9, 0xa3, 0x51, 0x75, 0x87, 0xe7, 0xc4, 0xcb, 0x5a, 0x26, 0x3c, 0x0e, - 0x0a, 0xa1, 0xdf, 0x85, 0x9e, 0xc9, 0xf9, 0xd6, 0x5c, 0x57, 0x91, 0xb9, 0x38, 0xb6, 0x65, 0x38, - 0x62, 0xee, 0xd7, 0xe4, 0x1b, 0x6f, 0xbf, 0xfa, 0xb7, 0x3f, 0xfd, 0x3c, 0x4e, 0xf4, 0x5a, 0xbe, - 0x82, 0x43, 0x91, 0x92, 0x45, 0xa1, 0xd2, 0xf7, 0x54, 0xa5, 0x64, 0x93, 0xaa, 0x34, 0x22, 0x5b, - 0xe6, 0x9f, 0xe8, 0xed, 0x8c, 0x29, 0x1c, 0xd0, 0xcd, 0x22, 0xdb, 0x1b, 0xa6, 0x14, 0x8d, 0x59, - 0x60, 0x73, 0xf9, 0x99, 0xdb, 0xe5, 0x69, 0x4b, 0xb7, 0x8b, 0x25, 0x38, 0x1c, 0x51, 0x4d, 0xaf, - 0xc6, 0xd2, 0xa4, 0xf2, 0x9f, 0xc2, 0x5a, 0x9f, 0x63, 0xc0, 0x54, 0xbe, 0x7e, 0xb4, 0xc5, 0x49, - 0x38, 0x66, 0xb0, 0x3a, 0x49, 0xe4, 0x2a, 0x63, 0xd4, 0xcc, 0x5f, 0x47, 0x3e, 0x87, 0x93, 0x25, - 0x61, 0xa7, 0x30, 0x87, 0xae, 0x0c, 0xb3, 0xb5, 0x33, 0x02, 0x47, 0x8c, 0x21, 0xda, 0x01, 0xf0, - 0xd6, 0xa9, 0x5b, 0x46, 0x4d, 0x5c, 0xd6, 0x5d, 0x78, 0x40, 0xc1, 0x78, 0xad, 0xcb, 0x84, 0xb8, - 0x1a, 0xc4, 0x1f, 0x7f, 0xfd, 0xfd, 0x32, 0x34, 0x87, 0xee, 0x93, 0xd2, 0x76, 0x0f, 0x5d, 0x58, - 0xc7, 0x15, 0x10, 0xfa, 0x06, 0xe0, 0xcd, 0x93, 0x37, 0x89, 0x1e, 0x0f, 0xb0, 0x2d, 0xad, 0x33, - 0xaf, 0x79, 0x89, 0x08, 0xc7, 0xd9, 0x30, 0x9c, 0x0f, 0xd0, 0x6c, 0x39, 0xa7, 0x1d, 0x75, 0x0a, - 0x5c, 0xf4, 0x15, 0xc0, 0xf1, 0xfe, 0x7b, 0x44, 0xf8, 0x5c, 0xcb, 0x13, 0x75, 0xe2, 0x91, 0x0b, - 0xeb, 0x1d, 0xe0, 0x43, 0x03, 0x38, 0x8b, 0xee, 0x0d, 0x04, 0x94, 0x96, 0xe6, 0x3b, 0x80, 0xf0, - 0xf8, 0xf9, 0x41, 0x8f, 0x06, 0x98, 0x9d, 0x79, 0xdc, 0xbc, 0xc6, 0x05, 0xd5, 0x0e, 0xac, 0x6d, - 0xc0, 0x5e, 0xa2, 0x17, 0xa4, 0x9b, 0x53, 0x45, 0x65, 0x63, 0x35, 0xb1, 0x70, 0x09, 0xd7, 0x4c, - 0x86, 0x6b, 0x34, 0xe1, 0xa6, 0x03, 0x22, 0x96, 0x0a, 0xfb, 0xcd, 0x4c, 0xed, 0x4b, 0xdf, 0x51, - 0xbd, 0x5c, 0xed, 0x78, 0xf7, 0xa0, 0x0e, 0xf6, 0x0e, 0xea, 0xe0, 0xcf, 0x41, 0x1d, 0x7c, 0x3e, - 0xac, 0x57, 0xf6, 0x0e, 0xeb, 0x95, 0xdf, 0x87, 0xf5, 0x0a, 0x9c, 0x48, 0x44, 0x29, 0xce, 0x3b, - 0xf0, 0xa1, 0xd5, 0xd7, 0x20, 0xc7, 0x92, 0x46, 0x22, 0xfa, 0x4f, 0x68, 0xab, 0x38, 0x23, 0xd3, - 0x2c, 0x2b, 0xd7, 0xcc, 0x83, 0xf9, 0xe4, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0x51, 0xaf, - 0x92, 0x7d, 0x06, 0x00, 0x00, + // 575 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbd, 0x6e, 0x13, 0x31, + 0x1c, 0x8f, 0xab, 0x94, 0x16, 0x83, 0x40, 0xb2, 0x22, 0x5a, 0x8e, 0x72, 0xad, 0x4e, 0x02, 0x3a, + 0x10, 0x9b, 0x84, 0x0a, 0x09, 0x04, 0x43, 0xd3, 0x19, 0x41, 0x2f, 0x03, 0x12, 0x4b, 0xe4, 0x5c, + 0xdc, 0xeb, 0x49, 0x3d, 0xfb, 0x62, 0xfb, 0xd2, 0x66, 0x65, 0x41, 0x6c, 0x48, 0xbc, 0x02, 0x03, + 0x0b, 0x1b, 0x0f, 0xd1, 0xb1, 0x82, 0x85, 0xa9, 0x42, 0x09, 0x4f, 0xc1, 0x84, 0x62, 0xfb, 0x9a, + 0xd2, 0x9e, 0x02, 0x95, 0x58, 0x12, 0x7f, 0xfc, 0xbe, 0xfc, 0xff, 0xdb, 0x07, 0xd7, 0x32, 0x29, + 0x06, 0x8c, 0x53, 0x1e, 0x31, 0x22, 0x24, 0x8d, 0xf6, 0x18, 0x19, 0x34, 0x48, 0x3f, 0x67, 0x72, + 0x88, 0x33, 0x29, 0xb4, 0x40, 0xb5, 0x29, 0x02, 0x5b, 0x04, 0x1e, 0x34, 0xbc, 0x5a, 0x2c, 0x62, + 0x61, 0x00, 0x64, 0x32, 0xb2, 0x58, 0x6f, 0x25, 0x16, 0x22, 0xde, 0x63, 0x84, 0x66, 0x09, 0xa1, + 0x9c, 0x0b, 0x4d, 0x75, 0x22, 0xb8, 0x72, 0xbb, 0x37, 0x23, 0xa1, 0x52, 0xa1, 0x3a, 0x96, 0x66, + 0x27, 0xc5, 0x96, 0x23, 0x9a, 0x59, 0x37, 0xdf, 0x21, 0x94, 0x3b, 0xff, 0x60, 0x03, 0xde, 0xd8, + 0x9e, 0xc4, 0x31, 0x3f, 0x6d, 0x4d, 0x35, 0x0b, 0x59, 0x3f, 0x67, 0x4a, 0x23, 0x0f, 0x2e, 0xaa, + 0xc9, 0x90, 0x47, 0x6c, 0x19, 0xac, 0x81, 0xf5, 0x6a, 0x78, 0x32, 0x0f, 0xde, 0x02, 0xb8, 0x74, + 0x8e, 0xa6, 0x32, 0xc1, 0x15, 0x43, 0x1b, 0x70, 0x41, 0x5a, 0x09, 0x43, 0xbb, 0xd2, 0xac, 0x61, + 0x6b, 0x8f, 0x0b, 0x7b, 0xbc, 0xc9, 0x87, 0xad, 0xea, 0xe1, 0xf1, 0x6a, 0x25, 0x2c, 0xa0, 0xe8, + 0x11, 0x5c, 0x94, 0x4e, 0x61, 0x79, 0xee, 0x2f, 0x34, 0x10, 0x9e, 0x60, 0x83, 0xdb, 0xf0, 0x96, + 0xc9, 0xb0, 0x25, 0xb8, 0x96, 0x34, 0xd2, 0x9b, 0xbd, 0x9e, 0x64, 0x4a, 0xb9, 0x43, 0x04, 0x21, + 0x5c, 0x29, 0xdf, 0x76, 0x61, 0x9b, 0x70, 0x81, 0xda, 0x25, 0x13, 0xf6, 0x72, 0x6b, 0xf9, 0xeb, + 0x97, 0x7a, 0xcd, 0x15, 0xcf, 0x81, 0xdb, 0x5a, 0x26, 0x3c, 0x0e, 0x0b, 0x60, 0xd0, 0x87, 0x9e, + 0xd1, 0x7c, 0x61, 0xda, 0x55, 0x28, 0x17, 0x65, 0x6b, 0xc3, 0x79, 0xd3, 0x5f, 0xa3, 0x77, 0xb5, + 0xf5, 0xec, 0xd7, 0xf1, 0xea, 0xe3, 0x38, 0xd1, 0xbb, 0x79, 0x17, 0x47, 0x22, 0x25, 0x5b, 0x42, + 0xa5, 0xaf, 0xa8, 0x4a, 0xc9, 0x3e, 0x55, 0x69, 0x8f, 0x1c, 0x98, 0x7f, 0xa2, 0x87, 0x19, 0x53, + 0x38, 0xa4, 0xfb, 0x85, 0xda, 0x73, 0xa6, 0x14, 0x8d, 0x59, 0x68, 0xb5, 0x82, 0xcc, 0x9d, 0xf2, + 0xac, 0xa5, 0x3b, 0xc5, 0x36, 0xac, 0xf6, 0xa8, 0xa6, 0xff, 0xc7, 0xd2, 0x48, 0x35, 0xdf, 0x55, + 0xe1, 0xbc, 0xb1, 0x44, 0x9f, 0x00, 0xbc, 0x7e, 0xa6, 0x7c, 0xa8, 0x81, 0xcb, 0xae, 0x2d, 0x9e, + 0xd1, 0x09, 0xaf, 0x79, 0x11, 0x8a, 0x6b, 0x2e, 0x7e, 0xf3, 0xed, 0xe7, 0x87, 0xb9, 0x75, 0x74, + 0x97, 0x94, 0xbe, 0xa3, 0xc8, 0xd1, 0x3a, 0xae, 0x33, 0xe8, 0x23, 0x80, 0xd7, 0xfe, 0x2c, 0x11, + 0x7a, 0x30, 0xc3, 0xb6, 0xb4, 0x81, 0x5e, 0xe3, 0x02, 0x0c, 0x97, 0xb3, 0x6e, 0x72, 0xde, 0x43, + 0x77, 0xca, 0x73, 0xda, 0x51, 0xa7, 0x88, 0x8b, 0x3e, 0x03, 0x08, 0xa7, 0x0f, 0x07, 0xdd, 0x9f, + 0x61, 0x78, 0xee, 0x59, 0x7a, 0xf5, 0x7f, 0x44, 0xbb, 0x68, 0x2d, 0x13, 0xed, 0x29, 0x7a, 0x42, + 0xfa, 0x39, 0x55, 0x54, 0xd6, 0x77, 0x12, 0x1b, 0x2f, 0xe1, 0x9a, 0xc9, 0x68, 0x97, 0x26, 0xdc, + 0x5c, 0xb1, 0x1e, 0x4b, 0x85, 0x5d, 0x33, 0x53, 0xfb, 0x8d, 0xea, 0xa8, 0x89, 0x56, 0x2b, 0x3e, + 0x1c, 0xf9, 0xe0, 0x68, 0xe4, 0x83, 0x1f, 0x23, 0x1f, 0xbc, 0x1f, 0xfb, 0x95, 0xa3, 0xb1, 0x5f, + 0xf9, 0x3e, 0xf6, 0x2b, 0x70, 0x29, 0x11, 0xa5, 0x71, 0x5e, 0x82, 0xd7, 0xcd, 0x53, 0x37, 0x70, + 0x0a, 0xa9, 0x27, 0xe2, 0x74, 0x8d, 0x0e, 0x8a, 0x2a, 0x99, 0xdb, 0xd8, 0xbd, 0x64, 0x9e, 0xfa, + 0xc3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xb8, 0xea, 0xba, 0x37, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -469,8 +370,6 @@ type QueryClient interface { ContractAddress(ctx context.Context, in *QueryContractAddressRequest, opts ...grpc.CallOption) (*QueryContractAddressResponse, error) // OracleContract sends a query to the oracle's contract OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) - // OracleResult returns the address of the oracle's contract - OracleResult(ctx context.Context, in *QueryOracleResultRequest, opts ...grpc.CallOption) (*QueryOracleResultResponse, error) QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) } @@ -500,15 +399,6 @@ func (c *queryClient) OracleContract(ctx context.Context, in *QueryOracleContrac return out, nil } -func (c *queryClient) OracleResult(ctx context.Context, in *QueryOracleResultRequest, opts ...grpc.CallOption) (*QueryOracleResultResponse, error) { - out := new(QueryOracleResultResponse) - err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/OracleResult", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) { out := new(QueryQueryStateResponse) err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/QueryState", in, out, opts...) @@ -524,8 +414,6 @@ type QueryServer interface { ContractAddress(context.Context, *QueryContractAddressRequest) (*QueryContractAddressResponse, error) // OracleContract sends a query to the oracle's contract OracleContract(context.Context, *QueryOracleContractRequest) (*QueryOracleContractResponse, error) - // OracleResult returns the address of the oracle's contract - OracleResult(context.Context, *QueryOracleResultRequest) (*QueryOracleResultResponse, error) QueryState(context.Context, *QueryQueryStateRequest) (*QueryQueryStateResponse, error) } @@ -539,9 +427,6 @@ func (*UnimplementedQueryServer) ContractAddress(ctx context.Context, req *Query func (*UnimplementedQueryServer) OracleContract(ctx context.Context, req *QueryOracleContractRequest) (*QueryOracleContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OracleContract not implemented") } -func (*UnimplementedQueryServer) OracleResult(ctx context.Context, req *QueryOracleResultRequest) (*QueryOracleResultResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method OracleResult not implemented") -} func (*UnimplementedQueryServer) QueryState(ctx context.Context, req *QueryQueryStateRequest) (*QueryQueryStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryState not implemented") } @@ -586,24 +471,6 @@ func _Query_OracleContract_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Query_OracleResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOracleResultRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).OracleResult(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/provenance.oracle.v1.Query/OracleResult", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).OracleResult(ctx, req.(*QueryOracleResultRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_QueryState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryQueryStateRequest) if err := dec(in); err != nil { @@ -634,10 +501,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "OracleContract", Handler: _Query_OracleContract_Handler, }, - { - MethodName: "OracleResult", - Handler: _Query_OracleResult_Handler, - }, { MethodName: "QueryState", Handler: _Query_QueryState_Handler, @@ -833,64 +696,6 @@ func (m *QueryOracleContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryOracleResultRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryOracleResultRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryOracleResultRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QueryId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QueryId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryOracleResultResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryOracleResultResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryOracleResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -977,31 +782,6 @@ func (m *QueryOracleContractResponse) Size() (n int) { return n } -func (m *QueryOracleResultRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QueryId != 0 { - n += 1 + sovQuery(uint64(m.QueryId)) - } - return n -} - -func (m *QueryOracleResultResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Data) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1496,159 +1276,6 @@ func (m *QueryOracleContractResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOracleResultRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryOracleResultRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOracleResultRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) - } - m.QueryId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryOracleResultResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryOracleResultResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOracleResultResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 602ad6edc2..05a8308b10 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -85,42 +85,6 @@ func local_request_Query_OracleContract_0(ctx context.Context, marshaler runtime } -var ( - filter_Query_OracleResult_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_OracleResult_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOracleResultRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleResult_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.OracleResult(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_OracleResult_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOracleResultRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleResult_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.OracleResult(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_QueryState_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -203,26 +167,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_OracleResult_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_OracleResult_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_OracleResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -324,26 +268,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_OracleResult_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_OracleResult_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_OracleResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -372,8 +296,6 @@ var ( pattern_Query_OracleContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_contract"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_OracleResult_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_result"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"quasar-finance", "interchainquerydemo", "interquery", "query_state"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -382,7 +304,5 @@ var ( forward_Query_OracleContract_0 = runtime.ForwardResponseMessage - forward_Query_OracleResult_0 = runtime.ForwardResponseMessage - forward_Query_QueryState_0 = runtime.ForwardResponseMessage ) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 1ab3990fbd..6d65efff44 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -9,7 +9,7 @@ import ( github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/codec/types" - query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -32,126 +32,12 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type MsgSendQueryAllBalances struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` - Pagination *query.PageRequest `protobuf:"bytes,4,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *MsgSendQueryAllBalances) Reset() { *m = MsgSendQueryAllBalances{} } -func (m *MsgSendQueryAllBalances) String() string { return proto.CompactTextString(m) } -func (*MsgSendQueryAllBalances) ProtoMessage() {} -func (*MsgSendQueryAllBalances) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{0} -} -func (m *MsgSendQueryAllBalances) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSendQueryAllBalances) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSendQueryAllBalances.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSendQueryAllBalances) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSendQueryAllBalances.Merge(m, src) -} -func (m *MsgSendQueryAllBalances) XXX_Size() int { - return m.Size() -} -func (m *MsgSendQueryAllBalances) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSendQueryAllBalances.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSendQueryAllBalances proto.InternalMessageInfo - -func (m *MsgSendQueryAllBalances) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgSendQueryAllBalances) GetChannelId() string { - if m != nil { - return m.ChannelId - } - return "" -} - -func (m *MsgSendQueryAllBalances) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *MsgSendQueryAllBalances) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -type MsgSendQueryAllBalancesResponse struct { - Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` -} - -func (m *MsgSendQueryAllBalancesResponse) Reset() { *m = MsgSendQueryAllBalancesResponse{} } -func (m *MsgSendQueryAllBalancesResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSendQueryAllBalancesResponse) ProtoMessage() {} -func (*MsgSendQueryAllBalancesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{1} -} -func (m *MsgSendQueryAllBalancesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSendQueryAllBalancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSendQueryAllBalancesResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSendQueryAllBalancesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSendQueryAllBalancesResponse.Merge(m, src) -} -func (m *MsgSendQueryAllBalancesResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgSendQueryAllBalancesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSendQueryAllBalancesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSendQueryAllBalancesResponse proto.InternalMessageInfo - -func (m *MsgSendQueryAllBalancesResponse) GetSequence() uint64 { - if m != nil { - return m.Sequence - } - return 0 -} - // MsgQueryOracleRequest queries an Oracle on another chain type MsgQueryOracleRequest struct { // Query contains the query data passed to the oracle. Query github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=query,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"query,omitempty"` - // Source port is the source port to the oracle. - SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` - // Source channel is the channel to the oracle. - SourceChannel string `protobuf:"bytes,3,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` + // Channel is the channel to the oracle. + Channel string `protobuf:"bytes,3,opt,name=channel,proto3" json:"channel,omitempty"` // The signing authority for the request Authority string `protobuf:"bytes,4,opt,name=authority,proto3" json:"authority,omitempty"` } @@ -160,7 +46,7 @@ func (m *MsgQueryOracleRequest) Reset() { *m = MsgQueryOracleRequest{} } func (m *MsgQueryOracleRequest) String() string { return proto.CompactTextString(m) } func (*MsgQueryOracleRequest) ProtoMessage() {} func (*MsgQueryOracleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{2} + return fileDescriptor_66a39dda41c6a784, []int{0} } func (m *MsgQueryOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -196,16 +82,9 @@ func (m *MsgQueryOracleRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_type return nil } -func (m *MsgQueryOracleRequest) GetSourcePort() string { - if m != nil { - return m.SourcePort - } - return "" -} - -func (m *MsgQueryOracleRequest) GetSourceChannel() string { +func (m *MsgQueryOracleRequest) GetChannel() string { if m != nil { - return m.SourceChannel + return m.Channel } return "" } @@ -219,15 +98,15 @@ func (m *MsgQueryOracleRequest) GetAuthority() string { // MsgQueryOracleResponse contains the id of the oracle query. type MsgQueryOracleResponse struct { - // The id that uniquely identifies the query. - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` + // The sequence number that uniquely identifies the query. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (m *MsgQueryOracleResponse) Reset() { *m = MsgQueryOracleResponse{} } func (m *MsgQueryOracleResponse) String() string { return proto.CompactTextString(m) } func (*MsgQueryOracleResponse) ProtoMessage() {} func (*MsgQueryOracleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{3} + return fileDescriptor_66a39dda41c6a784, []int{1} } func (m *MsgQueryOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -256,9 +135,9 @@ func (m *MsgQueryOracleResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgQueryOracleResponse proto.InternalMessageInfo -func (m *MsgQueryOracleResponse) GetQueryId() uint64 { +func (m *MsgQueryOracleResponse) GetSequence() uint64 { if m != nil { - return m.QueryId + return m.Sequence } return 0 } @@ -275,7 +154,7 @@ func (m *MsgUpdateOracleRequest) Reset() { *m = MsgUpdateOracleRequest{} func (m *MsgUpdateOracleRequest) String() string { return proto.CompactTextString(m) } func (*MsgUpdateOracleRequest) ProtoMessage() {} func (*MsgUpdateOracleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{4} + return fileDescriptor_66a39dda41c6a784, []int{2} } func (m *MsgUpdateOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,7 +205,7 @@ func (m *MsgUpdateOracleResponse) Reset() { *m = MsgUpdateOracleResponse func (m *MsgUpdateOracleResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateOracleResponse) ProtoMessage() {} func (*MsgUpdateOracleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66a39dda41c6a784, []int{5} + return fileDescriptor_66a39dda41c6a784, []int{3} } func (m *MsgUpdateOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -356,8 +235,6 @@ func (m *MsgUpdateOracleResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateOracleResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgSendQueryAllBalances)(nil), "provenance.oracle.v1.MsgSendQueryAllBalances") - proto.RegisterType((*MsgSendQueryAllBalancesResponse)(nil), "provenance.oracle.v1.MsgSendQueryAllBalancesResponse") proto.RegisterType((*MsgQueryOracleRequest)(nil), "provenance.oracle.v1.MsgQueryOracleRequest") proto.RegisterType((*MsgQueryOracleResponse)(nil), "provenance.oracle.v1.MsgQueryOracleResponse") proto.RegisterType((*MsgUpdateOracleRequest)(nil), "provenance.oracle.v1.MsgUpdateOracleRequest") @@ -367,47 +244,37 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/tx.proto", fileDescriptor_66a39dda41c6a784) } var fileDescriptor_66a39dda41c6a784 = []byte{ - // 625 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x41, 0x4f, 0x13, 0x41, - 0x14, 0x66, 0x00, 0x85, 0x0e, 0xe8, 0x61, 0x52, 0xa5, 0x6d, 0xc2, 0x96, 0x6c, 0xa2, 0x21, 0x0a, - 0x3b, 0x69, 0x89, 0x26, 0x9a, 0x70, 0xa0, 0x24, 0x26, 0x1c, 0x1a, 0x71, 0x89, 0x31, 0xf1, 0x42, - 0xa6, 0xbb, 0xe3, 0x74, 0xe3, 0x76, 0x66, 0x99, 0x99, 0x2d, 0x34, 0xf1, 0x37, 0x18, 0x8f, 0x1e, - 0xf9, 0x11, 0xfc, 0x08, 0x8f, 0xc4, 0x93, 0xf1, 0x60, 0x0c, 0x5c, 0x3c, 0xf8, 0x0b, 0x3c, 0x99, - 0x9d, 0x19, 0x68, 0xd1, 0x12, 0xeb, 0xa9, 0x7d, 0xef, 0x7d, 0xdf, 0xcc, 0xf7, 0xbe, 0xb7, 0x6f, - 0xe0, 0x72, 0x26, 0x45, 0x9f, 0x72, 0xc2, 0x23, 0x8a, 0x85, 0x24, 0x51, 0x4a, 0x71, 0xbf, 0x81, - 0xf5, 0x51, 0x90, 0x49, 0xa1, 0x05, 0x2a, 0x0f, 0xcb, 0x81, 0x2d, 0x07, 0xfd, 0x46, 0xad, 0x1a, - 0x09, 0xd5, 0x13, 0x6a, 0xdf, 0x60, 0xb0, 0x0d, 0x2c, 0xa1, 0x56, 0x66, 0x82, 0x09, 0x9b, 0x2f, - 0xfe, 0xb9, 0xec, 0x03, 0x8b, 0xc1, 0x1d, 0xa2, 0x28, 0x3e, 0xc8, 0xa9, 0x1c, 0xe0, 0x7e, 0xa3, - 0x43, 0x35, 0x69, 0xe0, 0x8c, 0xb0, 0x84, 0x13, 0x9d, 0x08, 0xee, 0xb0, 0x55, 0x26, 0x04, 0x4b, - 0x29, 0x36, 0x51, 0x27, 0x7f, 0x83, 0x09, 0x1f, 0xd8, 0x92, 0x7f, 0x02, 0xe0, 0x52, 0x5b, 0xb1, - 0x3d, 0xca, 0xe3, 0x17, 0xc5, 0x21, 0x5b, 0x69, 0xda, 0x22, 0x69, 0x21, 0x4e, 0xa1, 0x0a, 0x9c, - 0x8b, 0x24, 0x25, 0x5a, 0xc8, 0x0a, 0x58, 0x01, 0xab, 0xa5, 0xf0, 0x22, 0x44, 0xcb, 0x10, 0x46, - 0x5d, 0xc2, 0x39, 0x4d, 0xf7, 0x93, 0xb8, 0x32, 0x6d, 0x8a, 0x25, 0x97, 0xd9, 0x89, 0x0b, 0x22, - 0x89, 0x63, 0x49, 0x95, 0xaa, 0xcc, 0x58, 0xa2, 0x0b, 0xd1, 0x33, 0x08, 0x87, 0xea, 0x2a, 0xb3, - 0x2b, 0x60, 0x75, 0xa1, 0x79, 0x3f, 0x70, 0xed, 0x16, 0xad, 0x04, 0xa6, 0x95, 0xc0, 0xb5, 0x12, - 0xec, 0x12, 0x46, 0x43, 0x7a, 0x90, 0x53, 0xa5, 0xc3, 0x11, 0xa6, 0xbf, 0x09, 0xeb, 0xd7, 0xa8, - 0x0e, 0xa9, 0xca, 0x04, 0x57, 0x14, 0xd5, 0xe0, 0xbc, 0x2a, 0x98, 0x3c, 0xa2, 0x46, 0xfe, 0x6c, - 0x78, 0x19, 0xfb, 0x3f, 0x01, 0xbc, 0xd3, 0x56, 0xcc, 0x70, 0x9f, 0x9b, 0x19, 0xb8, 0x4b, 0xd0, - 0x1e, 0xbc, 0x61, 0x14, 0x18, 0xca, 0x62, 0x6b, 0xf3, 0xd7, 0xb7, 0xfa, 0x13, 0x96, 0xe8, 0x6e, - 0xde, 0x09, 0x22, 0xd1, 0xc3, 0xdb, 0x42, 0xf5, 0x5e, 0x11, 0xd5, 0xc3, 0x87, 0x44, 0xf5, 0x62, - 0x7c, 0x64, 0x7e, 0xb1, 0x1e, 0x64, 0x54, 0x05, 0x21, 0x39, 0xdc, 0x16, 0x5c, 0x4b, 0x12, 0xe9, - 0x36, 0x55, 0xaa, 0x50, 0x6e, 0xcf, 0x42, 0x75, 0xb8, 0xa0, 0x44, 0x2e, 0x23, 0xba, 0x9f, 0x09, - 0xa9, 0x9d, 0x5f, 0xd0, 0xa6, 0x76, 0x85, 0xd4, 0xe8, 0x1e, 0xbc, 0xed, 0x00, 0xce, 0x44, 0xe7, - 0xdb, 0x2d, 0x9b, 0xdd, 0xb6, 0x49, 0xf4, 0x18, 0x96, 0x48, 0xae, 0xbb, 0x42, 0x26, 0x7a, 0x60, - 0xcc, 0x2b, 0xb5, 0x2a, 0x9f, 0x4f, 0xd6, 0xcb, 0xce, 0xbf, 0x2d, 0x6b, 0xf2, 0x9e, 0x96, 0x09, - 0x67, 0xe1, 0x10, 0xea, 0x6f, 0xc0, 0xbb, 0x7f, 0x76, 0xeb, 0x4c, 0xaa, 0xc2, 0x79, 0x23, 0xb1, - 0x18, 0xa3, 0x35, 0x69, 0xce, 0xc4, 0x3b, 0xb1, 0xff, 0x1e, 0x18, 0xd6, 0xcb, 0x2c, 0x26, 0x9a, - 0x5e, 0x35, 0xa9, 0x39, 0x9c, 0x2f, 0xf8, 0x87, 0x8a, 0xcb, 0xc9, 0x5f, 0xd1, 0x3e, 0x3d, 0xb1, - 0xf6, 0xa7, 0xf3, 0x1f, 0x8f, 0xeb, 0xe0, 0xc7, 0x71, 0x1d, 0xf8, 0x55, 0xf3, 0xa5, 0x5e, 0xd5, - 0x63, 0xdb, 0x68, 0x7e, 0x9d, 0x86, 0x33, 0x6d, 0xc5, 0xd0, 0x5b, 0xb8, 0x38, 0x5a, 0x47, 0x6b, - 0xc1, 0xb8, 0x65, 0x0b, 0xc6, 0xb7, 0x55, 0x5b, 0x9f, 0x10, 0xed, 0xbc, 0xeb, 0xc2, 0x85, 0x11, - 0x4b, 0xd1, 0xc3, 0x6b, 0xd9, 0x7f, 0x7f, 0x66, 0xb5, 0xb5, 0xc9, 0xc0, 0xee, 0xa6, 0x77, 0xb0, - 0x3c, 0x76, 0x41, 0xaf, 0x17, 0x3c, 0x0e, 0x5e, 0x7b, 0xf4, 0x5f, 0xf0, 0x8b, 0xdb, 0x5b, 0xec, - 0xd3, 0x99, 0x07, 0x4e, 0xcf, 0x3c, 0xf0, 0xfd, 0xcc, 0x03, 0x1f, 0xce, 0xbd, 0xa9, 0xd3, 0x73, - 0x6f, 0xea, 0xcb, 0xb9, 0x37, 0x05, 0x97, 0x12, 0x31, 0xf6, 0xc8, 0x5d, 0xf0, 0xba, 0x39, 0xb2, - 0x34, 0x43, 0xc8, 0x7a, 0x22, 0x46, 0x22, 0x7c, 0x74, 0xf1, 0x3e, 0x9a, 0x05, 0xea, 0xdc, 0x34, - 0x4f, 0xd2, 0xc6, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xeb, 0xbf, 0x88, 0x41, 0x05, 0x00, - 0x00, + // 475 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xce, 0xd1, 0x42, 0xdb, 0xa3, 0x93, 0x15, 0xa8, 0x63, 0x09, 0xa7, 0xca, 0x54, 0x41, 0xe3, + 0x53, 0x02, 0x42, 0x02, 0x89, 0x81, 0x74, 0x8e, 0x00, 0x57, 0x08, 0x89, 0x05, 0x9d, 0x9d, 0xe3, + 0x62, 0x11, 0xdf, 0x73, 0xfd, 0xce, 0x69, 0xf2, 0x27, 0x10, 0x23, 0x63, 0x7f, 0x04, 0x33, 0x33, + 0x63, 0xc5, 0xc4, 0x80, 0x10, 0x4a, 0x16, 0x7e, 0x03, 0x13, 0xca, 0x5d, 0x42, 0x5c, 0x1a, 0xaa, + 0x4c, 0xf6, 0xbb, 0xef, 0x7b, 0xef, 0xbe, 0xef, 0xe9, 0x3b, 0x7a, 0x27, 0xcb, 0x61, 0x28, 0x14, + 0x57, 0xb1, 0x60, 0x90, 0xf3, 0x78, 0x20, 0xd8, 0xb0, 0xc5, 0xf4, 0x28, 0xc8, 0x72, 0xd0, 0xe0, + 0x54, 0x97, 0x70, 0x60, 0xe1, 0x60, 0xd8, 0xf2, 0x6a, 0x31, 0x60, 0x0a, 0xf8, 0xc6, 0x70, 0x98, + 0x2d, 0x6c, 0x83, 0x57, 0x95, 0x20, 0xc1, 0x9e, 0xcf, 0xfe, 0xe6, 0xa7, 0x77, 0x2d, 0x87, 0x45, + 0x1c, 0x05, 0x3b, 0x29, 0x44, 0x3e, 0x66, 0xc3, 0x56, 0x24, 0x34, 0x6f, 0xb1, 0x8c, 0xcb, 0x44, + 0x71, 0x9d, 0x80, 0x9a, 0x73, 0x6b, 0x12, 0x40, 0x0e, 0x04, 0x33, 0x55, 0x54, 0xbc, 0x65, 0x5c, + 0x8d, 0x2d, 0xd4, 0xf8, 0x4c, 0xe8, 0xad, 0x2e, 0xca, 0x17, 0xb3, 0x01, 0xcf, 0x8c, 0x9a, 0x50, + 0x9c, 0x14, 0x02, 0xb5, 0x73, 0x4c, 0xaf, 0x9b, 0xb1, 0x2e, 0xd9, 0x27, 0x07, 0xbb, 0x9d, 0x27, + 0xbf, 0x7f, 0xd4, 0x1f, 0xc9, 0x44, 0xf7, 0x8b, 0x28, 0x88, 0x21, 0x65, 0x47, 0x80, 0xe9, 0x2b, + 0x8e, 0x29, 0x3b, 0xe5, 0x98, 0xf6, 0xd8, 0xc8, 0x7c, 0x99, 0x1e, 0x67, 0x02, 0x83, 0x90, 0x9f, + 0x1e, 0x81, 0xd2, 0x39, 0x8f, 0x75, 0x57, 0x20, 0x72, 0x29, 0x42, 0x3b, 0xcb, 0x71, 0xe9, 0x56, + 0xdc, 0xe7, 0x4a, 0x89, 0x81, 0xbb, 0xb1, 0x4f, 0x0e, 0x76, 0xc2, 0x45, 0xe9, 0x3c, 0xa4, 0x3b, + 0xbc, 0xd0, 0x7d, 0xc8, 0x13, 0x3d, 0x76, 0x37, 0x67, 0x58, 0xc7, 0xfd, 0xfa, 0xa9, 0x59, 0x9d, + 0xaf, 0xe2, 0x69, 0xaf, 0x97, 0x0b, 0xc4, 0x63, 0x9d, 0x27, 0x4a, 0x86, 0x4b, 0x6a, 0xe3, 0x01, + 0xbd, 0xfd, 0xaf, 0x7e, 0xcc, 0x40, 0xa1, 0x70, 0x3c, 0xba, 0x8d, 0x33, 0x2f, 0x2a, 0x16, 0xc6, + 0xc3, 0x66, 0xf8, 0xb7, 0x6e, 0xbc, 0x27, 0xa6, 0xed, 0x65, 0xd6, 0xe3, 0x5a, 0x5c, 0xf4, 0xdd, + 0xa6, 0x5b, 0xdc, 0x5e, 0x66, 0xba, 0xae, 0x92, 0xb1, 0x20, 0x5e, 0x14, 0x7f, 0x6d, 0x6d, 0xf1, + 0x8f, 0xb7, 0x3f, 0x9e, 0xd5, 0xc9, 0xaf, 0xb3, 0x3a, 0x69, 0xd4, 0xe8, 0xde, 0x25, 0x3d, 0xd6, + 0x47, 0xfb, 0x3b, 0xa1, 0x1b, 0x5d, 0x94, 0xce, 0x3b, 0xba, 0x5b, 0xc6, 0x9d, 0xc3, 0x60, 0x55, + 0x92, 0x82, 0xd5, 0xb6, 0xbc, 0xe6, 0x9a, 0xec, 0xf9, 0xf2, 0xfa, 0xf4, 0x66, 0x69, 0xa7, 0xce, + 0xbd, 0xff, 0x76, 0x5f, 0x4e, 0x8e, 0x77, 0xb8, 0x1e, 0xd9, 0xde, 0xd4, 0x91, 0x5f, 0x26, 0x3e, + 0x39, 0x9f, 0xf8, 0xe4, 0xe7, 0xc4, 0x27, 0x1f, 0xa6, 0x7e, 0xe5, 0x7c, 0xea, 0x57, 0xbe, 0x4d, + 0xfd, 0x0a, 0xdd, 0x4b, 0x60, 0xe5, 0xa4, 0xe7, 0xe4, 0x75, 0xbb, 0x94, 0xc4, 0x25, 0xa5, 0x99, + 0x40, 0xa9, 0x62, 0xa3, 0xc5, 0xf3, 0x33, 0xa9, 0x8c, 0x6e, 0x98, 0xc4, 0xdf, 0xff, 0x13, 0x00, + 0x00, 0xff, 0xff, 0xdc, 0x47, 0x0a, 0x6d, 0xa0, 0x03, 0x00, 0x00, } func (this *MsgUpdateOracleRequest) Equal(that interface{}) bool { @@ -454,7 +321,6 @@ type MsgClient interface { UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest, opts ...grpc.CallOption) (*MsgUpdateOracleResponse, error) // QueryOracle sends an icq to an oracle on another chain QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, opts ...grpc.CallOption) (*MsgQueryOracleResponse, error) - SendQueryAllBalances(ctx context.Context, in *MsgSendQueryAllBalances, opts ...grpc.CallOption) (*MsgSendQueryAllBalancesResponse, error) } type msgClient struct { @@ -483,22 +349,12 @@ func (c *msgClient) QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, return out, nil } -func (c *msgClient) SendQueryAllBalances(ctx context.Context, in *MsgSendQueryAllBalances, opts ...grpc.CallOption) (*MsgSendQueryAllBalancesResponse, error) { - out := new(MsgSendQueryAllBalancesResponse) - err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Msg/SendQueryAllBalances", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateOracle is the RPC endpoint for updating the oracle UpdateOracle(context.Context, *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) // QueryOracle sends an icq to an oracle on another chain QueryOracle(context.Context, *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) - SendQueryAllBalances(context.Context, *MsgSendQueryAllBalances) (*MsgSendQueryAllBalancesResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -511,9 +367,6 @@ func (*UnimplementedMsgServer) UpdateOracle(ctx context.Context, req *MsgUpdateO func (*UnimplementedMsgServer) QueryOracle(ctx context.Context, req *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryOracle not implemented") } -func (*UnimplementedMsgServer) SendQueryAllBalances(ctx context.Context, req *MsgSendQueryAllBalances) (*MsgSendQueryAllBalancesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SendQueryAllBalances not implemented") -} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -555,24 +408,6 @@ func _Msg_QueryOracle_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } -func _Msg_SendQueryAllBalances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSendQueryAllBalances) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SendQueryAllBalances(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/provenance.oracle.v1.Msg/SendQueryAllBalances", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SendQueryAllBalances(ctx, req.(*MsgSendQueryAllBalances)) - } - return interceptor(ctx, in, info, handler) -} - var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "provenance.oracle.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -585,99 +420,11 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryOracle", Handler: _Msg_QueryOracle_Handler, }, - { - MethodName: "SendQueryAllBalances", - Handler: _Msg_SendQueryAllBalances_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/oracle/v1/tx.proto", } -func (m *MsgSendQueryAllBalances) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSendQueryAllBalances) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSendQueryAllBalances) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x1a - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgSendQueryAllBalancesResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSendQueryAllBalancesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSendQueryAllBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *MsgQueryOracleRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -705,20 +452,13 @@ func (m *MsgQueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if len(m.SourceChannel) > 0 { - i -= len(m.SourceChannel) - copy(dAtA[i:], m.SourceChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannel))) + if len(m.Channel) > 0 { + i -= len(m.Channel) + copy(dAtA[i:], m.Channel) + i = encodeVarintTx(dAtA, i, uint64(len(m.Channel))) i-- dAtA[i] = 0x1a } - if len(m.SourcePort) > 0 { - i -= len(m.SourcePort) - copy(dAtA[i:], m.SourcePort) - i = encodeVarintTx(dAtA, i, uint64(len(m.SourcePort))) - i-- - dAtA[i] = 0x12 - } if len(m.Query) > 0 { i -= len(m.Query) copy(dAtA[i:], m.Query) @@ -749,8 +489,8 @@ func (m *MsgQueryOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if m.QueryId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.QueryId)) + if m.Sequence != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) i-- dAtA[i] = 0x8 } @@ -828,43 +568,6 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgSendQueryAllBalances) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgSendQueryAllBalancesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sequence != 0 { - n += 1 + sovTx(uint64(m.Sequence)) - } - return n -} - func (m *MsgQueryOracleRequest) Size() (n int) { if m == nil { return 0 @@ -875,11 +578,7 @@ func (m *MsgQueryOracleRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.SourcePort) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.SourceChannel) + l = len(m.Channel) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -896,8 +595,8 @@ func (m *MsgQueryOracleResponse) Size() (n int) { } var l int _ = l - if m.QueryId != 0 { - n += 1 + sovTx(uint64(m.QueryId)) + if m.Sequence != 0 { + n += 1 + sovTx(uint64(m.Sequence)) } return n } @@ -934,257 +633,6 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgSendQueryAllBalances) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSendQueryAllBalances: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSendQueryAllBalances: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSendQueryAllBalancesResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSendQueryAllBalancesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSendQueryAllBalancesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) - } - m.Sequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Sequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1248,41 +696,9 @@ func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { m.Query = []byte{} } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourcePort", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SourcePort = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1310,7 +726,7 @@ func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SourceChannel = string(dAtA[iNdEx:postIndex]) + m.Channel = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { @@ -1396,9 +812,9 @@ func (m *MsgQueryOracleResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } - m.QueryId = 0 + m.Sequence = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1408,7 +824,7 @@ func (m *MsgQueryOracleResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift + m.Sequence |= uint64(b&0x7F) << shift if b < 0x80 { break } From 520eb712f92ae54404ef7431eff93eafa41e77f2 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 10:35:45 -0400 Subject: [PATCH 12/96] Finished basic implementation of Chain1 -> Chain2 -> Contract implementation. Worked in tests. --- app/app.go | 27 ++++++++++++++------------- x/oracle/client/cli/tx.go | 1 + x/oracle/keeper/keeper.go | 21 +++++++++++++-------- x/oracle/keeper/query_server.go | 19 ++++++++++++++++--- x/oracle/types/codec.go | 5 ++--- 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/app/app.go b/app/app.go index 4ee461d586..86e02eae14 100644 --- a/app/app.go +++ b/app/app.go @@ -520,19 +520,6 @@ func New( icqModule := icq.NewAppModule(app.ICQKeeper) icqIBCModule := icq.NewIBCModule(app.ICQKeeper) - app.ScopedOracleKeeper = scopedOracleKeeper - app.OracleKeeper = *oraclekeeper.NewKeeper( - appCodec, - keys[oracletypes.StoreKey], - keys[oracletypes.MemStoreKey], - app.GetSubspace(icqtypes.ModuleName), - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - scopedOracleKeeper, - ) - oracleModule := oraclemodule.NewAppModule(appCodec, app.OracleKeeper) - // Init CosmWasm module wasmDir := filepath.Join(homePath, "data", "wasm") @@ -586,6 +573,20 @@ func New( wasmkeeper.WithMessageEncoders(provwasm.MessageEncoders(encoderRegistry, logger)), ) + app.ScopedOracleKeeper = scopedOracleKeeper + app.OracleKeeper = *oraclekeeper.NewKeeper( + appCodec, + keys[oracletypes.StoreKey], + keys[oracletypes.MemStoreKey], + app.GetSubspace(icqtypes.ModuleName), + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + scopedOracleKeeper, + wasmkeeper.Querier(&app.WasmKeeper), + ) + oracleModule := oraclemodule.NewAppModule(appCodec, app.OracleKeeper) + unsanctionableAddrs := make([]sdk.AccAddress, 0, len(maccPerms)+1) for mName := range maccPerms { unsanctionableAddrs = append(unsanctionableAddrs, authtypes.NewModuleAddress(mName)) diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 6cd1e18287..4fd9f3ae9f 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -29,6 +29,7 @@ func NewTxCmd() *cobra.Command { txCmd.AddCommand( CmdOracleQuery(), + CmdOracleUpdate(), ) return txCmd diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index d50d43ecd6..39af64fdeb 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -13,6 +13,8 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) type Keeper struct { @@ -21,10 +23,11 @@ type Keeper struct { memKey storetypes.StoreKey paramstore paramtypes.Subspace - ics4Wrapper types.ICS4Wrapper - channelKeeper types.ChannelKeeper - portKeeper types.PortKeeper - scopedKeeper capabilitykeeper.ScopedKeeper + ics4Wrapper types.ICS4Wrapper + channelKeeper types.ChannelKeeper + portKeeper types.PortKeeper + scopedKeeper capabilitykeeper.ScopedKeeper + wasmQueryServer wasmtypes.QueryServer } func NewKeeper( @@ -36,6 +39,7 @@ func NewKeeper( channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, + wasmQueryServer wasmtypes.QueryServer, ) *Keeper { if !ps.HasKeyTable() { @@ -48,10 +52,11 @@ func NewKeeper( memKey: memKey, paramstore: ps, - ics4Wrapper: ics4Wrapper, - channelKeeper: channelKeeper, - portKeeper: portKeeper, - scopedKeeper: scopedKeeper, + ics4Wrapper: ics4Wrapper, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + scopedKeeper: scopedKeeper, + wasmQueryServer: wasmQueryServer, } } diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index ab1666d7e6..aa5671745f 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/provenance-io/provenance/x/oracle/types" @@ -27,9 +28,21 @@ func (k Keeper) ContractAddress(goCtx context.Context, req *types.QueryContractA return &types.QueryContractAddressResponse{Address: contract.String()}, nil } -func (k Keeper) OracleContract(ctx context.Context, req *types.QueryOracleContractRequest) (*types.QueryOracleContractResponse, error) { - // We do the logic here to actually send it to the oracle - return &types.QueryOracleContractResponse{}, nil +func (k Keeper) OracleContract(goCtx context.Context, req *types.QueryOracleContractRequest) (*types.QueryOracleContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + addr, err := k.GetOracleContract(ctx) + if err != nil { + return nil, err + } + query := &wasmtypes.QuerySmartContractStateRequest{ + Address: addr.String(), + QueryData: req.Query, + } + resp, err := k.wasmQueryServer.SmartContractState(ctx, query) + if err != nil { + return nil, err + } + return &types.QueryOracleContractResponse{Data: resp.Data}, nil } func (k Keeper) QueryState(goCtx context.Context, req *types.QueryQueryStateRequest) (*types.QueryQueryStateResponse, error) { diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index ec0395c2bf..2471c02cde 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -4,7 +4,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/gogo/protobuf/proto" ) @@ -18,8 +17,8 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { ) registry.RegisterImplementations((*proto.Message)(nil), - &banktypes.QueryAllBalancesRequest{}, - &banktypes.QueryAllBalancesResponse{}, + &QueryOracleContractRequest{}, + &QueryOracleContractResponse{}, ) } From b2b16c59f52216fe961ad38e4fb0342fbf688897 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 11:49:02 -0400 Subject: [PATCH 13/96] Renamed queries and transactions. Added ExportGenesis logic. Fixed some comments. --- docs/proto-docs.md | 70 ++--- proto/provenance/oracle/v1/event.proto | 4 +- proto/provenance/oracle/v1/genesis.proto | 4 +- proto/provenance/oracle/v1/query.proto | 39 +-- proto/provenance/oracle/v1/tx.proto | 12 +- x/oracle/client/cli/query.go | 4 +- x/oracle/keeper/genesis.go | 6 +- x/oracle/keeper/msg_server.go | 8 +- x/oracle/keeper/queries.go | 16 +- x/oracle/keeper/query_server.go | 8 +- x/oracle/keeper/relay.go | 2 +- x/oracle/types/codec.go | 6 +- x/oracle/types/event.pb.go | 42 +-- x/oracle/types/genesis.go | 10 +- x/oracle/types/genesis.pb.go | 44 +-- x/oracle/types/msgs.go | 10 +- x/oracle/types/query.pb.go | 336 ++++++++++++----------- x/oracle/types/query.pb.gw.go | 64 ++--- x/oracle/types/tx.pb.go | 194 ++++++------- 19 files changed, 444 insertions(+), 435 deletions(-) diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 7b51ae2cc0..90b9bd2865 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -440,18 +440,18 @@ - [GenesisState](#provenance.oracle.v1.GenesisState) - [provenance/oracle/v1/query.proto](#provenance/oracle/v1/query.proto) - - [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) - - [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) - - [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) - - [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) + - [QueryOracleAddressRequest](#provenance.oracle.v1.QueryOracleAddressRequest) + - [QueryOracleAddressResponse](#provenance.oracle.v1.QueryOracleAddressResponse) + - [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) + - [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) - [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) - [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) - [Query](#provenance.oracle.v1.Query) - [provenance/oracle/v1/tx.proto](#provenance/oracle/v1/tx.proto) - - [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) - - [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) + - [MsgSendQueryOracleRequest](#provenance.oracle.v1.MsgSendQueryOracleRequest) + - [MsgSendQueryOracleResponse](#provenance.oracle.v1.MsgSendQueryOracleResponse) - [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) - [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) @@ -6686,7 +6686,7 @@ EventOracleQueryResponse is an event for when the chain receives a response from | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `query_id` | [string](#string) | | query_id is a unique identifier of the query | +| `sequence_id` | [string](#string) | | sequence_id is a unique identifier of the query | @@ -6743,7 +6743,7 @@ GenesisState defines the oracle module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `query_id` | [uint64](#uint64) | | Query id is the next auto incremented id to be assigned to the next query | +| `sequence` | [uint64](#uint64) | | Sequence is the next auto incremented id to be assigned to the next query | | `params` | [Params](#provenance.oracle.v1.Params) | | Params | | `port_id` | [string](#string) | | The port to assign to the module | @@ -6768,55 +6768,55 @@ GenesisState defines the oracle module's genesis state. - + -### QueryContractAddressRequest -QueryContractAddressRequest queries for the Trigger with an identifier of id. +### QueryOracleAddressRequest +QueryOracleAddressRequest queries for the address of the oracle. - + -### QueryContractAddressResponse -QueryContractAddressResponse contains the address of the oracle's contract. +### QueryOracleAddressResponse +QueryOracleAddressResponse contains the address of the oracle. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | The address of the oracle's contract | +| `address` | [string](#string) | | The address of the oracle | - + -### QueryOracleContractRequest -QueryOracleContractRequest queries the oracle's smart contract +### QueryOracleRequest +QueryOracleRequest queries the module's oracle. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `query` | [bytes](#bytes) | | Query contains the query data passed to the contract. | +| `query` | [bytes](#bytes) | | Query contains the query data passed to the oracle. | - + -### QueryOracleContractResponse -QueryOracleContractResponse contains the result of the query to the oracle's smart contract +### QueryOracleResponse +QueryOracleResponse contains the result of the query sent to the oracle. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `data` | [bytes](#bytes) | | Data contains the json data returned from the smart contract. | +| `data` | [bytes](#bytes) | | Data contains the json data returned from the oracle. | @@ -6826,7 +6826,7 @@ QueryOracleContractResponse contains the result of the query to the oracle's sma ### QueryQueryStateRequest - +QueryQueryStateRequest queries for the state of the ICQ. | Field | Type | Label | Description | @@ -6841,7 +6841,7 @@ QueryOracleContractResponse contains the result of the query to the oracle's sma ### QueryQueryStateResponse - +QueryQueryStateResponse contains the ICQ and its response. | Field | Type | Label | Description | @@ -6867,9 +6867,9 @@ Query defines the gRPC querier service for oracle module. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ContractAddress` | [QueryContractAddressRequest](#provenance.oracle.v1.QueryContractAddressRequest) | [QueryContractAddressResponse](#provenance.oracle.v1.QueryContractAddressResponse) | ContractAddress returns the address of the oracle's contract | GET|/provenance/oracle/v1/contract_address| -| `OracleContract` | [QueryOracleContractRequest](#provenance.oracle.v1.QueryOracleContractRequest) | [QueryOracleContractResponse](#provenance.oracle.v1.QueryOracleContractResponse) | OracleContract sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle_contract| -| `QueryState` | [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) | [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) | | GET|/quasar-finance/interchainquerydemo/interquery/query_state| +| `OracleAddress` | [QueryOracleAddressRequest](#provenance.oracle.v1.QueryOracleAddressRequest) | [QueryOracleAddressResponse](#provenance.oracle.v1.QueryOracleAddressResponse) | OracleAddress returns the address of the oracle | GET|/provenance/oracle/v1/oracle_address| +| `Oracle` | [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) | [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) | Oracle sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle| +| `QueryState` | [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) | [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) | QueryState returns the state of the oracle query | GET|/provenance/oracle/v1/query_state| @@ -6882,10 +6882,10 @@ Query defines the gRPC querier service for oracle module. - + -### MsgQueryOracleRequest -MsgQueryOracleRequest queries an Oracle on another chain +### MsgSendQueryOracleRequest +MsgSendQueryOracleRequest queries an oracle on another chain | Field | Type | Label | Description | @@ -6899,10 +6899,10 @@ MsgQueryOracleRequest queries an Oracle on another chain - + -### MsgQueryOracleResponse -MsgQueryOracleResponse contains the id of the oracle query. +### MsgSendQueryOracleResponse +MsgSendQueryOracleResponse contains the id of the oracle query. | Field | Type | Label | Description | @@ -6954,7 +6954,7 @@ Msg | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `UpdateOracle` | [MsgUpdateOracleRequest](#provenance.oracle.v1.MsgUpdateOracleRequest) | [MsgUpdateOracleResponse](#provenance.oracle.v1.MsgUpdateOracleResponse) | UpdateOracle is the RPC endpoint for updating the oracle | | -| `QueryOracle` | [MsgQueryOracleRequest](#provenance.oracle.v1.MsgQueryOracleRequest) | [MsgQueryOracleResponse](#provenance.oracle.v1.MsgQueryOracleResponse) | QueryOracle sends an icq to an oracle on another chain | | +| `SendQueryOracle` | [MsgSendQueryOracleRequest](#provenance.oracle.v1.MsgSendQueryOracleRequest) | [MsgSendQueryOracleResponse](#provenance.oracle.v1.MsgSendQueryOracleResponse) | SendQueryOracle sends a query to an oracle on another chain | | diff --git a/proto/provenance/oracle/v1/event.proto b/proto/provenance/oracle/v1/event.proto index e7fb76edb0..dd4216613e 100644 --- a/proto/provenance/oracle/v1/event.proto +++ b/proto/provenance/oracle/v1/event.proto @@ -8,6 +8,6 @@ option java_multiple_files = true; // EventOracleQueryResponse is an event for when the chain receives a response from an oracle query message EventOracleQueryResponse { - // query_id is a unique identifier of the query - string query_id = 1; + // sequence_id is a unique identifier of the query + string sequence_id = 1; } \ No newline at end of file diff --git a/proto/provenance/oracle/v1/genesis.proto b/proto/provenance/oracle/v1/genesis.proto index b03e7700b3..8f28cb856c 100644 --- a/proto/provenance/oracle/v1/genesis.proto +++ b/proto/provenance/oracle/v1/genesis.proto @@ -13,8 +13,8 @@ message GenesisState { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // Query id is the next auto incremented id to be assigned to the next query - uint64 query_id = 1; + // Sequence is the next auto incremented id to be assigned to the next query + uint64 sequence = 1; // Params Params params = 2 [(gogoproto.nullable) = false]; // The port to assign to the module diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index 808b5fe980..65b7295795 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -12,47 +12,50 @@ option java_multiple_files = true; // Query defines the gRPC querier service for oracle module. service Query { - // ContractAddress returns the address of the oracle's contract - rpc ContractAddress(QueryContractAddressRequest) returns (QueryContractAddressResponse) { - option (google.api.http).get = "/provenance/oracle/v1/contract_address"; + // OracleAddress returns the address of the oracle + rpc OracleAddress(QueryOracleAddressRequest) returns (QueryOracleAddressResponse) { + option (google.api.http).get = "/provenance/oracle/v1/oracle_address"; } - // OracleContract sends a query to the oracle's contract - rpc OracleContract(QueryOracleContractRequest) returns (QueryOracleContractResponse) { - option (google.api.http).get = "/provenance/oracle/v1/oracle_contract"; + // Oracle sends a query to the oracle's contract + rpc Oracle(QueryOracleRequest) returns (QueryOracleResponse) { + option (google.api.http).get = "/provenance/oracle/v1/oracle"; } + // QueryState returns the state of the oracle query rpc QueryState(QueryQueryStateRequest) returns (QueryQueryStateResponse) { - option (google.api.http).get = "/quasar-finance/interchainquerydemo/interquery/query_state"; + option (google.api.http).get = "/provenance/oracle/v1/query_state"; } } +// QueryQueryStateRequest queries for the state of the ICQ. message QueryQueryStateRequest { uint64 sequence = 1; } +// QueryQueryStateResponse contains the ICQ and its response. message QueryQueryStateResponse { google.protobuf.Any request = 1 [(gogoproto.nullable) = false]; google.protobuf.Any response = 2 [(gogoproto.nullable) = true]; } -// QueryContractAddressRequest queries for the Trigger with an identifier of id. -message QueryContractAddressRequest {} +// QueryOracleAddressRequest queries for the address of the oracle. +message QueryOracleAddressRequest {} -// QueryContractAddressResponse contains the address of the oracle's contract. -message QueryContractAddressResponse { - // The address of the oracle's contract +// QueryOracleAddressResponse contains the address of the oracle. +message QueryOracleAddressResponse { + // The address of the oracle string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -// QueryOracleContractRequest queries the oracle's smart contract -message QueryOracleContractRequest { - // Query contains the query data passed to the contract. +// QueryOracleRequest queries the module's oracle. +message QueryOracleRequest { + // Query contains the query data passed to the oracle. bytes query = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; } -// QueryOracleContractResponse contains the result of the query to the oracle's smart contract -message QueryOracleContractResponse { - // Data contains the json data returned from the smart contract. +// QueryOracleResponse contains the result of the query sent to the oracle. +message QueryOracleResponse { + // Data contains the json data returned from the oracle. bytes data = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; } \ No newline at end of file diff --git a/proto/provenance/oracle/v1/tx.proto b/proto/provenance/oracle/v1/tx.proto index 3ddcbe201e..19752ee2a2 100644 --- a/proto/provenance/oracle/v1/tx.proto +++ b/proto/provenance/oracle/v1/tx.proto @@ -14,12 +14,12 @@ option java_multiple_files = true; service Msg { // UpdateOracle is the RPC endpoint for updating the oracle rpc UpdateOracle(MsgUpdateOracleRequest) returns (MsgUpdateOracleResponse); - // QueryOracle sends an icq to an oracle on another chain - rpc QueryOracle(MsgQueryOracleRequest) returns (MsgQueryOracleResponse); + // SendQueryOracle sends a query to an oracle on another chain + rpc SendQueryOracle(MsgSendQueryOracleRequest) returns (MsgSendQueryOracleResponse); } -// MsgQueryOracleRequest queries an Oracle on another chain -message MsgQueryOracleRequest { +// MsgSendQueryOracleRequest queries an oracle on another chain +message MsgSendQueryOracleRequest { // Query contains the query data passed to the oracle. bytes query = 1 [(gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage"]; // Channel is the channel to the oracle. @@ -28,8 +28,8 @@ message MsgQueryOracleRequest { string authority = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -// MsgQueryOracleResponse contains the id of the oracle query. -message MsgQueryOracleResponse { +// MsgSendQueryOracleResponse contains the id of the oracle query. +message MsgSendQueryOracleResponse { // The sequence number that uniquely identifies the query. uint64 sequence = 1; } diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index cde297e9a0..83798194de 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -78,9 +78,9 @@ func CmdQueryContractAddress() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryContractAddressRequest{} + params := &types.QueryOracleAddressRequest{} - res, err := queryClient.ContractAddress(context.Background(), params) + res, err := queryClient.OracleAddress(context.Background(), params) if err != nil { return err } diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 2167b94572..aa104e4c46 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -7,7 +7,11 @@ import ( // ExportGenesis returns a GenesisState for a given context. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - return types.DefaultGenesis() + return &types.GenesisState{ + Sequence: k.GetLastQueryPacketSeq(ctx), + Params: k.GetParams(ctx), + PortId: k.GetPort(ctx), + } } // InitGenesis new trigger genesis diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index be726e50a7..080cc3f3da 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -32,7 +32,7 @@ func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracl return &types.MsgUpdateOracleResponse{}, nil } -func (k msgServer) QueryOracle(goCtx context.Context, msg *types.MsgQueryOracleRequest) (*types.MsgQueryOracleResponse, error) { +func (k msgServer) SendQueryOracle(goCtx context.Context, msg *types.MsgSendQueryOracleRequest) (*types.MsgSendQueryOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(k.GetPort(ctx), msg.Channel)) @@ -40,13 +40,13 @@ func (k msgServer) QueryOracle(goCtx context.Context, msg *types.MsgQueryOracleR return nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") } - q := types.QueryOracleContractRequest{ + q := types.QueryOracleRequest{ Query: msg.GetQuery(), } reqs := []abcitypes.RequestQuery{ { - Path: "/provenance.oracle.v1.Query/OracleContract", + Path: "/provenance.oracle.v1.Query/Oracle", Data: k.cdc.MustMarshal(&q), }, } @@ -59,7 +59,7 @@ func (k msgServer) QueryOracle(goCtx context.Context, msg *types.MsgQueryOracleR k.SetQueryRequest(ctx, seq, q) - return &types.MsgQueryOracleResponse{ + return &types.MsgSendQueryOracleResponse{ Sequence: seq, }, nil } diff --git a/x/oracle/keeper/queries.go b/x/oracle/keeper/queries.go index 7716cb07b3..823c3ef154 100644 --- a/x/oracle/keeper/queries.go +++ b/x/oracle/keeper/queries.go @@ -8,39 +8,39 @@ import ( ) // SetQueryRequest saves the query request -func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req types.QueryOracleContractRequest) { +func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req types.QueryOracleRequest) { store := ctx.KVStore(k.storeKey) store.Set(types.QueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) } // GetQueryRequest returns the query request by packet sequence -func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.QueryOracleContractRequest, error) { +func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.QueryOracleRequest, error) { bz := ctx.KVStore(k.storeKey).Get(types.QueryRequestStoreKey(packetSequence)) if bz == nil { - return types.QueryOracleContractRequest{}, sdkerrors.Wrapf(types.ErrSample, + return types.QueryOracleRequest{}, sdkerrors.Wrapf(types.ErrSample, "GetQueryRequest: Result for packet sequence %d is not available.", packetSequence, ) } - var req types.QueryOracleContractRequest + var req types.QueryOracleRequest k.cdc.MustUnmarshal(bz, &req) return req, nil } // SetQueryResponse saves the query response -func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp types.QueryOracleContractResponse) { +func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp types.QueryOracleResponse) { store := ctx.KVStore(k.storeKey) store.Set(types.QueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) } // GetQueryResponse returns the query response by packet sequence -func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types.QueryOracleContractResponse, error) { +func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types.QueryOracleResponse, error) { bz := ctx.KVStore(k.storeKey).Get(types.QueryResponseStoreKey(packetSequence)) if bz == nil { - return types.QueryOracleContractResponse{}, sdkerrors.Wrapf(types.ErrSample, + return types.QueryOracleResponse{}, sdkerrors.Wrapf(types.ErrSample, "GetQueryResponse: Result for packet sequence %d is not available.", packetSequence, ) } - var resp types.QueryOracleContractResponse + var resp types.QueryOracleResponse k.cdc.MustUnmarshal(bz, &resp) return resp, nil } diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index aa5671745f..6683f73164 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -14,7 +14,7 @@ import ( var _ types.QueryServer = Keeper{} // QueryAddress returns the address of the oracle's contract -func (k Keeper) ContractAddress(goCtx context.Context, req *types.QueryContractAddressRequest) (*types.QueryContractAddressResponse, error) { +func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddressRequest) (*types.QueryOracleAddressResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -25,10 +25,10 @@ func (k Keeper) ContractAddress(goCtx context.Context, req *types.QueryContractA return nil, err } - return &types.QueryContractAddressResponse{Address: contract.String()}, nil + return &types.QueryOracleAddressResponse{Address: contract.String()}, nil } -func (k Keeper) OracleContract(goCtx context.Context, req *types.QueryOracleContractRequest) (*types.QueryOracleContractResponse, error) { +func (k Keeper) Oracle(goCtx context.Context, req *types.QueryOracleRequest) (*types.QueryOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := k.GetOracleContract(ctx) if err != nil { @@ -42,7 +42,7 @@ func (k Keeper) OracleContract(goCtx context.Context, req *types.QueryOracleCont if err != nil { return nil, err } - return &types.QueryOracleContractResponse{Data: resp.Data}, nil + return &types.QueryOracleResponse{Data: resp.Data}, nil } func (k Keeper) QueryState(goCtx context.Context, req *types.QueryQueryStateRequest) (*types.QueryQueryStateResponse, error) { diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index c674282b3b..582b0d79e0 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -98,7 +98,7 @@ func (k Keeper) OnAcknowledgementPacket( return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") } - var r types.QueryOracleContractResponse + var r types.QueryOracleResponse if err := k.cdc.Unmarshal(resps[0].Value, &r); err != nil { return sdkerrors.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) } diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 2471c02cde..60beec2721 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -13,12 +13,12 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgUpdateOracleRequest{}, - &MsgQueryOracleRequest{}, + &MsgSendQueryOracleRequest{}, ) registry.RegisterImplementations((*proto.Message)(nil), - &QueryOracleContractRequest{}, - &QueryOracleContractResponse{}, + &QueryOracleRequest{}, + &QueryOracleResponse{}, ) } diff --git a/x/oracle/types/event.pb.go b/x/oracle/types/event.pb.go index f74abc358b..2e8ba71f5a 100644 --- a/x/oracle/types/event.pb.go +++ b/x/oracle/types/event.pb.go @@ -24,8 +24,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // EventOracleQueryResponse is an event for when the chain receives a response from an oracle query type EventOracleQueryResponse struct { - // query_id is a unique identifier of the query - QueryId string `protobuf:"bytes,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` + // sequence_id is a unique identifier of the query + SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` } func (m *EventOracleQueryResponse) Reset() { *m = EventOracleQueryResponse{} } @@ -61,9 +61,9 @@ func (m *EventOracleQueryResponse) XXX_DiscardUnknown() { var xxx_messageInfo_EventOracleQueryResponse proto.InternalMessageInfo -func (m *EventOracleQueryResponse) GetQueryId() string { +func (m *EventOracleQueryResponse) GetSequenceId() string { if m != nil { - return m.QueryId + return m.SequenceId } return "" } @@ -75,19 +75,19 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/event.proto", fileDescriptor_e98d10c8454ad24d) } var fileDescriptor_e98d10c8454ad24d = []byte{ - // 184 bytes of a gzipped FileDescriptorProto + // 189 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, - 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x54, 0x32, 0xe5, 0x92, 0x70, 0x05, 0x29, 0xf2, 0x07, 0x8b, - 0x04, 0x96, 0xa6, 0x16, 0x55, 0x06, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x49, 0x72, - 0x71, 0x14, 0x82, 0x04, 0xe2, 0x33, 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xd8, 0xc1, - 0x7c, 0xcf, 0x14, 0xa7, 0xf4, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, - 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0xe0, 0x12, - 0xcf, 0xcc, 0xd7, 0xc3, 0x66, 0x53, 0x00, 0x63, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, - 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x42, 0x89, 0x6e, 0x66, 0x3e, 0x12, 0x4f, 0xbf, 0x02, 0xe6, 0xfc, - 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xe3, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xa5, 0x30, 0xb5, 0xdf, 0xe0, 0x00, 0x00, 0x00, + 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x54, 0xb2, 0xe6, 0x92, 0x70, 0x05, 0x29, 0xf2, 0x07, 0x8b, + 0x04, 0x96, 0xa6, 0x16, 0x55, 0x06, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0xc9, 0x73, + 0x71, 0x17, 0xa7, 0x16, 0x96, 0xa6, 0xe6, 0x25, 0xa7, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, + 0x6a, 0x70, 0x06, 0x71, 0xc1, 0x84, 0x3c, 0x53, 0x9c, 0xd2, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, + 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, + 0xf1, 0x58, 0x8e, 0x81, 0x4b, 0x3c, 0x33, 0x5f, 0x0f, 0x9b, 0x7d, 0x01, 0x8c, 0x51, 0x46, 0xe9, + 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x08, 0x25, 0xba, 0x99, 0xf9, 0x48, + 0x3c, 0xfd, 0x0a, 0x98, 0x27, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x5e, 0x30, 0x06, + 0x04, 0x00, 0x00, 0xff, 0xff, 0x53, 0x56, 0x12, 0x9d, 0xe6, 0x00, 0x00, 0x00, } func (m *EventOracleQueryResponse) Marshal() (dAtA []byte, err error) { @@ -110,10 +110,10 @@ func (m *EventOracleQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l - if len(m.QueryId) > 0 { - i -= len(m.QueryId) - copy(dAtA[i:], m.QueryId) - i = encodeVarintEvent(dAtA, i, uint64(len(m.QueryId))) + if len(m.SequenceId) > 0 { + i -= len(m.SequenceId) + copy(dAtA[i:], m.SequenceId) + i = encodeVarintEvent(dAtA, i, uint64(len(m.SequenceId))) i-- dAtA[i] = 0xa } @@ -137,7 +137,7 @@ func (m *EventOracleQueryResponse) Size() (n int) { } var l int _ = l - l = len(m.QueryId) + l = len(m.SequenceId) if l > 0 { n += 1 + l + sovEvent(uint64(l)) } @@ -181,7 +181,7 @@ func (m *EventOracleQueryResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SequenceId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -209,7 +209,7 @@ func (m *EventOracleQueryResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.QueryId = string(dAtA[iNdEx:postIndex]) + m.SequenceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 4d8ff7ff84..f9f152543a 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -6,11 +6,11 @@ import ( host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -func NewGenesisState(port string, params Params, queryID uint64) *GenesisState { +func NewGenesisState(port string, params Params, sequence uint64) *GenesisState { return &GenesisState{ - PortId: port, - Params: params, - QueryId: queryID, + PortId: port, + Params: params, + Sequence: sequence, } } @@ -22,7 +22,7 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - if gs.QueryId == 0 { + if gs.Sequence == 0 { return fmt.Errorf("invalid query id") } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index ea8f6b9a5c..f40c8a928a 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -25,8 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the oracle module's genesis state. type GenesisState struct { - // Query id is the next auto incremented id to be assigned to the next query - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` + // Sequence is the next auto incremented id to be assigned to the next query + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` // Params Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` // The port to assign to the module @@ -75,24 +75,24 @@ func init() { } var fileDescriptor_f8d8aecd974cfd80 = []byte{ - // 263 bytes of a gzipped FileDescriptorProto + // 262 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0xa5, 0x14, 0xb1, 0x9a, 0x57, 0x90, 0x58, 0x94, 0x98, 0x0b, 0x35, - 0x4e, 0xa9, 0x83, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x41, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, 0x24, - 0x17, 0x47, 0x61, 0x69, 0x6a, 0x51, 0x65, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4b, - 0x10, 0x3b, 0x98, 0xef, 0x99, 0x22, 0x64, 0xc5, 0xc5, 0x06, 0xd1, 0x2b, 0xc1, 0xa4, 0xc0, 0xa8, - 0xc1, 0x6d, 0x24, 0xa3, 0x87, 0xcd, 0x2d, 0x7a, 0x01, 0x60, 0x35, 0x4e, 0x2c, 0x27, 0xee, 0xc9, - 0x33, 0x04, 0x41, 0x75, 0x08, 0x89, 0x73, 0xb1, 0x17, 0xe4, 0x17, 0x95, 0x80, 0x4c, 0x65, 0x56, - 0x60, 0xd4, 0xe0, 0x0c, 0x62, 0x03, 0x71, 0x3d, 0x53, 0xac, 0x38, 0x3a, 0x16, 0xc8, 0x33, 0xbc, - 0x58, 0x20, 0xcf, 0xe0, 0x94, 0x7e, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, - 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, - 0xe2, 0x99, 0xf9, 0x58, 0xad, 0x0a, 0x60, 0x8c, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, - 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x28, 0xd1, 0xcd, 0xcc, 0x47, 0xe2, 0xe9, 0x57, 0xc0, 0x7c, 0x5f, - 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, 0xba, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xea, - 0xc2, 0x2b, 0xf1, 0x6f, 0x01, 0x00, 0x00, + 0x4e, 0xa9, 0x93, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x41, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, 0x14, + 0x17, 0x47, 0x71, 0x6a, 0x61, 0x69, 0x6a, 0x5e, 0x72, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4b, + 0x10, 0x9c, 0x2f, 0x64, 0xc5, 0xc5, 0x06, 0xd1, 0x2c, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, + 0xa3, 0x87, 0xcd, 0x31, 0x7a, 0x01, 0x60, 0x35, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, + 0x75, 0x08, 0x89, 0x73, 0xb1, 0x17, 0xe4, 0x17, 0x95, 0xc4, 0x67, 0xa6, 0x48, 0x30, 0x2b, 0x30, + 0x6a, 0x70, 0x06, 0xb1, 0x81, 0xb8, 0x9e, 0x29, 0x56, 0x1c, 0x1d, 0x0b, 0xe4, 0x19, 0x5e, 0x2c, + 0x90, 0x67, 0x70, 0x4a, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, + 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, 0xf1, + 0xcc, 0x7c, 0xac, 0x56, 0x05, 0x30, 0x46, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, + 0xe7, 0xe7, 0xea, 0x23, 0x94, 0xe8, 0x66, 0xe6, 0x23, 0xf1, 0xf4, 0x2b, 0x60, 0xde, 0x2f, 0xa9, + 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xfb, 0xdd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xef, + 0xaf, 0x1e, 0x70, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -132,8 +132,8 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - if m.QueryId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.QueryId)) + if m.Sequence != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Sequence)) i-- dAtA[i] = 0x8 } @@ -157,8 +157,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if m.QueryId != 0 { - n += 1 + sovGenesis(uint64(m.QueryId)) + if m.Sequence != 0 { + n += 1 + sovGenesis(uint64(m.Sequence)) } l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) @@ -206,9 +206,9 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } - m.QueryId = 0 + m.Sequence = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -218,7 +218,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift + m.Sequence |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index fc02e3e0bf..19ebfaa7cb 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -4,10 +4,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgQueryOracleRequest{} +var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgSendQueryOracleRequest{} -func NewMsgQueryOracle(creator, channelId string, query []byte) *MsgQueryOracleRequest { - return &MsgQueryOracleRequest{ +func NewMsgQueryOracle(creator, channelId string, query []byte) *MsgSendQueryOracleRequest { + return &MsgSendQueryOracleRequest{ Authority: creator, Channel: channelId, Query: query, @@ -32,11 +32,11 @@ func (msg MsgUpdateOracleRequest) ValidateBasic() error { } // GetSigners indicates that the message must have been signed by the parent. -func (msg MsgQueryOracleRequest) GetSigners() []sdk.AccAddress { +func (msg MsgSendQueryOracleRequest) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sdk.MustAccAddressFromBech32(msg.Authority)} } // ValidateBasic runs stateless validation checks on the message. -func (msg MsgQueryOracleRequest) ValidateBasic() error { +func (msg MsgSendQueryOracleRequest) ValidateBasic() error { return nil } diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 4c9c10c21d..a295582810 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -32,6 +32,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryQueryStateRequest queries for the state of the ICQ. type QueryQueryStateRequest struct { Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` } @@ -76,6 +77,7 @@ func (m *QueryQueryStateRequest) GetSequence() uint64 { return 0 } +// QueryQueryStateResponse contains the ICQ and its response. type QueryQueryStateResponse struct { Request types.Any `protobuf:"bytes,1,opt,name=request,proto3" json:"request"` Response *types.Any `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` @@ -128,22 +130,22 @@ func (m *QueryQueryStateResponse) GetResponse() *types.Any { return nil } -// QueryContractAddressRequest queries for the Trigger with an identifier of id. -type QueryContractAddressRequest struct { +// QueryOracleAddressRequest queries for the address of the oracle. +type QueryOracleAddressRequest struct { } -func (m *QueryContractAddressRequest) Reset() { *m = QueryContractAddressRequest{} } -func (m *QueryContractAddressRequest) String() string { return proto.CompactTextString(m) } -func (*QueryContractAddressRequest) ProtoMessage() {} -func (*QueryContractAddressRequest) Descriptor() ([]byte, []int) { +func (m *QueryOracleAddressRequest) Reset() { *m = QueryOracleAddressRequest{} } +func (m *QueryOracleAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOracleAddressRequest) ProtoMessage() {} +func (*QueryOracleAddressRequest) Descriptor() ([]byte, []int) { return fileDescriptor_169907f611744c57, []int{2} } -func (m *QueryContractAddressRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryOracleAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryContractAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOracleAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryContractAddressRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOracleAddressRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -153,36 +155,36 @@ func (m *QueryContractAddressRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryContractAddressRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryContractAddressRequest.Merge(m, src) +func (m *QueryOracleAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleAddressRequest.Merge(m, src) } -func (m *QueryContractAddressRequest) XXX_Size() int { +func (m *QueryOracleAddressRequest) XXX_Size() int { return m.Size() } -func (m *QueryContractAddressRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryContractAddressRequest.DiscardUnknown(m) +func (m *QueryOracleAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleAddressRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryContractAddressRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryOracleAddressRequest proto.InternalMessageInfo -// QueryContractAddressResponse contains the address of the oracle's contract. -type QueryContractAddressResponse struct { - // The address of the oracle's contract +// QueryOracleAddressResponse contains the address of the oracle. +type QueryOracleAddressResponse struct { + // The address of the oracle Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } -func (m *QueryContractAddressResponse) Reset() { *m = QueryContractAddressResponse{} } -func (m *QueryContractAddressResponse) String() string { return proto.CompactTextString(m) } -func (*QueryContractAddressResponse) ProtoMessage() {} -func (*QueryContractAddressResponse) Descriptor() ([]byte, []int) { +func (m *QueryOracleAddressResponse) Reset() { *m = QueryOracleAddressResponse{} } +func (m *QueryOracleAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOracleAddressResponse) ProtoMessage() {} +func (*QueryOracleAddressResponse) Descriptor() ([]byte, []int) { return fileDescriptor_169907f611744c57, []int{3} } -func (m *QueryContractAddressResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryOracleAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryContractAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOracleAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryContractAddressResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOracleAddressResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -192,43 +194,43 @@ func (m *QueryContractAddressResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryContractAddressResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryContractAddressResponse.Merge(m, src) +func (m *QueryOracleAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleAddressResponse.Merge(m, src) } -func (m *QueryContractAddressResponse) XXX_Size() int { +func (m *QueryOracleAddressResponse) XXX_Size() int { return m.Size() } -func (m *QueryContractAddressResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryContractAddressResponse.DiscardUnknown(m) +func (m *QueryOracleAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleAddressResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryContractAddressResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryOracleAddressResponse proto.InternalMessageInfo -func (m *QueryContractAddressResponse) GetAddress() string { +func (m *QueryOracleAddressResponse) GetAddress() string { if m != nil { return m.Address } return "" } -// QueryOracleContractRequest queries the oracle's smart contract -type QueryOracleContractRequest struct { - // Query contains the query data passed to the contract. +// QueryOracleRequest queries the module's oracle. +type QueryOracleRequest struct { + // Query contains the query data passed to the oracle. Query github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=query,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"query,omitempty"` } -func (m *QueryOracleContractRequest) Reset() { *m = QueryOracleContractRequest{} } -func (m *QueryOracleContractRequest) String() string { return proto.CompactTextString(m) } -func (*QueryOracleContractRequest) ProtoMessage() {} -func (*QueryOracleContractRequest) Descriptor() ([]byte, []int) { +func (m *QueryOracleRequest) Reset() { *m = QueryOracleRequest{} } +func (m *QueryOracleRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOracleRequest) ProtoMessage() {} +func (*QueryOracleRequest) Descriptor() ([]byte, []int) { return fileDescriptor_169907f611744c57, []int{4} } -func (m *QueryOracleContractRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOracleContractRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOracleContractRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOracleRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -238,43 +240,43 @@ func (m *QueryOracleContractRequest) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryOracleContractRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOracleContractRequest.Merge(m, src) +func (m *QueryOracleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleRequest.Merge(m, src) } -func (m *QueryOracleContractRequest) XXX_Size() int { +func (m *QueryOracleRequest) XXX_Size() int { return m.Size() } -func (m *QueryOracleContractRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOracleContractRequest.DiscardUnknown(m) +func (m *QueryOracleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryOracleContractRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryOracleRequest proto.InternalMessageInfo -func (m *QueryOracleContractRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { +func (m *QueryOracleRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { if m != nil { return m.Query } return nil } -// QueryOracleContractResponse contains the result of the query to the oracle's smart contract -type QueryOracleContractResponse struct { - // Data contains the json data returned from the smart contract. +// QueryOracleResponse contains the result of the query sent to the oracle. +type QueryOracleResponse struct { + // Data contains the json data returned from the oracle. Data github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=data,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"data,omitempty"` } -func (m *QueryOracleContractResponse) Reset() { *m = QueryOracleContractResponse{} } -func (m *QueryOracleContractResponse) String() string { return proto.CompactTextString(m) } -func (*QueryOracleContractResponse) ProtoMessage() {} -func (*QueryOracleContractResponse) Descriptor() ([]byte, []int) { +func (m *QueryOracleResponse) Reset() { *m = QueryOracleResponse{} } +func (m *QueryOracleResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOracleResponse) ProtoMessage() {} +func (*QueryOracleResponse) Descriptor() ([]byte, []int) { return fileDescriptor_169907f611744c57, []int{5} } -func (m *QueryOracleContractResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOracleContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOracleContractResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOracleResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -284,19 +286,19 @@ func (m *QueryOracleContractResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryOracleContractResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOracleContractResponse.Merge(m, src) +func (m *QueryOracleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOracleResponse.Merge(m, src) } -func (m *QueryOracleContractResponse) XXX_Size() int { +func (m *QueryOracleResponse) XXX_Size() int { return m.Size() } -func (m *QueryOracleContractResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOracleContractResponse.DiscardUnknown(m) +func (m *QueryOracleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOracleResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryOracleContractResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryOracleResponse proto.InternalMessageInfo -func (m *QueryOracleContractResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { +func (m *QueryOracleResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { if m != nil { return m.Data } @@ -306,52 +308,50 @@ func (m *QueryOracleContractResponse) GetData() github_com_CosmWasm_wasmd_x_wasm func init() { proto.RegisterType((*QueryQueryStateRequest)(nil), "provenance.oracle.v1.QueryQueryStateRequest") proto.RegisterType((*QueryQueryStateResponse)(nil), "provenance.oracle.v1.QueryQueryStateResponse") - proto.RegisterType((*QueryContractAddressRequest)(nil), "provenance.oracle.v1.QueryContractAddressRequest") - proto.RegisterType((*QueryContractAddressResponse)(nil), "provenance.oracle.v1.QueryContractAddressResponse") - proto.RegisterType((*QueryOracleContractRequest)(nil), "provenance.oracle.v1.QueryOracleContractRequest") - proto.RegisterType((*QueryOracleContractResponse)(nil), "provenance.oracle.v1.QueryOracleContractResponse") + proto.RegisterType((*QueryOracleAddressRequest)(nil), "provenance.oracle.v1.QueryOracleAddressRequest") + proto.RegisterType((*QueryOracleAddressResponse)(nil), "provenance.oracle.v1.QueryOracleAddressResponse") + proto.RegisterType((*QueryOracleRequest)(nil), "provenance.oracle.v1.QueryOracleRequest") + proto.RegisterType((*QueryOracleResponse)(nil), "provenance.oracle.v1.QueryOracleResponse") } func init() { proto.RegisterFile("provenance/oracle/v1/query.proto", fileDescriptor_169907f611744c57) } var fileDescriptor_169907f611744c57 = []byte{ - // 575 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbd, 0x6e, 0x13, 0x31, - 0x1c, 0x8f, 0xab, 0x94, 0x16, 0x83, 0x40, 0xb2, 0x22, 0x5a, 0x8e, 0x72, 0xad, 0x4e, 0x02, 0x3a, - 0x10, 0x9b, 0x84, 0x0a, 0x09, 0x04, 0x43, 0xd3, 0x19, 0x41, 0x2f, 0x03, 0x12, 0x4b, 0xe4, 0x5c, - 0xdc, 0xeb, 0x49, 0x3d, 0xfb, 0x62, 0xfb, 0xd2, 0x66, 0x65, 0x41, 0x6c, 0x48, 0xbc, 0x02, 0x03, - 0x0b, 0x1b, 0x0f, 0xd1, 0xb1, 0x82, 0x85, 0xa9, 0x42, 0x09, 0x4f, 0xc1, 0x84, 0x62, 0xfb, 0x9a, - 0xd2, 0x9e, 0x02, 0x95, 0x58, 0x12, 0x7f, 0xfc, 0xbe, 0xfc, 0xff, 0xdb, 0x07, 0xd7, 0x32, 0x29, - 0x06, 0x8c, 0x53, 0x1e, 0x31, 0x22, 0x24, 0x8d, 0xf6, 0x18, 0x19, 0x34, 0x48, 0x3f, 0x67, 0x72, - 0x88, 0x33, 0x29, 0xb4, 0x40, 0xb5, 0x29, 0x02, 0x5b, 0x04, 0x1e, 0x34, 0xbc, 0x5a, 0x2c, 0x62, - 0x61, 0x00, 0x64, 0x32, 0xb2, 0x58, 0x6f, 0x25, 0x16, 0x22, 0xde, 0x63, 0x84, 0x66, 0x09, 0xa1, - 0x9c, 0x0b, 0x4d, 0x75, 0x22, 0xb8, 0x72, 0xbb, 0x37, 0x23, 0xa1, 0x52, 0xa1, 0x3a, 0x96, 0x66, - 0x27, 0xc5, 0x96, 0x23, 0x9a, 0x59, 0x37, 0xdf, 0x21, 0x94, 0x3b, 0xff, 0x60, 0x03, 0xde, 0xd8, - 0x9e, 0xc4, 0x31, 0x3f, 0x6d, 0x4d, 0x35, 0x0b, 0x59, 0x3f, 0x67, 0x4a, 0x23, 0x0f, 0x2e, 0xaa, - 0xc9, 0x90, 0x47, 0x6c, 0x19, 0xac, 0x81, 0xf5, 0x6a, 0x78, 0x32, 0x0f, 0xde, 0x02, 0xb8, 0x74, - 0x8e, 0xa6, 0x32, 0xc1, 0x15, 0x43, 0x1b, 0x70, 0x41, 0x5a, 0x09, 0x43, 0xbb, 0xd2, 0xac, 0x61, - 0x6b, 0x8f, 0x0b, 0x7b, 0xbc, 0xc9, 0x87, 0xad, 0xea, 0xe1, 0xf1, 0x6a, 0x25, 0x2c, 0xa0, 0xe8, - 0x11, 0x5c, 0x94, 0x4e, 0x61, 0x79, 0xee, 0x2f, 0x34, 0x10, 0x9e, 0x60, 0x83, 0xdb, 0xf0, 0x96, - 0xc9, 0xb0, 0x25, 0xb8, 0x96, 0x34, 0xd2, 0x9b, 0xbd, 0x9e, 0x64, 0x4a, 0xb9, 0x43, 0x04, 0x21, - 0x5c, 0x29, 0xdf, 0x76, 0x61, 0x9b, 0x70, 0x81, 0xda, 0x25, 0x13, 0xf6, 0x72, 0x6b, 0xf9, 0xeb, - 0x97, 0x7a, 0xcd, 0x15, 0xcf, 0x81, 0xdb, 0x5a, 0x26, 0x3c, 0x0e, 0x0b, 0x60, 0xd0, 0x87, 0x9e, - 0xd1, 0x7c, 0x61, 0xda, 0x55, 0x28, 0x17, 0x65, 0x6b, 0xc3, 0x79, 0xd3, 0x5f, 0xa3, 0x77, 0xb5, - 0xf5, 0xec, 0xd7, 0xf1, 0xea, 0xe3, 0x38, 0xd1, 0xbb, 0x79, 0x17, 0x47, 0x22, 0x25, 0x5b, 0x42, - 0xa5, 0xaf, 0xa8, 0x4a, 0xc9, 0x3e, 0x55, 0x69, 0x8f, 0x1c, 0x98, 0x7f, 0xa2, 0x87, 0x19, 0x53, - 0x38, 0xa4, 0xfb, 0x85, 0xda, 0x73, 0xa6, 0x14, 0x8d, 0x59, 0x68, 0xb5, 0x82, 0xcc, 0x9d, 0xf2, - 0xac, 0xa5, 0x3b, 0xc5, 0x36, 0xac, 0xf6, 0xa8, 0xa6, 0xff, 0xc7, 0xd2, 0x48, 0x35, 0xdf, 0x55, - 0xe1, 0xbc, 0xb1, 0x44, 0x9f, 0x00, 0xbc, 0x7e, 0xa6, 0x7c, 0xa8, 0x81, 0xcb, 0xae, 0x2d, 0x9e, - 0xd1, 0x09, 0xaf, 0x79, 0x11, 0x8a, 0x6b, 0x2e, 0x7e, 0xf3, 0xed, 0xe7, 0x87, 0xb9, 0x75, 0x74, - 0x97, 0x94, 0xbe, 0xa3, 0xc8, 0xd1, 0x3a, 0xae, 0x33, 0xe8, 0x23, 0x80, 0xd7, 0xfe, 0x2c, 0x11, - 0x7a, 0x30, 0xc3, 0xb6, 0xb4, 0x81, 0x5e, 0xe3, 0x02, 0x0c, 0x97, 0xb3, 0x6e, 0x72, 0xde, 0x43, - 0x77, 0xca, 0x73, 0xda, 0x51, 0xa7, 0x88, 0x8b, 0x3e, 0x03, 0x08, 0xa7, 0x0f, 0x07, 0xdd, 0x9f, - 0x61, 0x78, 0xee, 0x59, 0x7a, 0xf5, 0x7f, 0x44, 0xbb, 0x68, 0x2d, 0x13, 0xed, 0x29, 0x7a, 0x42, - 0xfa, 0x39, 0x55, 0x54, 0xd6, 0x77, 0x12, 0x1b, 0x2f, 0xe1, 0x9a, 0xc9, 0x68, 0x97, 0x26, 0xdc, - 0x5c, 0xb1, 0x1e, 0x4b, 0x85, 0x5d, 0x33, 0x53, 0xfb, 0x8d, 0xea, 0xa8, 0x89, 0x56, 0x2b, 0x3e, - 0x1c, 0xf9, 0xe0, 0x68, 0xe4, 0x83, 0x1f, 0x23, 0x1f, 0xbc, 0x1f, 0xfb, 0x95, 0xa3, 0xb1, 0x5f, - 0xf9, 0x3e, 0xf6, 0x2b, 0x70, 0x29, 0x11, 0xa5, 0x71, 0x5e, 0x82, 0xd7, 0xcd, 0x53, 0x37, 0x70, - 0x0a, 0xa9, 0x27, 0xe2, 0x74, 0x8d, 0x0e, 0x8a, 0x2a, 0x99, 0xdb, 0xd8, 0xbd, 0x64, 0x9e, 0xfa, - 0xc3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xb8, 0xea, 0xba, 0x37, 0x05, 0x00, 0x00, + // 539 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbf, 0x6e, 0x13, 0x31, + 0x18, 0x8f, 0x4b, 0xff, 0xf1, 0x01, 0x8b, 0x89, 0x68, 0x7a, 0x54, 0xd7, 0x72, 0x54, 0xa8, 0x95, + 0x1a, 0x9b, 0x86, 0x0a, 0x89, 0x81, 0xa1, 0xe9, 0x8c, 0x68, 0x2f, 0x03, 0x12, 0x4b, 0xe4, 0x5c, + 0xcc, 0xf5, 0xa4, 0xc6, 0xbe, 0x9e, 0x9d, 0xb4, 0x59, 0x61, 0x60, 0x45, 0x82, 0x07, 0xe0, 0x21, + 0x78, 0x07, 0x3a, 0x56, 0xb0, 0x30, 0x55, 0x28, 0xe1, 0x29, 0x98, 0x50, 0x6c, 0x5f, 0x93, 0xaa, + 0x69, 0x9b, 0x81, 0x25, 0xb1, 0xcf, 0xbf, 0x7f, 0xf7, 0xf9, 0xfb, 0x0e, 0x56, 0xd2, 0x4c, 0x76, + 0xb8, 0x60, 0x22, 0xe2, 0x54, 0x66, 0x2c, 0x3a, 0xe0, 0xb4, 0xb3, 0x49, 0x0f, 0xdb, 0x3c, 0xeb, + 0x92, 0x34, 0x93, 0x5a, 0xe2, 0xe2, 0x10, 0x41, 0x2c, 0x82, 0x74, 0x36, 0xbd, 0x62, 0x2c, 0x63, + 0x69, 0x00, 0x74, 0xb0, 0xb2, 0x58, 0x6f, 0x29, 0x96, 0x32, 0x3e, 0xe0, 0x94, 0xa5, 0x09, 0x65, + 0x42, 0x48, 0xcd, 0x74, 0x22, 0x85, 0x72, 0xa7, 0x8b, 0x91, 0x54, 0x2d, 0xa9, 0xea, 0x96, 0x66, + 0x37, 0xf9, 0x91, 0x23, 0x9a, 0x5d, 0xa3, 0xfd, 0x8e, 0x32, 0xe1, 0xfc, 0x83, 0x2d, 0x78, 0xb0, + 0x37, 0x88, 0x63, 0x7e, 0x6a, 0x9a, 0x69, 0x1e, 0xf2, 0xc3, 0x36, 0x57, 0x1a, 0x7b, 0x30, 0xaf, + 0x06, 0x4b, 0x11, 0xf1, 0x12, 0x5a, 0x41, 0x6b, 0xd3, 0xe1, 0xf9, 0x3e, 0xf8, 0x88, 0x60, 0xe1, + 0x12, 0x4d, 0xa5, 0x52, 0x28, 0x8e, 0xb7, 0x60, 0x2e, 0xb3, 0x12, 0x86, 0x76, 0xa7, 0x52, 0x24, + 0xd6, 0x9e, 0xe4, 0xf6, 0x64, 0x5b, 0x74, 0xab, 0xd3, 0x27, 0x67, 0xcb, 0x85, 0x30, 0x87, 0xe2, + 0xe7, 0x30, 0x9f, 0x39, 0x85, 0xd2, 0xd4, 0x0d, 0x34, 0x14, 0x9e, 0x63, 0x83, 0x87, 0xb0, 0x68, + 0x32, 0xbc, 0x36, 0xb5, 0xdb, 0x6e, 0x36, 0x33, 0xae, 0x94, 0x7b, 0x85, 0x60, 0x17, 0xbc, 0x71, + 0x87, 0x2e, 0x68, 0x05, 0xe6, 0x98, 0x7d, 0x64, 0x82, 0xde, 0xae, 0x96, 0x7e, 0x7c, 0x2b, 0x17, + 0x5d, 0xe1, 0x1c, 0xb8, 0xa6, 0xb3, 0x44, 0xc4, 0x61, 0x0e, 0x0c, 0x12, 0xc0, 0x23, 0x8a, 0x79, + 0xa9, 0x6a, 0x30, 0x63, 0xee, 0xd4, 0xe8, 0xdc, 0xad, 0xbe, 0xfc, 0x7b, 0xb6, 0xfc, 0x22, 0x4e, + 0xf4, 0x7e, 0xbb, 0x41, 0x22, 0xd9, 0xa2, 0x3b, 0x52, 0xb5, 0xde, 0x30, 0xd5, 0xa2, 0x47, 0x4c, + 0xb5, 0x9a, 0xf4, 0xd8, 0xfc, 0x53, 0xdd, 0x4d, 0xb9, 0x22, 0x21, 0x3b, 0xda, 0x91, 0x42, 0x67, + 0x2c, 0xd2, 0xaf, 0xb8, 0x52, 0x2c, 0xe6, 0xa1, 0xd5, 0x0a, 0xf6, 0xe1, 0xfe, 0x05, 0x2b, 0x97, + 0x7a, 0x0f, 0xa6, 0x9b, 0x4c, 0xb3, 0xff, 0x63, 0x65, 0xa4, 0x2a, 0xdf, 0x6f, 0xc1, 0x8c, 0xb1, + 0xc2, 0x5f, 0x11, 0xdc, 0xbb, 0x50, 0x2c, 0x4c, 0xc9, 0xb8, 0x06, 0x25, 0x57, 0xd6, 0xdc, 0x7b, + 0x3a, 0x39, 0xc1, 0x5d, 0xe1, 0xc6, 0xfb, 0x9f, 0x7f, 0x3e, 0x4f, 0x3d, 0xc1, 0xab, 0x74, 0xec, + 0xb4, 0xd8, 0x55, 0xdd, 0xdd, 0x00, 0xfe, 0x80, 0x60, 0xd6, 0xea, 0xe0, 0xb5, 0x1b, 0xad, 0xf2, + 0x50, 0xeb, 0x13, 0x20, 0x5d, 0x9a, 0x55, 0x93, 0xc6, 0xc7, 0x4b, 0xd7, 0xa5, 0xc1, 0x5f, 0x10, + 0xc0, 0xb0, 0xf7, 0xf1, 0xc6, 0x35, 0xfa, 0x97, 0x26, 0xcb, 0x2b, 0x4f, 0x88, 0x76, 0x89, 0xd6, + 0x4d, 0xa2, 0xc7, 0xf8, 0x11, 0xbd, 0xfa, 0x6b, 0x52, 0x57, 0x03, 0x4a, 0x35, 0x3e, 0xe9, 0xf9, + 0xe8, 0xb4, 0xe7, 0xa3, 0xdf, 0x3d, 0x1f, 0x7d, 0xea, 0xfb, 0x85, 0xd3, 0xbe, 0x5f, 0xf8, 0xd5, + 0xf7, 0x0b, 0xb0, 0x90, 0xc8, 0xb1, 0xae, 0xbb, 0xe8, 0x6d, 0x65, 0xa4, 0x7f, 0x86, 0x90, 0x72, + 0x22, 0x47, 0xfd, 0x8e, 0x73, 0x47, 0xd3, 0x4b, 0x8d, 0x59, 0x33, 0x94, 0xcf, 0xfe, 0x05, 0x00, + 0x00, 0xff, 0xff, 0x8b, 0x00, 0xca, 0xa5, 0xe1, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -366,10 +366,11 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // ContractAddress returns the address of the oracle's contract - ContractAddress(ctx context.Context, in *QueryContractAddressRequest, opts ...grpc.CallOption) (*QueryContractAddressResponse, error) - // OracleContract sends a query to the oracle's contract - OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) + // OracleAddress returns the address of the oracle + OracleAddress(ctx context.Context, in *QueryOracleAddressRequest, opts ...grpc.CallOption) (*QueryOracleAddressResponse, error) + // Oracle sends a query to the oracle's contract + Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) + // QueryState returns the state of the oracle query QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) } @@ -381,18 +382,18 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) ContractAddress(ctx context.Context, in *QueryContractAddressRequest, opts ...grpc.CallOption) (*QueryContractAddressResponse, error) { - out := new(QueryContractAddressResponse) - err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/ContractAddress", in, out, opts...) +func (c *queryClient) OracleAddress(ctx context.Context, in *QueryOracleAddressRequest, opts ...grpc.CallOption) (*QueryOracleAddressResponse, error) { + out := new(QueryOracleAddressResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/OracleAddress", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) OracleContract(ctx context.Context, in *QueryOracleContractRequest, opts ...grpc.CallOption) (*QueryOracleContractResponse, error) { - out := new(QueryOracleContractResponse) - err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/OracleContract", in, out, opts...) +func (c *queryClient) Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) { + out := new(QueryOracleResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/Oracle", in, out, opts...) if err != nil { return nil, err } @@ -410,10 +411,11 @@ func (c *queryClient) QueryState(ctx context.Context, in *QueryQueryStateRequest // QueryServer is the server API for Query service. type QueryServer interface { - // ContractAddress returns the address of the oracle's contract - ContractAddress(context.Context, *QueryContractAddressRequest) (*QueryContractAddressResponse, error) - // OracleContract sends a query to the oracle's contract - OracleContract(context.Context, *QueryOracleContractRequest) (*QueryOracleContractResponse, error) + // OracleAddress returns the address of the oracle + OracleAddress(context.Context, *QueryOracleAddressRequest) (*QueryOracleAddressResponse, error) + // Oracle sends a query to the oracle's contract + Oracle(context.Context, *QueryOracleRequest) (*QueryOracleResponse, error) + // QueryState returns the state of the oracle query QueryState(context.Context, *QueryQueryStateRequest) (*QueryQueryStateResponse, error) } @@ -421,11 +423,11 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) ContractAddress(ctx context.Context, req *QueryContractAddressRequest) (*QueryContractAddressResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ContractAddress not implemented") +func (*UnimplementedQueryServer) OracleAddress(ctx context.Context, req *QueryOracleAddressRequest) (*QueryOracleAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OracleAddress not implemented") } -func (*UnimplementedQueryServer) OracleContract(ctx context.Context, req *QueryOracleContractRequest) (*QueryOracleContractResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method OracleContract not implemented") +func (*UnimplementedQueryServer) Oracle(ctx context.Context, req *QueryOracleRequest) (*QueryOracleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Oracle not implemented") } func (*UnimplementedQueryServer) QueryState(ctx context.Context, req *QueryQueryStateRequest) (*QueryQueryStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryState not implemented") @@ -435,38 +437,38 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_ContractAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryContractAddressRequest) +func _Query_OracleAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOracleAddressRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).ContractAddress(ctx, in) + return srv.(QueryServer).OracleAddress(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/provenance.oracle.v1.Query/ContractAddress", + FullMethod: "/provenance.oracle.v1.Query/OracleAddress", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ContractAddress(ctx, req.(*QueryContractAddressRequest)) + return srv.(QueryServer).OracleAddress(ctx, req.(*QueryOracleAddressRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_OracleContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOracleContractRequest) +func _Query_Oracle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOracleRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).OracleContract(ctx, in) + return srv.(QueryServer).Oracle(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/provenance.oracle.v1.Query/OracleContract", + FullMethod: "/provenance.oracle.v1.Query/Oracle", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).OracleContract(ctx, req.(*QueryOracleContractRequest)) + return srv.(QueryServer).Oracle(ctx, req.(*QueryOracleRequest)) } return interceptor(ctx, in, info, handler) } @@ -494,12 +496,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "ContractAddress", - Handler: _Query_ContractAddress_Handler, + MethodName: "OracleAddress", + Handler: _Query_OracleAddress_Handler, }, { - MethodName: "OracleContract", - Handler: _Query_OracleContract_Handler, + MethodName: "Oracle", + Handler: _Query_Oracle_Handler, }, { MethodName: "QueryState", @@ -583,7 +585,7 @@ func (m *QueryQueryStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryContractAddressRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryOracleAddressRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -593,12 +595,12 @@ func (m *QueryContractAddressRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryContractAddressRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOracleAddressRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryContractAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOracleAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -606,7 +608,7 @@ func (m *QueryContractAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryContractAddressResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryOracleAddressResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -616,12 +618,12 @@ func (m *QueryContractAddressResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryContractAddressResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOracleAddressResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryContractAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOracleAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -636,7 +638,7 @@ func (m *QueryContractAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryOracleContractRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryOracleRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -646,12 +648,12 @@ func (m *QueryOracleContractRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryOracleContractRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOracleRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOracleContractRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -666,7 +668,7 @@ func (m *QueryOracleContractRequest) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryOracleContractResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryOracleResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -676,12 +678,12 @@ func (m *QueryOracleContractResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryOracleContractResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOracleResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOracleContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -734,7 +736,7 @@ func (m *QueryQueryStateResponse) Size() (n int) { return n } -func (m *QueryContractAddressRequest) Size() (n int) { +func (m *QueryOracleAddressRequest) Size() (n int) { if m == nil { return 0 } @@ -743,7 +745,7 @@ func (m *QueryContractAddressRequest) Size() (n int) { return n } -func (m *QueryContractAddressResponse) Size() (n int) { +func (m *QueryOracleAddressResponse) Size() (n int) { if m == nil { return 0 } @@ -756,7 +758,7 @@ func (m *QueryContractAddressResponse) Size() (n int) { return n } -func (m *QueryOracleContractRequest) Size() (n int) { +func (m *QueryOracleRequest) Size() (n int) { if m == nil { return 0 } @@ -769,7 +771,7 @@ func (m *QueryOracleContractRequest) Size() (n int) { return n } -func (m *QueryOracleContractResponse) Size() (n int) { +func (m *QueryOracleResponse) Size() (n int) { if m == nil { return 0 } @@ -976,7 +978,7 @@ func (m *QueryQueryStateResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryContractAddressRequest) Unmarshal(dAtA []byte) error { +func (m *QueryOracleAddressRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -999,10 +1001,10 @@ func (m *QueryContractAddressRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryContractAddressRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOracleAddressRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryContractAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOracleAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1026,7 +1028,7 @@ func (m *QueryContractAddressRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryContractAddressResponse) Unmarshal(dAtA []byte) error { +func (m *QueryOracleAddressResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1049,10 +1051,10 @@ func (m *QueryContractAddressResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryContractAddressResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOracleAddressResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryContractAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOracleAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1108,7 +1110,7 @@ func (m *QueryContractAddressResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOracleContractRequest) Unmarshal(dAtA []byte) error { +func (m *QueryOracleRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1131,10 +1133,10 @@ func (m *QueryOracleContractRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOracleContractRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOracleRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOracleContractRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1192,7 +1194,7 @@ func (m *QueryOracleContractRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOracleContractResponse) Unmarshal(dAtA []byte) error { +func (m *QueryOracleResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1215,10 +1217,10 @@ func (m *QueryOracleContractResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOracleContractResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOracleResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOracleContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOracleResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 05a8308b10..2fac9500a9 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -31,56 +31,56 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -func request_Query_ContractAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryContractAddressRequest +func request_Query_OracleAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleAddressRequest var metadata runtime.ServerMetadata - msg, err := client.ContractAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.OracleAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_ContractAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryContractAddressRequest +func local_request_Query_OracleAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleAddressRequest var metadata runtime.ServerMetadata - msg, err := server.ContractAddress(ctx, &protoReq) + msg, err := server.OracleAddress(ctx, &protoReq) return msg, metadata, err } var ( - filter_Query_OracleContract_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_Oracle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_OracleContract_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOracleContractRequest +func request_Query_Oracle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleContract_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Oracle_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.OracleContract(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Oracle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_OracleContract_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOracleContractRequest +func local_request_Query_Oracle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOracleRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_OracleContract_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Oracle_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.OracleContract(ctx, &protoReq) + msg, err := server.Oracle(ctx, &protoReq) return msg, metadata, err } @@ -127,7 +127,7 @@ func local_request_Query_QueryState_0(ctx context.Context, marshaler runtime.Mar // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_ContractAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_OracleAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -136,18 +136,18 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_ContractAddress_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_OracleAddress_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_ContractAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_OracleAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_OracleContract_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Oracle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -156,14 +156,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_OracleContract_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_Oracle_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_OracleContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Oracle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -228,7 +228,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_ContractAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_OracleAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -237,18 +237,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_ContractAddress_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_OracleAddress_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_ContractAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_OracleAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_OracleContract_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Oracle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -257,14 +257,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_OracleContract_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_Oracle_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_OracleContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Oracle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -292,17 +292,17 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_ContractAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "contract_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_OracleAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_OracleContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_contract"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Oracle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"provenance", "oracle", "v1"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"quasar-finance", "interchainquerydemo", "interquery", "query_state"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "query_state"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_ContractAddress_0 = runtime.ForwardResponseMessage + forward_Query_OracleAddress_0 = runtime.ForwardResponseMessage - forward_Query_OracleContract_0 = runtime.ForwardResponseMessage + forward_Query_Oracle_0 = runtime.ForwardResponseMessage forward_Query_QueryState_0 = runtime.ForwardResponseMessage ) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 6d65efff44..87214b42d0 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -32,8 +32,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgQueryOracleRequest queries an Oracle on another chain -type MsgQueryOracleRequest struct { +// MsgSendQueryOracleRequest queries an oracle on another chain +type MsgSendQueryOracleRequest struct { // Query contains the query data passed to the oracle. Query github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,1,opt,name=query,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"query,omitempty"` // Channel is the channel to the oracle. @@ -42,18 +42,18 @@ type MsgQueryOracleRequest struct { Authority string `protobuf:"bytes,4,opt,name=authority,proto3" json:"authority,omitempty"` } -func (m *MsgQueryOracleRequest) Reset() { *m = MsgQueryOracleRequest{} } -func (m *MsgQueryOracleRequest) String() string { return proto.CompactTextString(m) } -func (*MsgQueryOracleRequest) ProtoMessage() {} -func (*MsgQueryOracleRequest) Descriptor() ([]byte, []int) { +func (m *MsgSendQueryOracleRequest) Reset() { *m = MsgSendQueryOracleRequest{} } +func (m *MsgSendQueryOracleRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSendQueryOracleRequest) ProtoMessage() {} +func (*MsgSendQueryOracleRequest) Descriptor() ([]byte, []int) { return fileDescriptor_66a39dda41c6a784, []int{0} } -func (m *MsgQueryOracleRequest) XXX_Unmarshal(b []byte) error { +func (m *MsgSendQueryOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgQueryOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSendQueryOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgQueryOracleRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSendQueryOracleRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -63,57 +63,57 @@ func (m *MsgQueryOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgQueryOracleRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgQueryOracleRequest.Merge(m, src) +func (m *MsgSendQueryOracleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendQueryOracleRequest.Merge(m, src) } -func (m *MsgQueryOracleRequest) XXX_Size() int { +func (m *MsgSendQueryOracleRequest) XXX_Size() int { return m.Size() } -func (m *MsgQueryOracleRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgQueryOracleRequest.DiscardUnknown(m) +func (m *MsgSendQueryOracleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendQueryOracleRequest.DiscardUnknown(m) } -var xxx_messageInfo_MsgQueryOracleRequest proto.InternalMessageInfo +var xxx_messageInfo_MsgSendQueryOracleRequest proto.InternalMessageInfo -func (m *MsgQueryOracleRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { +func (m *MsgSendQueryOracleRequest) GetQuery() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { if m != nil { return m.Query } return nil } -func (m *MsgQueryOracleRequest) GetChannel() string { +func (m *MsgSendQueryOracleRequest) GetChannel() string { if m != nil { return m.Channel } return "" } -func (m *MsgQueryOracleRequest) GetAuthority() string { +func (m *MsgSendQueryOracleRequest) GetAuthority() string { if m != nil { return m.Authority } return "" } -// MsgQueryOracleResponse contains the id of the oracle query. -type MsgQueryOracleResponse struct { +// MsgSendQueryOracleResponse contains the id of the oracle query. +type MsgSendQueryOracleResponse struct { // The sequence number that uniquely identifies the query. Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` } -func (m *MsgQueryOracleResponse) Reset() { *m = MsgQueryOracleResponse{} } -func (m *MsgQueryOracleResponse) String() string { return proto.CompactTextString(m) } -func (*MsgQueryOracleResponse) ProtoMessage() {} -func (*MsgQueryOracleResponse) Descriptor() ([]byte, []int) { +func (m *MsgSendQueryOracleResponse) Reset() { *m = MsgSendQueryOracleResponse{} } +func (m *MsgSendQueryOracleResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSendQueryOracleResponse) ProtoMessage() {} +func (*MsgSendQueryOracleResponse) Descriptor() ([]byte, []int) { return fileDescriptor_66a39dda41c6a784, []int{1} } -func (m *MsgQueryOracleResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgSendQueryOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgQueryOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSendQueryOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgQueryOracleResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSendQueryOracleResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -123,19 +123,19 @@ func (m *MsgQueryOracleResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *MsgQueryOracleResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgQueryOracleResponse.Merge(m, src) +func (m *MsgSendQueryOracleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendQueryOracleResponse.Merge(m, src) } -func (m *MsgQueryOracleResponse) XXX_Size() int { +func (m *MsgSendQueryOracleResponse) XXX_Size() int { return m.Size() } -func (m *MsgQueryOracleResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgQueryOracleResponse.DiscardUnknown(m) +func (m *MsgSendQueryOracleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendQueryOracleResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgQueryOracleResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgSendQueryOracleResponse proto.InternalMessageInfo -func (m *MsgQueryOracleResponse) GetSequence() uint64 { +func (m *MsgSendQueryOracleResponse) GetSequence() uint64 { if m != nil { return m.Sequence } @@ -235,8 +235,8 @@ func (m *MsgUpdateOracleResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateOracleResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgQueryOracleRequest)(nil), "provenance.oracle.v1.MsgQueryOracleRequest") - proto.RegisterType((*MsgQueryOracleResponse)(nil), "provenance.oracle.v1.MsgQueryOracleResponse") + proto.RegisterType((*MsgSendQueryOracleRequest)(nil), "provenance.oracle.v1.MsgSendQueryOracleRequest") + proto.RegisterType((*MsgSendQueryOracleResponse)(nil), "provenance.oracle.v1.MsgSendQueryOracleResponse") proto.RegisterType((*MsgUpdateOracleRequest)(nil), "provenance.oracle.v1.MsgUpdateOracleRequest") proto.RegisterType((*MsgUpdateOracleResponse)(nil), "provenance.oracle.v1.MsgUpdateOracleResponse") } @@ -244,37 +244,37 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/tx.proto", fileDescriptor_66a39dda41c6a784) } var fileDescriptor_66a39dda41c6a784 = []byte{ - // 475 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xce, 0xd1, 0x42, 0xdb, 0xa3, 0x93, 0x15, 0xa8, 0x63, 0x09, 0xa7, 0xca, 0x54, 0x41, 0xe3, - 0x53, 0x02, 0x42, 0x02, 0x89, 0x81, 0x74, 0x8e, 0x00, 0x57, 0x08, 0x89, 0x05, 0x9d, 0x9d, 0xe3, - 0x62, 0x11, 0xdf, 0x73, 0xfd, 0xce, 0x69, 0xf2, 0x27, 0x10, 0x23, 0x63, 0x7f, 0x04, 0x33, 0x33, - 0x63, 0xc5, 0xc4, 0x80, 0x10, 0x4a, 0x16, 0x7e, 0x03, 0x13, 0xca, 0x5d, 0x42, 0x5c, 0x1a, 0xaa, - 0x4c, 0xf6, 0xbb, 0xef, 0x7b, 0xef, 0xbe, 0xef, 0xe9, 0x3b, 0x7a, 0x27, 0xcb, 0x61, 0x28, 0x14, - 0x57, 0xb1, 0x60, 0x90, 0xf3, 0x78, 0x20, 0xd8, 0xb0, 0xc5, 0xf4, 0x28, 0xc8, 0x72, 0xd0, 0xe0, - 0x54, 0x97, 0x70, 0x60, 0xe1, 0x60, 0xd8, 0xf2, 0x6a, 0x31, 0x60, 0x0a, 0xf8, 0xc6, 0x70, 0x98, - 0x2d, 0x6c, 0x83, 0x57, 0x95, 0x20, 0xc1, 0x9e, 0xcf, 0xfe, 0xe6, 0xa7, 0x77, 0x2d, 0x87, 0x45, - 0x1c, 0x05, 0x3b, 0x29, 0x44, 0x3e, 0x66, 0xc3, 0x56, 0x24, 0x34, 0x6f, 0xb1, 0x8c, 0xcb, 0x44, - 0x71, 0x9d, 0x80, 0x9a, 0x73, 0x6b, 0x12, 0x40, 0x0e, 0x04, 0x33, 0x55, 0x54, 0xbc, 0x65, 0x5c, - 0x8d, 0x2d, 0xd4, 0xf8, 0x4c, 0xe8, 0xad, 0x2e, 0xca, 0x17, 0xb3, 0x01, 0xcf, 0x8c, 0x9a, 0x50, - 0x9c, 0x14, 0x02, 0xb5, 0x73, 0x4c, 0xaf, 0x9b, 0xb1, 0x2e, 0xd9, 0x27, 0x07, 0xbb, 0x9d, 0x27, - 0xbf, 0x7f, 0xd4, 0x1f, 0xc9, 0x44, 0xf7, 0x8b, 0x28, 0x88, 0x21, 0x65, 0x47, 0x80, 0xe9, 0x2b, - 0x8e, 0x29, 0x3b, 0xe5, 0x98, 0xf6, 0xd8, 0xc8, 0x7c, 0x99, 0x1e, 0x67, 0x02, 0x83, 0x90, 0x9f, - 0x1e, 0x81, 0xd2, 0x39, 0x8f, 0x75, 0x57, 0x20, 0x72, 0x29, 0x42, 0x3b, 0xcb, 0x71, 0xe9, 0x56, - 0xdc, 0xe7, 0x4a, 0x89, 0x81, 0xbb, 0xb1, 0x4f, 0x0e, 0x76, 0xc2, 0x45, 0xe9, 0x3c, 0xa4, 0x3b, - 0xbc, 0xd0, 0x7d, 0xc8, 0x13, 0x3d, 0x76, 0x37, 0x67, 0x58, 0xc7, 0xfd, 0xfa, 0xa9, 0x59, 0x9d, - 0xaf, 0xe2, 0x69, 0xaf, 0x97, 0x0b, 0xc4, 0x63, 0x9d, 0x27, 0x4a, 0x86, 0x4b, 0x6a, 0xe3, 0x01, - 0xbd, 0xfd, 0xaf, 0x7e, 0xcc, 0x40, 0xa1, 0x70, 0x3c, 0xba, 0x8d, 0x33, 0x2f, 0x2a, 0x16, 0xc6, - 0xc3, 0x66, 0xf8, 0xb7, 0x6e, 0xbc, 0x27, 0xa6, 0xed, 0x65, 0xd6, 0xe3, 0x5a, 0x5c, 0xf4, 0xdd, - 0xa6, 0x5b, 0xdc, 0x5e, 0x66, 0xba, 0xae, 0x92, 0xb1, 0x20, 0x5e, 0x14, 0x7f, 0x6d, 0x6d, 0xf1, - 0x8f, 0xb7, 0x3f, 0x9e, 0xd5, 0xc9, 0xaf, 0xb3, 0x3a, 0x69, 0xd4, 0xe8, 0xde, 0x25, 0x3d, 0xd6, - 0x47, 0xfb, 0x3b, 0xa1, 0x1b, 0x5d, 0x94, 0xce, 0x3b, 0xba, 0x5b, 0xc6, 0x9d, 0xc3, 0x60, 0x55, - 0x92, 0x82, 0xd5, 0xb6, 0xbc, 0xe6, 0x9a, 0xec, 0xf9, 0xf2, 0xfa, 0xf4, 0x66, 0x69, 0xa7, 0xce, - 0xbd, 0xff, 0x76, 0x5f, 0x4e, 0x8e, 0x77, 0xb8, 0x1e, 0xd9, 0xde, 0xd4, 0x91, 0x5f, 0x26, 0x3e, - 0x39, 0x9f, 0xf8, 0xe4, 0xe7, 0xc4, 0x27, 0x1f, 0xa6, 0x7e, 0xe5, 0x7c, 0xea, 0x57, 0xbe, 0x4d, - 0xfd, 0x0a, 0xdd, 0x4b, 0x60, 0xe5, 0xa4, 0xe7, 0xe4, 0x75, 0xbb, 0x94, 0xc4, 0x25, 0xa5, 0x99, - 0x40, 0xa9, 0x62, 0xa3, 0xc5, 0xf3, 0x33, 0xa9, 0x8c, 0x6e, 0x98, 0xc4, 0xdf, 0xff, 0x13, 0x00, - 0x00, 0xff, 0xff, 0xdc, 0x47, 0x0a, 0x6d, 0xa0, 0x03, 0x00, 0x00, + // 480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xed, 0xd2, 0x42, 0xdb, 0x55, 0x25, 0x24, 0x2b, 0xa2, 0x8e, 0x25, 0x9c, 0x2a, 0xa7, 0x0a, + 0x11, 0x2f, 0x09, 0x12, 0x02, 0x24, 0x0e, 0xa4, 0xe7, 0x08, 0x70, 0x84, 0x90, 0xb8, 0xa0, 0xb5, + 0xbd, 0x6c, 0x2c, 0xe2, 0x1d, 0xd7, 0xb3, 0x4e, 0x93, 0x9f, 0x40, 0x1c, 0x39, 0xf6, 0x23, 0xf8, + 0x02, 0x4e, 0x1c, 0x2b, 0x4e, 0x9c, 0x10, 0x4a, 0x2e, 0xfd, 0x06, 0x4e, 0x28, 0xbb, 0x09, 0x49, + 0xc1, 0xa0, 0x9c, 0xec, 0xb7, 0xef, 0xcd, 0xdb, 0x79, 0xa3, 0x59, 0x7a, 0x3b, 0x2f, 0x60, 0x24, + 0x14, 0x57, 0xb1, 0x60, 0x50, 0xf0, 0x78, 0x28, 0xd8, 0xa8, 0xcd, 0xf4, 0x38, 0xc8, 0x0b, 0xd0, + 0xe0, 0xd4, 0x56, 0x74, 0x60, 0xe9, 0x60, 0xd4, 0xf6, 0xea, 0x31, 0x60, 0x06, 0xf8, 0xc6, 0x68, + 0x98, 0x05, 0xb6, 0xc0, 0xab, 0x49, 0x90, 0x60, 0xcf, 0xe7, 0x7f, 0x8b, 0xd3, 0x3b, 0x56, 0xc3, + 0x22, 0x8e, 0x82, 0x9d, 0x96, 0xa2, 0x98, 0xb0, 0x51, 0x3b, 0x12, 0x9a, 0xb7, 0x59, 0xce, 0x65, + 0xaa, 0xb8, 0x4e, 0x41, 0x2d, 0xb4, 0x75, 0x09, 0x20, 0x87, 0x82, 0x19, 0x14, 0x95, 0x6f, 0x19, + 0x57, 0x13, 0x4b, 0x35, 0x3f, 0x13, 0x5a, 0xef, 0xa1, 0xec, 0x0b, 0x95, 0xbc, 0x98, 0x9b, 0x3c, + 0x33, 0x1d, 0x85, 0xe2, 0xb4, 0x14, 0xa8, 0x9d, 0x3e, 0xbd, 0x6e, 0xac, 0x5d, 0x72, 0x44, 0x8e, + 0x0f, 0xba, 0x4f, 0x7e, 0x7e, 0x6f, 0x3c, 0x92, 0xa9, 0x1e, 0x94, 0x51, 0x10, 0x43, 0xc6, 0x4e, + 0x00, 0xb3, 0x57, 0x1c, 0x33, 0x76, 0xc6, 0x31, 0x4b, 0xd8, 0xd8, 0x7c, 0x99, 0x9e, 0xe4, 0x02, + 0x83, 0x90, 0x9f, 0x9d, 0x80, 0xd2, 0x05, 0x8f, 0x75, 0x4f, 0x20, 0x72, 0x29, 0x42, 0xeb, 0xe5, + 0xb8, 0x74, 0x37, 0x1e, 0x70, 0xa5, 0xc4, 0xd0, 0xdd, 0x3e, 0x22, 0xc7, 0xfb, 0xe1, 0x12, 0x3a, + 0x0f, 0xe8, 0x3e, 0x2f, 0xf5, 0x00, 0x8a, 0x54, 0x4f, 0xdc, 0x9d, 0x39, 0xd7, 0x75, 0xbf, 0x7e, + 0x6a, 0xd5, 0x16, 0xe3, 0x78, 0x9a, 0x24, 0x85, 0x40, 0xec, 0xeb, 0x22, 0x55, 0x32, 0x5c, 0x49, + 0x9b, 0x0f, 0xa9, 0x57, 0x95, 0x01, 0x73, 0x50, 0x28, 0x1c, 0x8f, 0xee, 0xe1, 0x3c, 0x8f, 0x8a, + 0x85, 0xc9, 0xb1, 0x13, 0xfe, 0xc6, 0xcd, 0xf7, 0x84, 0xde, 0xea, 0xa1, 0x7c, 0x99, 0x27, 0x5c, + 0x8b, 0xab, 0xd9, 0x3b, 0x74, 0x97, 0xdb, 0x0b, 0x4d, 0xd5, 0xff, 0x5a, 0x59, 0x0a, 0xaf, 0x06, + 0xb8, 0xb6, 0x71, 0x80, 0xc7, 0x7b, 0x1f, 0xcf, 0x1b, 0xe4, 0xf2, 0xbc, 0x41, 0x9a, 0x75, 0x7a, + 0xf8, 0x57, 0x3f, 0x36, 0x47, 0xe7, 0x92, 0xd0, 0xed, 0x1e, 0x4a, 0xe7, 0x1d, 0x3d, 0x58, 0xe7, + 0x9d, 0xbb, 0x41, 0xd5, 0x46, 0x05, 0xd5, 0xb1, 0xbc, 0xd6, 0x86, 0xea, 0xc5, 0xf0, 0x34, 0xbd, + 0xf9, 0xc7, 0x5c, 0x1d, 0xf6, 0x4f, 0x87, 0xea, 0x2d, 0xf2, 0xee, 0x6d, 0x5e, 0x60, 0x6f, 0xed, + 0xca, 0x2f, 0x53, 0x9f, 0x5c, 0x4c, 0x7d, 0xf2, 0x63, 0xea, 0x93, 0x0f, 0x33, 0x7f, 0xeb, 0x62, + 0xe6, 0x6f, 0x7d, 0x9b, 0xf9, 0x5b, 0xf4, 0x30, 0x85, 0x4a, 0xb7, 0xe7, 0xe4, 0x75, 0x67, 0x6d, + 0x33, 0x57, 0x92, 0x56, 0x0a, 0x6b, 0x88, 0x8d, 0x97, 0x4f, 0xd2, 0x6c, 0x69, 0x74, 0xc3, 0xbc, + 0x82, 0xfb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xd9, 0x47, 0x26, 0xb4, 0x03, 0x00, 0x00, } func (this *MsgUpdateOracleRequest) Equal(that interface{}) bool { @@ -319,8 +319,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // UpdateOracle is the RPC endpoint for updating the oracle UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest, opts ...grpc.CallOption) (*MsgUpdateOracleResponse, error) - // QueryOracle sends an icq to an oracle on another chain - QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, opts ...grpc.CallOption) (*MsgQueryOracleResponse, error) + // SendQueryOracle sends a query to an oracle on another chain + SendQueryOracle(ctx context.Context, in *MsgSendQueryOracleRequest, opts ...grpc.CallOption) (*MsgSendQueryOracleResponse, error) } type msgClient struct { @@ -340,9 +340,9 @@ func (c *msgClient) UpdateOracle(ctx context.Context, in *MsgUpdateOracleRequest return out, nil } -func (c *msgClient) QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, opts ...grpc.CallOption) (*MsgQueryOracleResponse, error) { - out := new(MsgQueryOracleResponse) - err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Msg/QueryOracle", in, out, opts...) +func (c *msgClient) SendQueryOracle(ctx context.Context, in *MsgSendQueryOracleRequest, opts ...grpc.CallOption) (*MsgSendQueryOracleResponse, error) { + out := new(MsgSendQueryOracleResponse) + err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Msg/SendQueryOracle", in, out, opts...) if err != nil { return nil, err } @@ -353,8 +353,8 @@ func (c *msgClient) QueryOracle(ctx context.Context, in *MsgQueryOracleRequest, type MsgServer interface { // UpdateOracle is the RPC endpoint for updating the oracle UpdateOracle(context.Context, *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) - // QueryOracle sends an icq to an oracle on another chain - QueryOracle(context.Context, *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) + // SendQueryOracle sends a query to an oracle on another chain + SendQueryOracle(context.Context, *MsgSendQueryOracleRequest) (*MsgSendQueryOracleResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -364,8 +364,8 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateOracle(ctx context.Context, req *MsgUpdateOracleRequest) (*MsgUpdateOracleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateOracle not implemented") } -func (*UnimplementedMsgServer) QueryOracle(ctx context.Context, req *MsgQueryOracleRequest) (*MsgQueryOracleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryOracle not implemented") +func (*UnimplementedMsgServer) SendQueryOracle(ctx context.Context, req *MsgSendQueryOracleRequest) (*MsgSendQueryOracleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendQueryOracle not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -390,20 +390,20 @@ func _Msg_UpdateOracle_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Msg_QueryOracle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgQueryOracleRequest) +func _Msg_SendQueryOracle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSendQueryOracleRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).QueryOracle(ctx, in) + return srv.(MsgServer).SendQueryOracle(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/provenance.oracle.v1.Msg/QueryOracle", + FullMethod: "/provenance.oracle.v1.Msg/SendQueryOracle", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).QueryOracle(ctx, req.(*MsgQueryOracleRequest)) + return srv.(MsgServer).SendQueryOracle(ctx, req.(*MsgSendQueryOracleRequest)) } return interceptor(ctx, in, info, handler) } @@ -417,15 +417,15 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_UpdateOracle_Handler, }, { - MethodName: "QueryOracle", - Handler: _Msg_QueryOracle_Handler, + MethodName: "SendQueryOracle", + Handler: _Msg_SendQueryOracle_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/oracle/v1/tx.proto", } -func (m *MsgQueryOracleRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgSendQueryOracleRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -435,12 +435,12 @@ func (m *MsgQueryOracleRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgQueryOracleRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSendQueryOracleRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgQueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSendQueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -469,7 +469,7 @@ func (m *MsgQueryOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgQueryOracleResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSendQueryOracleResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -479,12 +479,12 @@ func (m *MsgQueryOracleResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgQueryOracleResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSendQueryOracleResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgQueryOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSendQueryOracleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -568,7 +568,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgQueryOracleRequest) Size() (n int) { +func (m *MsgSendQueryOracleRequest) Size() (n int) { if m == nil { return 0 } @@ -589,7 +589,7 @@ func (m *MsgQueryOracleRequest) Size() (n int) { return n } -func (m *MsgQueryOracleResponse) Size() (n int) { +func (m *MsgSendQueryOracleResponse) Size() (n int) { if m == nil { return 0 } @@ -633,7 +633,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { +func (m *MsgSendQueryOracleRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -656,10 +656,10 @@ func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgQueryOracleRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSendQueryOracleRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgQueryOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSendQueryOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -781,7 +781,7 @@ func (m *MsgQueryOracleRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgQueryOracleResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSendQueryOracleResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -804,10 +804,10 @@ func (m *MsgQueryOracleResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgQueryOracleResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSendQueryOracleResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgQueryOracleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSendQueryOracleResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: From 2a20ade5d7ad1775c2f371918ddb2311b1c71d9f Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 14:07:41 -0400 Subject: [PATCH 14/96] Moved some functions around and renamed files. --- x/oracle/keeper/icq.go | 42 +++++++++ x/oracle/keeper/msg_server.go | 30 +----- x/oracle/keeper/oracle.go | 16 ++-- x/oracle/keeper/queries.go | 61 ------------ x/oracle/keeper/query.go | 159 +++++++++----------------------- x/oracle/keeper/query_server.go | 4 +- 6 files changed, 100 insertions(+), 212 deletions(-) create mode 100644 x/oracle/keeper/icq.go delete mode 100644 x/oracle/keeper/queries.go diff --git a/x/oracle/keeper/icq.go b/x/oracle/keeper/icq.go new file mode 100644 index 0000000000..bb17308101 --- /dev/null +++ b/x/oracle/keeper/icq.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "time" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" + "github.com/provenance-io/provenance/x/oracle/types" + abcitypes "github.com/tendermint/tendermint/abci/types" +) + +// QueryOracle sends an ICQ to the other chain's module +func (k Keeper) QueryOracle(ctx sdk.Context, query wasmtypes.RawContractMessage, channel string) (uint64, error) { + chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(k.GetPort(ctx), channel)) + if !found { + return 0, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + } + + q := types.QueryOracleRequest{ + Query: query, + } + + reqs := []abcitypes.RequestQuery{ + { + Path: "/provenance.oracle.v1.Query/Oracle", + Data: k.cdc.MustMarshal(&q), + }, + } + + timeoutTimestamp := ctx.BlockTime().Add(time.Minute).UnixNano() + seq, err := k.SendQuery(ctx, types.PortID, channel, chanCap, reqs, clienttypes.ZeroHeight(), uint64(timeoutTimestamp)) + if err != nil { + return 0, err + } + + k.SetQueryRequest(ctx, seq, q) + return seq, nil +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 080cc3f3da..b3df71a03d 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -2,15 +2,9 @@ package keeper import ( "context" - "time" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v6/modules/core/24-host" "github.com/provenance-io/provenance/x/oracle/types" - abcitypes "github.com/tendermint/tendermint/abci/types" ) type msgServer struct { @@ -28,37 +22,19 @@ var _ types.MsgServer = msgServer{} // UpdateOracle changes the oracle's address to the provided one func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracleRequest) (*types.MsgUpdateOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - s.Keeper.SetOracleContract(ctx, sdk.MustAccAddressFromBech32(msg.Address)) + s.Keeper.SetOracle(ctx, sdk.MustAccAddressFromBech32(msg.Address)) return &types.MsgUpdateOracleResponse{}, nil } +// SendQueryOracle sends an icq to another chain's oracle func (k msgServer) SendQueryOracle(goCtx context.Context, msg *types.MsgSendQueryOracleRequest) (*types.MsgSendQueryOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(k.GetPort(ctx), msg.Channel)) - if !found { - return nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") - } - - q := types.QueryOracleRequest{ - Query: msg.GetQuery(), - } - - reqs := []abcitypes.RequestQuery{ - { - Path: "/provenance.oracle.v1.Query/Oracle", - Data: k.cdc.MustMarshal(&q), - }, - } - - timeoutTimestamp := ctx.BlockTime().Add(time.Minute).UnixNano() - seq, err := k.SendQuery(ctx, types.PortID, msg.Channel, chanCap, reqs, clienttypes.ZeroHeight(), uint64(timeoutTimestamp)) + seq, err := k.QueryOracle(ctx, msg.Query, msg.Channel) if err != nil { return nil, err } - k.SetQueryRequest(ctx, seq, q) - return &types.MsgSendQueryOracleResponse{ Sequence: seq, }, nil diff --git a/x/oracle/keeper/oracle.go b/x/oracle/keeper/oracle.go index 99f38aa581..5598ec5b72 100644 --- a/x/oracle/keeper/oracle.go +++ b/x/oracle/keeper/oracle.go @@ -5,20 +5,20 @@ import ( "github.com/provenance-io/provenance/x/oracle/types" ) -// SetTrigger Sets the trigger in the store. -func (k Keeper) SetOracleContract(ctx sdk.Context, contract sdk.AccAddress) { +// SetOracle Sets the oracle used by the module. +func (k Keeper) SetOracle(ctx sdk.Context, oracle sdk.AccAddress) { store := ctx.KVStore(k.storeKey) - store.Set(types.GetContractStoreKey(), contract) + store.Set(types.GetContractStoreKey(), oracle) } -// GetTrigger Gets a trigger from the store by id. -func (k Keeper) GetOracleContract(ctx sdk.Context) (acc sdk.AccAddress, err error) { +// GetOracle Gets the oracle used by the module. +func (k Keeper) GetOracle(ctx sdk.Context) (oracle sdk.AccAddress, err error) { store := ctx.KVStore(k.storeKey) key := types.GetContractStoreKey() - acc = store.Get(key) - if len(acc) == 0 { + oracle = store.Get(key) + if len(oracle) == 0 { return sdk.AccAddress{}, types.ErrContractAddressDoesNotExist } - return acc, err + return oracle, err } diff --git a/x/oracle/keeper/queries.go b/x/oracle/keeper/queries.go deleted file mode 100644 index 823c3ef154..0000000000 --- a/x/oracle/keeper/queries.go +++ /dev/null @@ -1,61 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogotypes "github.com/gogo/protobuf/types" - "github.com/provenance-io/provenance/x/oracle/types" -) - -// SetQueryRequest saves the query request -func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req types.QueryOracleRequest) { - store := ctx.KVStore(k.storeKey) - store.Set(types.QueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) -} - -// GetQueryRequest returns the query request by packet sequence -func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.QueryOracleRequest, error) { - bz := ctx.KVStore(k.storeKey).Get(types.QueryRequestStoreKey(packetSequence)) - if bz == nil { - return types.QueryOracleRequest{}, sdkerrors.Wrapf(types.ErrSample, - "GetQueryRequest: Result for packet sequence %d is not available.", packetSequence, - ) - } - var req types.QueryOracleRequest - k.cdc.MustUnmarshal(bz, &req) - return req, nil -} - -// SetQueryResponse saves the query response -func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp types.QueryOracleResponse) { - store := ctx.KVStore(k.storeKey) - store.Set(types.QueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) -} - -// GetQueryResponse returns the query response by packet sequence -func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types.QueryOracleResponse, error) { - bz := ctx.KVStore(k.storeKey).Get(types.QueryResponseStoreKey(packetSequence)) - if bz == nil { - return types.QueryOracleResponse{}, sdkerrors.Wrapf(types.ErrSample, - "GetQueryResponse: Result for packet sequence %d is not available.", packetSequence, - ) - } - var resp types.QueryOracleResponse - k.cdc.MustUnmarshal(bz, &resp) - return resp, nil -} - -// GetLastQueryPacketSeq return the id from the last query request -func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { - bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.LastQueryPacketSeqKey)) - uintV := gogotypes.UInt64Value{} - k.cdc.MustUnmarshalLengthPrefixed(bz, &uintV) - return uintV.GetValue() -} - -// SetLastQueryPacketSeq saves the id from the last query request -func (k Keeper) SetLastQueryPacketSeq(ctx sdk.Context, packetSequence uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.KeyPrefix(types.LastQueryPacketSeqKey), - k.cdc.MustMarshalLengthPrefixed(&gogotypes.UInt64Value{Value: packetSequence})) -} diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go index 9808fbd47f..823c3ef154 100644 --- a/x/oracle/keeper/query.go +++ b/x/oracle/keeper/query.go @@ -1,130 +1,61 @@ package keeper -/*import ( +import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/quasar-finance/interchain-query-demo/x/interquery/types" - - icqtypes "github.com/cosmos/ibc-go/v6/modules/apps/icq/types" - clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" - abci "github.com/tendermint/tendermint/abci/types" + gogotypes "github.com/gogo/protobuf/types" + "github.com/provenance-io/provenance/x/oracle/types" ) -func (k Keeper) SendQuery( - ctx sdk.Context, - sourcePort, - sourceChannel string, - chanCap *capabilitytypes.Capability, - reqs []abci.RequestQuery, - timeoutHeight clienttypes.Height, - timeoutTimestamp uint64, -) (uint64, error) { - sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) - if !found { - return 0, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) - } - - destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() - destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() - - data, err := icqtypes.SerializeCosmosQuery(reqs) - if err != nil { - return 0, sdkerrors.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) +// SetQueryRequest saves the query request +func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req types.QueryOracleRequest) { + store := ctx.KVStore(k.storeKey) + store.Set(types.QueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) } -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, sdkerrors.Wrap(err, "invalid interchain query packet data") - } - - // get the next sequence - sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) - if !found { - return 0, sdkerrors.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); err != nil { - return 0, err +// GetQueryRequest returns the query request by packet sequence +func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.QueryOracleRequest, error) { + bz := ctx.KVStore(k.storeKey).Get(types.QueryRequestStoreKey(packetSequence)) + if bz == nil { + return types.QueryOracleRequest{}, sdkerrors.Wrapf(types.ErrSample, + "GetQueryRequest: Result for packet sequence %d is not available.", packetSequence, + ) } - - return packet.Sequence, nil + var req types.QueryOracleRequest + k.cdc.MustUnmarshal(bz, &req) + return req, nil } -func (k Keeper) OnAcknowledgementPacket( - ctx sdk.Context, - modulePacket channeltypes.Packet, - ack channeltypes.Acknowledgement, -) error { - switch resp := ack.Response.(type) { - case *channeltypes.Acknowledgement_Result: - var ackData icqtypes.InterchainQueryPacketAck - if err := icqtypes.ModuleCdc.UnmarshalJSON(resp.Result, &ackData); err != nil { - return sdkerrors.Wrap(err, "failed to unmarshal interchain query packet ack") - } - resps, err := icqtypes.DeserializeCosmosResponse(ackData.Data) - if err != nil { - return sdkerrors.Wrap(err, "could not deserialize data to cosmos response") - } - - if len(resps) < 1 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") - } - - var r banktypes.QueryAllBalancesResponse - if err := k.cdc.Unmarshal(resps[0].Value, &r); err != nil { - return sdkerrors.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) - } - - k.SetQueryResponse(ctx, modulePacket.Sequence, r) - k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) +// SetQueryResponse saves the query response +func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp types.QueryOracleResponse) { + store := ctx.KVStore(k.storeKey) + store.Set(types.QueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) +} - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeQueryResult, - sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), - ), +// GetQueryResponse returns the query response by packet sequence +func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types.QueryOracleResponse, error) { + bz := ctx.KVStore(k.storeKey).Get(types.QueryResponseStoreKey(packetSequence)) + if bz == nil { + return types.QueryOracleResponse{}, sdkerrors.Wrapf(types.ErrSample, + "GetQueryResponse: Result for packet sequence %d is not available.", packetSequence, ) + } + var resp types.QueryOracleResponse + k.cdc.MustUnmarshal(bz, &resp) + return resp, nil +} - k.Logger(ctx).Info("interchain query response", "sequence", modulePacket.Sequence, "response", r) - case *channeltypes.Acknowledgement_Error: - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeQueryResult, - sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), - ), - ) +// GetLastQueryPacketSeq return the id from the last query request +func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { + bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.LastQueryPacketSeqKey)) + uintV := gogotypes.UInt64Value{} + k.cdc.MustUnmarshalLengthPrefixed(bz, &uintV) + return uintV.GetValue() +} - k.Logger(ctx).Error("interchain query response", "sequence", modulePacket.Sequence, "error", resp.Error) - } - return nil +// SetLastQueryPacketSeq saves the id from the last query request +func (k Keeper) SetLastQueryPacketSeq(ctx sdk.Context, packetSequence uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyPrefix(types.LastQueryPacketSeqKey), + k.cdc.MustMarshalLengthPrefixed(&gogotypes.UInt64Value{Value: packetSequence})) } -*/ diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 6683f73164..64d82069fa 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -20,7 +20,7 @@ func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddre } ctx := sdk.UnwrapSDKContext(goCtx) - contract, err := k.GetOracleContract(ctx) + contract, err := k.GetOracle(ctx) if err != nil { return nil, err } @@ -30,7 +30,7 @@ func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddre func (k Keeper) Oracle(goCtx context.Context, req *types.QueryOracleRequest) (*types.QueryOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - addr, err := k.GetOracleContract(ctx) + addr, err := k.GetOracle(ctx) if err != nil { return nil, err } From 3ec7d93672617aed17d2df78d565936ab78a2903 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 15:08:11 -0400 Subject: [PATCH 15/96] Removed the ibc events and made them query typed events. --- docs/proto-docs.md | 42 +- proto/provenance/oracle/v1/event.proto | 20 +- x/oracle/keeper/genesis.go | 1 + x/oracle/keeper/msg_server.go | 16 + x/oracle/keeper/relay.go | 35 +- x/oracle/module/module_ibc.go | 15 +- x/oracle/types/event.pb.go | 524 +++++++++++++++++++++++-- x/oracle/types/events_ibc.go | 13 - 8 files changed, 586 insertions(+), 80 deletions(-) delete mode 100644 x/oracle/types/events_ibc.go diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 90b9bd2865..21663a48fb 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -431,7 +431,9 @@ - [Msg](#provenance.name.v1.Msg) - [provenance/oracle/v1/event.proto](#provenance/oracle/v1/event.proto) - - [EventOracleQueryResponse](#provenance.oracle.v1.EventOracleQueryResponse) + - [EventOracleQueryError](#provenance.oracle.v1.EventOracleQueryError) + - [EventOracleQuerySuccess](#provenance.oracle.v1.EventOracleQuerySuccess) + - [EventOracleQueryTimeout](#provenance.oracle.v1.EventOracleQueryTimeout) - [provenance/oracle/v1/params.proto](#provenance/oracle/v1/params.proto) - [Params](#provenance.oracle.v1.Params) @@ -6678,10 +6680,42 @@ Msg defines the bank Msg service. - + -### EventOracleQueryResponse -EventOracleQueryResponse is an event for when the chain receives a response from an oracle query +### EventOracleQueryError +EventOracleQueryError is an event for when the chain receives an error response from an oracle query + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sequence_id` | [string](#string) | | sequence_id is a unique identifier of the query | +| `error` | [string](#string) | | error is the error message received from the query | + + + + + + + + +### EventOracleQuerySuccess +EventOracleQuerySuccess is an event for when the chain receives a successful response from an oracle query + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sequence_id` | [string](#string) | | sequence_id is a unique identifier of the query | +| `result` | [string](#string) | | result is the data received from the query | + + + + + + + + +### EventOracleQueryTimeout +EventOracleQueryTimeout is an event for when the chain receives a timeout from an oracle query | Field | Type | Label | Description | diff --git a/proto/provenance/oracle/v1/event.proto b/proto/provenance/oracle/v1/event.proto index dd4216613e..bdce520a9d 100644 --- a/proto/provenance/oracle/v1/event.proto +++ b/proto/provenance/oracle/v1/event.proto @@ -6,8 +6,24 @@ option go_package = "github.com/provenance-io/provenance/x/oracle/types"; option java_package = "io.provenance.oracle.v1"; option java_multiple_files = true; -// EventOracleQueryResponse is an event for when the chain receives a response from an oracle query -message EventOracleQueryResponse { +// EventOracleQuerySuccess is an event for when the chain receives a successful response from an oracle query +message EventOracleQuerySuccess { + // sequence_id is a unique identifier of the query + string sequence_id = 1; + // result is the data received from the query + string result = 2; +} + +// EventOracleQueryError is an event for when the chain receives an error response from an oracle query +message EventOracleQueryError { + // sequence_id is a unique identifier of the query + string sequence_id = 1; + // error is the error message received from the query + string error = 2; +} + +// EventOracleQueryTimeout is an event for when the chain receives a timeout from an oracle query +message EventOracleQueryTimeout { // sequence_id is a unique identifier of the query string sequence_id = 1; } \ No newline at end of file diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index aa104e4c46..21281b5030 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -29,4 +29,5 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { } k.SetParams(ctx, genState.Params) + k.SetLastQueryPacketSeq(ctx, genState.Sequence) } diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index b3df71a03d..ea6d86835f 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -22,7 +22,16 @@ var _ types.MsgServer = msgServer{} // UpdateOracle changes the oracle's address to the provided one func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracleRequest) (*types.MsgUpdateOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + s.Keeper.SetOracle(ctx, sdk.MustAccAddressFromBech32(msg.Address)) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + ) + return &types.MsgUpdateOracleResponse{}, nil } @@ -35,6 +44,13 @@ func (k msgServer) SendQueryOracle(goCtx context.Context, msg *types.MsgSendQuer return nil, err } + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + ) + return &types.MsgSendQueryOracleResponse{ Sequence: seq, }, nil diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index 582b0d79e0..7e12c222e2 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -1,6 +1,8 @@ package keeper import ( + "strconv" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -106,23 +108,32 @@ func (k Keeper) OnAcknowledgementPacket( k.SetQueryResponse(ctx, modulePacket.Sequence, r) k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeQueryResult, - sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), - ), - ) + ctx.EventManager().EmitTypedEvent(&types.EventOracleQuerySuccess{ + SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), + Result: string(resp.Result), + }) k.Logger(ctx).Info("interchain query response", "sequence", modulePacket.Sequence, "response", r) case *channeltypes.Acknowledgement_Error: - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeQueryResult, - sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), - ), - ) + ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryError{ + SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), + Error: resp.Error, + }) k.Logger(ctx).Error("interchain query response", "sequence", modulePacket.Sequence, "error", resp.Error) } return nil } + +func (k Keeper) OnTimeoutPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, +) error { + ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryTimeout{ + SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), + }) + + k.Logger(ctx).Error("Packet timeout", "sequence", modulePacket.Sequence) + + return nil +} diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index e516724e9d..9a76604ad7 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -1,8 +1,6 @@ package oracle import ( - "strconv" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -128,7 +126,7 @@ func (am AppModule) OnRecvPacket( modulePacket channeltypes.Packet, relayer sdk.AccAddress, ) ibcexported.Acknowledgement { - return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrapf(icqtypes.ErrInvalidChannelFlow, "inter-query module can not receive packets")) + return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrapf(icqtypes.ErrInvalidChannelFlow, "oracle module can not receive packets")) } // OnAcknowledgementPacket implements the IBCModule interface @@ -152,16 +150,7 @@ func (am AppModule) OnTimeoutPacket( modulePacket channeltypes.Packet, relayer sdk.AccAddress, ) error { - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeTimeout, - sdk.NewAttribute(types.AttributeKeySequence, strconv.FormatUint(modulePacket.Sequence, 10)), - ), - ) - - am.keeper.Logger(ctx).Error("Packet timeout", "sequence", modulePacket.Sequence) - - return nil + return am.keeper.OnTimeoutPacket(ctx, modulePacket) } func (am AppModule) NegotiateAppVersion( diff --git a/x/oracle/types/event.pb.go b/x/oracle/types/event.pb.go index 2e8ba71f5a..6bdb745a81 100644 --- a/x/oracle/types/event.pb.go +++ b/x/oracle/types/event.pb.go @@ -22,24 +22,26 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// EventOracleQueryResponse is an event for when the chain receives a response from an oracle query -type EventOracleQueryResponse struct { +// EventOracleQuerySuccess is an event for when the chain receives a successful response from an oracle query +type EventOracleQuerySuccess struct { // sequence_id is a unique identifier of the query SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` + // result is the data received from the query + Result string `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"` } -func (m *EventOracleQueryResponse) Reset() { *m = EventOracleQueryResponse{} } -func (m *EventOracleQueryResponse) String() string { return proto.CompactTextString(m) } -func (*EventOracleQueryResponse) ProtoMessage() {} -func (*EventOracleQueryResponse) Descriptor() ([]byte, []int) { +func (m *EventOracleQuerySuccess) Reset() { *m = EventOracleQuerySuccess{} } +func (m *EventOracleQuerySuccess) String() string { return proto.CompactTextString(m) } +func (*EventOracleQuerySuccess) ProtoMessage() {} +func (*EventOracleQuerySuccess) Descriptor() ([]byte, []int) { return fileDescriptor_e98d10c8454ad24d, []int{0} } -func (m *EventOracleQueryResponse) XXX_Unmarshal(b []byte) error { +func (m *EventOracleQuerySuccess) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventOracleQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventOracleQuerySuccess) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventOracleQueryResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_EventOracleQuerySuccess.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -49,19 +51,127 @@ func (m *EventOracleQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *EventOracleQueryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventOracleQueryResponse.Merge(m, src) +func (m *EventOracleQuerySuccess) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventOracleQuerySuccess.Merge(m, src) } -func (m *EventOracleQueryResponse) XXX_Size() int { +func (m *EventOracleQuerySuccess) XXX_Size() int { return m.Size() } -func (m *EventOracleQueryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_EventOracleQueryResponse.DiscardUnknown(m) +func (m *EventOracleQuerySuccess) XXX_DiscardUnknown() { + xxx_messageInfo_EventOracleQuerySuccess.DiscardUnknown(m) } -var xxx_messageInfo_EventOracleQueryResponse proto.InternalMessageInfo +var xxx_messageInfo_EventOracleQuerySuccess proto.InternalMessageInfo -func (m *EventOracleQueryResponse) GetSequenceId() string { +func (m *EventOracleQuerySuccess) GetSequenceId() string { + if m != nil { + return m.SequenceId + } + return "" +} + +func (m *EventOracleQuerySuccess) GetResult() string { + if m != nil { + return m.Result + } + return "" +} + +// EventOracleQueryError is an event for when the chain receives an error response from an oracle query +type EventOracleQueryError struct { + // sequence_id is a unique identifier of the query + SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` + // error is the error message received from the query + Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` +} + +func (m *EventOracleQueryError) Reset() { *m = EventOracleQueryError{} } +func (m *EventOracleQueryError) String() string { return proto.CompactTextString(m) } +func (*EventOracleQueryError) ProtoMessage() {} +func (*EventOracleQueryError) Descriptor() ([]byte, []int) { + return fileDescriptor_e98d10c8454ad24d, []int{1} +} +func (m *EventOracleQueryError) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventOracleQueryError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventOracleQueryError.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventOracleQueryError) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventOracleQueryError.Merge(m, src) +} +func (m *EventOracleQueryError) XXX_Size() int { + return m.Size() +} +func (m *EventOracleQueryError) XXX_DiscardUnknown() { + xxx_messageInfo_EventOracleQueryError.DiscardUnknown(m) +} + +var xxx_messageInfo_EventOracleQueryError proto.InternalMessageInfo + +func (m *EventOracleQueryError) GetSequenceId() string { + if m != nil { + return m.SequenceId + } + return "" +} + +func (m *EventOracleQueryError) GetError() string { + if m != nil { + return m.Error + } + return "" +} + +// EventOracleQueryTimeout is an event for when the chain receives a timeout from an oracle query +type EventOracleQueryTimeout struct { + // sequence_id is a unique identifier of the query + SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` +} + +func (m *EventOracleQueryTimeout) Reset() { *m = EventOracleQueryTimeout{} } +func (m *EventOracleQueryTimeout) String() string { return proto.CompactTextString(m) } +func (*EventOracleQueryTimeout) ProtoMessage() {} +func (*EventOracleQueryTimeout) Descriptor() ([]byte, []int) { + return fileDescriptor_e98d10c8454ad24d, []int{2} +} +func (m *EventOracleQueryTimeout) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventOracleQueryTimeout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventOracleQueryTimeout.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventOracleQueryTimeout) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventOracleQueryTimeout.Merge(m, src) +} +func (m *EventOracleQueryTimeout) XXX_Size() int { + return m.Size() +} +func (m *EventOracleQueryTimeout) XXX_DiscardUnknown() { + xxx_messageInfo_EventOracleQueryTimeout.DiscardUnknown(m) +} + +var xxx_messageInfo_EventOracleQueryTimeout proto.InternalMessageInfo + +func (m *EventOracleQueryTimeout) GetSequenceId() string { if m != nil { return m.SequenceId } @@ -69,28 +179,71 @@ func (m *EventOracleQueryResponse) GetSequenceId() string { } func init() { - proto.RegisterType((*EventOracleQueryResponse)(nil), "provenance.oracle.v1.EventOracleQueryResponse") + proto.RegisterType((*EventOracleQuerySuccess)(nil), "provenance.oracle.v1.EventOracleQuerySuccess") + proto.RegisterType((*EventOracleQueryError)(nil), "provenance.oracle.v1.EventOracleQueryError") + proto.RegisterType((*EventOracleQueryTimeout)(nil), "provenance.oracle.v1.EventOracleQueryTimeout") } func init() { proto.RegisterFile("provenance/oracle/v1/event.proto", fileDescriptor_e98d10c8454ad24d) } var fileDescriptor_e98d10c8454ad24d = []byte{ - // 189 bytes of a gzipped FileDescriptorProto + // 241 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, - 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x54, 0xb2, 0xe6, 0x92, 0x70, 0x05, 0x29, 0xf2, 0x07, 0x8b, - 0x04, 0x96, 0xa6, 0x16, 0x55, 0x06, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0xc9, 0x73, - 0x71, 0x17, 0xa7, 0x16, 0x96, 0xa6, 0xe6, 0x25, 0xa7, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, - 0x6a, 0x70, 0x06, 0x71, 0xc1, 0x84, 0x3c, 0x53, 0x9c, 0xd2, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, - 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, - 0xf1, 0x58, 0x8e, 0x81, 0x4b, 0x3c, 0x33, 0x5f, 0x0f, 0x9b, 0x7d, 0x01, 0x8c, 0x51, 0x46, 0xe9, - 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x08, 0x25, 0xba, 0x99, 0xf9, 0x48, - 0x3c, 0xfd, 0x0a, 0x98, 0x27, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x5e, 0x30, 0x06, - 0x04, 0x00, 0x00, 0xff, 0xff, 0x53, 0x56, 0x12, 0x9d, 0xe6, 0x00, 0x00, 0x00, -} - -func (m *EventOracleQueryResponse) Marshal() (dAtA []byte, err error) { + 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x54, 0x0a, 0xe2, 0x12, 0x77, 0x05, 0x29, 0xf2, 0x07, 0x8b, + 0x04, 0x96, 0xa6, 0x16, 0x55, 0x06, 0x97, 0x26, 0x27, 0xa7, 0x16, 0x17, 0x0b, 0xc9, 0x73, 0x71, + 0x17, 0xa7, 0x16, 0x96, 0xa6, 0xe6, 0x25, 0xa7, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, + 0x70, 0x06, 0x71, 0xc1, 0x84, 0x3c, 0x53, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x52, 0x8b, 0x4b, 0x73, + 0x4a, 0x24, 0x98, 0xc0, 0x72, 0x50, 0x9e, 0x92, 0x1f, 0x97, 0x28, 0xba, 0x99, 0xae, 0x45, 0x45, + 0xf9, 0x45, 0x84, 0x4d, 0x14, 0xe1, 0x62, 0x4d, 0x05, 0xa9, 0x84, 0x1a, 0x08, 0xe1, 0x28, 0x59, + 0x61, 0xba, 0x31, 0x24, 0x33, 0x37, 0x35, 0xbf, 0xb4, 0x84, 0xa0, 0x89, 0x4e, 0xe9, 0x27, 0x1e, + 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, + 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0xc0, 0x25, 0x9e, 0x99, 0xaf, 0x87, 0x2d, 0x48, 0x02, + 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, 0x4a, + 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0xb0, 0x70, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, + 0x03, 0x87, 0xb2, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, 0xe8, 0xf6, 0x89, 0x01, 0x00, + 0x00, +} + +func (m *EventOracleQuerySuccess) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventOracleQuerySuccess) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventOracleQuerySuccess) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Result) > 0 { + i -= len(m.Result) + copy(dAtA[i:], m.Result) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x12 + } + if len(m.SequenceId) > 0 { + i -= len(m.SequenceId) + copy(dAtA[i:], m.SequenceId) + i = encodeVarintEvent(dAtA, i, uint64(len(m.SequenceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventOracleQueryError) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -100,12 +253,49 @@ func (m *EventOracleQueryResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventOracleQueryResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *EventOracleQueryError) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventOracleQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventOracleQueryError) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x12 + } + if len(m.SequenceId) > 0 { + i -= len(m.SequenceId) + copy(dAtA[i:], m.SequenceId) + i = encodeVarintEvent(dAtA, i, uint64(len(m.SequenceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventOracleQueryTimeout) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventOracleQueryTimeout) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventOracleQueryTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -131,7 +321,41 @@ func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *EventOracleQueryResponse) Size() (n int) { +func (m *EventOracleQuerySuccess) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SequenceId) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Result) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func (m *EventOracleQueryError) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SequenceId) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Error) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func (m *EventOracleQueryTimeout) Size() (n int) { if m == nil { return 0 } @@ -150,7 +374,235 @@ func sovEvent(x uint64) (n int) { func sozEvent(x uint64) (n int) { return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *EventOracleQueryResponse) Unmarshal(dAtA []byte) error { +func (m *EventOracleQuerySuccess) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventOracleQuerySuccess: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventOracleQuerySuccess: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SequenceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SequenceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventOracleQueryError) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventOracleQueryError: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventOracleQueryError: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SequenceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SequenceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventOracleQueryTimeout) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -173,10 +625,10 @@ func (m *EventOracleQueryResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventOracleQueryResponse: wiretype end group for non-group") + return fmt.Errorf("proto: EventOracleQueryTimeout: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventOracleQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventOracleQueryTimeout: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/oracle/types/events_ibc.go b/x/oracle/types/events_ibc.go deleted file mode 100644 index d3c7fc73f6..0000000000 --- a/x/oracle/types/events_ibc.go +++ /dev/null @@ -1,13 +0,0 @@ -package types - -// IBC events -const ( - EventTypeQueryResult = "query_result" - EventTypeTimeout = "timeout" - // this line is used by starport scaffolding # ibc/packet/event - - AttributeKeyAckSuccess = "success" - AttributeKeyAck = "acknowledgement" - AttributeKeyAckError = "error" - AttributeKeySequence = "sequence" -) From 0c59b77140ec6cdb355b29fbd6e92d0d2a8af7f0 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 15:14:40 -0400 Subject: [PATCH 16/96] Updated CHANGELOG. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d26047ed..f11c10b2ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features * Allow marker's transfer authority to prevent transfer of restricted coin with deny list on send [#1518](https://github.com/provenance-io/provenance/issues/1518). +* Add ICQHost and Oracle module to allow cross chain oracle queries [#1497](https://github.com/provenance-io/provenance/issues/1497). ### Improvements From 1b678d165d672975aa7c354c1d587ef4a7188473 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 15:38:11 -0400 Subject: [PATCH 17/96] Updated documentation for CLI and fixed command names. --- x/oracle/client/cli/query.go | 29 +++++++++++++++++++---------- x/oracle/client/cli/tx.go | 33 +++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index 83798194de..158fd6060f 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -7,10 +7,12 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" "github.com/provenance-io/provenance/x/oracle/types" "github.com/spf13/cobra" ) +// GetQueryCmd is the top-level command for trigger CLI queries. func GetQueryCmd() *cobra.Command { queryCmd := &cobra.Command{ Use: types.ModuleName, @@ -20,19 +22,23 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } queryCmd.AddCommand( - CmdQueryState(), - CmdQueryContractAddress(), + GetQueryStateCmd(), + GetQueryOracleAddressCmd(), ) return queryCmd } var _ = strconv.Itoa(0) +var cmdStart = fmt.Sprintf("%s query oracle", version.AppName) -func CmdQueryState() *cobra.Command { +// GetQueryStateCmd queries for the state of an existing oracle query +func GetQueryStateCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "query-state [sequence]", - Short: "Returns the request and response of an ICQ query given the packet sequence", - Args: cobra.ExactArgs(1), + Use: "query-state [sequence]", + Short: "Returns the request and response of an ICQ query given the packet sequence", + Args: cobra.ExactArgs(1), + Aliases: []string{"qs", "state"}, + Example: fmt.Sprintf(`%[1]s q oracle query-state 1`, version.AppName), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientQueryContext(cmd) @@ -64,11 +70,14 @@ func CmdQueryState() *cobra.Command { return cmd } -func CmdQueryContractAddress() *cobra.Command { +// GetQueryOracleAddressCmd queries for the module's oracle address +func GetQueryOracleAddressCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "contract-address", - Short: "Returns the address of the contract that the oracle is using", - Args: cobra.ExactArgs(0), + Use: "address", + Short: "Returns the address of the module's oracle", + Args: cobra.ExactArgs(0), + Aliases: []string{"a"}, + Example: fmt.Sprintf(`%[1]s q oracle address`, version.AppName), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientQueryContext(cmd) diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 4fd9f3ae9f..f906c19bc9 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" "github.com/provenance-io/provenance/x/oracle/types" "github.com/spf13/cobra" ) @@ -28,8 +29,8 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - CmdOracleQuery(), - CmdOracleUpdate(), + GetCmdSendQuery(), + GetCmdOracleUpdate(), ) return txCmd @@ -37,11 +38,14 @@ func NewTxCmd() *cobra.Command { var _ = strconv.Itoa(0) -func CmdOracleUpdate() *cobra.Command { +// GetCmdOracleUpdate is a command to update the address of the module's oracle +func GetCmdOracleUpdate() *cobra.Command { cmd := &cobra.Command{ - Use: "oracle-update [address]", - Short: "Update the local oracle's contract address", - Args: cobra.ExactArgs(1), + Use: "update
", + Short: "Update the module's oracle address", + Args: cobra.ExactArgs(1), + Aliases: []string{"u"}, + Example: fmt.Sprintf(`%[1]s tx oracle update pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk`, version.AppName), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -64,18 +68,23 @@ func CmdOracleUpdate() *cobra.Command { return cmd } -func CmdOracleQuery() *cobra.Command { +// GetCmdSendQuery is a command to send a query to another chain's oracle +func GetCmdSendQuery() *cobra.Command { decoder := newArgDecoder(asciiDecodeString) cmd := &cobra.Command{ - Use: "oracle-query [channel-id] [json]", - Short: "Query the oracle on the remote chain via ICQ", - Args: cobra.ExactArgs(2), + Use: "send-query ", + Short: "Send a query to an oracle on a remote chain via IBC", + Args: cobra.ExactArgs(2), + Aliases: []string{"sq"}, + Example: fmt.Sprintf(`%[1]s tx oracle send-query channel-1 '{"query_version":{}}'`, version.AppName), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } + channelID := args[0] + queryData, err := decoder.DecodeString(args[1]) if err != nil { return fmt.Errorf("decode query: %s", err) @@ -86,8 +95,8 @@ func CmdOracleQuery() *cobra.Command { msg := types.NewMsgQueryOracle( clientCtx.GetFromAddress().String(), - args[0], // channel id - queryData, // address + channelID, + queryData, ) if err := msg.ValidateBasic(); err != nil { return err From ea5dcfe657da6aad68cb21ed1caf13cc053fb208 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 15:47:01 -0400 Subject: [PATCH 18/96] More cleanup and removal of unused method. --- x/oracle/client/cli/query.go | 1 - x/oracle/client/cli/tx.go | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index 158fd6060f..6e46601c4b 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -29,7 +29,6 @@ func GetQueryCmd() *cobra.Command { } var _ = strconv.Itoa(0) -var cmdStart = fmt.Sprintf("%s query oracle", version.AppName) // GetQueryStateCmd queries for the state of an existing oracle query func GetQueryStateCmd() *cobra.Command { diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index f906c19bc9..5cadde7fc0 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -5,9 +5,7 @@ import ( "encoding/hex" "encoding/json" "errors" - "flag" "fmt" - "strconv" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -36,8 +34,6 @@ func NewTxCmd() *cobra.Command { return txCmd } -var _ = strconv.Itoa(0) - // GetCmdOracleUpdate is a command to update the address of the module's oracle func GetCmdOracleUpdate() *cobra.Command { cmd := &cobra.Command{ @@ -120,12 +116,7 @@ func newArgDecoder(def func(string) ([]byte, error)) *argumentDecoder { return &argumentDecoder{dec: def} } -func (a *argumentDecoder) RegisterFlags(f *flag.FlagSet, argName string) { - f.BoolVar(&a.asciiF, "ascii", false, "ascii encoded "+argName) - f.BoolVar(&a.hexF, "hex", false, "hex encoded "+argName) - f.BoolVar(&a.b64F, "b64", false, "base64 encoded "+argName) -} - +// DecodeString decodes the supplied json string func (a *argumentDecoder) DecodeString(s string) ([]byte, error) { found := -1 for i, v := range []*bool{&a.asciiF, &a.hexF, &a.b64F} { From f55f793c6c1e1990f88e4df0a646697bd60f1501 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 3 Aug 2023 16:12:04 -0400 Subject: [PATCH 19/96] Added ValidateBasic logic and some error checks on the query server. --- x/oracle/keeper/query_server.go | 7 +++++++ x/oracle/types/msgs.go | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 64d82069fa..97320600bd 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -29,6 +29,13 @@ func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddre } func (k Keeper) Oracle(goCtx context.Context, req *types.QueryOracleRequest) (*types.QueryOracleResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + if err := req.Query.ValidateBasic(); err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid query data") + } + ctx := sdk.UnwrapSDKContext(goCtx) addr, err := k.GetOracle(ctx) if err != nil { diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 19ebfaa7cb..67dc826700 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -1,7 +1,10 @@ package types import ( + fmt "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgSendQueryOracleRequest{} @@ -28,6 +31,12 @@ func (msg MsgUpdateOracleRequest) GetSigners() []sdk.AccAddress { // ValidateBasic runs stateless validation checks on the message. func (msg MsgUpdateOracleRequest) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { + return fmt.Errorf("invalid address for oracle: %w", err) + } + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return fmt.Errorf("invalid authority address: %w", err) + } return nil } @@ -38,5 +47,14 @@ func (msg MsgSendQueryOracleRequest) GetSigners() []sdk.AccAddress { // ValidateBasic runs stateless validation checks on the message. func (msg MsgSendQueryOracleRequest) ValidateBasic() error { + if err := host.ChannelIdentifierValidator(msg.Channel); err != nil { + return fmt.Errorf("invalid channel id: %w", err) + } + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return fmt.Errorf("invalid authority address: %w", err) + } + if err := msg.Query.ValidateBasic(); err != nil { + return fmt.Errorf("invalid query data: %w", err) + } return nil } From d562b073dbce0cf0bb1f4da82a34e1fd73d175b9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 4 Aug 2023 10:02:26 -0400 Subject: [PATCH 20/96] Added more documentation and moved keys to single file. --- x/oracle/keeper/keeper.go | 4 ++-- x/oracle/keeper/oracle.go | 2 +- x/oracle/keeper/query.go | 4 ++-- x/oracle/keeper/query_server.go | 4 +++- x/oracle/keeper/relay.go | 3 +++ x/oracle/types/errors.go | 10 ++++---- x/oracle/types/expected_keepers.go | 1 + x/oracle/types/keys.go | 35 +++++++++++++++++++++++---- x/oracle/types/msgs.go | 2 ++ x/oracle/types/queries.go | 38 ------------------------------ 10 files changed, 50 insertions(+), 53 deletions(-) delete mode 100644 x/oracle/types/queries.go diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 39af64fdeb..f8514999ae 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -79,13 +79,13 @@ func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { // GetPort returns the portID for the transfer module. Used in ExportGenesis func (k Keeper) GetPort(ctx sdk.Context) string { store := ctx.KVStore(k.storeKey) - return string(store.Get(types.PortKey)) + return string(store.Get(types.PortStoreKey)) } // SetPort sets the portID for the transfer module. Used in InitGenesis func (k Keeper) SetPort(ctx sdk.Context, portID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.PortKey, []byte(portID)) + store.Set(types.PortStoreKey, []byte(portID)) } // AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function diff --git a/x/oracle/keeper/oracle.go b/x/oracle/keeper/oracle.go index 5598ec5b72..82902daf59 100644 --- a/x/oracle/keeper/oracle.go +++ b/x/oracle/keeper/oracle.go @@ -17,7 +17,7 @@ func (k Keeper) GetOracle(ctx sdk.Context) (oracle sdk.AccAddress, err error) { key := types.GetContractStoreKey() oracle = store.Get(key) if len(oracle) == 0 { - return sdk.AccAddress{}, types.ErrContractAddressDoesNotExist + return sdk.AccAddress{}, types.ErrMissingOracleAddress } return oracle, err diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go index 823c3ef154..e223ee54d1 100644 --- a/x/oracle/keeper/query.go +++ b/x/oracle/keeper/query.go @@ -47,7 +47,7 @@ func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types. // GetLastQueryPacketSeq return the id from the last query request func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { - bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.LastQueryPacketSeqKey)) + bz := ctx.KVStore(k.storeKey).Get(types.LastQueryPacketSeqKey) uintV := gogotypes.UInt64Value{} k.cdc.MustUnmarshalLengthPrefixed(bz, &uintV) return uintV.GetValue() @@ -56,6 +56,6 @@ func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { // SetLastQueryPacketSeq saves the id from the last query request func (k Keeper) SetLastQueryPacketSeq(ctx sdk.Context, packetSequence uint64) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyPrefix(types.LastQueryPacketSeqKey), + store.Set(types.LastQueryPacketSeqKey, k.cdc.MustMarshalLengthPrefixed(&gogotypes.UInt64Value{Value: packetSequence})) } diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 97320600bd..63b6be7de0 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -13,7 +13,7 @@ import ( var _ types.QueryServer = Keeper{} -// QueryAddress returns the address of the oracle's contract +// QueryAddress returns the address of the module's oracle func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddressRequest) (*types.QueryOracleAddressResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") @@ -28,6 +28,7 @@ func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddre return &types.QueryOracleAddressResponse{Address: contract.String()}, nil } +// Oracle queries module's oracle func (k Keeper) Oracle(goCtx context.Context, req *types.QueryOracleRequest) (*types.QueryOracleResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") @@ -52,6 +53,7 @@ func (k Keeper) Oracle(goCtx context.Context, req *types.QueryOracleRequest) (*t return &types.QueryOracleResponse{Data: resp.Data}, nil } +// QueryState gets the state of an icq func (k Keeper) QueryState(goCtx context.Context, req *types.QueryQueryStateRequest) (*types.QueryQueryStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index 7e12c222e2..0e6d2f30d6 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -14,6 +14,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) +// SendQuery sends and records an icq func (k Keeper) SendQuery( ctx sdk.Context, sourcePort, @@ -80,6 +81,7 @@ func (k Keeper) createOutgoingPacket( return packet.Sequence, nil } +// OnAcknowledgementPacket reacts to an Acknowledgement packet. func (k Keeper) OnAcknowledgementPacket( ctx sdk.Context, modulePacket channeltypes.Packet, @@ -125,6 +127,7 @@ func (k Keeper) OnAcknowledgementPacket( return nil } +// OnTimeoutPacket reacts to a timed out packet. func (k Keeper) OnTimeoutPacket( ctx sdk.Context, modulePacket channeltypes.Packet, diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index e181e7e753..f6e1d27111 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -1,12 +1,12 @@ package types import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + cerrs "cosmossdk.io/errors" ) var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") - ErrInvalidPacketTimeout = sdkerrors.Register(ModuleName, 1500, "invalid packet timeout") - ErrInvalidVersion = sdkerrors.Register(ModuleName, 1501, "invalid version") - ErrContractAddressDoesNotExist = sdkerrors.Register(ModuleName, 1502, "missing contract address") + ErrSample = cerrs.Register(ModuleName, 2, "sample error") + ErrInvalidPacketTimeout = cerrs.Register(ModuleName, 3, "invalid packet timeout") + ErrInvalidVersion = cerrs.Register(ModuleName, 4, "invalid version") + ErrMissingOracleAddress = cerrs.Register(ModuleName, 5, "missing oracle address") ) diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go index 66b6fc73da..f620058838 100644 --- a/x/oracle/types/expected_keepers.go +++ b/x/oracle/types/expected_keepers.go @@ -20,6 +20,7 @@ type ICS4Wrapper interface { ) (sequence uint64, err error) } +// PortKeeper defines the expected IBC channel keeper type ChannelKeeper interface { GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 22873d0f14..d5790784ca 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -1,6 +1,8 @@ package types import ( + "encoding/binary" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" ) @@ -22,10 +24,35 @@ const ( ) var ( - // PortKey defines the key to store the port ID in store - PortKey = KeyPrefix("oracle-port-") + // ContractStoreKey is the key for the oracle's contract address + ContractStoreKey = []byte{0x01} + // LastQueryPacketSeqKey is the key for the last packet sequence + LastQueryPacketSeqKey = []byte{0x02} + // PortStoreKey defines the key to store the port ID in store + PortStoreKey = []byte{0x03} + // QueryResponseStoreKeyPrefix is a prefix for storing request + QueryRequestStoreKeyPrefix = []byte{0x04} + // QueryResponseStoreKeyPrefix is a prefix for storing result + QueryResponseStoreKeyPrefix = []byte{0x05} ) -func KeyPrefix(p string) []byte { - return []byte(p) +// ContractStoreKey is a function to get the key for the oracle's contract in store +func GetContractStoreKey() []byte { + return ContractStoreKey +} + +// QueryRequestStoreKey is a function to generate key for each result in store +func QueryRequestStoreKey(packetSequence uint64) []byte { + return append(QueryRequestStoreKeyPrefix, uint64ToBytes(packetSequence)...) +} + +// QueryResponseStoreKey is a function to generate key for each result in store +func QueryResponseStoreKey(packetSequence uint64) []byte { + return append(QueryResponseStoreKeyPrefix, uint64ToBytes(packetSequence)...) +} + +func uint64ToBytes(num uint64) []byte { + result := make([]byte, 8) + binary.BigEndian.PutUint64(result, uint64(num)) + return result } diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 67dc826700..d7f6657e9a 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -9,6 +9,7 @@ import ( var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgSendQueryOracleRequest{} +// NewMsgQueryOracle creates a new MsgSendQueryOracleRequest func NewMsgQueryOracle(creator, channelId string, query []byte) *MsgSendQueryOracleRequest { return &MsgSendQueryOracleRequest{ Authority: creator, @@ -17,6 +18,7 @@ func NewMsgQueryOracle(creator, channelId string, query []byte) *MsgSendQueryOra } } +// NewMsgUpdateOracle creates a new MsgUpdateOracleRequest func NewMsgUpdateOracle(creator, addr string) *MsgUpdateOracleRequest { return &MsgUpdateOracleRequest{ Authority: creator, diff --git a/x/oracle/types/queries.go b/x/oracle/types/queries.go deleted file mode 100644 index a206fe089f..0000000000 --- a/x/oracle/types/queries.go +++ /dev/null @@ -1,38 +0,0 @@ -package types - -import "encoding/binary" - -var ( - // QueryResponseStoreKeyPrefix is a prefix for storing request - QueryRequestStoreKeyPrefix = "coin_rates_request" - - // QueryResponseStoreKeyPrefix is a prefix for storing result - QueryResponseStoreKeyPrefix = "coin_rates_response" - - // LastQueryPacketSeqKey is the key for the last packet sequence - LastQueryPacketSeqKey = "coin_rates_last_id" - - // ContractStoreKey is the key for the oracle's contract address - ContractStoreKey = []byte{0x01} -) - -// ContractStoreKey is a function to get the key for the oracle's contract in store -func GetContractStoreKey() []byte { - return []byte(ContractStoreKey) -} - -// QueryRequestStoreKey is a function to generate key for each result in store -func QueryRequestStoreKey(packetSequence uint64) []byte { - return append(KeyPrefix(QueryRequestStoreKeyPrefix), uint64ToBytes(packetSequence)...) -} - -// QueryResponseStoreKey is a function to generate key for each result in store -func QueryResponseStoreKey(packetSequence uint64) []byte { - return append(KeyPrefix(QueryResponseStoreKeyPrefix), uint64ToBytes(packetSequence)...) -} - -func uint64ToBytes(num uint64) []byte { - result := make([]byte, 8) - binary.BigEndian.PutUint64(result, uint64(num)) - return result -} From 1eaf2b8ad0051c42bbe64a9ee49516e46cabf1dc Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 4 Aug 2023 10:06:16 -0400 Subject: [PATCH 21/96] Fixed module naming in comments. --- x/oracle/client/cli/query.go | 4 ++-- x/oracle/client/cli/tx.go | 4 ++-- x/oracle/keeper/genesis.go | 2 +- x/oracle/module/module.go | 34 +++++++++++++++++----------------- x/oracle/types/genesis.go | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index 6e46601c4b..8280675c9a 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -12,11 +12,11 @@ import ( "github.com/spf13/cobra" ) -// GetQueryCmd is the top-level command for trigger CLI queries. +// GetQueryCmd is the top-level command for oracle CLI queries. func GetQueryCmd() *cobra.Command { queryCmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the triggers module", + Short: "Querying commands for the oracle module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 5cadde7fc0..06f52f1810 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -15,12 +15,12 @@ import ( "github.com/spf13/cobra" ) -// NewTxCmd is the top-level command for trigger CLI transactions. +// NewTxCmd is the top-level command for oracle CLI transactions. func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ Use: types.ModuleName, Aliases: []string{"t"}, - Short: "Transaction commands for the trigger module", + Short: "Transaction commands for the oracle module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 21281b5030..bf6b2a18aa 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -14,7 +14,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { } } -// InitGenesis new trigger genesis +// InitGenesis new oracle genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { if err := genState.Validate(); err != nil { panic(err) diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index 79c53f1607..e15d3a928e 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -30,32 +30,32 @@ var ( _ module.AppModuleSimulation = AppModule{} ) -// AppModuleBasic defines the basic application module used by the trigger module. +// AppModuleBasic defines the basic application module used by the oracle module. type AppModuleBasic struct { cdc codec.Codec } -// Name returns the trigger module's name. +// Name returns the oracle module's name. func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterLegacyAminoCodec registers the trigger module's types for the given codec. +// RegisterLegacyAminoCodec registers the oracle module's types for the given codec. func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { } -// RegisterInterfaces registers the trigger module's interface types +// RegisterInterfaces registers the oracle module's interface types func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } -// DefaultGenesis returns default genesis state as raw bytes for the trigger +// DefaultGenesis returns default genesis state as raw bytes for the oracle // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesis()) } -// ValidateGenesis performs genesis state validation for the trigger module. +// ValidateGenesis performs genesis state validation for the oracle module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ sdkclient.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { @@ -65,23 +65,23 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ sdkclient.TxEncodin return data.Validate() } -// RegisterRESTRoutes registers the REST routes for the trigger module. +// RegisterRESTRoutes registers the REST routes for the oracle module. // Deprecated: RegisterRESTRoutes is deprecated. func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the trigger module. +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the oracle module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { panic(err) } } -// GetQueryCmd returns the cli query commands for the trigger module +// GetQueryCmd returns the cli query commands for the oracle module func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// GetTxCmd returns the transaction commands for the trigger module +// GetTxCmd returns the transaction commands for the oracle module func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } @@ -100,7 +100,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { } } -// GenerateGenesisState creates a randomized GenState of the trigger module. +// GenerateGenesisState creates a randomized GenState of the oracle module. func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { // simulation.RandomizedGenState(simState) } @@ -130,7 +130,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp )*/ } -// Name returns the trigger module's name. +// Name returns the oracle module's name. func (AppModule) Name() string { return types.ModuleName } @@ -138,7 +138,7 @@ func (AppModule) Name() string { // RegisterInvariants does nothing, there are no invariants to enforce func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the trigger module. +// Deprecated: Route returns the message routing key for the oracle module. func (am AppModule) Route() sdk.Route { return sdk.Route{} } @@ -146,12 +146,12 @@ func (am AppModule) Route() sdk.Route { // QuerierRoute returns the route we respond to for abci queries func (AppModule) QuerierRoute() string { return "" } -// LegacyQuerierHandler returns the trigger module sdk.Querier. +// LegacyQuerierHandler returns the oracle module sdk.Querier. func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil } -// InitGenesis performs genesis initialization for the trigger module. It returns +// InitGenesis performs genesis initialization for the oracle module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState @@ -160,7 +160,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. return []abci.ValidatorUpdate{} } -// ExportGenesis returns the exported genesis state as raw bytes for the trigger +// ExportGenesis returns the exported genesis state as raw bytes for the oracle // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs := am.keeper.ExportGenesis(ctx) @@ -171,7 +171,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock is the `BeginBlocker` function run at the beginning of each block to -// process trigger module updates. +// process oracle module updates. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { } diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index f9f152543a..eaabdabdfc 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -14,7 +14,7 @@ func NewGenesisState(port string, params Params, sequence uint64) *GenesisState } } -// DefaultGenesis returns the default trigger genesis state +// DefaultGenesis returns the default oracle genesis state func DefaultGenesis() *GenesisState { return NewGenesisState(PortID, DefaultParams(), 1) } From 20a124d466d9fc392c9af8db776a993a6d773569 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 4 Aug 2023 11:54:37 -0400 Subject: [PATCH 22/96] Updated genesis.go errors and added tests. --- x/oracle/types/genesis.go | 2 +- x/oracle/types/genesis_test.go | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 x/oracle/types/genesis_test.go diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index eaabdabdfc..dd7636bad2 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -23,7 +23,7 @@ func DefaultGenesis() *GenesisState { // failure. func (gs GenesisState) Validate() error { if gs.Sequence == 0 { - return fmt.Errorf("invalid query id") + return fmt.Errorf("sequence %d is invalid, must be greater than 0", int(gs.Sequence)) } if err := host.PortIdentifierValidator(gs.PortId); err != nil { diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go new file mode 100644 index 0000000000..a38557bae8 --- /dev/null +++ b/x/oracle/types/genesis_test.go @@ -0,0 +1,61 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNewGenesisState(t *testing.T) { + port := "random" + params := DefaultParams() + sequence := uint64(10) + + genesis := NewGenesisState(port, params, sequence) + assert.Equal(t, port, genesis.PortId, "port id must match") + assert.Equal(t, params, genesis.Params, "params must match") + assert.Equal(t, int(sequence), int(genesis.Sequence), "sequence must match") +} + +func TestDefaultGenesis(t *testing.T) { + genesis := DefaultGenesis() + params := DefaultParams() + + assert.Equal(t, PortID, genesis.PortId, "port id must match") + assert.Equal(t, params, genesis.Params, "params must match") + assert.Equal(t, int(1), int(genesis.Sequence), "sequence must be 1") +} + +func TestGenesisValidate(t *testing.T) { + tests := []struct { + name string + state *GenesisState + err string + }{ + { + name: "success - all fields are valid", + state: NewGenesisState(PortID, DefaultParams(), 1), + }, + { + name: "failure - port id is invalid", + state: NewGenesisState("x", DefaultParams(), 1), + err: "identifier x has invalid length: 1, must be between 2-128 characters: invalid identifier", + }, + { + name: "failure - sequence id is invalid", + state: NewGenesisState(PortID, DefaultParams(), 0), + err: "sequence 0 is invalid, must be greater than 0", + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + res := tc.state.Validate() + if len(tc.err) > 0 { + assert.EqualError(t, res, tc.err, "Genesis.Validate") + } else { + assert.NoError(t, res, "Genesis.Validate") + } + }) + } +} From cbde82dbb9acf755905b1148dfd9c4d5d6ed2c1c Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 4 Aug 2023 13:19:27 -0400 Subject: [PATCH 23/96] Added tests for keys and ensured all keys have getters. --- x/oracle/keeper/keeper.go | 4 ++-- x/oracle/keeper/query.go | 12 ++++++------ x/oracle/types/keys.go | 20 +++++++++++++++----- x/oracle/types/keys_test.go | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 x/oracle/types/keys_test.go diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index f8514999ae..d275eea0aa 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -79,13 +79,13 @@ func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { // GetPort returns the portID for the transfer module. Used in ExportGenesis func (k Keeper) GetPort(ctx sdk.Context) string { store := ctx.KVStore(k.storeKey) - return string(store.Get(types.PortStoreKey)) + return string(store.Get(types.GetPortStoreKey())) } // SetPort sets the portID for the transfer module. Used in InitGenesis func (k Keeper) SetPort(ctx sdk.Context, portID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.PortStoreKey, []byte(portID)) + store.Set(types.GetPortStoreKey(), []byte(portID)) } // AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go index e223ee54d1..0d5cd5f942 100644 --- a/x/oracle/keeper/query.go +++ b/x/oracle/keeper/query.go @@ -10,12 +10,12 @@ import ( // SetQueryRequest saves the query request func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req types.QueryOracleRequest) { store := ctx.KVStore(k.storeKey) - store.Set(types.QueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) + store.Set(types.GetQueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) } // GetQueryRequest returns the query request by packet sequence func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.QueryOracleRequest, error) { - bz := ctx.KVStore(k.storeKey).Get(types.QueryRequestStoreKey(packetSequence)) + bz := ctx.KVStore(k.storeKey).Get(types.GetQueryRequestStoreKey(packetSequence)) if bz == nil { return types.QueryOracleRequest{}, sdkerrors.Wrapf(types.ErrSample, "GetQueryRequest: Result for packet sequence %d is not available.", packetSequence, @@ -29,12 +29,12 @@ func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.Q // SetQueryResponse saves the query response func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp types.QueryOracleResponse) { store := ctx.KVStore(k.storeKey) - store.Set(types.QueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) + store.Set(types.GetQueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) } // GetQueryResponse returns the query response by packet sequence func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types.QueryOracleResponse, error) { - bz := ctx.KVStore(k.storeKey).Get(types.QueryResponseStoreKey(packetSequence)) + bz := ctx.KVStore(k.storeKey).Get(types.GetQueryResponseStoreKey(packetSequence)) if bz == nil { return types.QueryOracleResponse{}, sdkerrors.Wrapf(types.ErrSample, "GetQueryResponse: Result for packet sequence %d is not available.", packetSequence, @@ -47,7 +47,7 @@ func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types. // GetLastQueryPacketSeq return the id from the last query request func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { - bz := ctx.KVStore(k.storeKey).Get(types.LastQueryPacketSeqKey) + bz := ctx.KVStore(k.storeKey).Get(types.GetLastQueryPacketSeqKey()) uintV := gogotypes.UInt64Value{} k.cdc.MustUnmarshalLengthPrefixed(bz, &uintV) return uintV.GetValue() @@ -56,6 +56,6 @@ func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { // SetLastQueryPacketSeq saves the id from the last query request func (k Keeper) SetLastQueryPacketSeq(ctx sdk.Context, packetSequence uint64) { store := ctx.KVStore(k.storeKey) - store.Set(types.LastQueryPacketSeqKey, + store.Set(types.GetLastQueryPacketSeqKey(), k.cdc.MustMarshalLengthPrefixed(&gogotypes.UInt64Value{Value: packetSequence})) } diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index d5790784ca..03d4fb373e 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -36,18 +36,28 @@ var ( QueryResponseStoreKeyPrefix = []byte{0x05} ) -// ContractStoreKey is a function to get the key for the oracle's contract in store +// GetContractStoreKey is a function to get the key for the oracle in store func GetContractStoreKey() []byte { return ContractStoreKey } -// QueryRequestStoreKey is a function to generate key for each result in store -func QueryRequestStoreKey(packetSequence uint64) []byte { +// GetPortStoreKey is a function to get the key for the port in store +func GetPortStoreKey() []byte { + return PortStoreKey +} + +// GetLastQueryPacketSeqKey is a function to get the key for the last query packet sequence in store +func GetLastQueryPacketSeqKey() []byte { + return LastQueryPacketSeqKey +} + +// GetQueryRequestStoreKey is a function to generate key for each result in store +func GetQueryRequestStoreKey(packetSequence uint64) []byte { return append(QueryRequestStoreKeyPrefix, uint64ToBytes(packetSequence)...) } -// QueryResponseStoreKey is a function to generate key for each result in store -func QueryResponseStoreKey(packetSequence uint64) []byte { +// GetQueryResponseStoreKey is a function to generate key for each result in store +func GetQueryResponseStoreKey(packetSequence uint64) []byte { return append(QueryResponseStoreKeyPrefix, uint64ToBytes(packetSequence)...) } diff --git a/x/oracle/types/keys_test.go b/x/oracle/types/keys_test.go new file mode 100644 index 0000000000..73111467f4 --- /dev/null +++ b/x/oracle/types/keys_test.go @@ -0,0 +1,35 @@ +package types + +import ( + "encoding/binary" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetContractStoreKey(t *testing.T) { + key := GetContractStoreKey() + assert.EqualValues(t, ContractStoreKey, key[0:1], "must return correct contract key") +} + +func TestGetPortStoreKey(t *testing.T) { + key := GetPortStoreKey() + assert.EqualValues(t, PortStoreKey, key[0:1], "must return correct port key") +} + +func TestGetLastQueryPacketSeqKey(t *testing.T) { + key := GetLastQueryPacketSeqKey() + assert.EqualValues(t, LastQueryPacketSeqKey, key[0:1], "must return correct last query packet sequence key") +} + +func TestQueryRequestStoreKey(t *testing.T) { + key := GetQueryRequestStoreKey(5) + assert.EqualValues(t, QueryRequestStoreKeyPrefix, key[0:1], "must have correct prefix") + assert.EqualValues(t, int(5), int(binary.BigEndian.Uint64(key[1:9])), "must have correct sequence") +} + +func TestQueryResponseStoreKey(t *testing.T) { + key := GetQueryResponseStoreKey(5) + assert.EqualValues(t, QueryResponseStoreKeyPrefix, key[0:1], "must have correct prefix") + assert.EqualValues(t, int(5), int(binary.BigEndian.Uint64(key[1:9])), "must have correct sequence") +} From 4d6dbb4171d148a8541e1ed86474436afc65260e Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 4 Aug 2023 14:06:21 -0400 Subject: [PATCH 24/96] Added tests for msgs. --- x/oracle/client/cli/tx.go | 2 +- x/oracle/types/msgs.go | 4 +- x/oracle/types/msgs_test.go | 120 ++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 x/oracle/types/msgs_test.go diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 06f52f1810..d3b72075c8 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -89,7 +89,7 @@ func GetCmdSendQuery() *cobra.Command { return errors.New("query data must be json") } - msg := types.NewMsgQueryOracle( + msg := types.NewMsgSendQueryOracle( clientCtx.GetFromAddress().String(), channelID, queryData, diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index d7f6657e9a..9d437ba59e 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -9,8 +9,8 @@ import ( var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgSendQueryOracleRequest{} -// NewMsgQueryOracle creates a new MsgSendQueryOracleRequest -func NewMsgQueryOracle(creator, channelId string, query []byte) *MsgSendQueryOracleRequest { +// NewMsgSendQueryOracle creates a new MsgSendQueryOracleRequest +func NewMsgSendQueryOracle(creator, channelId string, query []byte) *MsgSendQueryOracleRequest { return &MsgSendQueryOracleRequest{ Authority: creator, Channel: channelId, diff --git a/x/oracle/types/msgs_test.go b/x/oracle/types/msgs_test.go new file mode 100644 index 0000000000..ae14e3ec6d --- /dev/null +++ b/x/oracle/types/msgs_test.go @@ -0,0 +1,120 @@ +package types + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" +) + +func TestNewMsgQueryOracle(t *testing.T) { + authority := "creator" + channel := "channel" + query := []byte{0x01, 0x02, 0x04} + + msg := NewMsgSendQueryOracle(authority, channel, query) + assert.Equal(t, authority, msg.Authority, "must have the correct authority") + assert.Equal(t, channel, msg.Channel, "must have the correct channel") + assert.EqualValues(t, query, msg.Query, "must have the correct query") +} + +func TestNewMsgUpdateOracle(t *testing.T) { + authority := "creator" + address := "address" + + msg := NewMsgUpdateOracle(authority, address) + assert.Equal(t, authority, msg.Authority, "must have the correct authority") + assert.Equal(t, address, msg.Address, "must have the correct address") +} + +func TestMsgUpdateOracleRequestGetSigners(t *testing.T) { + authority := sdk.MustAccAddressFromBech32("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma") + address := "address" + + msg := NewMsgUpdateOracle(authority.String(), address) + signers := msg.GetSigners() + assert.Equal(t, []sdk.AccAddress{authority}, signers, "must have the correct signers") +} + +func TestMsgUpdateOracleRequestValidateBasic(t *testing.T) { + tests := []struct { + name string + msg *MsgUpdateOracleRequest + err string + }{ + { + name: "success - all fields are valid", + msg: NewMsgUpdateOracle("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + }, + { + name: "failure - invalid authority", + msg: NewMsgUpdateOracle("jackthecat", "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + err: "invalid authority address: decoding bech32 failed: invalid separator index -1", + }, + { + name: "failure - invalid address", + msg: NewMsgUpdateOracle("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", "jackthecat"), + err: "invalid address for oracle: decoding bech32 failed: invalid separator index -1", + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + res := tc.msg.ValidateBasic() + if len(tc.err) > 0 { + assert.EqualError(t, res, tc.err, "MsgUpdateOracleRequest.ValidateBasic") + } else { + assert.NoError(t, res, "MsgUpdateOracleRequest.ValidateBasic") + } + }) + } +} + +func TestMsgSendQueryOracleRequestGetSigners(t *testing.T) { + authority := sdk.MustAccAddressFromBech32("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma") + channel := "channel-1" + query := []byte{0x01, 0x02, 0x04} + + msg := NewMsgSendQueryOracle(authority.String(), channel, query) + signers := msg.GetSigners() + assert.Equal(t, []sdk.AccAddress{authority}, signers, "must have the correct signers") +} + +func TestMsgSendQueryOracleRequestValidateBasic(t *testing.T) { + tests := []struct { + name string + msg *MsgSendQueryOracleRequest + err string + }{ + { + name: "success - all fields are valid", + msg: NewMsgSendQueryOracle("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", "channel-1", []byte("{}")), + }, + { + name: "failure - invalid authority", + msg: NewMsgSendQueryOracle("jackthecat", "channel-1", []byte("{}")), + err: "invalid authority address: decoding bech32 failed: invalid separator index -1", + }, + { + name: "failure - invalid channel", + msg: NewMsgSendQueryOracle("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", "bad", []byte("{}")), + err: "invalid channel id: identifier bad has invalid length: 3, must be between 8-64 characters: invalid identifier [cosmos/ibc-go/v6/modules/core/24-host/validate.go:49]", + }, + { + name: "failure - invalid query", + msg: NewMsgSendQueryOracle("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", "channel-1", []byte{}), + err: "invalid query data: invalid", + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + res := tc.msg.ValidateBasic() + if len(tc.err) > 0 { + assert.EqualError(t, res, tc.err, "NewMsgSendQueryOracleRequest.ValidateBasic") + } else { + assert.NoError(t, res, "NewMsgSendQueryOracleRequest.ValidateBasic") + } + }) + } +} From a10304ad4fe1ddb20bc4f54a413942b8898ce887 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 4 Aug 2023 16:33:24 -0400 Subject: [PATCH 25/96] Removed references to contract, and used oracle instead. Updated documentation for keys. --- x/oracle/keeper/oracle.go | 4 ++-- x/oracle/keeper/query_server.go | 4 ++-- x/oracle/types/keys.go | 36 ++++++++++++++++++++++++++++----- x/oracle/types/keys_test.go | 6 +++--- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/x/oracle/keeper/oracle.go b/x/oracle/keeper/oracle.go index 82902daf59..5db8c33a4a 100644 --- a/x/oracle/keeper/oracle.go +++ b/x/oracle/keeper/oracle.go @@ -8,13 +8,13 @@ import ( // SetOracle Sets the oracle used by the module. func (k Keeper) SetOracle(ctx sdk.Context, oracle sdk.AccAddress) { store := ctx.KVStore(k.storeKey) - store.Set(types.GetContractStoreKey(), oracle) + store.Set(types.GetOracleStoreKey(), oracle) } // GetOracle Gets the oracle used by the module. func (k Keeper) GetOracle(ctx sdk.Context) (oracle sdk.AccAddress, err error) { store := ctx.KVStore(k.storeKey) - key := types.GetContractStoreKey() + key := types.GetOracleStoreKey() oracle = store.Get(key) if len(oracle) == 0 { return sdk.AccAddress{}, types.ErrMissingOracleAddress diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 63b6be7de0..7511c7ca63 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -20,12 +20,12 @@ func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddre } ctx := sdk.UnwrapSDKContext(goCtx) - contract, err := k.GetOracle(ctx) + oracle, err := k.GetOracle(ctx) if err != nil { return nil, err } - return &types.QueryOracleAddressResponse{Address: contract.String()}, nil + return &types.QueryOracleAddressResponse{Address: oracle.String()}, nil } // Oracle queries module's oracle diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 03d4fb373e..b870337833 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -23,9 +23,35 @@ const ( PortID = "oracle" ) +// The Oracle module's KVStore categorizes each item in the store using a single byte prefix +// Any additional bytes appended after this prefix are to help in making multiple unique entries per category +// The keys in this section are relatively simple and are used for module setup and configuration +// +// OracleStoreKey +// - 0x01: sdk.AccAddress +// | 1 | +// +// LastQueryPacketSeqKey +// - 0x02: uint64 +// | 1 | +// +// PortStoreKey +// - 0x03: string +// | 1 | +// +// The following keys are used to store ICQ oracle requests and responses +// The are 8 bytes to uniquely identify a ICQ request +// +// QueryRequestStoreKey +// - 0x04: QueryOracleRequest +// | 1 | 8 | +// +// QueryResponseStoreKey +// - 0x05: QueryOracleResponse +// | 1 | 8 | var ( - // ContractStoreKey is the key for the oracle's contract address - ContractStoreKey = []byte{0x01} + // OracleStoreKey is the key for the module's oracle address + OracleStoreKey = []byte{0x01} // LastQueryPacketSeqKey is the key for the last packet sequence LastQueryPacketSeqKey = []byte{0x02} // PortStoreKey defines the key to store the port ID in store @@ -36,9 +62,9 @@ var ( QueryResponseStoreKeyPrefix = []byte{0x05} ) -// GetContractStoreKey is a function to get the key for the oracle in store -func GetContractStoreKey() []byte { - return ContractStoreKey +// GetOracleStoreKey is a function to get the key for the oracle's address in store +func GetOracleStoreKey() []byte { + return OracleStoreKey } // GetPortStoreKey is a function to get the key for the port in store diff --git a/x/oracle/types/keys_test.go b/x/oracle/types/keys_test.go index 73111467f4..3ced71759a 100644 --- a/x/oracle/types/keys_test.go +++ b/x/oracle/types/keys_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/assert" ) -func TestGetContractStoreKey(t *testing.T) { - key := GetContractStoreKey() - assert.EqualValues(t, ContractStoreKey, key[0:1], "must return correct contract key") +func TestGetOracleStoreKey(t *testing.T) { + key := GetOracleStoreKey() + assert.EqualValues(t, OracleStoreKey, key[0:1], "must return correct oracle key") } func TestGetPortStoreKey(t *testing.T) { From 16d1be98544c526dfa7d8fe9bf309cf3c4a2b4df Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 10:24:09 -0400 Subject: [PATCH 26/96] Changed update oracle to be a proposal. --- x/oracle/client/cli/tx.go | 31 ++++++++++++++++++++++++++++--- x/oracle/keeper/keeper.go | 19 +++++++++++++------ x/oracle/keeper/msg_server.go | 5 +++++ 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index d3b72075c8..e8de06fcfa 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -10,11 +10,19 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + sdktx "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/version" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/provenance-io/provenance/x/oracle/types" "github.com/spf13/cobra" ) +// The flag to specify that the command should be ran as a gov proposal +const FlagGovProposal = "gov-proposal" + // NewTxCmd is the top-level command for oracle CLI transactions. func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ @@ -39,26 +47,43 @@ func GetCmdOracleUpdate() *cobra.Command { cmd := &cobra.Command{ Use: "update
", Short: "Update the module's oracle address", + Long: "Submit an update oracle via governance proposal along with an initial deposit.", Args: cobra.ExactArgs(1), Aliases: []string{"u"}, - Example: fmt.Sprintf(`%[1]s tx oracle update pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk`, version.AppName), + Example: fmt.Sprintf(`%[1]s tx oracle update pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk --deposit 50000nhash`, version.AppName), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } + authority := authtypes.NewModuleAddress(govtypes.ModuleName) + msg := types.NewMsgUpdateOracle( - clientCtx.GetFromAddress().String(), + authority.String(), args[0], ) + + proposal, govErr := govcli.ReadGovPropFlags(clientCtx, cmd.Flags()) + if govErr != nil { + return govErr + } + anys, govErr := sdktx.SetMsgs([]sdk.Msg{msg}) + if govErr != nil { + return govErr + } + proposal.Messages = anys + var req sdk.Msg = proposal + if err := msg.ValidateBasic(); err != nil { return err } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), req) }, } + cmd.Flags().Bool(FlagGovProposal, false, "Run transaction as gov proposal") + govcli.AddGovPropFlagsToCmd(cmd) flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index d275eea0aa..d8a0d3359d 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -3,18 +3,17 @@ package keeper import ( "github.com/tendermint/tendermint/libs/log" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - host "github.com/cosmos/ibc-go/v6/modules/core/24-host" - "github.com/provenance-io/provenance/x/oracle/types" - + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" + "github.com/provenance-io/provenance/x/oracle/types" ) type Keeper struct { @@ -28,6 +27,9 @@ type Keeper struct { portKeeper types.PortKeeper scopedKeeper capabilitykeeper.ScopedKeeper wasmQueryServer wasmtypes.QueryServer + + // the signing authority for the gov proposals + authority string } func NewKeeper( @@ -57,6 +59,7 @@ func NewKeeper( portKeeper: portKeeper, scopedKeeper: scopedKeeper, wasmQueryServer: wasmQueryServer, + authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), } } @@ -97,3 +100,7 @@ func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Cap func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { return k.scopedKeeper.ClaimCapability(ctx, cap, name) } + +func (k Keeper) GetAuthority() string { + return k.authority +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index ea6d86835f..0864e799e1 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -4,6 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/provenance-io/provenance/x/oracle/types" ) @@ -23,6 +24,10 @@ var _ types.MsgServer = msgServer{} func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracleRequest) (*types.MsgUpdateOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + if msg.Authority != s.Keeper.GetAuthority() { + return nil, sdkerrors.ErrUnauthorized.Wrapf("expected authority %s got %s", s.Keeper.GetAuthority(), msg.GetAuthority()) + } + s.Keeper.SetOracle(ctx, sdk.MustAccAddressFromBech32(msg.Address)) ctx.EventManager().EmitEvent( From 65ff1bb04c061471c4f5b90fe5d7648e19654631 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 11:58:23 -0400 Subject: [PATCH 27/96] Finished README and concepts. --- x/oracle/spec/01_concepts.md | 19 +++++++++++++++++++ x/oracle/spec/README.md | 9 +++++++++ 2 files changed, 28 insertions(+) create mode 100644 x/oracle/spec/01_concepts.md diff --git a/x/oracle/spec/01_concepts.md b/x/oracle/spec/01_concepts.md new file mode 100644 index 0000000000..791e04bf66 --- /dev/null +++ b/x/oracle/spec/01_concepts.md @@ -0,0 +1,19 @@ + + +# Concepts + +The oracle module is very minimal, but users should understand what the `Oracle` is and how it interacts with `ICQ`. + +## Oracle + +The `Oracle` is a custom built CosmWasm smart contract that the chain queries for data. Chain users can update the address with a proposal. + +## Interchain Queries (ICQ) + +`ICQ` is heavily leveraged in order to allow one Provenance Blockcahin to query another Provenance Blockchain's `Oracle`. This module acts as both the `Controller` and receiver of the `Host` in the `ICQ` realm. + +When a user intends to query another chain, they initiate the process by submitting a query through a transaction on the `ICQ Controller`. This `Controller` delivers the query from the transaction to the `ICQ Host` module of the destination chain via `IBC`. Subsequently, the received query is routed by the `ICQ Host` to this module. Upon receipt, the module queries the `Oracle` using the provided input, and the resulting information is then transmitted back to the `ICQ Controller` in the form of an `ACK` message. + +It should be noted that responses, which arrive in the form of the `ACK`, indicate that queries operate asynchronously. Consequently, these results might not be immediately accessible, necessitating a separate query invocation to retrieve the outcomes. For additional details, you can refer to the [Async ICQ Module](https://github.com/strangelove-ventures/async-icq) developed by strangelove-ventures. \ No newline at end of file diff --git a/x/oracle/spec/README.md b/x/oracle/spec/README.md index e69de29bb2..50d7ede8fc 100644 --- a/x/oracle/spec/README.md +++ b/x/oracle/spec/README.md @@ -0,0 +1,9 @@ +# `oracle` + +## Overview +The oracle module provides the Provenance Blockchain with the capability to dynamically expose query endpoints through Interchain Queries (ICQ) + +One challenge that the Provenance Blockchain faces is supporting each Provenance Blockchain Zone with a unique set of queries. It is not feasible to create an evolving set of queries for each chain. Furthermore, it is not desirable for other parties to request Provenance to build these endpoints for them and then upgrade. This module resolves these issues by enabling Provenance Blockchain zones to manage their own oracle. + +## Contents +1. **[Concepts](01_concepts.md)** \ No newline at end of file From f55974ef7f21ffdbbec5605ee712cf53dea01548 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 14:29:33 -0400 Subject: [PATCH 28/96] Added note about the ibc channel. --- x/oracle/spec/01_concepts.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x/oracle/spec/01_concepts.md b/x/oracle/spec/01_concepts.md index 791e04bf66..33fe2b9819 100644 --- a/x/oracle/spec/01_concepts.md +++ b/x/oracle/spec/01_concepts.md @@ -16,4 +16,8 @@ The `Oracle` is a custom built CosmWasm smart contract that the chain queries fo When a user intends to query another chain, they initiate the process by submitting a query through a transaction on the `ICQ Controller`. This `Controller` delivers the query from the transaction to the `ICQ Host` module of the destination chain via `IBC`. Subsequently, the received query is routed by the `ICQ Host` to this module. Upon receipt, the module queries the `Oracle` using the provided input, and the resulting information is then transmitted back to the `ICQ Controller` in the form of an `ACK` message. -It should be noted that responses, which arrive in the form of the `ACK`, indicate that queries operate asynchronously. Consequently, these results might not be immediately accessible, necessitating a separate query invocation to retrieve the outcomes. For additional details, you can refer to the [Async ICQ Module](https://github.com/strangelove-ventures/async-icq) developed by strangelove-ventures. \ No newline at end of file +It should be noted that responses, which arrive in the form of the `ACK`, indicate that queries operate asynchronously. Consequently, these results might not be immediately accessible, necessitating a separate query invocation to retrieve the outcomes. For additional details, you can refer to the [Async ICQ Module](https://github.com/strangelove-ventures/async-icq) developed by strangelove-ventures. + +### Note + +For `ICQ` to function correctly, it is essential to establish an `unordered channel` connecting the two chains. This channel should be configured utilizing the `oracle` and `icqhost` ports on the `ICQ Controller` and `ICQ Host` correspondingly. The `version` should be designated as `icq-1`. Moreover, it is crucial to ensure that the `HostEnabled` parameter is enabled with a value of `true`, while the `AllowQueries` parameter should encompass the path `"/provenance.oracle.v1.Query/Oracle"`. \ No newline at end of file From 65865991f93e2c1a7647e29be11f6527f49616e6 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 14:54:25 -0400 Subject: [PATCH 29/96] Added state to spec. --- x/oracle/spec/02_state.md | 31 +++++++++++++++++++++++++++++++ x/oracle/spec/README.md | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 x/oracle/spec/02_state.md diff --git a/x/oracle/spec/02_state.md b/x/oracle/spec/02_state.md new file mode 100644 index 0000000000..7502ecd654 --- /dev/null +++ b/x/oracle/spec/02_state.md @@ -0,0 +1,31 @@ + + +# State + +The oracle module manages the address of the Oracle and the ICQ state. + +## Oracle + +The `Oracle` is a CosmWasm smart contract that the module forwards its queries to and relays responses from. Users can manipulate this state by submitting a update oracle proposal. + +* Oracle `0x01 -> []byte{}` + +--- +## IBC + +`IBC` communication exists between the `oracle` and `icqhost` modules. The `oracle` module tracks its channel's `port` in state. It also ensures that each `ICQ` packet has a unique `sequence number` by trackinig this in state. + +* Port `0x03 -> []byte{}` +* Last Query Sequence Number `0x02 -> uint64` + +--- +## ICQ Responses + +The asynchronous nature of the `ICQ` implementation necessitates the module to retain both the request and the corresponding response. This enables users to monitor the progress of their requests and subsequently review the received responses. + +* QueryRequest `0x04 | Sequence ID (8 Bytes) -> ProtocolBuffers(QueryOracleRequest)` +* QueryResponse `0x05 | Sequence ID (8 Bytes) -> ProtocolBuffers(QueryOracleResponse)` + ++++ https://github.com/provenance-io/provenance/blob/a10304ad4fe1ddb20bc4f54a413942b8898ce887/proto/provenance/oracle/v1/query.proto#L51C1-L61 \ No newline at end of file diff --git a/x/oracle/spec/README.md b/x/oracle/spec/README.md index 50d7ede8fc..443c8355d4 100644 --- a/x/oracle/spec/README.md +++ b/x/oracle/spec/README.md @@ -6,4 +6,5 @@ The oracle module provides the Provenance Blockchain with the capability to dyna One challenge that the Provenance Blockchain faces is supporting each Provenance Blockchain Zone with a unique set of queries. It is not feasible to create an evolving set of queries for each chain. Furthermore, it is not desirable for other parties to request Provenance to build these endpoints for them and then upgrade. This module resolves these issues by enabling Provenance Blockchain zones to manage their own oracle. ## Contents -1. **[Concepts](01_concepts.md)** \ No newline at end of file +1. **[Concepts](01_concepts.md)** +2. **[State](02_state.md)** \ No newline at end of file From ccd76765991f4264ec35f0fed292e1b3182a872b Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 15:19:17 -0400 Subject: [PATCH 30/96] Added messages spec. --- x/oracle/spec/03_messages.md | 40 ++++++++++++++++++++++++++++++++++++ x/oracle/spec/README.md | 3 ++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 x/oracle/spec/03_messages.md diff --git a/x/oracle/spec/03_messages.md b/x/oracle/spec/03_messages.md new file mode 100644 index 0000000000..15db335780 --- /dev/null +++ b/x/oracle/spec/03_messages.md @@ -0,0 +1,40 @@ + + +# Messages + +In this section we describe the processing of the oracle messages and their corresponding updates to the state. + +## Msg/UpdateOracleRequest + +The oracle's address is modified by proposing the `MsgUpdateOracleRequest` message. + +### Request + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/tx.proto#L37-L46 + +### Response + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/tx.proto#L48-L49 + +The message will fail under the following conditions: +* The authority does not match the gov module. +* The new address does not pass basic integrity and format checks. + +## Msg/SendQueryOracleRequest + +Sends a query to another chain's `Oracle` using `ICQ`. + +### Request + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/tx.proto#L21-L29 + +### Response + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/tx.proto#L31-L35 + +The message will fail under the following conditions: +* The authority does not pass basic integrity and format checks. +* The query does not have the correct format. +* The channel is invalid or does not pass basic integrity and format checks. \ No newline at end of file diff --git a/x/oracle/spec/README.md b/x/oracle/spec/README.md index 443c8355d4..0292f2495b 100644 --- a/x/oracle/spec/README.md +++ b/x/oracle/spec/README.md @@ -7,4 +7,5 @@ One challenge that the Provenance Blockchain faces is supporting each Provenance ## Contents 1. **[Concepts](01_concepts.md)** -2. **[State](02_state.md)** \ No newline at end of file +2. **[State](02_state.md)** +3. **[Messages](03_messages.md)** \ No newline at end of file From 96f828be46fc613478ee5d564d469ab4862e0931 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 15:57:01 -0400 Subject: [PATCH 31/96] Added queries spec. --- x/oracle/spec/04_queries.md | 46 +++++++++++++++++++++++++++++++++++++ x/oracle/spec/README.md | 3 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 x/oracle/spec/04_queries.md diff --git a/x/oracle/spec/04_queries.md b/x/oracle/spec/04_queries.md new file mode 100644 index 0000000000..c15153d9d4 --- /dev/null +++ b/x/oracle/spec/04_queries.md @@ -0,0 +1,46 @@ + + +# Queries + +In this section we describe the queries available for looking up oracle information. + +--- +## Query Oracle Address +The `QueryOracleAddress` query is used to obtain the address of the module's oracle. + +### Request + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L42-L43 + +### Response + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L45-L49 + + +--- +## Query Oracle +The `QueryOracle` query forwards a query to the module's oracle. + +### Request + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L51-L55 + +### Response + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L57-L61 + +The data from the `query` field is a `CosmWasm query` forwarded to the `oracle`. + +--- +## Query Query State +The `QueryQueryState` query is used to obtain the state of an existing query. + +### Request + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L31-L34 + +### Response + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L36-L40 \ No newline at end of file diff --git a/x/oracle/spec/README.md b/x/oracle/spec/README.md index 0292f2495b..093b856bab 100644 --- a/x/oracle/spec/README.md +++ b/x/oracle/spec/README.md @@ -8,4 +8,5 @@ One challenge that the Provenance Blockchain faces is supporting each Provenance ## Contents 1. **[Concepts](01_concepts.md)** 2. **[State](02_state.md)** -3. **[Messages](03_messages.md)** \ No newline at end of file +3. **[Messages](03_messages.md)** +4. **[Queries](04_queries.md)** \ No newline at end of file From 15ec8528dd2d508c4771b39f823ab54ebead9dbf Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 16:38:36 -0400 Subject: [PATCH 32/96] Finished documentation for events. --- x/oracle/spec/05_events.md | 37 +++++++++++++++++++++++++++++++++++++ x/oracle/spec/README.md | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 x/oracle/spec/05_events.md diff --git a/x/oracle/spec/05_events.md b/x/oracle/spec/05_events.md new file mode 100644 index 0000000000..c922b005b9 --- /dev/null +++ b/x/oracle/spec/05_events.md @@ -0,0 +1,37 @@ + + +# Events + +The oracle module emits the following events: + + +--- +## EventOracleQuerySuccess + +This event is emitted when a `ICQ` response is received from an `ACK` and is successful. + +| Type | Attribute Key | Attribute Value | +| ------------------ | ------------- | ------------------------------- | +| OracleQuerySuccess | sequence_id | Sequence ID of the ICQ request | +| OracleQuerySuccess | result | Query data obtained from oracle | + +--- +## EventOracleQueryError + +This event is emitted when a `ICQ` response is received from an `ACK` and contains an error. + +| Type | Attribute Key | Attribute Value | +| ---------------- | ------------- | ------------------------------ | +| OracleQueryError | sequence_id | Sequence ID of the ICQ request | +| OracleQueryError | error | Error received from the module | + +--- +## EventOracleQueryTimeout + +This event is emitted when a `ICQ` request results in a `Timeout`. + +| Type | Attribute Key | Attribute Value | +| ------------------ | ------------- | ------------------------------ | +| OracleQueryTimeout | sequence_id | Sequence ID of the ICQ request | \ No newline at end of file diff --git a/x/oracle/spec/README.md b/x/oracle/spec/README.md index 093b856bab..3a5bb7ce56 100644 --- a/x/oracle/spec/README.md +++ b/x/oracle/spec/README.md @@ -9,4 +9,5 @@ One challenge that the Provenance Blockchain faces is supporting each Provenance 1. **[Concepts](01_concepts.md)** 2. **[State](02_state.md)** 3. **[Messages](03_messages.md)** -4. **[Queries](04_queries.md)** \ No newline at end of file +4. **[Queries](04_queries.md)** +5. **[Events](05_events.md)** \ No newline at end of file From 930a5c37ba7193ee3f15ccf05211f244cc92aa42 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 16:42:17 -0400 Subject: [PATCH 33/96] Finished documentation for genesis. --- x/oracle/spec/06_genesis.md | 13 +++++++++++++ x/oracle/spec/README.md | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 x/oracle/spec/06_genesis.md diff --git a/x/oracle/spec/06_genesis.md b/x/oracle/spec/06_genesis.md new file mode 100644 index 0000000000..aad53c5f0d --- /dev/null +++ b/x/oracle/spec/06_genesis.md @@ -0,0 +1,13 @@ + + +# Oracle Genesis + +In this section we describe the processing of the oracle messages and the corresponding updates to the state. + +## Msg/GenesisState + +The GenesisState encompasses the upcoming sequence ID for an ICQ packet, the associated parameters, and the designated port ID for the module. These values are both extracted for export and imported for storage within the store. + ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/genesis.proto#L11-L22 \ No newline at end of file diff --git a/x/oracle/spec/README.md b/x/oracle/spec/README.md index 3a5bb7ce56..46e222a1a5 100644 --- a/x/oracle/spec/README.md +++ b/x/oracle/spec/README.md @@ -10,4 +10,5 @@ One challenge that the Provenance Blockchain faces is supporting each Provenance 2. **[State](02_state.md)** 3. **[Messages](03_messages.md)** 4. **[Queries](04_queries.md)** -5. **[Events](05_events.md)** \ No newline at end of file +5. **[Events](05_events.md)** +6. **[Genesis](06_genesis.md)** \ No newline at end of file From b52cc25eec172c17817a142e8cc60edf3b2e25b6 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 16:45:52 -0400 Subject: [PATCH 34/96] Fixed typo in documentation. --- x/oracle/spec/05_events.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/oracle/spec/05_events.md b/x/oracle/spec/05_events.md index c922b005b9..518967b830 100644 --- a/x/oracle/spec/05_events.md +++ b/x/oracle/spec/05_events.md @@ -10,7 +10,7 @@ The oracle module emits the following events: --- ## EventOracleQuerySuccess -This event is emitted when a `ICQ` response is received from an `ACK` and is successful. +This event is emitted when an `ICQ` response is received from an `ACK` and is successful. | Type | Attribute Key | Attribute Value | | ------------------ | ------------- | ------------------------------- | @@ -20,7 +20,7 @@ This event is emitted when a `ICQ` response is received from an `ACK` and is suc --- ## EventOracleQueryError -This event is emitted when a `ICQ` response is received from an `ACK` and contains an error. +This event is emitted when an `ICQ` response is received from an `ACK` and contains an error. | Type | Attribute Key | Attribute Value | | ---------------- | ------------- | ------------------------------ | @@ -30,7 +30,7 @@ This event is emitted when a `ICQ` response is received from an `ACK` and contai --- ## EventOracleQueryTimeout -This event is emitted when a `ICQ` request results in a `Timeout`. +This event is emitted when an `ICQ` request results in a `Timeout`. | Type | Attribute Key | Attribute Value | | ------------------ | ------------- | ------------------------------ | From 0c700238bfebb851738950fff205fa8cbc3712b8 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 7 Aug 2023 16:54:26 -0400 Subject: [PATCH 35/96] Added table of contents to all spec files. --- x/oracle/spec/01_concepts.md | 8 +++++++- x/oracle/spec/02_state.md | 9 ++++++++- x/oracle/spec/03_messages.md | 8 +++++++- x/oracle/spec/04_queries.md | 7 ++++++- x/oracle/spec/05_events.md | 7 ++++++- x/oracle/spec/06_genesis.md | 7 ++++++- 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/x/oracle/spec/01_concepts.md b/x/oracle/spec/01_concepts.md index 33fe2b9819..0c37fb33b0 100644 --- a/x/oracle/spec/01_concepts.md +++ b/x/oracle/spec/01_concepts.md @@ -6,6 +6,12 @@ order: 1 The oracle module is very minimal, but users should understand what the `Oracle` is and how it interacts with `ICQ`. + + - [Oracle](#oracle) + - [Interchain Queries (ICQ)](#interchain-queries-icq) + + +--- ## Oracle The `Oracle` is a custom built CosmWasm smart contract that the chain queries for data. Chain users can update the address with a proposal. @@ -20,4 +26,4 @@ It should be noted that responses, which arrive in the form of the `ACK`, indica ### Note -For `ICQ` to function correctly, it is essential to establish an `unordered channel` connecting the two chains. This channel should be configured utilizing the `oracle` and `icqhost` ports on the `ICQ Controller` and `ICQ Host` correspondingly. The `version` should be designated as `icq-1`. Moreover, it is crucial to ensure that the `HostEnabled` parameter is enabled with a value of `true`, while the `AllowQueries` parameter should encompass the path `"/provenance.oracle.v1.Query/Oracle"`. \ No newline at end of file +For `ICQ` to function correctly, it is essential to establish an `unordered channel` connecting the two chains. This channel should be configured utilizing the `oracle` and `icqhost` ports on the `ICQ Controller` and `ICQ Host` correspondingly. The `version` should be designated as `icq-1`. Moreover, it is crucial to ensure that the `HostEnabled` parameter is enabled with a value of `true`, while the `AllowQueries` parameter should encompass the path `"/provenance.oracle.v1.Query/Oracle"`. diff --git a/x/oracle/spec/02_state.md b/x/oracle/spec/02_state.md index 7502ecd654..88709b2cde 100644 --- a/x/oracle/spec/02_state.md +++ b/x/oracle/spec/02_state.md @@ -6,6 +6,13 @@ order: 2 The oracle module manages the address of the Oracle and the ICQ state. + + - [Oracle](#oracle) + - [IBC](#ibc) + - [ICQ Responses](#icq-responses) + + +--- ## Oracle The `Oracle` is a CosmWasm smart contract that the module forwards its queries to and relays responses from. Users can manipulate this state by submitting a update oracle proposal. @@ -28,4 +35,4 @@ The asynchronous nature of the `ICQ` implementation necessitates the module to r * QueryRequest `0x04 | Sequence ID (8 Bytes) -> ProtocolBuffers(QueryOracleRequest)` * QueryResponse `0x05 | Sequence ID (8 Bytes) -> ProtocolBuffers(QueryOracleResponse)` -+++ https://github.com/provenance-io/provenance/blob/a10304ad4fe1ddb20bc4f54a413942b8898ce887/proto/provenance/oracle/v1/query.proto#L51C1-L61 \ No newline at end of file ++++ https://github.com/provenance-io/provenance/blob/a10304ad4fe1ddb20bc4f54a413942b8898ce887/proto/provenance/oracle/v1/query.proto#L51C1-L61 diff --git a/x/oracle/spec/03_messages.md b/x/oracle/spec/03_messages.md index 15db335780..8eb34eaa0b 100644 --- a/x/oracle/spec/03_messages.md +++ b/x/oracle/spec/03_messages.md @@ -6,6 +6,12 @@ order: 3 In this section we describe the processing of the oracle messages and their corresponding updates to the state. + + - [Msg/UpdateOracleRequest](#msgupdateoraclerequest) + - [Msg/SendQueryOracleRequest](#msgsendqueryoraclerequest) + + +--- ## Msg/UpdateOracleRequest The oracle's address is modified by proposing the `MsgUpdateOracleRequest` message. @@ -37,4 +43,4 @@ Sends a query to another chain's `Oracle` using `ICQ`. The message will fail under the following conditions: * The authority does not pass basic integrity and format checks. * The query does not have the correct format. -* The channel is invalid or does not pass basic integrity and format checks. \ No newline at end of file +* The channel is invalid or does not pass basic integrity and format checks. diff --git a/x/oracle/spec/04_queries.md b/x/oracle/spec/04_queries.md index c15153d9d4..fa94df87d6 100644 --- a/x/oracle/spec/04_queries.md +++ b/x/oracle/spec/04_queries.md @@ -6,6 +6,11 @@ order: 4 In this section we describe the queries available for looking up oracle information. + + - [Query Oracle Address](#query-oracle-address) + - [Query Oracle](#query-oracle) + - [Query Query State](#query-query-state) + --- ## Query Oracle Address The `QueryOracleAddress` query is used to obtain the address of the module's oracle. @@ -43,4 +48,4 @@ The `QueryQueryState` query is used to obtain the state of an existing query. ### Response -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L36-L40 \ No newline at end of file ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L36-L40 diff --git a/x/oracle/spec/05_events.md b/x/oracle/spec/05_events.md index 518967b830..703bff5f3c 100644 --- a/x/oracle/spec/05_events.md +++ b/x/oracle/spec/05_events.md @@ -6,6 +6,11 @@ order: 5 The oracle module emits the following events: + + - [EventOracleQuerySuccess](#eventoraclequerysuccess) + - [EventOracleQueryError](#eventoraclequeryerror) + - [EventOracleQueryTimeout](#eventoraclequerytimeout) + --- ## EventOracleQuerySuccess @@ -34,4 +39,4 @@ This event is emitted when an `ICQ` request results in a `Timeout`. | Type | Attribute Key | Attribute Value | | ------------------ | ------------- | ------------------------------ | -| OracleQueryTimeout | sequence_id | Sequence ID of the ICQ request | \ No newline at end of file +| OracleQueryTimeout | sequence_id | Sequence ID of the ICQ request | diff --git a/x/oracle/spec/06_genesis.md b/x/oracle/spec/06_genesis.md index aad53c5f0d..42538d4dd7 100644 --- a/x/oracle/spec/06_genesis.md +++ b/x/oracle/spec/06_genesis.md @@ -6,8 +6,13 @@ order: 6 In this section we describe the processing of the oracle messages and the corresponding updates to the state. + + - [Msg/GenesisState](#msggenesisstate) + + +--- ## Msg/GenesisState The GenesisState encompasses the upcoming sequence ID for an ICQ packet, the associated parameters, and the designated port ID for the module. These values are both extracted for export and imported for storage within the store. -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/genesis.proto#L11-L22 \ No newline at end of file ++++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/genesis.proto#L11-L22 From f2aad087bebc5217a2f88b22ffb4f805c142a7b9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 09:04:12 -0400 Subject: [PATCH 36/96] Updated proto comment. --- docs/proto-docs.md | 2 +- proto/provenance/oracle/v1/query.proto | 2 +- x/oracle/types/query.pb.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 21663a48fb..9990d71e94 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -6902,7 +6902,7 @@ Query defines the gRPC querier service for oracle module. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `OracleAddress` | [QueryOracleAddressRequest](#provenance.oracle.v1.QueryOracleAddressRequest) | [QueryOracleAddressResponse](#provenance.oracle.v1.QueryOracleAddressResponse) | OracleAddress returns the address of the oracle | GET|/provenance/oracle/v1/oracle_address| -| `Oracle` | [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) | [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) | Oracle sends a query to the oracle's contract | GET|/provenance/oracle/v1/oracle| +| `Oracle` | [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) | [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) | Oracle forwards a query to the module's oracle | GET|/provenance/oracle/v1/oracle| | `QueryState` | [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) | [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) | QueryState returns the state of the oracle query | GET|/provenance/oracle/v1/query_state| diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index 65b7295795..43397366c3 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -17,7 +17,7 @@ service Query { option (google.api.http).get = "/provenance/oracle/v1/oracle_address"; } - // Oracle sends a query to the oracle's contract + // Oracle forwards a query to the module's oracle rpc Oracle(QueryOracleRequest) returns (QueryOracleResponse) { option (google.api.http).get = "/provenance/oracle/v1/oracle"; } diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index a295582810..943f2087d1 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -368,7 +368,7 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // OracleAddress returns the address of the oracle OracleAddress(ctx context.Context, in *QueryOracleAddressRequest, opts ...grpc.CallOption) (*QueryOracleAddressResponse, error) - // Oracle sends a query to the oracle's contract + // Oracle forwards a query to the module's oracle Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) // QueryState returns the state of the oracle query QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) @@ -413,7 +413,7 @@ func (c *queryClient) QueryState(ctx context.Context, in *QueryQueryStateRequest type QueryServer interface { // OracleAddress returns the address of the oracle OracleAddress(context.Context, *QueryOracleAddressRequest) (*QueryOracleAddressResponse, error) - // Oracle sends a query to the oracle's contract + // Oracle forwards a query to the module's oracle Oracle(context.Context, *QueryOracleRequest) (*QueryOracleResponse, error) // QueryState returns the state of the oracle query QueryState(context.Context, *QueryQueryStateRequest) (*QueryQueryStateResponse, error) From f2116ed0444d4b2fdadca4bd28437b65bbdeaac0 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 14:24:28 -0400 Subject: [PATCH 37/96] Hooked up the simulation tests, but have not verified their correctness. --- app/app.go | 4 +- app/params/weights.go | 3 + go.mod | 2 +- x/oracle/module/module.go | 38 ++++--- x/oracle/simulation/decoder.go | 52 +++++++++ x/oracle/simulation/genesis.go | 69 ++++++++++++ x/oracle/simulation/operations.go | 177 ++++++++++++++++++++++++++++++ 7 files changed, 326 insertions(+), 19 deletions(-) create mode 100644 x/oracle/simulation/decoder.go create mode 100644 x/oracle/simulation/operations.go diff --git a/app/app.go b/app/app.go index 86e02eae14..6ad0f8086d 100644 --- a/app/app.go +++ b/app/app.go @@ -585,7 +585,7 @@ func New( scopedOracleKeeper, wasmkeeper.Querier(&app.WasmKeeper), ) - oracleModule := oraclemodule.NewAppModule(appCodec, app.OracleKeeper) + oracleModule := oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper) unsanctionableAddrs := make([]sdk.AccAddress, 0, len(maccPerms)+1) for mName := range maccPerms { @@ -873,7 +873,7 @@ func New( msgfeesmodule.NewAppModule(appCodec, app.MsgFeesKeeper, app.interfaceRegistry), rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper), triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper), - oraclemodule.NewAppModule(appCodec, app.OracleKeeper), + oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper), provwasm.NewWrapper(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper), ibc.NewAppModule(app.IBCKeeper), diff --git a/app/params/weights.go b/app/params/weights.go index 76080f289b..9a367fd967 100644 --- a/app/params/weights.go +++ b/app/params/weights.go @@ -35,4 +35,7 @@ const ( // Trigger DefaultWeightSubmitCreateTrigger int = 95 DefaultWeightSubmitDestroyTrigger int = 5 + // Oracle + DefaultWeightUpdateOracle int = 25 + DefaultWeightSendOracleQuery int = 75 ) diff --git a/go.mod b/go.mod index 9181213bd2..f4a2178963 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/math v1.0.1 + github.com/99designs/keyring v1.2.1 github.com/CosmWasm/wasmd v0.29.0 github.com/CosmWasm/wasmvm v1.2.4 github.com/armon/go-metrics v0.4.1 @@ -48,7 +49,6 @@ require ( cloud.google.com/go/storage v1.28.1 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect - github.com/99designs/keyring v1.2.1 // indirect github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect github.com/aws/aws-sdk-go v1.44.122 // indirect diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index e15d3a928e..c786a47a08 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -5,22 +5,23 @@ import ( "encoding/json" "math/rand" + cerrs "cosmossdk.io/errors" + sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + channelkeeper "github.com/cosmos/ibc-go/v6/modules/core/04-channel/keeper" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/provenance-io/provenance/x/oracle/client/cli" "github.com/provenance-io/provenance/x/oracle/keeper" + "github.com/provenance-io/provenance/x/oracle/simulation" "github.com/provenance-io/provenance/x/oracle/types" "github.com/spf13/cobra" - - cerrs "cosmossdk.io/errors" - sdkclient "github.com/cosmos/cosmos-sdk/client" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - abci "github.com/tendermint/tendermint/abci/types" ) @@ -89,20 +90,26 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { // AppModule implements the sdk.AppModule interface type AppModule struct { AppModuleBasic - keeper keeper.Keeper + keeper keeper.Keeper + accountKeeper authkeeper.AccountKeeper + bankKeeper bankkeeper.Keeper + channelKeeper channelkeeper.Keeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, channelKeeper channelkeeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + channelKeeper: channelKeeper, } } // GenerateGenesisState creates a randomized GenState of the oracle module. func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { - // simulation.RandomizedGenState(simState) + simulation.RandomizedGenState(simState) } // ProposalContents returns content functions used to simulate governance proposals. @@ -119,15 +126,14 @@ func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { // RegisterStoreDecoder registers a func to decode each module's defined types from their corresponding store key func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - //sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) + sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) } // WeightedOperations returns simulation operations (i.e msgs) with their respective weight func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return []simtypes.WeightedOperation{} - /*return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, am.keeper, am.accountKeeper, am.bankKeeper, - )*/ + return simulation.WeightedOperations( + simState.AppParams, simState.Cdc, am.keeper, am.accountKeeper, am.bankKeeper, am.channelKeeper, + ) } // Name returns the oracle module's name. diff --git a/x/oracle/simulation/decoder.go b/x/oracle/simulation/decoder.go new file mode 100644 index 0000000000..ede0175f49 --- /dev/null +++ b/x/oracle/simulation/decoder.go @@ -0,0 +1,52 @@ +package simulation + +import ( + "bytes" + "encoding/binary" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/provenance-io/provenance/x/oracle/types" +) + +// NewDecodeStore returns a decoder function closure that unmarshalls the KVPair's +// Value +func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { + switch { + case bytes.Equal(kvA.Key[:1], types.OracleStoreKey): + var attribA, attribB sdk.AccAddress = kvA.Value, kvB.Value + return fmt.Sprintf("Oracle Address: A:[%v] B:[%v]\n", attribA, attribB) + case bytes.Equal(kvA.Key[:1], types.LastQueryPacketSeqKey): + attribA := binary.BigEndian.Uint64(kvA.Value) + attribB := binary.BigEndian.Uint64(kvB.Value) + + return fmt.Sprintf("Last Query Packet Sequence: A:[%v] B:[%v]\n", attribA, attribB) + case bytes.Equal(kvA.Key[:1], types.PortStoreKey): + attribA := string(kvA.Value) + attribB := string(kvB.Value) + + return fmt.Sprintf("Port: A:[%v] B:[%v]\n", attribA, attribB) + case bytes.Equal(kvA.Key[:1], types.QueryRequestStoreKeyPrefix): + var attribA, attribB types.QueryOracleRequest + + cdc.MustUnmarshal(kvA.Value, &attribA) + cdc.MustUnmarshal(kvB.Value, &attribB) + + return fmt.Sprintf("QueryOracleRequest: A:[%v] B:[%v]\n", attribA, attribB) + case bytes.Equal(kvA.Key[:1], types.QueryResponseStoreKeyPrefix): + var attribA, attribB types.QueryOracleResponse + + cdc.MustUnmarshal(kvA.Value, &attribA) + cdc.MustUnmarshal(kvB.Value, &attribB) + + return fmt.Sprintf("QueryOracleResponse: A:[%v] B:[%v]\n", attribA, attribB) + default: + panic(fmt.Sprintf("unexpected %s key %X (%s)", types.ModuleName, kvA.Key, kvA.Key)) + } + } +} diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 02eddda2ba..1d21905e7c 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -1 +1,70 @@ package simulation + +import ( + "encoding/json" + "fmt" + "math/rand" + "strings" + + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/provenance-io/provenance/x/oracle/types" + + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +const ( + SequenceID = "sequence_id" + Port = "port" +) + +// SequenceIDFn randomized sequence id +func SequenceIDFn(r *rand.Rand) uint64 { + return uint64(randIntBetween(r, 1, 10000000000)) +} + +// PortFn randomized port name +func PortFn(r *rand.Rand) string { + randomName := uint64(randIntBetween(r, 0, 1)) + if randomName < 1 { + return "oracle" + } + length := uint64(randIntBetween(r, 6, 10)) + return strings.ToLower(simtypes.RandStringOfLength(r, int(length))) +} + +// RandomizedGenState generates a random GenesisState for trigger +func RandomizedGenState(simState *module.SimulationState) { + var sequenceID uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, SequenceID, &sequenceID, simState.Rand, + func(r *rand.Rand) { sequenceID = SequenceIDFn(r) }, + ) + + var port string + simState.AppParams.GetOrGenerate( + simState.Cdc, Port, &port, simState.Rand, + func(r *rand.Rand) { port = PortFn(r) }, + ) + + params := types.DefaultParams() + + genesis := types.NewGenesisState(port, params, sequenceID) + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(genesis) + + bz, err := json.MarshalIndent(simState.GenState[types.ModuleName], "", " ") + if err != nil { + panic(err) + } + fmt.Printf("Selected randomly generated oracle parameters:\n%s\n", bz) +} + +// randIntBetween generates a random number between min and max inclusive. +func randIntBetween(r *rand.Rand, min, max int) int { + return r.Intn(max-min+1) + min +} + +// RandomChannel returns a random channel +func RandomChannel(r *rand.Rand) string { + channelNumber := r.Intn(1000) + return fmt.Sprintf("channel-%d", channelNumber) +} diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go new file mode 100644 index 0000000000..163609eef2 --- /dev/null +++ b/x/oracle/simulation/operations.go @@ -0,0 +1,177 @@ +package simulation + +import ( + "fmt" + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp/helpers" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/cosmos/cosmos-sdk/x/bank/testutil" + "github.com/cosmos/cosmos-sdk/x/simulation" + channelkeeper "github.com/cosmos/ibc-go/v6/modules/core/04-channel/keeper" + simappparams "github.com/provenance-io/provenance/app/params" + "github.com/provenance-io/provenance/internal/pioconfig" + "github.com/provenance-io/provenance/x/oracle/keeper" + "github.com/provenance-io/provenance/x/oracle/types" +) + +// Simulation operation weights constants +const ( + //nolint:gosec // not credentials + OpWeightMsgUpdateOracle = "op_weight_msg_update_oracle" + //nolint:gosec // not credentials + OpWeightMsgSendOracleQuery = "op_weight_msg_send_oracle_query" +) + +// WeightedOperations returns all the operations from the module with their respective weights +func WeightedOperations( + appParams simtypes.AppParams, cdc codec.JSONCodec, k keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, ck channelkeeper.Keeper, +) simulation.WeightedOperations { + var ( + weightMsgUpdateOracle int + weightMsgSendOracleQuery int + ) + + appParams.GetOrGenerate(cdc, OpWeightMsgUpdateOracle, &weightMsgUpdateOracle, nil, + func(_ *rand.Rand) { + weightMsgUpdateOracle = simappparams.DefaultWeightUpdateOracle + }, + ) + appParams.GetOrGenerate(cdc, OpWeightMsgSendOracleQuery, &weightMsgSendOracleQuery, nil, + func(_ *rand.Rand) { + weightMsgSendOracleQuery = simappparams.DefaultWeightSendOracleQuery + }, + ) + + return simulation.WeightedOperations{ + simulation.NewWeightedOperation( + weightMsgUpdateOracle, + SimulateMsgUpdateOracle(k, ak, bk), + ), + simulation.NewWeightedOperation( + weightMsgSendOracleQuery, + SimulateMsgSendQueryOracle(k, ak, bk, ck), + ), + } +} + +// SimulateMsgCreateTrigger sends a MsgUpdateOracle. +func SimulateMsgUpdateOracle(_ keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + raccs, err := RandomAccs(r, accs, 2) + if err != nil { + return simtypes.NoOpMsg(sdk.MsgTypeURL(&types.MsgUpdateOracleRequest{}), sdk.MsgTypeURL(&types.MsgUpdateOracleRequest{}), err.Error()), nil, nil + } + from := raccs[0] + to := raccs[1] + + msg := types.NewMsgUpdateOracle(from.Address.String(), to.Address.String()) + + return Dispatch(r, app, ctx, from, chainID, msg, ak, bk, nil) + } +} + +// SimulateMsgSendQueryOracle sends a MsgSendQueryOracle. +func SimulateMsgSendQueryOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, ck channelkeeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + raccs, err := RandomAccs(r, accs, 1) + if err != nil { + return simtypes.NoOpMsg(sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), err.Error()), nil, nil + } + addr := raccs[0] + + channel, err := randomChannel(r, ctx, ck) + if err != nil { + return simtypes.NoOpMsg(sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), err.Error()), nil, nil + } + query := []byte("{}") + + msg := types.NewMsgSendQueryOracle(addr.Address.String(), channel, query) + return Dispatch(r, app, ctx, addr, chainID, msg, ak, bk, nil) + } +} + +// Dispatch sends an operation to the chain using a given account/funds on account for fees. Failures on the server side +// are handled as no-op msg operations with the error string as the status/response. +func Dispatch( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + from simtypes.Account, + chainID string, + msg sdk.Msg, + ak authkeeper.AccountKeeperI, + bk bankkeeper.Keeper, + futures []simtypes.FutureOperation, +) ( + simtypes.OperationMsg, + []simtypes.FutureOperation, + error, +) { + account := ak.GetAccount(ctx, from.Address) + spendable := bk.SpendableCoins(ctx, account.GetAddress()) + + fees, err := simtypes.RandomFees(r, ctx, spendable) + if err != nil { + return simtypes.NoOpMsg(sdk.MsgTypeURL(msg), sdk.MsgTypeURL(msg), "unable to generate fees"), nil, err + } + err = testutil.FundAccount(bk, ctx, account.GetAddress(), sdk.NewCoins(sdk.Coin{ + Denom: pioconfig.GetProvenanceConfig().BondDenom, + Amount: sdk.NewInt(1_000_000_000_000_000), + })) + if err != nil { + return simtypes.NoOpMsg(sdk.MsgTypeURL(msg), sdk.MsgTypeURL(msg), "unable to fund account"), nil, err + } + txGen := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txGen, + []sdk.Msg{msg}, + fees, + helpers.DefaultGenTxGas, + chainID, + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + from.PrivKey, + ) + if err != nil { + return simtypes.NoOpMsg(sdk.MsgTypeURL(msg), sdk.MsgTypeURL(msg), "unable to generate mock tx"), nil, err + } + + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(sdk.MsgTypeURL(msg), sdk.MsgTypeURL(msg), err.Error()), nil, nil + } + + return simtypes.NewOperationMsg(msg, true, "", &codec.ProtoCodec{}), futures, nil +} + +func RandomAccs(r *rand.Rand, accs []simtypes.Account, count uint64) ([]simtypes.Account, error) { + if uint64(len(accs)) < count { + return nil, fmt.Errorf("cannot choose %d accounts because there are only %d", count, len(accs)) + } + raccs := make([]simtypes.Account, 0, len(accs)) + raccs = append(raccs, accs...) + r.Shuffle(len(raccs), func(i, j int) { + raccs[i], raccs[j] = raccs[j], raccs[i] + }) + return raccs[:count], nil +} + +func randomChannel(r *rand.Rand, ctx sdk.Context, ck channelkeeper.Keeper) (string, error) { + channels := ck.GetAllChannels(ctx) + if len(channels) == 0 { + return "", fmt.Errorf("cannot get random channel because none exist") + } + idx := r.Intn(len(channels)) + return channels[idx].String(), nil +} From a331111def72e17f83444f561ec4f4c4517101b2 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 15:39:46 -0400 Subject: [PATCH 38/96] Added genesis tests for keeper. --- x/oracle/keeper/genesis_test.go | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 x/oracle/keeper/genesis_test.go diff --git a/x/oracle/keeper/genesis_test.go b/x/oracle/keeper/genesis_test.go new file mode 100644 index 0000000000..0d88f13b0a --- /dev/null +++ b/x/oracle/keeper/genesis_test.go @@ -0,0 +1,56 @@ +package keeper_test + +import ( + "github.com/provenance-io/provenance/x/oracle/types" +) + +func (s *KeeperTestSuite) TestExportGenesis() { + genesis := s.app.OracleKeeper.ExportGenesis(s.ctx) + s.Assert().Equal(types.DefaultParams(), genesis.Params, "should export the correct params") + s.Assert().Equal("oracle", genesis.PortId, "should export the correct port") + s.Assert().Equal(int(1), int(genesis.Sequence), "should export the correct sequence number") +} + +func (s *KeeperTestSuite) TestInitGenesis() { + tests := []struct { + name string + genesis *types.GenesisState + err string + }{ + { + name: "success - valid genesis state", + genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1), + }, + { + name: "failure - invalid sequence number", + genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 0), + err: "sequence 0 is invalid, must be greater than 0", + }, + { + name: "failure - invalid port", + genesis: types.NewGenesisState("", types.DefaultParams(), 1), + err: "identifier cannot be blank: invalid identifier", + }, + { + name: "success - works with existing port", + genesis: types.NewGenesisState("oracle", types.DefaultParams(), 1), + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + + if len(tc.err) > 0 { + s.Assert().PanicsWithError(tc.err, func() { + s.app.OracleKeeper.InitGenesis(s.ctx, tc.genesis) + }, "invalid init genesis should cause panic") + } else { + s.app.OracleKeeper.InitGenesis(s.ctx, tc.genesis) + s.Assert().Equal(tc.genesis.Params, s.app.OracleKeeper.GetParams(s.ctx), "should correctly set params") + s.Assert().Equal(tc.genesis.PortId, s.app.OracleKeeper.GetPort(s.ctx), "should correctly set the port") + s.Assert().True(s.app.OracleKeeper.IsBound(s.ctx, tc.genesis.PortId), "should bind the port") + s.Assert().Equal(int(tc.genesis.Sequence), int(s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx)), "should set the last sequence number") + } + }) + } +} From 8802a2c53f37fd9a049f555581c00782306a8be4 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 17:01:20 -0400 Subject: [PATCH 39/96] Added oracle keeper tests. --- x/oracle/keeper/oracle_test.go | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 x/oracle/keeper/oracle_test.go diff --git a/x/oracle/keeper/oracle_test.go b/x/oracle/keeper/oracle_test.go new file mode 100644 index 0000000000..545c244cf3 --- /dev/null +++ b/x/oracle/keeper/oracle_test.go @@ -0,0 +1,38 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s *KeeperTestSuite) TestGetSetOracle() { + tests := []struct { + name string + address string + err string + }{ + { + name: "failure - address not set", + err: "missing oracle address", + }, + { + name: "success - address can be set", + address: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + if len(tc.address) > 0 { + s.app.OracleKeeper.SetOracle(s.ctx, sdk.MustAccAddressFromBech32(tc.address)) + } + oracle, err := s.app.OracleKeeper.GetOracle(s.ctx) + + if len(tc.err) > 0 { + s.Assert().EqualError(err, tc.err, "should throw the correct error") + } else { + s.Assert().NoError(err, "should not throw an error") + s.Assert().Equal(tc.address, oracle.String(), "should get back the set address") + } + }) + } +} From 2af9b510e3dbcc0ca19c948b0d6b7f93a9fb2900 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 17:10:02 -0400 Subject: [PATCH 40/96] Added tests for params. --- x/oracle/keeper/params_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 x/oracle/keeper/params_test.go diff --git a/x/oracle/keeper/params_test.go b/x/oracle/keeper/params_test.go new file mode 100644 index 0000000000..3ac56dfd0d --- /dev/null +++ b/x/oracle/keeper/params_test.go @@ -0,0 +1,8 @@ +package keeper_test + +import "github.com/provenance-io/provenance/x/oracle/types" + +func (s *KeeperTestSuite) TestGetParams() { + params := s.app.OracleKeeper.GetParams(s.ctx) + s.Assert().Equal(types.NewParams(), params, "should return correct params") +} From f5ce91d3c6dbb1739957e25e3ad582615bdff752 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 22:55:39 -0400 Subject: [PATCH 41/96] Updated comments in keeper.go --- x/oracle/keeper/keeper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index d8a0d3359d..3b4252c289 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -63,6 +63,7 @@ func NewKeeper( } } +// Logger returns the correctly named logger for the module func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } @@ -101,6 +102,7 @@ func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability return k.scopedKeeper.ClaimCapability(ctx, cap, name) } +// GetAuthority returns the module's authority address func (k Keeper) GetAuthority() string { return k.authority } From 3d6415e722310586243e04aa5cc460d0c2ffee14 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 22:56:21 -0400 Subject: [PATCH 42/96] Added missing keeper_test for setup of previous committed tests. --- x/oracle/keeper/keeper_test.go | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 x/oracle/keeper/keeper_test.go diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go new file mode 100644 index 0000000000..6e658f88ce --- /dev/null +++ b/x/oracle/keeper/keeper_test.go @@ -0,0 +1,60 @@ +package keeper_test + +import ( + "fmt" + "testing" + "time" + + "github.com/99designs/keyring" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/app" + simapp "github.com/provenance-io/provenance/app" + "github.com/provenance-io/provenance/x/oracle/keeper" + "github.com/provenance-io/provenance/x/oracle/types" + "github.com/stretchr/testify/suite" + + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +type KeeperTestSuite struct { + suite.Suite + + app *simapp.App + ctx sdk.Context + queryClient types.QueryClient + msgServer types.MsgServer + + accountAddr sdk.AccAddress + accountKey *secp256k1.PrivKey + keyring keyring.Keyring + keyringDir string + accountAddresses []sdk.AccAddress +} + +func (s *KeeperTestSuite) CreateAccounts(number int) { + for i := 0; i < number; i++ { + accountKey := secp256k1.GenPrivKeyFromSecret([]byte(fmt.Sprintf("acc%d", i+2))) + addr, err := sdk.AccAddressFromHexUnsafe(accountKey.PubKey().Address().String()) + s.Require().NoError(err) + s.accountAddr = addr + s.accountAddresses = append(s.accountAddresses, addr) + } +} + +func (s *KeeperTestSuite) SetupTest() { + s.app = app.Setup(s.T()) + s.CreateAccounts(4) + s.msgServer = keeper.NewMsgServerImpl(s.app.OracleKeeper) + s.ctx = s.app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now().UTC()}) + s.ctx = s.ctx.WithBlockHeight(100) + + queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, s.app.OracleKeeper) + s.queryClient = types.NewQueryClient(queryHelper) +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} From 386756278eadddee09b55635eb42405db99ee825 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 8 Aug 2023 22:57:26 -0400 Subject: [PATCH 43/96] Added tests for the query_server. Did not do QueryState since it's being removed. Still have to update it to include the response in the events. --- x/oracle/keeper/mocks_test.go | 63 +++++++++++++ x/oracle/keeper/query_server_test.go | 130 +++++++++++++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 x/oracle/keeper/mocks_test.go create mode 100644 x/oracle/keeper/query_server_test.go diff --git a/x/oracle/keeper/mocks_test.go b/x/oracle/keeper/mocks_test.go new file mode 100644 index 0000000000..3597057732 --- /dev/null +++ b/x/oracle/keeper/mocks_test.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "context" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" +) + +// This file is available only to unit tests and exposes private things +// so that they can be used in unit tests. + +type MockWasmServer struct { +} + +func (k *Keeper) SetWasmQueryServer(server wasmtypes.QueryServer) { + k.wasmQueryServer = server +} + +func (m MockWasmServer) ContractInfo(context.Context, *wasmtypes.QueryContractInfoRequest) (*wasmtypes.QueryContractInfoResponse, error) { + return nil, nil +} + +func (m MockWasmServer) ContractHistory(context.Context, *wasmtypes.QueryContractHistoryRequest) (*wasmtypes.QueryContractHistoryResponse, error) { + return nil, nil +} + +func (m MockWasmServer) ContractsByCode(context.Context, *wasmtypes.QueryContractsByCodeRequest) (*wasmtypes.QueryContractsByCodeResponse, error) { + return nil, nil +} + +func (m MockWasmServer) AllContractState(context.Context, *wasmtypes.QueryAllContractStateRequest) (*wasmtypes.QueryAllContractStateResponse, error) { + return nil, nil +} + +func (m MockWasmServer) RawContractState(context.Context, *wasmtypes.QueryRawContractStateRequest) (*wasmtypes.QueryRawContractStateResponse, error) { + return nil, nil +} + +func (m MockWasmServer) SmartContractState(context.Context, *wasmtypes.QuerySmartContractStateRequest) (*wasmtypes.QuerySmartContractStateResponse, error) { + return &wasmtypes.QuerySmartContractStateResponse{ + Data: []byte("{}"), + }, nil +} + +func (m MockWasmServer) Code(context.Context, *wasmtypes.QueryCodeRequest) (*wasmtypes.QueryCodeResponse, error) { + return nil, nil +} + +func (m MockWasmServer) Codes(context.Context, *wasmtypes.QueryCodesRequest) (*wasmtypes.QueryCodesResponse, error) { + return nil, nil +} + +func (m MockWasmServer) PinnedCodes(context.Context, *wasmtypes.QueryPinnedCodesRequest) (*wasmtypes.QueryPinnedCodesResponse, error) { + return nil, nil +} + +func (m MockWasmServer) Params(context.Context, *wasmtypes.QueryParamsRequest) (*wasmtypes.QueryParamsResponse, error) { + return nil, nil +} + +func (m MockWasmServer) ContractsByCreator(context.Context, *wasmtypes.QueryContractsByCreatorRequest) (*wasmtypes.QueryContractsByCreatorResponse, error) { + return nil, nil +} diff --git a/x/oracle/keeper/query_server_test.go b/x/oracle/keeper/query_server_test.go new file mode 100644 index 0000000000..dddb1648cf --- /dev/null +++ b/x/oracle/keeper/query_server_test.go @@ -0,0 +1,130 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/keeper" + "github.com/provenance-io/provenance/x/oracle/types" +) + +func (s *KeeperTestSuite) TestOracleAddress() { + tests := []struct { + name string + req *types.QueryOracleAddressRequest + expected *types.QueryOracleAddressResponse + oracle string + err string + }{ + { + name: "failure - should handle nil request", + req: nil, + expected: nil, + err: "rpc error: code = InvalidArgument desc = invalid request", + }, + { + name: "failure - should throw error when missing oracle address", + req: &types.QueryOracleAddressRequest{}, + expected: nil, + err: types.ErrMissingOracleAddress.Error(), + }, + { + name: "success - should throw error when missing oracle address", + req: &types.QueryOracleAddressRequest{}, + oracle: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + expected: &types.QueryOracleAddressResponse{Address: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"}, + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + if len(tc.oracle) > 0 { + s.app.OracleKeeper.SetOracle(s.ctx, sdk.MustAccAddressFromBech32(tc.oracle)) + } + resp, err := s.app.OracleKeeper.OracleAddress(s.ctx, tc.req) + if len(tc.err) > 0 { + s.Assert().EqualError(err, tc.err, "should return the correct error") + s.Assert().Nil(resp, "response should be nil") + } else { + s.Assert().NoError(err, "should not return an error") + s.Assert().Equal(tc.expected, resp, "should return the correct response") + } + }) + } +} + +func (s *KeeperTestSuite) TestOracle() { + tests := []struct { + name string + req *types.QueryOracleRequest + expected *types.QueryOracleResponse + oracle string + mockEnabled bool + err string + }{ + { + name: "failure - should handle nil request", + req: nil, + err: "rpc error: code = InvalidArgument desc = invalid request", + }, + { + name: "failure - should handle invalid query data", + req: &types.QueryOracleRequest{ + Query: []byte("abc"), + }, + err: "rpc error: code = InvalidArgument desc = invalid query data", + }, + { + name: "failure - should handle unset oracle", + req: &types.QueryOracleRequest{ + Query: []byte("{}"), + }, + err: "missing oracle address", + }, + { + name: "success - should handle error from contract", + req: &types.QueryOracleRequest{ + Query: []byte("{}"), + }, + err: "missing oracle address", + }, + { + name: "failure - should handle error from contract", + req: &types.QueryOracleRequest{ + Query: []byte("{}"), + }, + oracle: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + err: "contract: not found", + }, + { + name: "success - should handle response from contract", + req: &types.QueryOracleRequest{ + Query: []byte("{}"), + }, + oracle: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + expected: &types.QueryOracleResponse{ + Data: []byte("{}"), + }, + mockEnabled: true, + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + if tc.mockEnabled { + s.app.OracleKeeper.SetWasmQueryServer(keeper.MockWasmServer{}) + } + + if len(tc.oracle) > 0 { + s.app.OracleKeeper.SetOracle(s.ctx, sdk.MustAccAddressFromBech32(tc.oracle)) + } + + resp, err := s.app.OracleKeeper.Oracle(s.ctx, tc.req) + if len(tc.err) > 0 { + s.Assert().EqualError(err, tc.err, "should return the correct error") + s.Assert().Nil(resp, "response should be nil") + } else { + s.Assert().NoError(err, "should not return an error") + s.Assert().Equal(tc.expected, resp, "should return the correct response") + } + }) + } +} From e5f36058cf97f254b8deb1d1183ff45de3b73f3d Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 9 Aug 2023 09:00:07 -0400 Subject: [PATCH 44/96] Added tests for query. --- x/oracle/keeper/query_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 x/oracle/keeper/query_test.go diff --git a/x/oracle/keeper/query_test.go b/x/oracle/keeper/query_test.go new file mode 100644 index 0000000000..26622f04f4 --- /dev/null +++ b/x/oracle/keeper/query_test.go @@ -0,0 +1,9 @@ +package keeper_test + +func (s *KeeperTestSuite) TestSetGetLastQueryPacketSeq() { + sequence := s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx) + s.Assert().Equal(int(1), int(sequence), "should have the correct initial sequence") + s.app.OracleKeeper.SetLastQueryPacketSeq(s.ctx, 5) + sequence = s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx) + s.Assert().Equal(int(5), int(sequence), "should have the correct updated sequence") +} From 2ff17e69612bda670732332a5d9d2e1a584d8238 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 9 Aug 2023 11:35:47 -0400 Subject: [PATCH 45/96] Added tests for message server, and added mocks to properly mock keepers. --- app/app.go | 4 +- x/oracle/keeper/keeper.go | 5 +- x/oracle/keeper/keeper_test.go | 2 +- x/oracle/keeper/mocks_test.go | 62 ++++++++++++++ x/oracle/keeper/msg_server.go | 4 +- x/oracle/keeper/msg_server_test.go | 132 +++++++++++++++++++++++++++++ x/oracle/module/module.go | 6 +- x/oracle/types/expected_keepers.go | 9 +- 8 files changed, 212 insertions(+), 12 deletions(-) create mode 100644 x/oracle/keeper/msg_server_test.go diff --git a/app/app.go b/app/app.go index 6ad0f8086d..d226b8c441 100644 --- a/app/app.go +++ b/app/app.go @@ -585,7 +585,7 @@ func New( scopedOracleKeeper, wasmkeeper.Querier(&app.WasmKeeper), ) - oracleModule := oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper) + oracleModule := oraclemodule.NewAppModule(appCodec, &app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper) unsanctionableAddrs := make([]sdk.AccAddress, 0, len(maccPerms)+1) for mName := range maccPerms { @@ -873,7 +873,7 @@ func New( msgfeesmodule.NewAppModule(appCodec, app.MsgFeesKeeper, app.interfaceRegistry), rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper), triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper), - oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper), + oraclemodule.NewAppModule(appCodec, &app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper), provwasm.NewWrapper(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper), ibc.NewAppModule(app.IBCKeeper), diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 3b4252c289..f7124dfd32 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -8,7 +8,6 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -25,7 +24,7 @@ type Keeper struct { ics4Wrapper types.ICS4Wrapper channelKeeper types.ChannelKeeper portKeeper types.PortKeeper - scopedKeeper capabilitykeeper.ScopedKeeper + scopedKeeper types.ScopedKeeper wasmQueryServer wasmtypes.QueryServer // the signing authority for the gov proposals @@ -40,7 +39,7 @@ func NewKeeper( ics4Wrapper types.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, - scopedKeeper capabilitykeeper.ScopedKeeper, + scopedKeeper types.ScopedKeeper, wasmQueryServer wasmtypes.QueryServer, ) *Keeper { diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index 6e658f88ce..93ae2ef28d 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -46,7 +46,7 @@ func (s *KeeperTestSuite) CreateAccounts(number int) { func (s *KeeperTestSuite) SetupTest() { s.app = app.Setup(s.T()) s.CreateAccounts(4) - s.msgServer = keeper.NewMsgServerImpl(s.app.OracleKeeper) + s.msgServer = keeper.NewMsgServerImpl(&s.app.OracleKeeper) s.ctx = s.app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now().UTC()}) s.ctx = s.ctx.WithBlockHeight(100) diff --git a/x/oracle/keeper/mocks_test.go b/x/oracle/keeper/mocks_test.go index 3597057732..ba7792c82e 100644 --- a/x/oracle/keeper/mocks_test.go +++ b/x/oracle/keeper/mocks_test.go @@ -4,6 +4,11 @@ import ( "context" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + "github.com/provenance-io/provenance/x/oracle/types" ) // This file is available only to unit tests and exposes private things @@ -61,3 +66,60 @@ func (m MockWasmServer) Params(context.Context, *wasmtypes.QueryParamsRequest) ( func (m MockWasmServer) ContractsByCreator(context.Context, *wasmtypes.QueryContractsByCreatorRequest) (*wasmtypes.QueryContractsByCreatorResponse, error) { return nil, nil } + +type MockICS4Wrapper struct { + counter uint64 +} + +func (k *Keeper) SetMockICS4Wrapper(ics4wrapper types.ICS4Wrapper) { + k.ics4Wrapper = ics4wrapper +} + +func (k MockICS4Wrapper) SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + data []byte, +) (sequence uint64, err error) { + k.counter += 1 + return k.counter, nil +} + +type MockChannelKeeper struct { + counter uint64 +} + +func (k *Keeper) SetMockChannelKeeper(channelKeeper types.ChannelKeeper) { + k.channelKeeper = channelKeeper +} + +func (m MockChannelKeeper) GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) { + return channeltypes.Channel{}, true +} + +func (m MockChannelKeeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) { + m.counter++ + return m.counter, true +} + +type MockScopedKeeper struct { +} + +func (k *Keeper) SetMockScopedKeeper(scopedKeeper types.ScopedKeeper) { + k.scopedKeeper = scopedKeeper +} + +func (m MockScopedKeeper) GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) { + return &capabilitytypes.Capability{}, true +} + +func (m MockScopedKeeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { + return true +} + +func (m MockScopedKeeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { + return nil +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 0864e799e1..29e76c662c 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -9,12 +9,12 @@ import ( ) type msgServer struct { - Keeper + *Keeper } // NewMsgServerImpl returns an implementation of the account MsgServer interface // for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { +func NewMsgServerImpl(keeper *Keeper) types.MsgServer { return &msgServer{Keeper: keeper} } diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go new file mode 100644 index 0000000000..694245ef10 --- /dev/null +++ b/x/oracle/keeper/msg_server_test.go @@ -0,0 +1,132 @@ +package keeper_test + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/keeper" + "github.com/provenance-io/provenance/x/oracle/types" +) + +func (s *KeeperTestSuite) TestUpdateOracle() { + authority := s.app.OracleKeeper.GetAuthority() + event := sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ) + + tests := []struct { + name string + req *types.MsgUpdateOracleRequest + res *types.MsgUpdateOracleResponse + event *sdk.Event + err string + }{ + { + name: "failure - authority does not match module authority", + req: &types.MsgUpdateOracleRequest{ + Address: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + Authority: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + }, + res: nil, + err: fmt.Sprintf("expected authority %s got cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma: unauthorized", authority), + }, + { + name: "success - oracle is updated", + req: &types.MsgUpdateOracleRequest{ + Address: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + Authority: authority, + }, + res: &types.MsgUpdateOracleResponse{}, + event: &event, + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + res, err := s.msgServer.UpdateOracle(s.ctx, tc.req) + + if tc.event != nil { + s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events") + s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event") + } else { + s.Assert().Equal(0, len(s.ctx.EventManager().Events()), "should not emit events") + } + + if len(tc.err) > 0 { + s.Assert().Nil(res, "should have nil response") + s.Assert().EqualError(err, tc.err, "should have correct error") + } else { + s.Assert().NoError(err, "should not have error") + s.Assert().Equal(tc.res, res, "should have the correct response") + } + }) + } +} + +func (s *KeeperTestSuite) TestSendQueryOracle() { + event := sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ) + + s.app.OracleKeeper.SetMockICS4Wrapper(keeper.MockICS4Wrapper{}) + s.app.OracleKeeper.SetMockScopedKeeper(keeper.MockScopedKeeper{}) + + tests := []struct { + name string + req *types.MsgSendQueryOracleRequest + res *types.MsgSendQueryOracleResponse + event *sdk.Event + err string + mockChannel bool + }{ + { + name: "failure - a packet should not be sent on invalid channel", + req: &types.MsgSendQueryOracleRequest{ + Query: []byte("{}"), + Channel: "invalid-channel", + Authority: "authority", + }, + res: nil, + err: "port ID (oracle) channel ID (invalid-channel): channel not found", + }, + { + name: "success - a packet should be sent", + req: &types.MsgSendQueryOracleRequest{ + Query: []byte("{}"), + Channel: "channel-1", + Authority: "authority", + }, + res: &types.MsgSendQueryOracleResponse{ + Sequence: 1, + }, + event: &event, + mockChannel: true, + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + if tc.mockChannel { + s.app.OracleKeeper.SetMockChannelKeeper(keeper.MockChannelKeeper{}) + } + res, err := s.msgServer.SendQueryOracle(s.ctx, tc.req) + + if tc.event != nil { + s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events") + s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event") + } else { + s.Assert().Equal(0, len(s.ctx.EventManager().Events()), "should not emit events") + } + + if len(tc.err) > 0 { + s.Assert().Nil(res, "should have nil response") + s.Assert().EqualError(err, tc.err, "should have correct error") + } else { + s.Assert().NoError(err, "should not have error") + s.Assert().Equal(tc.res, res, "should have the correct response") + } + }) + } +} diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index c786a47a08..983bf7f4cd 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -90,14 +90,14 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { // AppModule implements the sdk.AppModule interface type AppModule struct { AppModuleBasic - keeper keeper.Keeper + keeper *keeper.Keeper accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper channelKeeper channelkeeper.Keeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, channelKeeper channelkeeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, channelKeeper channelkeeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, @@ -132,7 +132,7 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { // WeightedOperations returns simulation operations (i.e msgs) with their respective weight func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, am.keeper, am.accountKeeper, am.bankKeeper, am.channelKeeper, + simState.AppParams, simState.Cdc, *am.keeper, am.accountKeeper, am.bankKeeper, am.channelKeeper, ) } diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go index f620058838..16a7ee1883 100644 --- a/x/oracle/types/expected_keepers.go +++ b/x/oracle/types/expected_keepers.go @@ -20,7 +20,7 @@ type ICS4Wrapper interface { ) (sequence uint64, err error) } -// PortKeeper defines the expected IBC channel keeper +// Channel defines the expected IBC channel keeper type ChannelKeeper interface { GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) @@ -31,3 +31,10 @@ type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability IsBound(ctx sdk.Context, portID string) bool } + +// ScopedKeeper defines the expected x/capability scoped keeper interface +type ScopedKeeper interface { + GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) + AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool + ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error +} From b695a8e48d8b2f8e9461b7ac93d1444f7e78a0dc Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 9 Aug 2023 12:24:35 -0400 Subject: [PATCH 46/96] Added icq query tests. Updated channel keeper mock to have pointer receivers to update seq numbers --- x/oracle/keeper/icq_test.go | 68 ++++++++++++++++++++++++++++++ x/oracle/keeper/mocks_test.go | 6 +-- x/oracle/keeper/msg_server_test.go | 2 +- 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 x/oracle/keeper/icq_test.go diff --git a/x/oracle/keeper/icq_test.go b/x/oracle/keeper/icq_test.go new file mode 100644 index 0000000000..cb006bc79b --- /dev/null +++ b/x/oracle/keeper/icq_test.go @@ -0,0 +1,68 @@ +package keeper_test + +import ( + "github.com/provenance-io/provenance/x/oracle/keeper" +) + +func (s *KeeperTestSuite) TestQueryOracle() { + tests := []struct { + name string + query []byte + channel string + sequence uint64 + err string + setMocks bool + setIcs4Mock bool + }{ + { + name: "failure - missing channel capability", + query: []byte("{}"), + channel: "invalid", + sequence: 0, + err: "module does not own channel capability: channel capability not found", + }, + { + name: "failure - unable to send", + query: []byte("{}"), + channel: "channel-1", + sequence: 0, + err: "channel-1: channel not found", + setMocks: true, + }, + { + name: "success - should send a packet", + query: []byte("{}"), + channel: "channel-1", + sequence: 2, + setIcs4Mock: true, + }, + { + name: "success - should send a packet with the next sequence", + query: []byte("{}"), + channel: "channel-1", + sequence: 3, + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + if tc.setMocks { + s.app.OracleKeeper.SetMockScopedKeeper(keeper.MockScopedKeeper{}) + s.app.OracleKeeper.SetMockChannelKeeper(&keeper.MockChannelKeeper{}) + } + if tc.setIcs4Mock { + s.app.OracleKeeper.SetMockICS4Wrapper(keeper.MockICS4Wrapper{}) + } + sequence, err := s.app.OracleKeeper.QueryOracle(s.ctx, tc.query, tc.channel) + s.Assert().Equal(int(tc.sequence), int(sequence), "should have correct sequence") + if len(tc.err) > 0 { + s.Assert().EqualError(err, tc.err, "should have the correct error") + + } else { + s.Assert().Nil(err, "should have nil error") + s.Assert().Equal(int(tc.sequence), int(sequence), "should have correct sequence") + } + + }) + } +} diff --git a/x/oracle/keeper/mocks_test.go b/x/oracle/keeper/mocks_test.go index ba7792c82e..3ac532e587 100644 --- a/x/oracle/keeper/mocks_test.go +++ b/x/oracle/keeper/mocks_test.go @@ -96,12 +96,12 @@ func (k *Keeper) SetMockChannelKeeper(channelKeeper types.ChannelKeeper) { k.channelKeeper = channelKeeper } -func (m MockChannelKeeper) GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) { +func (m *MockChannelKeeper) GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) { return channeltypes.Channel{}, true } -func (m MockChannelKeeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) { - m.counter++ +func (m *MockChannelKeeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) { + m.counter += 1 return m.counter, true } diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index 694245ef10..ffcb8dbd1f 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -109,7 +109,7 @@ func (s *KeeperTestSuite) TestSendQueryOracle() { for _, tc := range tests { s.Run(tc.name, func() { if tc.mockChannel { - s.app.OracleKeeper.SetMockChannelKeeper(keeper.MockChannelKeeper{}) + s.app.OracleKeeper.SetMockChannelKeeper(&keeper.MockChannelKeeper{}) } res, err := s.msgServer.SendQueryOracle(s.ctx, tc.req) From ce2cd364ad77a82dd6b3a694554a4df133574c43 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 9 Aug 2023 16:01:30 -0400 Subject: [PATCH 47/96] Finished tests for relay.go --- x/oracle/keeper/relay_test.go | 191 ++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 x/oracle/keeper/relay_test.go diff --git a/x/oracle/keeper/relay_test.go b/x/oracle/keeper/relay_test.go new file mode 100644 index 0000000000..dcefbeefa8 --- /dev/null +++ b/x/oracle/keeper/relay_test.go @@ -0,0 +1,191 @@ +package keeper_test + +import ( + "fmt" + "strconv" + + "github.com/cosmos/cosmos-sdk/codec" + sdktypes "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + proto "github.com/gogo/protobuf/proto" + "github.com/provenance-io/provenance/x/oracle/keeper" + "github.com/provenance-io/provenance/x/oracle/types" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +func (s *KeeperTestSuite) TestSendQuery() { + tests := []struct { + name string + err string + sequence uint64 + req []abci.RequestQuery + enableMocks bool + }{ + { + name: "failure - invalid channel", + err: "port ID (port) channel ID (channel): channel not found", + sequence: 0, + req: nil, + }, + { + name: "success - valid send query", + sequence: 1, + req: []abci.RequestQuery{{Data: []byte("{}")}}, + enableMocks: true, + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + if tc.enableMocks { + s.app.OracleKeeper.SetMockChannelKeeper(&keeper.MockChannelKeeper{}) + s.app.OracleKeeper.SetMockICS4Wrapper(&keeper.MockICS4Wrapper{}) + } + sequence, err := s.app.OracleKeeper.SendQuery(s.ctx, "port", "channel", nil, tc.req, clienttypes.ZeroHeight(), 0) + if len(tc.err) > 0 { + s.Assert().Equal(int(tc.sequence), int(sequence), "should have correct sequence number") + s.Assert().EqualError(err, tc.err, "should have correct error") + } else { + s.Assert().Equal(int(tc.sequence), int(sequence), "should have correct sequence number") + s.Assert().Nil(err, "should have no error") + } + }) + } +} + +func (s *KeeperTestSuite) TestOnAcknowledgementPacket() { + wasmError := sdkerrors.New("codespace", 2, "jackthecat ran away") + _, code, _ := sdkerrors.ABCIInfo(wasmError, false) + + tests := []struct { + name string + ack channeltypes.Acknowledgement + packet channeltypes.Packet + event proto.Message + err string + }{ + { + name: "success - error event is emitted on ack error", + ack: channeltypes.NewErrorAcknowledgement(wasmError), + packet: channeltypes.Packet{Sequence: 5}, + event: &types.EventOracleQueryError{ + SequenceId: strconv.FormatUint(5, 10), + Error: fmt.Sprintf("ABCI code: %d: %s", code, "error handling packet: see events for details"), + }, + }, + { + name: "success - success event is emitted on ack", + ack: channeltypes.NewResultAcknowledgement(createICQResponse(s.app.AppCodec(), "{}")), + packet: channeltypes.Packet{Sequence: 5}, + event: &types.EventOracleQuerySuccess{ + SequenceId: strconv.FormatUint(5, 10), + Result: "{\"data\":\"CgY6BAoCe30=\"}", + }, + }, + { + name: "failure - invalid icq packet ack in result ack", + ack: channeltypes.NewResultAcknowledgement([]byte("baddata")), + packet: channeltypes.Packet{Sequence: 5}, + event: nil, + err: "failed to unmarshal interchain query packet ack: invalid character 'b' looking for beginning of value", + }, + { + name: "failure - invalid cosmos response in icq packet ack", + ack: channeltypes.NewResultAcknowledgement(createInvalidICQPacketAck()), + packet: channeltypes.Packet{Sequence: 5}, + event: nil, + err: "could not deserialize data to cosmos response: unexpected EOF", + }, + { + name: "failure - empty cosmos response in icq packet ack", + ack: channeltypes.NewResultAcknowledgement(createEmptyICQPacketAck()), + packet: channeltypes.Packet{Sequence: 5}, + event: nil, + err: "no responses in interchain query packet ack: invalid request", + }, + { + name: "failure - invalid query response in cosmos response", + ack: channeltypes.NewResultAcknowledgement(createInvalidCosmosResponse()), + packet: channeltypes.Packet{Sequence: 5}, + event: nil, + err: "failed to unmarshal interchain query response to type *types.Acknowledgement_Result: unexpected EOF", + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + s.ctx = s.ctx.WithEventManager(sdktypes.NewEventManager()) + err := s.app.OracleKeeper.OnAcknowledgementPacket(s.ctx, tc.packet, tc.ack) + + if len(tc.err) > 0 { + s.Assert().EqualError(err, tc.err, "should return expected error") + } else { + s.Assert().NoError(err, "should not return error") + event, _ := sdktypes.TypedEventToEvent(tc.event) + events := s.ctx.EventManager().Events() + s.Assert().Equal(event, events[0], "should emit correct event") + } + }) + } +} + +func (s *KeeperTestSuite) TestOnTimeoutPacket() { + packet := channeltypes.Packet{Sequence: 5} + err := s.app.OracleKeeper.OnTimeoutPacket(s.ctx, packet) + event, _ := sdktypes.TypedEventToEvent(&types.EventOracleQueryTimeout{ + SequenceId: strconv.FormatUint(5, 10), + }) + s.Assert().NoError(err, "should not throw an error") + emitted := s.ctx.EventManager().Events() + s.Assert().Equal(event, emitted[0], "timeout event should be emitted") +} + +func createICQResponse(cdc codec.Codec, response string) []byte { + 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 { + icqPacket := icqtypes.InterchainQueryPacketAck{ + Data: []byte("abc"), + } + icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) + return icqBytes +} + +func createEmptyICQPacketAck() []byte { + bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{}) + + icqPacket := icqtypes.InterchainQueryPacketAck{ + Data: bytes, + } + + icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) + return icqBytes +} + +func createInvalidCosmosResponse() []byte { + bytes, _ := icqtypes.SerializeCosmosResponse([]abci.ResponseQuery{{ + Value: []byte("baddata"), + }}) + + icqPacket := icqtypes.InterchainQueryPacketAck{ + Data: bytes, + } + icqBytes, _ := icqtypes.ModuleCdc.MarshalJSON(&icqPacket) + return icqBytes +} From 5afab1b1797b0071cf6a19ea5928c5b8f8831329 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 9 Aug 2023 16:40:09 -0400 Subject: [PATCH 48/96] Removed storing query request and response in state and just have the response in the event. Also added the local channel on each event to help improve identification of where these packets come from in events. --- docs/proto-docs.md | 37 +- proto/provenance/oracle/v1/event.proto | 16 +- proto/provenance/oracle/v1/query.proto | 16 - x/oracle/client/cli/query.go | 43 --- x/oracle/keeper/icq.go | 1 - x/oracle/keeper/query.go | 39 -- x/oracle/keeper/query_server.go | 33 -- x/oracle/keeper/relay.go | 4 +- x/oracle/keeper/relay_test.go | 9 +- x/oracle/simulation/decoder.go | 14 - x/oracle/types/event.pb.go | 203 ++++++++-- x/oracle/types/keys.go | 27 +- x/oracle/types/keys_test.go | 13 - x/oracle/types/query.pb.go | 500 ++----------------------- x/oracle/types/query.pb.gw.go | 80 ---- 15 files changed, 238 insertions(+), 797 deletions(-) diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 9990d71e94..1990f17f2b 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -446,8 +446,6 @@ - [QueryOracleAddressResponse](#provenance.oracle.v1.QueryOracleAddressResponse) - [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) - [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) - - [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) - - [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) - [Query](#provenance.oracle.v1.Query) @@ -6688,6 +6686,7 @@ EventOracleQueryError is an event for when the chain receives an error response | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | +| `channel` | [string](#string) | | channel is the local channel that the oracle query response was received from | | `sequence_id` | [string](#string) | | sequence_id is a unique identifier of the query | | `error` | [string](#string) | | error is the error message received from the query | @@ -6704,6 +6703,7 @@ EventOracleQuerySuccess is an event for when the chain receives a successful res | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | +| `channel` | [string](#string) | | channel is the local channel that the oracle query response was received from | | `sequence_id` | [string](#string) | | sequence_id is a unique identifier of the query | | `result` | [string](#string) | | result is the data received from the query | @@ -6720,6 +6720,7 @@ EventOracleQueryTimeout is an event for when the chain receives a timeout from a | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | +| `channel` | [string](#string) | | channel is the local channel that the oracle timeout was received from | | `sequence_id` | [string](#string) | | sequence_id is a unique identifier of the query | @@ -6856,37 +6857,6 @@ QueryOracleResponse contains the result of the query sent to the oracle. - - - -### QueryQueryStateRequest -QueryQueryStateRequest queries for the state of the ICQ. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `sequence` | [uint64](#uint64) | | | - - - - - - - - -### QueryQueryStateResponse -QueryQueryStateResponse contains the ICQ and its response. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `request` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `response` | [google.protobuf.Any](#google.protobuf.Any) | | | - - - - - @@ -6903,7 +6873,6 @@ Query defines the gRPC querier service for oracle module. | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `OracleAddress` | [QueryOracleAddressRequest](#provenance.oracle.v1.QueryOracleAddressRequest) | [QueryOracleAddressResponse](#provenance.oracle.v1.QueryOracleAddressResponse) | OracleAddress returns the address of the oracle | GET|/provenance/oracle/v1/oracle_address| | `Oracle` | [QueryOracleRequest](#provenance.oracle.v1.QueryOracleRequest) | [QueryOracleResponse](#provenance.oracle.v1.QueryOracleResponse) | Oracle forwards a query to the module's oracle | GET|/provenance/oracle/v1/oracle| -| `QueryState` | [QueryQueryStateRequest](#provenance.oracle.v1.QueryQueryStateRequest) | [QueryQueryStateResponse](#provenance.oracle.v1.QueryQueryStateResponse) | QueryState returns the state of the oracle query | GET|/provenance/oracle/v1/query_state| diff --git a/proto/provenance/oracle/v1/event.proto b/proto/provenance/oracle/v1/event.proto index bdce520a9d..3327a19b14 100644 --- a/proto/provenance/oracle/v1/event.proto +++ b/proto/provenance/oracle/v1/event.proto @@ -8,22 +8,28 @@ option java_multiple_files = true; // EventOracleQuerySuccess is an event for when the chain receives a successful response from an oracle query message EventOracleQuerySuccess { + // channel is the local channel that the oracle query response was received from + string channel = 1; // sequence_id is a unique identifier of the query - string sequence_id = 1; + string sequence_id = 2; // result is the data received from the query - string result = 2; + string result = 3; } // EventOracleQueryError is an event for when the chain receives an error response from an oracle query message EventOracleQueryError { + // channel is the local channel that the oracle query response was received from + string channel = 1; // sequence_id is a unique identifier of the query - string sequence_id = 1; + string sequence_id = 2; // error is the error message received from the query - string error = 2; + string error = 3; } // EventOracleQueryTimeout is an event for when the chain receives a timeout from an oracle query message EventOracleQueryTimeout { + // channel is the local channel that the oracle timeout was received from + string channel = 1; // sequence_id is a unique identifier of the query - string sequence_id = 1; + string sequence_id = 2; } \ No newline at end of file diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index 43397366c3..3aa7b65d1c 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -21,22 +21,6 @@ service Query { rpc Oracle(QueryOracleRequest) returns (QueryOracleResponse) { option (google.api.http).get = "/provenance/oracle/v1/oracle"; } - - // QueryState returns the state of the oracle query - rpc QueryState(QueryQueryStateRequest) returns (QueryQueryStateResponse) { - option (google.api.http).get = "/provenance/oracle/v1/query_state"; - } -} - -// QueryQueryStateRequest queries for the state of the ICQ. -message QueryQueryStateRequest { - uint64 sequence = 1; -} - -// QueryQueryStateResponse contains the ICQ and its response. -message QueryQueryStateResponse { - google.protobuf.Any request = 1 [(gogoproto.nullable) = false]; - google.protobuf.Any response = 2 [(gogoproto.nullable) = true]; } // QueryOracleAddressRequest queries for the address of the oracle. diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index 8280675c9a..897b4c82bf 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -3,7 +3,6 @@ package cli import ( "context" "fmt" - "strconv" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -22,53 +21,11 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } queryCmd.AddCommand( - GetQueryStateCmd(), GetQueryOracleAddressCmd(), ) return queryCmd } -var _ = strconv.Itoa(0) - -// GetQueryStateCmd queries for the state of an existing oracle query -func GetQueryStateCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "query-state [sequence]", - Short: "Returns the request and response of an ICQ query given the packet sequence", - Args: cobra.ExactArgs(1), - Aliases: []string{"qs", "state"}, - Example: fmt.Sprintf(`%[1]s q oracle query-state 1`, version.AppName), - RunE: func(cmd *cobra.Command, args []string) (err error) { - - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - sequence, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return fmt.Errorf("invalid sequence: %w", err) - } - params := &types.QueryQueryStateRequest{ - Sequence: sequence, - } - - res, err := queryClient.QueryState(context.Background(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - // GetQueryOracleAddressCmd queries for the module's oracle address func GetQueryOracleAddressCmd() *cobra.Command { cmd := &cobra.Command{ diff --git a/x/oracle/keeper/icq.go b/x/oracle/keeper/icq.go index bb17308101..ed35712757 100644 --- a/x/oracle/keeper/icq.go +++ b/x/oracle/keeper/icq.go @@ -37,6 +37,5 @@ func (k Keeper) QueryOracle(ctx sdk.Context, query wasmtypes.RawContractMessage, return 0, err } - k.SetQueryRequest(ctx, seq, q) return seq, nil } diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go index 0d5cd5f942..2c3d509b4a 100644 --- a/x/oracle/keeper/query.go +++ b/x/oracle/keeper/query.go @@ -2,49 +2,10 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" gogotypes "github.com/gogo/protobuf/types" "github.com/provenance-io/provenance/x/oracle/types" ) -// SetQueryRequest saves the query request -func (k Keeper) SetQueryRequest(ctx sdk.Context, packetSequence uint64, req types.QueryOracleRequest) { - store := ctx.KVStore(k.storeKey) - store.Set(types.GetQueryRequestStoreKey(packetSequence), k.cdc.MustMarshal(&req)) -} - -// GetQueryRequest returns the query request by packet sequence -func (k Keeper) GetQueryRequest(ctx sdk.Context, packetSequence uint64) (types.QueryOracleRequest, error) { - bz := ctx.KVStore(k.storeKey).Get(types.GetQueryRequestStoreKey(packetSequence)) - if bz == nil { - return types.QueryOracleRequest{}, sdkerrors.Wrapf(types.ErrSample, - "GetQueryRequest: Result for packet sequence %d is not available.", packetSequence, - ) - } - var req types.QueryOracleRequest - k.cdc.MustUnmarshal(bz, &req) - return req, nil -} - -// SetQueryResponse saves the query response -func (k Keeper) SetQueryResponse(ctx sdk.Context, packetSequence uint64, resp types.QueryOracleResponse) { - store := ctx.KVStore(k.storeKey) - store.Set(types.GetQueryResponseStoreKey(packetSequence), k.cdc.MustMarshal(&resp)) -} - -// GetQueryResponse returns the query response by packet sequence -func (k Keeper) GetQueryResponse(ctx sdk.Context, packetSequence uint64) (types.QueryOracleResponse, error) { - bz := ctx.KVStore(k.storeKey).Get(types.GetQueryResponseStoreKey(packetSequence)) - if bz == nil { - return types.QueryOracleResponse{}, sdkerrors.Wrapf(types.ErrSample, - "GetQueryResponse: Result for packet sequence %d is not available.", packetSequence, - ) - } - var resp types.QueryOracleResponse - k.cdc.MustUnmarshal(bz, &resp) - return resp, nil -} - // GetLastQueryPacketSeq return the id from the last query request func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { bz := ctx.KVStore(k.storeKey).Get(types.GetLastQueryPacketSeqKey()) diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 7511c7ca63..5caf3cc6eb 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -4,7 +4,6 @@ import ( "context" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/provenance-io/provenance/x/oracle/types" "google.golang.org/grpc/codes" @@ -52,35 +51,3 @@ func (k Keeper) Oracle(goCtx context.Context, req *types.QueryOracleRequest) (*t } return &types.QueryOracleResponse{Data: resp.Data}, nil } - -// QueryState gets the state of an icq -func (k Keeper) QueryState(goCtx context.Context, req *types.QueryQueryStateRequest) (*types.QueryQueryStateResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - qreq, err := k.GetQueryRequest(ctx, req.Sequence) - if err != nil { - return nil, status.Error(codes.NotFound, err.Error()) - } - - var anyQResp *cdctypes.Any - qresp, err := k.GetQueryResponse(ctx, req.Sequence) - if err == nil { - anyQResp, err = cdctypes.NewAnyWithValue(&qresp) - if err != nil { - panic(err) - } - } - - anyQReq, err := cdctypes.NewAnyWithValue(&qreq) - if err != nil { - panic(err) - } - return &types.QueryQueryStateResponse{ - Request: *anyQReq, - Response: anyQResp, - }, nil -} diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index 0e6d2f30d6..ee59f65864 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -107,12 +107,12 @@ func (k Keeper) OnAcknowledgementPacket( return sdkerrors.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) } - k.SetQueryResponse(ctx, modulePacket.Sequence, r) k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) ctx.EventManager().EmitTypedEvent(&types.EventOracleQuerySuccess{ SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), Result: string(resp.Result), + Channel: modulePacket.DestinationChannel, }) k.Logger(ctx).Info("interchain query response", "sequence", modulePacket.Sequence, "response", r) @@ -120,6 +120,7 @@ func (k Keeper) OnAcknowledgementPacket( ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryError{ SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), Error: resp.Error, + Channel: modulePacket.DestinationChannel, }) k.Logger(ctx).Error("interchain query response", "sequence", modulePacket.Sequence, "error", resp.Error) @@ -134,6 +135,7 @@ func (k Keeper) OnTimeoutPacket( ) error { ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryTimeout{ SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), + Channel: modulePacket.DestinationChannel, }) k.Logger(ctx).Error("Packet timeout", "sequence", modulePacket.Sequence) diff --git a/x/oracle/keeper/relay_test.go b/x/oracle/keeper/relay_test.go index dcefbeefa8..a4316d2a75 100644 --- a/x/oracle/keeper/relay_test.go +++ b/x/oracle/keeper/relay_test.go @@ -70,19 +70,21 @@ func (s *KeeperTestSuite) TestOnAcknowledgementPacket() { { name: "success - error event is emitted on ack error", ack: channeltypes.NewErrorAcknowledgement(wasmError), - packet: channeltypes.Packet{Sequence: 5}, + packet: channeltypes.Packet{Sequence: 5, DestinationChannel: "oracle-channel"}, event: &types.EventOracleQueryError{ SequenceId: strconv.FormatUint(5, 10), Error: fmt.Sprintf("ABCI code: %d: %s", code, "error handling packet: see events for details"), + Channel: "oracle-channel", }, }, { name: "success - success event is emitted on ack", ack: channeltypes.NewResultAcknowledgement(createICQResponse(s.app.AppCodec(), "{}")), - packet: channeltypes.Packet{Sequence: 5}, + packet: channeltypes.Packet{Sequence: 5, DestinationChannel: "oracle-channel"}, event: &types.EventOracleQuerySuccess{ SequenceId: strconv.FormatUint(5, 10), Result: "{\"data\":\"CgY6BAoCe30=\"}", + Channel: "oracle-channel", }, }, { @@ -133,10 +135,11 @@ func (s *KeeperTestSuite) TestOnAcknowledgementPacket() { } func (s *KeeperTestSuite) TestOnTimeoutPacket() { - packet := channeltypes.Packet{Sequence: 5} + packet := channeltypes.Packet{Sequence: 5, DestinationChannel: "oracle-channel"} err := s.app.OracleKeeper.OnTimeoutPacket(s.ctx, packet) event, _ := sdktypes.TypedEventToEvent(&types.EventOracleQueryTimeout{ SequenceId: strconv.FormatUint(5, 10), + Channel: "oracle-channel", }) s.Assert().NoError(err, "should not throw an error") emitted := s.ctx.EventManager().Events() diff --git a/x/oracle/simulation/decoder.go b/x/oracle/simulation/decoder.go index ede0175f49..9d0b857cf8 100644 --- a/x/oracle/simulation/decoder.go +++ b/x/oracle/simulation/decoder.go @@ -31,20 +31,6 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { attribB := string(kvB.Value) return fmt.Sprintf("Port: A:[%v] B:[%v]\n", attribA, attribB) - case bytes.Equal(kvA.Key[:1], types.QueryRequestStoreKeyPrefix): - var attribA, attribB types.QueryOracleRequest - - cdc.MustUnmarshal(kvA.Value, &attribA) - cdc.MustUnmarshal(kvB.Value, &attribB) - - return fmt.Sprintf("QueryOracleRequest: A:[%v] B:[%v]\n", attribA, attribB) - case bytes.Equal(kvA.Key[:1], types.QueryResponseStoreKeyPrefix): - var attribA, attribB types.QueryOracleResponse - - cdc.MustUnmarshal(kvA.Value, &attribA) - cdc.MustUnmarshal(kvB.Value, &attribB) - - return fmt.Sprintf("QueryOracleResponse: A:[%v] B:[%v]\n", attribA, attribB) default: panic(fmt.Sprintf("unexpected %s key %X (%s)", types.ModuleName, kvA.Key, kvA.Key)) } diff --git a/x/oracle/types/event.pb.go b/x/oracle/types/event.pb.go index 6bdb745a81..7dd3d9462d 100644 --- a/x/oracle/types/event.pb.go +++ b/x/oracle/types/event.pb.go @@ -24,10 +24,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // EventOracleQuerySuccess is an event for when the chain receives a successful response from an oracle query type EventOracleQuerySuccess struct { + // channel is the local channel that the oracle query response was received from + Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` // sequence_id is a unique identifier of the query - SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` + SequenceId string `protobuf:"bytes,2,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` // result is the data received from the query - Result string `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"` + Result string `protobuf:"bytes,3,opt,name=result,proto3" json:"result,omitempty"` } func (m *EventOracleQuerySuccess) Reset() { *m = EventOracleQuerySuccess{} } @@ -63,6 +65,13 @@ func (m *EventOracleQuerySuccess) XXX_DiscardUnknown() { var xxx_messageInfo_EventOracleQuerySuccess proto.InternalMessageInfo +func (m *EventOracleQuerySuccess) GetChannel() string { + if m != nil { + return m.Channel + } + return "" +} + func (m *EventOracleQuerySuccess) GetSequenceId() string { if m != nil { return m.SequenceId @@ -79,10 +88,12 @@ func (m *EventOracleQuerySuccess) GetResult() string { // EventOracleQueryError is an event for when the chain receives an error response from an oracle query type EventOracleQueryError struct { + // channel is the local channel that the oracle query response was received from + Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` // sequence_id is a unique identifier of the query - SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` + SequenceId string `protobuf:"bytes,2,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` // error is the error message received from the query - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` + Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` } func (m *EventOracleQueryError) Reset() { *m = EventOracleQueryError{} } @@ -118,6 +129,13 @@ func (m *EventOracleQueryError) XXX_DiscardUnknown() { var xxx_messageInfo_EventOracleQueryError proto.InternalMessageInfo +func (m *EventOracleQueryError) GetChannel() string { + if m != nil { + return m.Channel + } + return "" +} + func (m *EventOracleQueryError) GetSequenceId() string { if m != nil { return m.SequenceId @@ -134,8 +152,10 @@ func (m *EventOracleQueryError) GetError() string { // EventOracleQueryTimeout is an event for when the chain receives a timeout from an oracle query type EventOracleQueryTimeout struct { + // channel is the local channel that the oracle timeout was received from + Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` // sequence_id is a unique identifier of the query - SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` + SequenceId string `protobuf:"bytes,2,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"` } func (m *EventOracleQueryTimeout) Reset() { *m = EventOracleQueryTimeout{} } @@ -171,6 +191,13 @@ func (m *EventOracleQueryTimeout) XXX_DiscardUnknown() { var xxx_messageInfo_EventOracleQueryTimeout proto.InternalMessageInfo +func (m *EventOracleQueryTimeout) GetChannel() string { + if m != nil { + return m.Channel + } + return "" +} + func (m *EventOracleQueryTimeout) GetSequenceId() string { if m != nil { return m.SequenceId @@ -187,23 +214,24 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/event.proto", fileDescriptor_e98d10c8454ad24d) } var fileDescriptor_e98d10c8454ad24d = []byte{ - // 241 bytes of a gzipped FileDescriptorProto + // 258 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, - 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x54, 0x0a, 0xe2, 0x12, 0x77, 0x05, 0x29, 0xf2, 0x07, 0x8b, - 0x04, 0x96, 0xa6, 0x16, 0x55, 0x06, 0x97, 0x26, 0x27, 0xa7, 0x16, 0x17, 0x0b, 0xc9, 0x73, 0x71, - 0x17, 0xa7, 0x16, 0x96, 0xa6, 0xe6, 0x25, 0xa7, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, - 0x70, 0x06, 0x71, 0xc1, 0x84, 0x3c, 0x53, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x52, 0x8b, 0x4b, 0x73, - 0x4a, 0x24, 0x98, 0xc0, 0x72, 0x50, 0x9e, 0x92, 0x1f, 0x97, 0x28, 0xba, 0x99, 0xae, 0x45, 0x45, - 0xf9, 0x45, 0x84, 0x4d, 0x14, 0xe1, 0x62, 0x4d, 0x05, 0xa9, 0x84, 0x1a, 0x08, 0xe1, 0x28, 0x59, - 0x61, 0xba, 0x31, 0x24, 0x33, 0x37, 0x35, 0xbf, 0xb4, 0x84, 0xa0, 0x89, 0x4e, 0xe9, 0x27, 0x1e, - 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, - 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0xc0, 0x25, 0x9e, 0x99, 0xaf, 0x87, 0x2d, 0x48, 0x02, - 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, 0x4a, - 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0xb0, 0x70, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, - 0x03, 0x87, 0xb2, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, 0xe8, 0xf6, 0x89, 0x01, 0x00, - 0x00, + 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x54, 0xca, 0xe1, 0x12, 0x77, 0x05, 0x29, 0xf2, 0x07, 0x8b, + 0x04, 0x96, 0xa6, 0x16, 0x55, 0x06, 0x97, 0x26, 0x27, 0xa7, 0x16, 0x17, 0x0b, 0x49, 0x70, 0xb1, + 0x27, 0x67, 0x24, 0xe6, 0xe5, 0xa5, 0xe6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, + 0x42, 0xf2, 0x5c, 0xdc, 0xc5, 0xa9, 0x85, 0xa5, 0xa9, 0x79, 0xc9, 0xa9, 0xf1, 0x99, 0x29, 0x12, + 0x4c, 0x60, 0x59, 0x2e, 0x98, 0x90, 0x67, 0x8a, 0x90, 0x18, 0x17, 0x5b, 0x51, 0x6a, 0x71, 0x69, + 0x4e, 0x89, 0x04, 0x33, 0x58, 0x0e, 0xca, 0x53, 0xca, 0xe0, 0x12, 0x45, 0xb7, 0xcd, 0xb5, 0xa8, + 0x28, 0xbf, 0x88, 0x12, 0xbb, 0x44, 0xb8, 0x58, 0x53, 0x41, 0x66, 0x40, 0xad, 0x82, 0x70, 0x94, + 0x42, 0x30, 0xfd, 0x15, 0x92, 0x99, 0x9b, 0x9a, 0x5f, 0x5a, 0x42, 0x81, 0x5d, 0x4e, 0xe9, 0x27, + 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, + 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0xc0, 0x25, 0x9e, 0x99, 0xaf, 0x87, 0x2d, 0x80, + 0x03, 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, + 0x4a, 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0xb0, 0x58, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, + 0x62, 0x03, 0xc7, 0x99, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x36, 0xdb, 0x1f, 0x32, 0xd7, 0x01, + 0x00, 0x00, } func (m *EventOracleQuerySuccess) Marshal() (dAtA []byte, err error) { @@ -231,13 +259,20 @@ func (m *EventOracleQuerySuccess) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.Result) i = encodeVarintEvent(dAtA, i, uint64(len(m.Result))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.SequenceId) > 0 { i -= len(m.SequenceId) copy(dAtA[i:], m.SequenceId) i = encodeVarintEvent(dAtA, i, uint64(len(m.SequenceId))) i-- + dAtA[i] = 0x12 + } + if len(m.Channel) > 0 { + i -= len(m.Channel) + copy(dAtA[i:], m.Channel) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Channel))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -268,13 +303,20 @@ func (m *EventOracleQueryError) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Error) i = encodeVarintEvent(dAtA, i, uint64(len(m.Error))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.SequenceId) > 0 { i -= len(m.SequenceId) copy(dAtA[i:], m.SequenceId) i = encodeVarintEvent(dAtA, i, uint64(len(m.SequenceId))) i-- + dAtA[i] = 0x12 + } + if len(m.Channel) > 0 { + i -= len(m.Channel) + copy(dAtA[i:], m.Channel) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Channel))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -305,6 +347,13 @@ func (m *EventOracleQueryTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.SequenceId) i = encodeVarintEvent(dAtA, i, uint64(len(m.SequenceId))) i-- + dAtA[i] = 0x12 + } + if len(m.Channel) > 0 { + i -= len(m.Channel) + copy(dAtA[i:], m.Channel) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Channel))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -327,6 +376,10 @@ func (m *EventOracleQuerySuccess) Size() (n int) { } var l int _ = l + l = len(m.Channel) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } l = len(m.SequenceId) if l > 0 { n += 1 + l + sovEvent(uint64(l)) @@ -344,6 +397,10 @@ func (m *EventOracleQueryError) Size() (n int) { } var l int _ = l + l = len(m.Channel) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } l = len(m.SequenceId) if l > 0 { n += 1 + l + sovEvent(uint64(l)) @@ -361,6 +418,10 @@ func (m *EventOracleQueryTimeout) Size() (n int) { } var l int _ = l + l = len(m.Channel) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } l = len(m.SequenceId) if l > 0 { n += 1 + l + sovEvent(uint64(l)) @@ -404,6 +465,38 @@ func (m *EventOracleQuerySuccess) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Channel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SequenceId", wireType) } @@ -435,7 +528,7 @@ func (m *EventOracleQuerySuccess) Unmarshal(dAtA []byte) error { } m.SequenceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) } @@ -518,6 +611,38 @@ func (m *EventOracleQueryError) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Channel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SequenceId", wireType) } @@ -549,7 +674,7 @@ func (m *EventOracleQueryError) Unmarshal(dAtA []byte) error { } m.SequenceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) } @@ -632,6 +757,38 @@ func (m *EventOracleQueryTimeout) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Channel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SequenceId", wireType) } diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index b870337833..bbbd7e7cd7 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -25,7 +25,7 @@ const ( // The Oracle module's KVStore categorizes each item in the store using a single byte prefix // Any additional bytes appended after this prefix are to help in making multiple unique entries per category -// The keys in this section are relatively simple and are used for module setup and configuration +// The keys are relatively simple and are used for module setup and configuration // // OracleStoreKey // - 0x01: sdk.AccAddress @@ -38,17 +38,6 @@ const ( // PortStoreKey // - 0x03: string // | 1 | -// -// The following keys are used to store ICQ oracle requests and responses -// The are 8 bytes to uniquely identify a ICQ request -// -// QueryRequestStoreKey -// - 0x04: QueryOracleRequest -// | 1 | 8 | -// -// QueryResponseStoreKey -// - 0x05: QueryOracleResponse -// | 1 | 8 | var ( // OracleStoreKey is the key for the module's oracle address OracleStoreKey = []byte{0x01} @@ -56,10 +45,6 @@ var ( LastQueryPacketSeqKey = []byte{0x02} // PortStoreKey defines the key to store the port ID in store PortStoreKey = []byte{0x03} - // QueryResponseStoreKeyPrefix is a prefix for storing request - QueryRequestStoreKeyPrefix = []byte{0x04} - // QueryResponseStoreKeyPrefix is a prefix for storing result - QueryResponseStoreKeyPrefix = []byte{0x05} ) // GetOracleStoreKey is a function to get the key for the oracle's address in store @@ -77,16 +62,6 @@ func GetLastQueryPacketSeqKey() []byte { return LastQueryPacketSeqKey } -// GetQueryRequestStoreKey is a function to generate key for each result in store -func GetQueryRequestStoreKey(packetSequence uint64) []byte { - return append(QueryRequestStoreKeyPrefix, uint64ToBytes(packetSequence)...) -} - -// GetQueryResponseStoreKey is a function to generate key for each result in store -func GetQueryResponseStoreKey(packetSequence uint64) []byte { - return append(QueryResponseStoreKeyPrefix, uint64ToBytes(packetSequence)...) -} - func uint64ToBytes(num uint64) []byte { result := make([]byte, 8) binary.BigEndian.PutUint64(result, uint64(num)) diff --git a/x/oracle/types/keys_test.go b/x/oracle/types/keys_test.go index 3ced71759a..472b012246 100644 --- a/x/oracle/types/keys_test.go +++ b/x/oracle/types/keys_test.go @@ -1,7 +1,6 @@ package types import ( - "encoding/binary" "testing" "github.com/stretchr/testify/assert" @@ -21,15 +20,3 @@ func TestGetLastQueryPacketSeqKey(t *testing.T) { key := GetLastQueryPacketSeqKey() assert.EqualValues(t, LastQueryPacketSeqKey, key[0:1], "must return correct last query packet sequence key") } - -func TestQueryRequestStoreKey(t *testing.T) { - key := GetQueryRequestStoreKey(5) - assert.EqualValues(t, QueryRequestStoreKeyPrefix, key[0:1], "must have correct prefix") - assert.EqualValues(t, int(5), int(binary.BigEndian.Uint64(key[1:9])), "must have correct sequence") -} - -func TestQueryResponseStoreKey(t *testing.T) { - key := GetQueryResponseStoreKey(5) - assert.EqualValues(t, QueryResponseStoreKeyPrefix, key[0:1], "must have correct prefix") - assert.EqualValues(t, int(5), int(binary.BigEndian.Uint64(key[1:9])), "must have correct sequence") -} diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 943f2087d1..4b1fc85efc 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -8,7 +8,7 @@ import ( fmt "fmt" github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" - types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -32,104 +32,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryQueryStateRequest queries for the state of the ICQ. -type QueryQueryStateRequest struct { - Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` -} - -func (m *QueryQueryStateRequest) Reset() { *m = QueryQueryStateRequest{} } -func (m *QueryQueryStateRequest) String() string { return proto.CompactTextString(m) } -func (*QueryQueryStateRequest) ProtoMessage() {} -func (*QueryQueryStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{0} -} -func (m *QueryQueryStateRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryQueryStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryQueryStateRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryQueryStateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryQueryStateRequest.Merge(m, src) -} -func (m *QueryQueryStateRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryQueryStateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryQueryStateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryQueryStateRequest proto.InternalMessageInfo - -func (m *QueryQueryStateRequest) GetSequence() uint64 { - if m != nil { - return m.Sequence - } - return 0 -} - -// QueryQueryStateResponse contains the ICQ and its response. -type QueryQueryStateResponse struct { - Request types.Any `protobuf:"bytes,1,opt,name=request,proto3" json:"request"` - Response *types.Any `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` -} - -func (m *QueryQueryStateResponse) Reset() { *m = QueryQueryStateResponse{} } -func (m *QueryQueryStateResponse) String() string { return proto.CompactTextString(m) } -func (*QueryQueryStateResponse) ProtoMessage() {} -func (*QueryQueryStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{1} -} -func (m *QueryQueryStateResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryQueryStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryQueryStateResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryQueryStateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryQueryStateResponse.Merge(m, src) -} -func (m *QueryQueryStateResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryQueryStateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryQueryStateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryQueryStateResponse proto.InternalMessageInfo - -func (m *QueryQueryStateResponse) GetRequest() types.Any { - if m != nil { - return m.Request - } - return types.Any{} -} - -func (m *QueryQueryStateResponse) GetResponse() *types.Any { - if m != nil { - return m.Response - } - return nil -} - // QueryOracleAddressRequest queries for the address of the oracle. type QueryOracleAddressRequest struct { } @@ -138,7 +40,7 @@ func (m *QueryOracleAddressRequest) Reset() { *m = QueryOracleAddressReq func (m *QueryOracleAddressRequest) String() string { return proto.CompactTextString(m) } func (*QueryOracleAddressRequest) ProtoMessage() {} func (*QueryOracleAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{2} + return fileDescriptor_169907f611744c57, []int{0} } func (m *QueryOracleAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -177,7 +79,7 @@ func (m *QueryOracleAddressResponse) Reset() { *m = QueryOracleAddressRe func (m *QueryOracleAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryOracleAddressResponse) ProtoMessage() {} func (*QueryOracleAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{3} + return fileDescriptor_169907f611744c57, []int{1} } func (m *QueryOracleAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -223,7 +125,7 @@ func (m *QueryOracleRequest) Reset() { *m = QueryOracleRequest{} } func (m *QueryOracleRequest) String() string { return proto.CompactTextString(m) } func (*QueryOracleRequest) ProtoMessage() {} func (*QueryOracleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{4} + return fileDescriptor_169907f611744c57, []int{2} } func (m *QueryOracleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -269,7 +171,7 @@ func (m *QueryOracleResponse) Reset() { *m = QueryOracleResponse{} } func (m *QueryOracleResponse) String() string { return proto.CompactTextString(m) } func (*QueryOracleResponse) ProtoMessage() {} func (*QueryOracleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_169907f611744c57, []int{5} + return fileDescriptor_169907f611744c57, []int{3} } func (m *QueryOracleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -306,8 +208,6 @@ func (m *QueryOracleResponse) GetData() github_com_CosmWasm_wasmd_x_wasm_types.R } func init() { - proto.RegisterType((*QueryQueryStateRequest)(nil), "provenance.oracle.v1.QueryQueryStateRequest") - proto.RegisterType((*QueryQueryStateResponse)(nil), "provenance.oracle.v1.QueryQueryStateResponse") proto.RegisterType((*QueryOracleAddressRequest)(nil), "provenance.oracle.v1.QueryOracleAddressRequest") proto.RegisterType((*QueryOracleAddressResponse)(nil), "provenance.oracle.v1.QueryOracleAddressResponse") proto.RegisterType((*QueryOracleRequest)(nil), "provenance.oracle.v1.QueryOracleRequest") @@ -317,41 +217,35 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/query.proto", fileDescriptor_169907f611744c57) } var fileDescriptor_169907f611744c57 = []byte{ - // 539 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbf, 0x6e, 0x13, 0x31, - 0x18, 0x8f, 0x4b, 0xff, 0xf1, 0x01, 0x8b, 0x89, 0x68, 0x7a, 0x54, 0xd7, 0x72, 0x54, 0xa8, 0x95, - 0x1a, 0x9b, 0x86, 0x0a, 0x89, 0x81, 0xa1, 0xe9, 0x8c, 0x68, 0x2f, 0x03, 0x12, 0x4b, 0xe4, 0x5c, - 0xcc, 0xf5, 0xa4, 0xc6, 0xbe, 0x9e, 0x9d, 0xb4, 0x59, 0x61, 0x60, 0x45, 0x82, 0x07, 0xe0, 0x21, - 0x78, 0x07, 0x3a, 0x56, 0xb0, 0x30, 0x55, 0x28, 0xe1, 0x29, 0x98, 0x50, 0x6c, 0x5f, 0x93, 0xaa, - 0x69, 0x9b, 0x81, 0x25, 0xb1, 0xcf, 0xbf, 0x7f, 0xf7, 0xf9, 0xfb, 0x0e, 0x56, 0xd2, 0x4c, 0x76, - 0xb8, 0x60, 0x22, 0xe2, 0x54, 0x66, 0x2c, 0x3a, 0xe0, 0xb4, 0xb3, 0x49, 0x0f, 0xdb, 0x3c, 0xeb, - 0x92, 0x34, 0x93, 0x5a, 0xe2, 0xe2, 0x10, 0x41, 0x2c, 0x82, 0x74, 0x36, 0xbd, 0x62, 0x2c, 0x63, - 0x69, 0x00, 0x74, 0xb0, 0xb2, 0x58, 0x6f, 0x29, 0x96, 0x32, 0x3e, 0xe0, 0x94, 0xa5, 0x09, 0x65, - 0x42, 0x48, 0xcd, 0x74, 0x22, 0x85, 0x72, 0xa7, 0x8b, 0x91, 0x54, 0x2d, 0xa9, 0xea, 0x96, 0x66, - 0x37, 0xf9, 0x91, 0x23, 0x9a, 0x5d, 0xa3, 0xfd, 0x8e, 0x32, 0xe1, 0xfc, 0x83, 0x2d, 0x78, 0xb0, - 0x37, 0x88, 0x63, 0x7e, 0x6a, 0x9a, 0x69, 0x1e, 0xf2, 0xc3, 0x36, 0x57, 0x1a, 0x7b, 0x30, 0xaf, - 0x06, 0x4b, 0x11, 0xf1, 0x12, 0x5a, 0x41, 0x6b, 0xd3, 0xe1, 0xf9, 0x3e, 0xf8, 0x88, 0x60, 0xe1, - 0x12, 0x4d, 0xa5, 0x52, 0x28, 0x8e, 0xb7, 0x60, 0x2e, 0xb3, 0x12, 0x86, 0x76, 0xa7, 0x52, 0x24, - 0xd6, 0x9e, 0xe4, 0xf6, 0x64, 0x5b, 0x74, 0xab, 0xd3, 0x27, 0x67, 0xcb, 0x85, 0x30, 0x87, 0xe2, - 0xe7, 0x30, 0x9f, 0x39, 0x85, 0xd2, 0xd4, 0x0d, 0x34, 0x14, 0x9e, 0x63, 0x83, 0x87, 0xb0, 0x68, - 0x32, 0xbc, 0x36, 0xb5, 0xdb, 0x6e, 0x36, 0x33, 0xae, 0x94, 0x7b, 0x85, 0x60, 0x17, 0xbc, 0x71, - 0x87, 0x2e, 0x68, 0x05, 0xe6, 0x98, 0x7d, 0x64, 0x82, 0xde, 0xae, 0x96, 0x7e, 0x7c, 0x2b, 0x17, - 0x5d, 0xe1, 0x1c, 0xb8, 0xa6, 0xb3, 0x44, 0xc4, 0x61, 0x0e, 0x0c, 0x12, 0xc0, 0x23, 0x8a, 0x79, - 0xa9, 0x6a, 0x30, 0x63, 0xee, 0xd4, 0xe8, 0xdc, 0xad, 0xbe, 0xfc, 0x7b, 0xb6, 0xfc, 0x22, 0x4e, - 0xf4, 0x7e, 0xbb, 0x41, 0x22, 0xd9, 0xa2, 0x3b, 0x52, 0xb5, 0xde, 0x30, 0xd5, 0xa2, 0x47, 0x4c, - 0xb5, 0x9a, 0xf4, 0xd8, 0xfc, 0x53, 0xdd, 0x4d, 0xb9, 0x22, 0x21, 0x3b, 0xda, 0x91, 0x42, 0x67, - 0x2c, 0xd2, 0xaf, 0xb8, 0x52, 0x2c, 0xe6, 0xa1, 0xd5, 0x0a, 0xf6, 0xe1, 0xfe, 0x05, 0x2b, 0x97, - 0x7a, 0x0f, 0xa6, 0x9b, 0x4c, 0xb3, 0xff, 0x63, 0x65, 0xa4, 0x2a, 0xdf, 0x6f, 0xc1, 0x8c, 0xb1, - 0xc2, 0x5f, 0x11, 0xdc, 0xbb, 0x50, 0x2c, 0x4c, 0xc9, 0xb8, 0x06, 0x25, 0x57, 0xd6, 0xdc, 0x7b, - 0x3a, 0x39, 0xc1, 0x5d, 0xe1, 0xc6, 0xfb, 0x9f, 0x7f, 0x3e, 0x4f, 0x3d, 0xc1, 0xab, 0x74, 0xec, - 0xb4, 0xd8, 0x55, 0xdd, 0xdd, 0x00, 0xfe, 0x80, 0x60, 0xd6, 0xea, 0xe0, 0xb5, 0x1b, 0xad, 0xf2, - 0x50, 0xeb, 0x13, 0x20, 0x5d, 0x9a, 0x55, 0x93, 0xc6, 0xc7, 0x4b, 0xd7, 0xa5, 0xc1, 0x5f, 0x10, - 0xc0, 0xb0, 0xf7, 0xf1, 0xc6, 0x35, 0xfa, 0x97, 0x26, 0xcb, 0x2b, 0x4f, 0x88, 0x76, 0x89, 0xd6, - 0x4d, 0xa2, 0xc7, 0xf8, 0x11, 0xbd, 0xfa, 0x6b, 0x52, 0x57, 0x03, 0x4a, 0x35, 0x3e, 0xe9, 0xf9, - 0xe8, 0xb4, 0xe7, 0xa3, 0xdf, 0x3d, 0x1f, 0x7d, 0xea, 0xfb, 0x85, 0xd3, 0xbe, 0x5f, 0xf8, 0xd5, - 0xf7, 0x0b, 0xb0, 0x90, 0xc8, 0xb1, 0xae, 0xbb, 0xe8, 0x6d, 0x65, 0xa4, 0x7f, 0x86, 0x90, 0x72, - 0x22, 0x47, 0xfd, 0x8e, 0x73, 0x47, 0xd3, 0x4b, 0x8d, 0x59, 0x33, 0x94, 0xcf, 0xfe, 0x05, 0x00, - 0x00, 0xff, 0xff, 0x8b, 0x00, 0xca, 0xa5, 0xe1, 0x04, 0x00, 0x00, + // 434 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x8f, 0xd3, 0x30, + 0x18, 0xc6, 0xeb, 0x13, 0x77, 0x08, 0x0b, 0x16, 0x53, 0x89, 0xbb, 0x70, 0x0a, 0xa7, 0xe8, 0x84, + 0x0e, 0x89, 0x8b, 0xb9, 0x32, 0x31, 0x30, 0xd0, 0x9b, 0x11, 0xd7, 0x74, 0x40, 0x62, 0xa9, 0xdc, + 0xc4, 0xb8, 0x91, 0x1a, 0xbf, 0x69, 0xec, 0xf4, 0xcf, 0x0a, 0x5f, 0x00, 0x89, 0x2f, 0xc0, 0x47, + 0x60, 0xe0, 0x43, 0x30, 0x56, 0xb0, 0x30, 0x21, 0xd4, 0xf2, 0x29, 0x98, 0x50, 0x6d, 0x47, 0x6d, + 0xa5, 0x00, 0x1d, 0x98, 0x6a, 0xf7, 0x7d, 0xde, 0xe7, 0xf7, 0xe4, 0x7d, 0x8d, 0x4f, 0xf2, 0x02, + 0xc6, 0x5c, 0x32, 0x19, 0x73, 0x0a, 0x05, 0x8b, 0x87, 0x9c, 0x8e, 0x2f, 0xe8, 0xa8, 0xe4, 0xc5, + 0x2c, 0xcc, 0x0b, 0xd0, 0x40, 0x9a, 0x6b, 0x45, 0x68, 0x15, 0xe1, 0xf8, 0xc2, 0x6b, 0x0a, 0x10, + 0x60, 0x04, 0x74, 0x75, 0xb2, 0x5a, 0xef, 0x58, 0x00, 0x88, 0x21, 0xa7, 0x2c, 0x4f, 0x29, 0x93, + 0x12, 0x34, 0xd3, 0x29, 0x48, 0xe5, 0xaa, 0x47, 0x31, 0xa8, 0x0c, 0x54, 0xcf, 0xb6, 0xd9, 0x4b, + 0x55, 0x72, 0x8d, 0xe6, 0xd6, 0x2f, 0x5f, 0x53, 0x26, 0x1d, 0x3f, 0xb8, 0x8b, 0x8f, 0x3a, 0xab, + 0x38, 0x2f, 0x0c, 0xfb, 0x59, 0x92, 0x14, 0x5c, 0xa9, 0x88, 0x8f, 0x4a, 0xae, 0x74, 0x70, 0x85, + 0xbd, 0xba, 0xa2, 0xca, 0x41, 0x2a, 0x4e, 0x5a, 0xf8, 0x3a, 0xb3, 0x7f, 0x1d, 0xa2, 0x13, 0x74, + 0x76, 0xa3, 0x7d, 0xf8, 0xe5, 0xd3, 0x79, 0xd3, 0x81, 0x9d, 0xb8, 0xab, 0x8b, 0x54, 0x8a, 0xa8, + 0x12, 0x06, 0x29, 0x26, 0x1b, 0x8e, 0x8e, 0x43, 0xba, 0x78, 0xdf, 0xcc, 0xc4, 0xf8, 0xdc, 0x6c, + 0x3f, 0xfd, 0xf5, 0xfd, 0xde, 0x13, 0x91, 0xea, 0x41, 0xd9, 0x0f, 0x63, 0xc8, 0xe8, 0x25, 0xa8, + 0xec, 0x25, 0x53, 0x19, 0x9d, 0x30, 0x95, 0x25, 0x74, 0x6a, 0x7e, 0xa9, 0x9e, 0xe5, 0x5c, 0x85, + 0x11, 0x9b, 0x5c, 0x82, 0xd4, 0x05, 0x8b, 0xf5, 0x73, 0xae, 0x14, 0x13, 0x3c, 0xb2, 0x5e, 0xc1, + 0x00, 0xdf, 0xde, 0x42, 0xb9, 0xd4, 0x1d, 0x7c, 0x2d, 0x61, 0x9a, 0xfd, 0x1f, 0x94, 0xb1, 0x6a, + 0x7d, 0xdc, 0xc3, 0xfb, 0x06, 0x45, 0x3e, 0x20, 0x7c, 0x6b, 0x6b, 0x58, 0x84, 0x86, 0x75, 0x0b, + 0x0e, 0xff, 0x38, 0x73, 0xef, 0xd1, 0xee, 0x0d, 0xf6, 0x8b, 0x82, 0x87, 0x6f, 0xbe, 0xfe, 0x7c, + 0xbf, 0x77, 0x9f, 0x9c, 0xd2, 0xda, 0xd7, 0x66, 0x4f, 0x3d, 0xb7, 0x01, 0xf2, 0x16, 0xe1, 0x03, + 0xeb, 0x43, 0xce, 0xfe, 0x89, 0xaa, 0x42, 0x3d, 0xd8, 0x41, 0xe9, 0xd2, 0x9c, 0x9a, 0x34, 0x3e, + 0x39, 0xfe, 0x5b, 0x9a, 0xb6, 0xf8, 0xbc, 0xf0, 0xd1, 0x7c, 0xe1, 0xa3, 0x1f, 0x0b, 0x1f, 0xbd, + 0x5b, 0xfa, 0x8d, 0xf9, 0xd2, 0x6f, 0x7c, 0x5b, 0xfa, 0x0d, 0x7c, 0x27, 0x85, 0x5a, 0xd8, 0x15, + 0x7a, 0xd5, 0xda, 0x58, 0xd4, 0x5a, 0x72, 0x9e, 0xc2, 0x26, 0x6a, 0x5a, 0xc1, 0xcc, 0xd2, 0xfa, + 0x07, 0xe6, 0x99, 0x3f, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xb3, 0xbd, 0x64, 0x4f, 0x8a, 0x03, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -370,8 +264,6 @@ type QueryClient interface { OracleAddress(ctx context.Context, in *QueryOracleAddressRequest, opts ...grpc.CallOption) (*QueryOracleAddressResponse, error) // Oracle forwards a query to the module's oracle Oracle(ctx context.Context, in *QueryOracleRequest, opts ...grpc.CallOption) (*QueryOracleResponse, error) - // QueryState returns the state of the oracle query - QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) } type queryClient struct { @@ -400,23 +292,12 @@ func (c *queryClient) Oracle(ctx context.Context, in *QueryOracleRequest, opts . return out, nil } -func (c *queryClient) QueryState(ctx context.Context, in *QueryQueryStateRequest, opts ...grpc.CallOption) (*QueryQueryStateResponse, error) { - out := new(QueryQueryStateResponse) - err := c.cc.Invoke(ctx, "/provenance.oracle.v1.Query/QueryState", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // OracleAddress returns the address of the oracle OracleAddress(context.Context, *QueryOracleAddressRequest) (*QueryOracleAddressResponse, error) // Oracle forwards a query to the module's oracle Oracle(context.Context, *QueryOracleRequest) (*QueryOracleResponse, error) - // QueryState returns the state of the oracle query - QueryState(context.Context, *QueryQueryStateRequest) (*QueryQueryStateResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -429,9 +310,6 @@ func (*UnimplementedQueryServer) OracleAddress(ctx context.Context, req *QueryOr func (*UnimplementedQueryServer) Oracle(ctx context.Context, req *QueryOracleRequest) (*QueryOracleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Oracle not implemented") } -func (*UnimplementedQueryServer) QueryState(ctx context.Context, req *QueryQueryStateRequest) (*QueryQueryStateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryState not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -473,24 +351,6 @@ func _Query_Oracle_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_QueryState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryQueryStateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryState(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/provenance.oracle.v1.Query/QueryState", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryState(ctx, req.(*QueryQueryStateRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "provenance.oracle.v1.Query", HandlerType: (*QueryServer)(nil), @@ -503,88 +363,11 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Oracle", Handler: _Query_Oracle_Handler, }, - { - MethodName: "QueryState", - Handler: _Query_QueryState_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/oracle/v1/query.proto", } -func (m *QueryQueryStateRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryQueryStateRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryQueryStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sequence != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryQueryStateResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryQueryStateResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryQueryStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Response != nil { - { - size, err := m.Response.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Request.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *QueryOracleAddressRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -709,33 +492,6 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryQueryStateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sequence != 0 { - n += 1 + sovQuery(uint64(m.Sequence)) - } - return n -} - -func (m *QueryQueryStateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Request.Size() - n += 1 + l + sovQuery(uint64(l)) - if m.Response != nil { - l = m.Response.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func (m *QueryOracleAddressRequest) Size() (n int) { if m == nil { return 0 @@ -790,194 +546,6 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryQueryStateRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryQueryStateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryQueryStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) - } - m.Sequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Sequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryQueryStateResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryQueryStateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryQueryStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Request.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Response == nil { - m.Response = &types.Any{} - } - if err := m.Response.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryOracleAddressRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 2fac9500a9..890ce9af78 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -85,42 +85,6 @@ func local_request_Query_Oracle_0(ctx context.Context, marshaler runtime.Marshal } -var ( - filter_Query_QueryState_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QueryState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryQueryStateRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryState_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryQueryStateRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryState_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryState(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -167,26 +131,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_QueryState_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -268,26 +212,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_QueryState_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -295,14 +219,10 @@ var ( pattern_Query_OracleAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "oracle_address"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Oracle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"provenance", "oracle", "v1"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"provenance", "oracle", "v1", "query_state"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_OracleAddress_0 = runtime.ForwardResponseMessage forward_Query_Oracle_0 = runtime.ForwardResponseMessage - - forward_Query_QueryState_0 = runtime.ForwardResponseMessage ) From cc5794230fc3e2151c23515e39a66a271b31cd66 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 09:26:17 -0400 Subject: [PATCH 49/96] Updated spec with removal of query request response state. Updated events in the spec to include the channel. Updated comments in protobuf. --- docs/proto-docs.md | 2 +- proto/provenance/oracle/v1/genesis.proto | 2 +- x/oracle/spec/01_concepts.md | 4 +++- x/oracle/spec/02_state.md | 12 +---------- x/oracle/spec/04_queries.md | 26 ++++++++---------------- x/oracle/spec/05_events.md | 26 ++++++++++++++---------- x/oracle/types/genesis.pb.go | 2 +- 7 files changed, 31 insertions(+), 43 deletions(-) diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 1990f17f2b..e4419e4164 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -6779,7 +6779,7 @@ GenesisState defines the oracle module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `sequence` | [uint64](#uint64) | | Sequence is the next auto incremented id to be assigned to the next query | -| `params` | [Params](#provenance.oracle.v1.Params) | | Params | +| `params` | [Params](#provenance.oracle.v1.Params) | | Params are the parameters that the module uses | | `port_id` | [string](#string) | | The port to assign to the module | diff --git a/proto/provenance/oracle/v1/genesis.proto b/proto/provenance/oracle/v1/genesis.proto index 8f28cb856c..c48d1e2a04 100644 --- a/proto/provenance/oracle/v1/genesis.proto +++ b/proto/provenance/oracle/v1/genesis.proto @@ -15,7 +15,7 @@ message GenesisState { // Sequence is the next auto incremented id to be assigned to the next query uint64 sequence = 1; - // Params + // Params are the parameters that the module uses Params params = 2 [(gogoproto.nullable) = false]; // The port to assign to the module string port_id = 3; diff --git a/x/oracle/spec/01_concepts.md b/x/oracle/spec/01_concepts.md index 0c37fb33b0..51017bde06 100644 --- a/x/oracle/spec/01_concepts.md +++ b/x/oracle/spec/01_concepts.md @@ -7,8 +7,10 @@ order: 1 The oracle module is very minimal, but users should understand what the `Oracle` is and how it interacts with `ICQ`. +- [Concepts](#concepts) - [Oracle](#oracle) - [Interchain Queries (ICQ)](#interchain-queries-icq) + - [Note](#note) --- @@ -22,7 +24,7 @@ The `Oracle` is a custom built CosmWasm smart contract that the chain queries fo When a user intends to query another chain, they initiate the process by submitting a query through a transaction on the `ICQ Controller`. This `Controller` delivers the query from the transaction to the `ICQ Host` module of the destination chain via `IBC`. Subsequently, the received query is routed by the `ICQ Host` to this module. Upon receipt, the module queries the `Oracle` using the provided input, and the resulting information is then transmitted back to the `ICQ Controller` in the form of an `ACK` message. -It should be noted that responses, which arrive in the form of the `ACK`, indicate that queries operate asynchronously. Consequently, these results might not be immediately accessible, necessitating a separate query invocation to retrieve the outcomes. For additional details, you can refer to the [Async ICQ Module](https://github.com/strangelove-ventures/async-icq) developed by strangelove-ventures. +It should be noted that responses, which arrive in the form of the `ACK`, indicate that queries operate asynchronously. Consequently, these results will not be immediately accessible, requiring the user to wait for an emitted event on the response. For additional details, you can refer to the [Async ICQ Module](https://github.com/strangelove-ventures/async-icq) developed by strangelove-ventures. ### Note diff --git a/x/oracle/spec/02_state.md b/x/oracle/spec/02_state.md index 88709b2cde..d67e125fce 100644 --- a/x/oracle/spec/02_state.md +++ b/x/oracle/spec/02_state.md @@ -7,9 +7,9 @@ order: 2 The oracle module manages the address of the Oracle and the ICQ state. +- [State](#state) - [Oracle](#oracle) - [IBC](#ibc) - - [ICQ Responses](#icq-responses) --- @@ -26,13 +26,3 @@ The `Oracle` is a CosmWasm smart contract that the module forwards its queries t * Port `0x03 -> []byte{}` * Last Query Sequence Number `0x02 -> uint64` - ---- -## ICQ Responses - -The asynchronous nature of the `ICQ` implementation necessitates the module to retain both the request and the corresponding response. This enables users to monitor the progress of their requests and subsequently review the received responses. - -* QueryRequest `0x04 | Sequence ID (8 Bytes) -> ProtocolBuffers(QueryOracleRequest)` -* QueryResponse `0x05 | Sequence ID (8 Bytes) -> ProtocolBuffers(QueryOracleResponse)` - -+++ https://github.com/provenance-io/provenance/blob/a10304ad4fe1ddb20bc4f54a413942b8898ce887/proto/provenance/oracle/v1/query.proto#L51C1-L61 diff --git a/x/oracle/spec/04_queries.md b/x/oracle/spec/04_queries.md index fa94df87d6..f28ec59ddc 100644 --- a/x/oracle/spec/04_queries.md +++ b/x/oracle/spec/04_queries.md @@ -7,9 +7,13 @@ order: 4 In this section we describe the queries available for looking up oracle information. +- [Queries](#queries) - [Query Oracle Address](#query-oracle-address) + - [Request](#request) + - [Response](#response) - [Query Oracle](#query-oracle) - - [Query Query State](#query-query-state) + - [Request](#request-1) + - [Response](#response-1) --- ## Query Oracle Address @@ -17,11 +21,11 @@ The `QueryOracleAddress` query is used to obtain the address of the module's ora ### Request -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L42-L43 ++++ https://github.com/provenance-io/provenance/blob/5afab1b1797b0071cf6a19ea5928c5b8f8831329/proto/provenance/oracle/v1/query.proto#L26-L27 ### Response -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L45-L49 ++++ https://github.com/provenance-io/provenance/blob/5afab1b1797b0071cf6a19ea5928c5b8f8831329/proto/provenance/oracle/v1/query.proto#L29-L33 --- @@ -30,22 +34,10 @@ The `QueryOracle` query forwards a query to the module's oracle. ### Request -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L51-L55 ++++ https://github.com/provenance-io/provenance/blob/5afab1b1797b0071cf6a19ea5928c5b8f8831329/proto/provenance/oracle/v1/query.proto#L35-L39 ### Response -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L57-L61 ++++ https://github.com/provenance-io/provenance/blob/5afab1b1797b0071cf6a19ea5928c5b8f8831329/proto/provenance/oracle/v1/query.proto#L41-L45 The data from the `query` field is a `CosmWasm query` forwarded to the `oracle`. - ---- -## Query Query State -The `QueryQueryState` query is used to obtain the state of an existing query. - -### Request - -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L31-L34 - -### Response - -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/query.proto#L36-L40 diff --git a/x/oracle/spec/05_events.md b/x/oracle/spec/05_events.md index 703bff5f3c..7a4c2a7716 100644 --- a/x/oracle/spec/05_events.md +++ b/x/oracle/spec/05_events.md @@ -7,6 +7,7 @@ order: 5 The oracle module emits the following events: +- [Events](#events) - [EventOracleQuerySuccess](#eventoraclequerysuccess) - [EventOracleQueryError](#eventoraclequeryerror) - [EventOracleQueryTimeout](#eventoraclequerytimeout) @@ -17,26 +18,29 @@ The oracle module emits the following events: This event is emitted when an `ICQ` response is received from an `ACK` and is successful. -| Type | Attribute Key | Attribute Value | -| ------------------ | ------------- | ------------------------------- | -| OracleQuerySuccess | sequence_id | Sequence ID of the ICQ request | -| OracleQuerySuccess | result | Query data obtained from oracle | +| Type | Attribute Key | Attribute Value | +| ------------------ | ------------- | ----------------------------------- | +| OracleQuerySuccess | channel | Channel the ICQ request was sent on | +| OracleQuerySuccess | sequence_id | Sequence ID of the ICQ request | +| OracleQuerySuccess | result | Query data obtained from oracle | --- ## EventOracleQueryError This event is emitted when an `ICQ` response is received from an `ACK` and contains an error. -| Type | Attribute Key | Attribute Value | -| ---------------- | ------------- | ------------------------------ | -| OracleQueryError | sequence_id | Sequence ID of the ICQ request | -| OracleQueryError | error | Error received from the module | +| Type | Attribute Key | Attribute Value | +| ---------------- | ------------- | ----------------------------------- | +| OracleQueryError | channel | Channel the ICQ request was sent on | +| OracleQueryError | sequence_id | Sequence ID of the ICQ request | +| OracleQueryError | error | Error received from the module | --- ## EventOracleQueryTimeout This event is emitted when an `ICQ` request results in a `Timeout`. -| Type | Attribute Key | Attribute Value | -| ------------------ | ------------- | ------------------------------ | -| OracleQueryTimeout | sequence_id | Sequence ID of the ICQ request | +| Type | Attribute Key | Attribute Value | +| ------------------ | ------------- | ----------------------------------- | +| OracleQueryTimeout | channel | Channel the ICQ request was sent on | +| OracleQueryTimeout | sequence_id | Sequence ID of the ICQ request | diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index f40c8a928a..159724fe14 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -27,7 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // Sequence is the next auto incremented id to be assigned to the next query Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` - // Params + // Params are the parameters that the module uses Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` // The port to assign to the module PortId string `protobuf:"bytes,3,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` From 6291d15eb3a97e7d35850240fb89adc2e434bb90 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 09:36:53 -0400 Subject: [PATCH 50/96] Updated the error for channel id validate basic. --- x/oracle/types/msgs.go | 2 +- x/oracle/types/msgs_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 9d437ba59e..a52bf43075 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -50,7 +50,7 @@ func (msg MsgSendQueryOracleRequest) GetSigners() []sdk.AccAddress { // ValidateBasic runs stateless validation checks on the message. func (msg MsgSendQueryOracleRequest) ValidateBasic() error { if err := host.ChannelIdentifierValidator(msg.Channel); err != nil { - return fmt.Errorf("invalid channel id: %w", err) + return fmt.Errorf("invalid channel id") } if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return fmt.Errorf("invalid authority address: %w", err) diff --git a/x/oracle/types/msgs_test.go b/x/oracle/types/msgs_test.go index ae14e3ec6d..f5e5cb200a 100644 --- a/x/oracle/types/msgs_test.go +++ b/x/oracle/types/msgs_test.go @@ -98,7 +98,7 @@ func TestMsgSendQueryOracleRequestValidateBasic(t *testing.T) { { name: "failure - invalid channel", msg: NewMsgSendQueryOracle("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", "bad", []byte("{}")), - err: "invalid channel id: identifier bad has invalid length: 3, must be between 8-64 characters: invalid identifier [cosmos/ibc-go/v6/modules/core/24-host/validate.go:49]", + err: "invalid channel id", }, { name: "failure - invalid query", From a41e4c94f4ad7a107f84c2fb5f4624b44ea62d18 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 11:29:33 -0400 Subject: [PATCH 51/96] Added the oracle to the genesis state. --- docs/proto-docs.md | 1 + proto/provenance/oracle/v1/genesis.proto | 2 + x/oracle/keeper/genesis.go | 9 +++ x/oracle/keeper/genesis_test.go | 20 +++++-- x/oracle/simulation/genesis.go | 2 +- x/oracle/spec/06_genesis.md | 3 +- x/oracle/types/genesis.go | 11 +++- x/oracle/types/genesis.pb.go | 72 +++++++++++++++++++----- x/oracle/types/genesis_test.go | 20 +++++-- 9 files changed, 115 insertions(+), 25 deletions(-) diff --git a/docs/proto-docs.md b/docs/proto-docs.md index e4419e4164..879890a54f 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -6781,6 +6781,7 @@ GenesisState defines the oracle module's genesis state. | `sequence` | [uint64](#uint64) | | Sequence is the next auto incremented id to be assigned to the next query | | `params` | [Params](#provenance.oracle.v1.Params) | | Params are the parameters that the module uses | | `port_id` | [string](#string) | | The port to assign to the module | +| `oracle` | [string](#string) | | The address of the oracle | diff --git a/proto/provenance/oracle/v1/genesis.proto b/proto/provenance/oracle/v1/genesis.proto index c48d1e2a04..9989a28c7a 100644 --- a/proto/provenance/oracle/v1/genesis.proto +++ b/proto/provenance/oracle/v1/genesis.proto @@ -19,4 +19,6 @@ message GenesisState { Params params = 2 [(gogoproto.nullable) = false]; // The port to assign to the module string port_id = 3; + // The address of the oracle + string oracle = 4; } \ No newline at end of file diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index bf6b2a18aa..3629b712b7 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -7,10 +7,12 @@ import ( // ExportGenesis returns a GenesisState for a given context. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + oracle, _ := k.GetOracle(ctx) return &types.GenesisState{ Sequence: k.GetLastQueryPacketSeq(ctx), Params: k.GetParams(ctx), PortId: k.GetPort(ctx), + Oracle: oracle.String(), } } @@ -30,4 +32,11 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { k.SetParams(ctx, genState.Params) k.SetLastQueryPacketSeq(ctx, genState.Sequence) + var oracle sdk.AccAddress + if len(genState.Oracle) == 0 { + oracle = sdk.AccAddress{} + } else { + oracle = sdk.MustAccAddressFromBech32(genState.Oracle) + } + k.SetOracle(ctx, oracle) } diff --git a/x/oracle/keeper/genesis_test.go b/x/oracle/keeper/genesis_test.go index 0d88f13b0a..0fa0a2c87f 100644 --- a/x/oracle/keeper/genesis_test.go +++ b/x/oracle/keeper/genesis_test.go @@ -9,6 +9,7 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.Assert().Equal(types.DefaultParams(), genesis.Params, "should export the correct params") s.Assert().Equal("oracle", genesis.PortId, "should export the correct port") s.Assert().Equal(int(1), int(genesis.Sequence), "should export the correct sequence number") + s.Assert().Equal("", genesis.Oracle, "should export the correct oracle address") } func (s *KeeperTestSuite) TestInitGenesis() { @@ -19,21 +20,30 @@ func (s *KeeperTestSuite) TestInitGenesis() { }{ { name: "success - valid genesis state", - genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1), + genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + }, + { + name: "success - valid genesis state with empty oracle", + genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1, ""), }, { name: "failure - invalid sequence number", - genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 0), + genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 0, ""), err: "sequence 0 is invalid, must be greater than 0", }, { name: "failure - invalid port", - genesis: types.NewGenesisState("", types.DefaultParams(), 1), + genesis: types.NewGenesisState("", types.DefaultParams(), 1, ""), err: "identifier cannot be blank: invalid identifier", }, + { + name: "failure - invalid oracle", + genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1, "abc"), + err: "decoding bech32 failed: invalid bech32 string length 3", + }, { name: "success - works with existing port", - genesis: types.NewGenesisState("oracle", types.DefaultParams(), 1), + genesis: types.NewGenesisState("oracle", types.DefaultParams(), 1, ""), }, } @@ -46,10 +56,12 @@ func (s *KeeperTestSuite) TestInitGenesis() { }, "invalid init genesis should cause panic") } else { s.app.OracleKeeper.InitGenesis(s.ctx, tc.genesis) + oracle, _ := s.app.OracleKeeper.GetOracle(s.ctx) s.Assert().Equal(tc.genesis.Params, s.app.OracleKeeper.GetParams(s.ctx), "should correctly set params") s.Assert().Equal(tc.genesis.PortId, s.app.OracleKeeper.GetPort(s.ctx), "should correctly set the port") s.Assert().True(s.app.OracleKeeper.IsBound(s.ctx, tc.genesis.PortId), "should bind the port") s.Assert().Equal(int(tc.genesis.Sequence), int(s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx)), "should set the last sequence number") + s.Assert().Equal(tc.genesis.Oracle, oracle.String(), "should get the correct oracle address") } }) } diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 1d21905e7c..6f7f1ac347 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -48,7 +48,7 @@ func RandomizedGenState(simState *module.SimulationState) { params := types.DefaultParams() - genesis := types.NewGenesisState(port, params, sequenceID) + genesis := types.NewGenesisState(port, params, sequenceID, "") simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(genesis) bz, err := json.MarshalIndent(simState.GenState[types.ModuleName], "", " ") diff --git a/x/oracle/spec/06_genesis.md b/x/oracle/spec/06_genesis.md index 42538d4dd7..4f8e37f7a4 100644 --- a/x/oracle/spec/06_genesis.md +++ b/x/oracle/spec/06_genesis.md @@ -7,12 +7,13 @@ order: 6 In this section we describe the processing of the oracle messages and the corresponding updates to the state. +- [Oracle Genesis](#oracle-genesis) - [Msg/GenesisState](#msggenesisstate) --- ## Msg/GenesisState -The GenesisState encompasses the upcoming sequence ID for an ICQ packet, the associated parameters, and the designated port ID for the module. These values are both extracted for export and imported for storage within the store. +The GenesisState encompasses the upcoming sequence ID for an ICQ packet, the associated parameters, the designated port ID for the module, and the oracle address. These values are both extracted for export and imported for storage within the store. +++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/genesis.proto#L11-L22 diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index dd7636bad2..08e074b083 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -3,20 +3,22 @@ package types import ( fmt "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -func NewGenesisState(port string, params Params, sequence uint64) *GenesisState { +func NewGenesisState(port string, params Params, sequence uint64, oracle string) *GenesisState { return &GenesisState{ PortId: port, Params: params, Sequence: sequence, + Oracle: oracle, } } // DefaultGenesis returns the default oracle genesis state func DefaultGenesis() *GenesisState { - return NewGenesisState(PortID, DefaultParams(), 1) + return NewGenesisState(PortID, DefaultParams(), 1, "") } // Validate performs basic genesis state validation returning an error upon any @@ -30,5 +32,10 @@ func (gs GenesisState) Validate() error { return err } + _, err := sdk.AccAddressFromBech32(gs.Oracle) + if len(gs.Oracle) > 0 && err != nil { + return err + } + return gs.Params.Validate() } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index 159724fe14..f5455b5c32 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -31,6 +31,8 @@ type GenesisState struct { Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` // The port to assign to the module PortId string `protobuf:"bytes,3,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // The address of the oracle + Oracle string `protobuf:"bytes,4,opt,name=oracle,proto3" json:"oracle,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -75,24 +77,25 @@ func init() { } var fileDescriptor_f8d8aecd974cfd80 = []byte{ - // 262 bytes of a gzipped FileDescriptorProto + // 274 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0xa5, 0x14, 0xb1, 0x9a, 0x57, 0x90, 0x58, 0x94, 0x98, 0x0b, 0x35, - 0x4e, 0xa9, 0x93, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x41, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, 0x14, - 0x17, 0x47, 0x71, 0x6a, 0x61, 0x69, 0x6a, 0x5e, 0x72, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4b, - 0x10, 0x9c, 0x2f, 0x64, 0xc5, 0xc5, 0x06, 0xd1, 0x2c, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, - 0xa3, 0x87, 0xcd, 0x31, 0x7a, 0x01, 0x60, 0x35, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, - 0x75, 0x08, 0x89, 0x73, 0xb1, 0x17, 0xe4, 0x17, 0x95, 0xc4, 0x67, 0xa6, 0x48, 0x30, 0x2b, 0x30, - 0x6a, 0x70, 0x06, 0xb1, 0x81, 0xb8, 0x9e, 0x29, 0x56, 0x1c, 0x1d, 0x0b, 0xe4, 0x19, 0x5e, 0x2c, - 0x90, 0x67, 0x70, 0x4a, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, - 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, 0xf1, - 0xcc, 0x7c, 0xac, 0x56, 0x05, 0x30, 0x46, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, - 0xe7, 0xe7, 0xea, 0x23, 0x94, 0xe8, 0x66, 0xe6, 0x23, 0xf1, 0xf4, 0x2b, 0x60, 0xde, 0x2f, 0xa9, - 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xfb, 0xdd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xef, - 0xaf, 0x1e, 0x70, 0x01, 0x00, 0x00, + 0x4e, 0x69, 0x21, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0x82, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x29, + 0x2e, 0x8e, 0xe2, 0xd4, 0xc2, 0xd2, 0xd4, 0xbc, 0xe4, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x96, + 0x20, 0x38, 0x5f, 0xc8, 0x8a, 0x8b, 0x0d, 0xa2, 0x59, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, + 0x46, 0x0f, 0x9b, 0x63, 0xf4, 0x02, 0xc0, 0x6a, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, + 0xea, 0x10, 0x12, 0xe7, 0x62, 0x2f, 0xc8, 0x2f, 0x2a, 0x89, 0xcf, 0x4c, 0x91, 0x60, 0x56, 0x60, + 0xd4, 0xe0, 0x0c, 0x62, 0x03, 0x71, 0x3d, 0x53, 0x84, 0xc4, 0xb8, 0xd8, 0x20, 0x5a, 0x25, 0x58, + 0x20, 0xe2, 0x10, 0x9e, 0x15, 0x47, 0xc7, 0x02, 0x79, 0x86, 0x17, 0x0b, 0xe4, 0x19, 0x9c, 0xd2, + 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, + 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x81, 0x4b, 0x3c, 0x33, 0x1f, 0xab, 0x13, + 0x02, 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, + 0x4a, 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0xb0, 0x60, 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, + 0x62, 0x03, 0x87, 0x89, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x98, 0xea, 0xb1, 0x01, 0x88, 0x01, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -115,6 +118,13 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Oracle) > 0 { + i -= len(m.Oracle) + copy(dAtA[i:], m.Oracle) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Oracle))) + i-- + dAtA[i] = 0x22 + } if len(m.PortId) > 0 { i -= len(m.PortId) copy(dAtA[i:], m.PortId) @@ -166,6 +176,10 @@ func (m *GenesisState) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = len(m.Oracle) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -288,6 +302,38 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.PortId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Oracle", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Oracle = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go index a38557bae8..2f05108c6e 100644 --- a/x/oracle/types/genesis_test.go +++ b/x/oracle/types/genesis_test.go @@ -10,11 +10,13 @@ func TestNewGenesisState(t *testing.T) { port := "random" params := DefaultParams() sequence := uint64(10) + oracle := "oracle" - genesis := NewGenesisState(port, params, sequence) + genesis := NewGenesisState(port, params, sequence, oracle) assert.Equal(t, port, genesis.PortId, "port id must match") assert.Equal(t, params, genesis.Params, "params must match") assert.Equal(t, int(sequence), int(genesis.Sequence), "sequence must match") + assert.Equal(t, oracle, genesis.Oracle, "oracle must match") } func TestDefaultGenesis(t *testing.T) { @@ -24,6 +26,7 @@ func TestDefaultGenesis(t *testing.T) { assert.Equal(t, PortID, genesis.PortId, "port id must match") assert.Equal(t, params, genesis.Params, "params must match") assert.Equal(t, int(1), int(genesis.Sequence), "sequence must be 1") + assert.Equal(t, "", genesis.Oracle, "oracle must match") } func TestGenesisValidate(t *testing.T) { @@ -34,18 +37,27 @@ func TestGenesisValidate(t *testing.T) { }{ { name: "success - all fields are valid", - state: NewGenesisState(PortID, DefaultParams(), 1), + state: NewGenesisState(PortID, DefaultParams(), 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + }, + { + name: "success - all fields are valid with empty oracle", + state: NewGenesisState(PortID, DefaultParams(), 1, ""), }, { name: "failure - port id is invalid", - state: NewGenesisState("x", DefaultParams(), 1), + state: NewGenesisState("x", DefaultParams(), 1, ""), err: "identifier x has invalid length: 1, must be between 2-128 characters: invalid identifier", }, { name: "failure - sequence id is invalid", - state: NewGenesisState(PortID, DefaultParams(), 0), + state: NewGenesisState(PortID, DefaultParams(), 0, ""), err: "sequence 0 is invalid, must be greater than 0", }, + { + name: "failure - oracle is invalid", + state: NewGenesisState(PortID, DefaultParams(), 1, "abc"), + err: "decoding bech32 failed: invalid bech32 string length 3", + }, } for _, tc := range tests { From ba0b65c54f61f99c951fe4694271847dbad0fb00 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 11:35:47 -0400 Subject: [PATCH 52/96] Error is not thrown when oracle is not set. Empty address will just be returned. --- x/oracle/keeper/query_server.go | 5 +---- x/oracle/keeper/query_server_test.go | 7 +++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 5caf3cc6eb..2a409272fe 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -19,10 +19,7 @@ func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddre } ctx := sdk.UnwrapSDKContext(goCtx) - oracle, err := k.GetOracle(ctx) - if err != nil { - return nil, err - } + oracle, _ := k.GetOracle(ctx) return &types.QueryOracleAddressResponse{Address: oracle.String()}, nil } diff --git a/x/oracle/keeper/query_server_test.go b/x/oracle/keeper/query_server_test.go index dddb1648cf..26020e7c10 100644 --- a/x/oracle/keeper/query_server_test.go +++ b/x/oracle/keeper/query_server_test.go @@ -21,13 +21,12 @@ func (s *KeeperTestSuite) TestOracleAddress() { err: "rpc error: code = InvalidArgument desc = invalid request", }, { - name: "failure - should throw error when missing oracle address", + name: "success - should return correct oracle address", req: &types.QueryOracleAddressRequest{}, - expected: nil, - err: types.ErrMissingOracleAddress.Error(), + expected: &types.QueryOracleAddressResponse{Address: ""}, }, { - name: "success - should throw error when missing oracle address", + name: "success - should return correct oracle address", req: &types.QueryOracleAddressRequest{}, oracle: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", expected: &types.QueryOracleAddressResponse{Address: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"}, From 739270f67d4718cef78999d42b9e1cc65ae67fdb Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 11:37:38 -0400 Subject: [PATCH 53/96] Added cli queries test for oracle. --- x/oracle/client/cli/cli_test.go | 171 ++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 x/oracle/client/cli/cli_test.go diff --git a/x/oracle/client/cli/cli_test.go b/x/oracle/client/cli/cli_test.go new file mode 100644 index 0000000000..d36f26bf49 --- /dev/null +++ b/x/oracle/client/cli/cli_test.go @@ -0,0 +1,171 @@ +package cli_test + +import ( + "fmt" + "testing" + + tmcli "github.com/tendermint/tendermint/libs/cli" + + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/stretchr/testify/suite" + + "github.com/provenance-io/provenance/internal/antewrapper" + "github.com/provenance-io/provenance/internal/pioconfig" + "github.com/provenance-io/provenance/testutil" + oraclecli "github.com/provenance-io/provenance/x/oracle/client/cli" + "github.com/provenance-io/provenance/x/oracle/types" + oracletypes "github.com/provenance-io/provenance/x/oracle/types" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network + keyring keyring.Keyring + keyringDir string + + accountAddr sdk.AccAddress + accountKey *secp256k1.PrivKey + accountAddresses []sdk.AccAddress + + params oracletypes.Params + sequence uint64 + port string + oracle string +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + pioconfig.SetProvenanceConfig("", 0) + s.accountKey = secp256k1.GenPrivKeyFromSecret([]byte("acc2")) + addr, err := sdk.AccAddressFromHexUnsafe(s.accountKey.PubKey().Address().String()) + s.Require().NoError(err) + s.accountAddr = addr + + s.cfg = testutil.DefaultTestNetworkConfig() + genesisState := s.cfg.GenesisState + + s.cfg.NumValidators = 1 + s.GenerateAccountsWithKeyrings(2) + + var genBalances []banktypes.Balance + for i := range s.accountAddresses { + genBalances = append(genBalances, banktypes.Balance{Address: s.accountAddresses[i].String(), Coins: sdk.NewCoins( + sdk.NewCoin("nhash", sdk.NewInt(100000000)), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100000000)), + ).Sort()}) + } + var bankGenState banktypes.GenesisState + bankGenState.Params = banktypes.DefaultParams() + bankGenState.Balances = genBalances + bankDataBz, err := s.cfg.Codec.MarshalJSON(&bankGenState) + s.Require().NoError(err, "should be able to marshal bank genesis state when setting up suite") + genesisState[banktypes.ModuleName] = bankDataBz + + var authData authtypes.GenesisState + var genAccounts []authtypes.GenesisAccount + authData.Params = authtypes.DefaultParams() + genAccounts = append(genAccounts, authtypes.NewBaseAccount(s.accountAddresses[0], nil, 3, 0)) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(s.accountAddresses[1], nil, 4, 0)) + accounts, err := authtypes.PackAccounts(genAccounts) + s.Require().NoError(err, "should be able to pack accounts for genesis state when setting up suite") + authData.Accounts = accounts + authDataBz, err := s.cfg.Codec.MarshalJSON(&authData) + s.Require().NoError(err, "should be able to marshal auth genesis state when setting up suite") + genesisState[authtypes.ModuleName] = authDataBz + + s.sequence = uint64(1) + s.params = oracletypes.DefaultParams() + s.port = oracletypes.PortID + s.oracle = "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma" + + oracleData := oracletypes.NewGenesisState( + s.port, + s.params, + s.sequence, + s.oracle, + ) + + oracleDataBz, err := s.cfg.Codec.MarshalJSON(oracleData) + s.Require().NoError(err, "should be able to marshal trigger genesis state when setting up suite") + genesisState[oracletypes.ModuleName] = oracleDataBz + + s.cfg.GenesisState = genesisState + + s.cfg.ChainID = antewrapper.SimAppChainID + + s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) + s.Require().NoError(err, "network.New") + + _, err = s.network.WaitForHeight(6) + s.Require().NoError(err, "WaitForHeight") +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.Require().NoError(s.network.WaitForNextBlock(), "WaitForNextBlock") + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) GenerateAccountsWithKeyrings(number int) { + path := hd.CreateHDPath(118, 0, 0).String() + s.keyringDir = s.T().TempDir() + kr, err := keyring.New(s.T().Name(), "test", s.keyringDir, nil, s.cfg.Codec) + s.Require().NoError(err, "Keyring.New") + s.keyring = kr + for i := 0; i < number; i++ { + keyId := fmt.Sprintf("test_key%v", i) + info, _, err := kr.NewMnemonic(keyId, keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + s.Require().NoError(err, "Keyring.NewMneomonic") + addr, err := info.GetAddress() + if err != nil { + panic(err) + } + s.accountAddresses = append(s.accountAddresses, addr) + } +} + +func (s *IntegrationTestSuite) TestQueryOracleAddress() { + testCases := []struct { + name string + expectErrMsg string + expectedCode uint32 + expectedAddress string + }{ + { + name: "success - query for oracle address", + expectedAddress: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + expectedCode: 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + clientCtx := s.network.Validators[0].ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, oraclecli.GetQueryOracleAddressCmd(), []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + if len(tc.expectErrMsg) > 0 { + s.EqualError(err, tc.expectErrMsg, "should have correct error message for invalid QueryOracleAddress") + } else { + var response types.QueryOracleAddressResponse + s.NoError(err, "should have no error message for valid QueryOracleAddress") + err = s.cfg.Codec.UnmarshalJSON(out.Bytes(), &response) + s.NoError(err, "should have no error message when unmarshalling response to QueryOracleAddress") + s.Equal(tc.expectedAddress, response.Address, "should have the correct oracle address") + } + }) + } +} From 3478888ce401cbfa86ca54feebf96cef60797ff5 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 11:39:21 -0400 Subject: [PATCH 54/96] Updated link in genesis spec. --- x/oracle/spec/06_genesis.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/oracle/spec/06_genesis.md b/x/oracle/spec/06_genesis.md index 4f8e37f7a4..8e67f3ef5f 100644 --- a/x/oracle/spec/06_genesis.md +++ b/x/oracle/spec/06_genesis.md @@ -16,4 +16,4 @@ In this section we describe the processing of the oracle messages and the corres The GenesisState encompasses the upcoming sequence ID for an ICQ packet, the associated parameters, the designated port ID for the module, and the oracle address. These values are both extracted for export and imported for storage within the store. -+++ https://github.com/provenance-io/provenance/blob/65865991f93e2c1a7647e29be11f6527f49616e6/proto/provenance/oracle/v1/genesis.proto#L11-L22 ++++ https://github.com/provenance-io/provenance/blob/ba0b65c54f61f99c951fe4694271847dbad0fb00/proto/provenance/oracle/v1/genesis.proto#L11-L24 From 8492f30f664ebb860194ffa0b3a57a6b4ed0cc7c Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 12:09:22 -0400 Subject: [PATCH 55/96] Added cli tx test for oracle. --- x/oracle/client/cli/cli_test.go | 129 ++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/x/oracle/client/cli/cli_test.go b/x/oracle/client/cli/cli_test.go index d36f26bf49..a9dd376946 100644 --- a/x/oracle/client/cli/cli_test.go +++ b/x/oracle/client/cli/cli_test.go @@ -6,6 +6,7 @@ import ( tmcli "github.com/tendermint/tendermint/libs/cli" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -169,3 +170,131 @@ func (s *IntegrationTestSuite) TestQueryOracleAddress() { }) } } + +func (s *IntegrationTestSuite) TestOracleUpdate() { + testCases := []struct { + name string + address string + expectErrMsg string + expectedCode uint32 + signer string + }{ + { + name: "success - address updated", + address: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma", + expectedCode: 0, + signer: s.accountAddresses[0].String(), + }, + { + name: "failure - unable to pass validate basic with bad address", + address: "badaddress", + expectErrMsg: "invalid address for oracle: decoding bech32 failed: invalid separator index -1", + signer: s.accountAddresses[0].String(), + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + + clientCtx := s.network.Validators[0].ClientCtx.WithKeyringDir(s.keyringDir).WithKeyring(s.keyring) + + args := []string{ + tc.address, + } + flags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, tc.signer), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + args = append(args, flags...) + + out, err := clitestutil.ExecTestCLICmd(clientCtx, oraclecli.GetCmdOracleUpdate(), append(args, []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}...)) + var response sdk.TxResponse + marshalErr := clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response) + if len(tc.expectErrMsg) > 0 { + s.Assert().EqualError(err, tc.expectErrMsg, "should have correct error for invalid OracleUpdate request") + s.Assert().Equal(tc.expectedCode, response.Code, "should have correct response code for invalid OracleUpdate request") + } else { + s.Assert().NoError(err, "should have no error for valid OracleUpdate request") + s.Assert().NoError(marshalErr, out.String(), "should have no marshal error for valid OracleUpdate request") + s.Assert().Equal(tc.expectedCode, response.Code, "should have correct response code for valid OracleUpdate request") + } + }) + } +} + +func (s *IntegrationTestSuite) TestSendQuery() { + testCases := []struct { + name string + query string + channel string + expectErrMsg string + expectedCode uint32 + signer string + }{ + { + name: "success - a valid message was attempted to be sent on ibc", + query: "{}", + channel: "channel-1", + expectedCode: 9, + signer: s.accountAddresses[0].String(), + }, + { + name: "failure - invalid query data", + query: "abc", + expectErrMsg: "query data must be json", + channel: "channel-1", + signer: s.accountAddresses[0].String(), + }, + { + name: "failure - invalid channel format", + query: "{}", + expectErrMsg: "invalid channel id", + channel: "a", + signer: s.accountAddresses[0].String(), + }, + { + name: "failure - invalid signer", + query: "{}", + expectErrMsg: "abc.info: key not found", + channel: "channel-1", + signer: "abc", + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + + clientCtx := s.network.Validators[0].ClientCtx.WithKeyringDir(s.keyringDir).WithKeyring(s.keyring) + + args := []string{ + tc.channel, + tc.query, + } + flags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, tc.signer), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + args = append(args, flags...) + + out, err := clitestutil.ExecTestCLICmd(clientCtx, oraclecli.GetCmdSendQuery(), append(args, []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}...)) + var response sdk.TxResponse + marshalErr := clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response) + if len(tc.expectErrMsg) > 0 { + s.Assert().EqualError(err, tc.expectErrMsg, "should have correct error for invalid SendQuery request") + s.Assert().Equal(tc.expectedCode, response.Code, "should have correct response code for invalid SendQuery request") + } else { + s.Assert().NoError(err, "should have no error for valid SendQuery request") + s.Assert().NoError(marshalErr, out.String(), "should have no marshal error for valid SendQuery request") + s.Assert().Equal(tc.expectedCode, response.Code, "should have correct response code for valid SendQuery request") + } + }) + } +} From 546e2c2df06dcc805ca93f24fce3a9c21ce9f59a Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 14:37:33 -0400 Subject: [PATCH 56/96] First attempt at simulation tets for oracle module. --- x/oracle/simulation/genesis.go | 22 ++- x/oracle/simulation/operations.go | 28 +++- x/oracle/simulation/operations_test.go | 224 +++++++++++++++++++++++++ 3 files changed, 267 insertions(+), 7 deletions(-) create mode 100644 x/oracle/simulation/operations_test.go diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 6f7f1ac347..6c3e703135 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -19,19 +19,27 @@ const ( // SequenceIDFn randomized sequence id func SequenceIDFn(r *rand.Rand) uint64 { - return uint64(randIntBetween(r, 1, 10000000000)) + return uint64(randIntBetween(r, 0, 10000000000)) } // PortFn randomized port name func PortFn(r *rand.Rand) string { - randomName := uint64(randIntBetween(r, 0, 1)) - if randomName < 1 { + if r.Intn(2) > 0 { return "oracle" } length := uint64(randIntBetween(r, 6, 10)) return strings.ToLower(simtypes.RandStringOfLength(r, int(length))) } +// OracleFn randomized oracle address +func OracleFn(r *rand.Rand, accs []simtypes.Account) string { + randomAccount, _ := RandomAccs(r, accs, 1) + if r.Intn(2) > 0 { + return "" + } + return randomAccount[0].Address.String() +} + // RandomizedGenState generates a random GenesisState for trigger func RandomizedGenState(simState *module.SimulationState) { var sequenceID uint64 @@ -48,7 +56,13 @@ func RandomizedGenState(simState *module.SimulationState) { params := types.DefaultParams() - genesis := types.NewGenesisState(port, params, sequenceID, "") + var oracle string + simState.AppParams.GetOrGenerate( + simState.Cdc, Port, &port, simState.Rand, + func(r *rand.Rand) { oracle = OracleFn(r, simState.Accounts) }, + ) + + genesis := types.NewGenesisState(port, params, sequenceID, oracle) simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(genesis) bz, err := json.MarshalIndent(simState.GenState[types.ModuleName], "", " ") diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index 163609eef2..2f01e6efde 100644 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -61,16 +61,21 @@ func WeightedOperations( } // SimulateMsgCreateTrigger sends a MsgUpdateOracle. -func SimulateMsgUpdateOracle(_ keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation { +func SimulateMsgUpdateOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - raccs, err := RandomAccs(r, accs, 2) + raccs, err := RandomAccs(r, accs, uint64(len(accs))) if err != nil { return simtypes.NoOpMsg(sdk.MsgTypeURL(&types.MsgUpdateOracleRequest{}), sdk.MsgTypeURL(&types.MsgUpdateOracleRequest{}), err.Error()), nil, nil } + + // 50% chance to be from the module's authority from := raccs[0] to := raccs[1] + if r.Intn(2) > 0 { + from = simtypes.Account{Address: sdk.MustAccAddressFromBech32(k.GetAuthority())} + } msg := types.NewMsgUpdateOracle(from.Address.String(), to.Address.String()) @@ -84,6 +89,7 @@ func SimulateMsgSendQueryOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, b r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { raccs, err := RandomAccs(r, accs, 1) + if err != nil { return simtypes.NoOpMsg(sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), err.Error()), nil, nil } @@ -93,7 +99,7 @@ func SimulateMsgSendQueryOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, b if err != nil { return simtypes.NoOpMsg(sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), err.Error()), nil, nil } - query := []byte("{}") + query := randomQuery(r, ctx) msg := types.NewMsgSendQueryOracle(addr.Address.String(), channel, query) return Dispatch(r, app, ctx, addr, chainID, msg, ak, bk, nil) @@ -175,3 +181,19 @@ func randomChannel(r *rand.Rand, ctx sdk.Context, ck channelkeeper.Keeper) (stri idx := r.Intn(len(channels)) return channels[idx].String(), nil } + +func randomQuery(r *rand.Rand, ctx sdk.Context) []byte { + queryType := randIntBetween(r, 0, 3) + var query string + if queryType == 0 { + query = "" + } else if queryType == 1 { + query = "{}" + } else if queryType == 2 { + query = "{\"version\":{}}" + } else { + query = "xyz" + } + + return []byte(query) +} diff --git a/x/oracle/simulation/operations_test.go b/x/oracle/simulation/operations_test.go new file mode 100644 index 0000000000..9d3eca2d23 --- /dev/null +++ b/x/oracle/simulation/operations_test.go @@ -0,0 +1,224 @@ +package simulation_test + +import ( + "bytes" + "fmt" + "math/rand" + "strings" + + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/bank/testutil" + "github.com/provenance-io/provenance/app" + simappparams "github.com/provenance-io/provenance/app/params" + "github.com/provenance-io/provenance/x/oracle/simulation" + "github.com/provenance-io/provenance/x/oracle/types" + "github.com/stretchr/testify/suite" +) + +type SimTestSuite struct { + suite.Suite + + ctx sdk.Context + app *app.App +} + +func (s *SimTestSuite) SetupTest() { + s.app = app.Setup(s.T()) + s.ctx = s.app.BaseApp.NewContext(false, tmproto.Header{}) +} + +// LogOperationMsg logs all fields of the provided operationMsg. +func (s *SimTestSuite) LogOperationMsg(operationMsg simtypes.OperationMsg, msg string, args ...interface{}) { + msgFmt := "%s" + if len(bytes.TrimSpace(operationMsg.Msg)) == 0 { + msgFmt = " %q" + } + fmtLines := []string{ + fmt.Sprintf(msg, args...), + "operationMsg.Route: %q", + "operationMsg.Name: %q", + "operationMsg.Comment: %q", + "operationMsg.OK: %t", + "operationMsg.Msg: " + msgFmt, + } + s.T().Logf(strings.Join(fmtLines, "\n"), + operationMsg.Route, operationMsg.Name, operationMsg.Comment, operationMsg.OK, string(operationMsg.Msg), + ) +} + +func (s *SimTestSuite) TestWeightedOperations() { + cdc := s.app.AppCodec() + appParams := make(simtypes.AppParams) + + weightedOps := simulation.WeightedOperations(appParams, cdc, s.app.OracleKeeper, + s.app.AccountKeeper, s.app.BankKeeper, s.app.IBCKeeper.ChannelKeeper, + ) + + // setup 3 accounts + source := rand.NewSource(1) + r := rand.New(source) + accs := s.getTestingAccounts(r, 3) + + // begin a new block + s.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash}}) + + expected := []struct { + weight int + opMsgRoute string + opMsgName string + }{ + {simappparams.DefaultWeightUpdateOracle, sdk.MsgTypeURL(&types.MsgUpdateOracleRequest{}), sdk.MsgTypeURL(&types.MsgUpdateOracleRequest{})}, + {simappparams.DefaultWeightSendOracleQuery, sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{})}, + } + + expNames := make([]string, len(expected)) + for i, exp := range expected { + expNames[i] = exp.opMsgName + } + + // Run all the ops and get the operation messages and their names. + opMsgs := make([]simtypes.OperationMsg, len(weightedOps)) + actualNames := make([]string, len(weightedOps)) + for i, w := range weightedOps { + opMsgs[i], _, _ = w.Op()(r, s.app.BaseApp, s.ctx, accs, "") + actualNames[i] = opMsgs[i].Name + } + + // First, make sure the op names are as expected since a failure there probably means the rest will fail. + // And it's probably easier to address when you've got a nice list comparison of names and their orderings. + s.Require().Equal(expNames, actualNames, "operation message names") + + // Now assert that each entry was as expected. + for i := range expected { + s.Assert().Equal(expected[i].weight, weightedOps[i].Weight(), "weightedOps[%d].Weight", i) + s.Assert().Equal(expected[i].opMsgRoute, opMsgs[i].Route, "weightedOps[%d] operationMsg.Route", i) + s.Assert().Equal(expected[i].opMsgName, opMsgs[i].Name, "weightedOps[%d] operationMsg.Name", i) + } +} + +func (s *SimTestSuite) TestSimulateMsgUpdateOracle() { + // setup 3 accounts + source := rand.NewSource(1) + r := rand.New(source) + accounts := s.getTestingAccounts(r, 3) + + // begin a new block + s.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash}}) + + // execute operation + op := simulation.SimulateMsgUpdateOracle(s.app.OracleKeeper, s.app.AccountKeeper, s.app.BankKeeper) + operationMsg, futureOperations, err := op(r, s.app.BaseApp, s.ctx, accounts, "") + s.Require().NoError(err, "SimulateMsgUpdateOracle op(...) error") + s.LogOperationMsg(operationMsg, "good") + + var msg types.MsgUpdateOracleRequest + s.Require().NoError(s.app.AppCodec().UnmarshalJSON(operationMsg.Msg, &msg), "UnmarshalJSON(operationMsg.Msg)") + + s.Assert().True(operationMsg.OK, "operationMsg.OK") + s.Assert().Equal(sdk.MsgTypeURL(&msg), operationMsg.Name, "operationMsg.Name") + s.Assert().Equal(sdk.MsgTypeURL(&msg), operationMsg.Route, "operationMsg.Route") + s.Assert().Len(futureOperations, 0, "futureOperations") +} + +func (s *SimTestSuite) TestSimulateMsgSendQueryOracle() { + // setup 3 accounts + source := rand.NewSource(1) + r := rand.New(source) + accounts := s.getTestingAccounts(r, 3) + + // begin a new block + s.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash}}) + + // execute operation + op := simulation.SimulateMsgSendQueryOracle(s.app.OracleKeeper, s.app.AccountKeeper, s.app.BankKeeper, s.app.IBCKeeper.ChannelKeeper) + operationMsg, futureOperations, err := op(r, s.app.BaseApp, s.ctx, accounts, "") + s.Require().NoError(err, "SimulateMsgSendQueryOracle op(...) error") + s.LogOperationMsg(operationMsg, "good") + + var msg types.MsgUpdateOracleRequest + s.Require().NoError(s.app.AppCodec().UnmarshalJSON(operationMsg.Msg, &msg), "UnmarshalJSON(operationMsg.Msg)") + + s.Assert().True(operationMsg.OK, "operationMsg.OK") + s.Assert().Equal(sdk.MsgTypeURL(&msg), operationMsg.Name, "operationMsg.Name") + s.Assert().Equal(sdk.MsgTypeURL(&msg), operationMsg.Route, "operationMsg.Route") + s.Assert().Len(futureOperations, 0, "futureOperations") +} + +func (s *SimTestSuite) TestRandomAccs() { + source := rand.NewSource(1) + r := rand.New(source) + accounts := s.getTestingAccounts(r, 3) + + tests := []struct { + name string + accs []simtypes.Account + expected []simtypes.Account + count uint64 + err string + }{ + { + name: "valid - return nothing when count is 0", + accs: []simtypes.Account{}, + expected: []simtypes.Account{}, + count: 0, + }, + { + name: "valid - return 1 when count is 1", + accs: []simtypes.Account{accounts[0]}, + expected: []simtypes.Account{accounts[0]}, + count: 1, + }, + { + name: "valid - return multiple when count greater than 1", + accs: []simtypes.Account{accounts[0], accounts[1]}, + expected: []simtypes.Account{accounts[1], accounts[0]}, + count: 2, + }, + { + name: "valid - return is limited by count", + accs: []simtypes.Account{accounts[0], accounts[1], accounts[2]}, + expected: []simtypes.Account{accounts[1]}, + count: 1, + }, + { + name: "invalid - return error when count is greater than length", + accs: []simtypes.Account{accounts[0], accounts[1]}, + expected: []simtypes.Account{}, + count: 3, + err: "cannot choose 3 accounts because there are only 2", + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + raccs, err := simulation.RandomAccs(r, tc.accs, tc.count) + if len(tc.err) == 0 { + s.Require().NoError(err, "should have no error for successful RandomAccs") + s.Require().Equal(tc.expected, raccs, "should have correct output for successful RandomAccs") + } else { + s.Require().EqualError(err, tc.err, "should have correct error message for RandomAccs") + } + }) + } +} + +func (s *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { + accounts := simtypes.RandomAccounts(r, n) + + initAmt := sdk.TokensFromConsensusPower(1000000, sdk.DefaultPowerReduction) + initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) + + // add coins to the accounts + for _, account := range accounts { + acc := s.app.AccountKeeper.NewAccountWithAddress(s.ctx, account.Address) + s.app.AccountKeeper.SetAccount(s.ctx, acc) + err := testutil.FundAccount(s.app.BankKeeper, s.ctx, account.Address, initCoins) + s.Require().NoError(err) + } + + return accounts +} From ee54dbb8a327e2b0e6ac54d022c087349787133e Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 15:36:07 -0400 Subject: [PATCH 57/96] Linted files and fixed one sim test. --- app/app.go | 6 +++--- x/oracle/client/cli/query.go | 5 +++-- x/oracle/client/cli/tx.go | 4 +++- x/oracle/keeper/genesis.go | 1 + x/oracle/keeper/icq.go | 5 ++++- x/oracle/keeper/keeper.go | 5 +++-- x/oracle/keeper/msg_server.go | 1 + x/oracle/keeper/oracle.go | 1 + x/oracle/keeper/params.go | 1 + x/oracle/keeper/query.go | 4 +++- x/oracle/keeper/query_server.go | 6 ++++-- x/oracle/keeper/relay.go | 10 ++++++---- x/oracle/module/module.go | 12 ++++++++---- x/oracle/module/module_ibc.go | 6 +++--- x/oracle/simulation/decoder.go | 3 +-- x/oracle/simulation/genesis.go | 4 ++-- x/oracle/simulation/operations.go | 4 +--- x/oracle/types/codec.go | 3 ++- x/oracle/types/params.go | 3 ++- 19 files changed, 52 insertions(+), 32 deletions(-) diff --git a/app/app.go b/app/app.go index d226b8c441..a8903b5b28 100644 --- a/app/app.go +++ b/app/app.go @@ -17,6 +17,9 @@ import ( "github.com/rakyll/statik/fs" "github.com/spf13/cast" "github.com/spf13/viper" + icq "github.com/strangelove-ventures/async-icq/v6" + icqkeeper "github.com/strangelove-ventures/async-icq/v6/keeper" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" @@ -117,9 +120,6 @@ import ( porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host" ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper" - icq "github.com/strangelove-ventures/async-icq/v6" - icqkeeper "github.com/strangelove-ventures/async-icq/v6/keeper" - icqtypes "github.com/strangelove-ventures/async-icq/v6/types" appparams "github.com/provenance-io/provenance/app/params" "github.com/provenance-io/provenance/internal/antewrapper" diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index 897b4c82bf..29ea90e673 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -4,11 +4,13 @@ import ( "context" "fmt" + "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" + "github.com/provenance-io/provenance/x/oracle/types" - "github.com/spf13/cobra" ) // GetQueryCmd is the top-level command for oracle CLI queries. @@ -35,7 +37,6 @@ func GetQueryOracleAddressCmd() *cobra.Command { Aliases: []string{"a"}, Example: fmt.Sprintf(`%[1]s q oracle address`, version.AppName), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index e8de06fcfa..172f0986ac 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -7,6 +7,8 @@ import ( "errors" "fmt" + "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -16,8 +18,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/provenance-io/provenance/x/oracle/types" - "github.com/spf13/cobra" ) // The flag to specify that the command should be ran as a gov proposal diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 3629b712b7..9c6d3c213b 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" ) diff --git a/x/oracle/keeper/icq.go b/x/oracle/keeper/icq.go index ed35712757..b0bf0c25ba 100644 --- a/x/oracle/keeper/icq.go +++ b/x/oracle/keeper/icq.go @@ -4,13 +4,16 @@ import ( "time" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + + abcitypes "github.com/tendermint/tendermint/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" + "github.com/provenance-io/provenance/x/oracle/types" - abcitypes "github.com/tendermint/tendermint/abci/types" ) // QueryOracle sends an ICQ to the other chain's module diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index f7124dfd32..7e06919833 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -1,9 +1,10 @@ package keeper import ( + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/tendermint/tendermint/libs/log" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,6 +13,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" + "github.com/provenance-io/provenance/x/oracle/types" ) @@ -42,7 +44,6 @@ func NewKeeper( scopedKeeper types.ScopedKeeper, wasmQueryServer wasmtypes.QueryServer, ) *Keeper { - if !ps.HasKeyTable() { ps = ps.WithKeyTable(types.ParamKeyTable()) } diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 29e76c662c..029ee6228d 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/provenance-io/provenance/x/oracle/types" ) diff --git a/x/oracle/keeper/oracle.go b/x/oracle/keeper/oracle.go index 5db8c33a4a..94ecb24872 100644 --- a/x/oracle/keeper/oracle.go +++ b/x/oracle/keeper/oracle.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" ) diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index 8af6500235..b483062da7 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" ) diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go index 2c3d509b4a..a0e216aa96 100644 --- a/x/oracle/keeper/query.go +++ b/x/oracle/keeper/query.go @@ -1,8 +1,10 @@ package keeper import ( - sdk "github.com/cosmos/cosmos-sdk/types" gogotypes "github.com/gogo/protobuf/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/oracle/types" ) diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 2a409272fe..6627d12a34 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -4,10 +4,12 @@ import ( "context" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/provenance-io/provenance/x/oracle/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/provenance-io/provenance/x/oracle/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index ee59f65864..3c9dfede49 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -3,15 +3,17 @@ package keeper import ( "strconv" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" + + abci "github.com/tendermint/tendermint/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/provenance-io/provenance/x/oracle/types" - clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" - icqtypes "github.com/strangelove-ventures/async-icq/v6/types" - abci "github.com/tendermint/tendermint/abci/types" + + "github.com/provenance-io/provenance/x/oracle/types" ) // SendQuery sends and records an icq diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index 983bf7f4cd..b9da5ad9b5 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -5,7 +5,14 @@ import ( "encoding/json" "math/rand" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + cerrs "cosmossdk.io/errors" + sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -15,14 +22,11 @@ import ( authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" channelkeeper "github.com/cosmos/ibc-go/v6/modules/core/04-channel/keeper" - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/provenance-io/provenance/x/oracle/client/cli" "github.com/provenance-io/provenance/x/oracle/keeper" "github.com/provenance-io/provenance/x/oracle/simulation" "github.com/provenance-io/provenance/x/oracle/types" - "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" ) var ( diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index 9a76604ad7..786e5ab7a5 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -1,6 +1,8 @@ package oracle import ( + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -8,8 +10,8 @@ import ( porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported" + "github.com/provenance-io/provenance/x/oracle/types" - icqtypes "github.com/strangelove-ventures/async-icq/v6/types" ) // OnChanOpenInit implements the IBCModule interface @@ -23,7 +25,6 @@ func (am AppModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) (string, error) { - // Require portID is the portID module is bound to boundPort := am.keeper.GetPort(ctx) if boundPort != portID { @@ -53,7 +54,6 @@ func (am AppModule) OnChanOpenTry( counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { - // Require portID is the portID module is bound to boundPort := am.keeper.GetPort(ctx) if boundPort != portID { diff --git a/x/oracle/simulation/decoder.go b/x/oracle/simulation/decoder.go index 9d0b857cf8..6c80a74134 100644 --- a/x/oracle/simulation/decoder.go +++ b/x/oracle/simulation/decoder.go @@ -6,9 +6,8 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/types/kv" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/provenance-io/provenance/x/oracle/types" ) diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 6c3e703135..0178087cc1 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/provenance-io/provenance/x/oracle/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/provenance-io/provenance/x/oracle/types" ) const ( diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index 2f01e6efde..d77704d387 100644 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/simulation" channelkeeper "github.com/cosmos/ibc-go/v6/modules/core/04-channel/keeper" + simappparams "github.com/provenance-io/provenance/app/params" "github.com/provenance-io/provenance/internal/pioconfig" "github.com/provenance-io/provenance/x/oracle/keeper" @@ -73,9 +74,6 @@ func SimulateMsgUpdateOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, bk b // 50% chance to be from the module's authority from := raccs[0] to := raccs[1] - if r.Intn(2) > 0 { - from = simtypes.Account{Address: sdk.MustAccAddressFromBech32(k.GetAuthority())} - } msg := types.NewMsgUpdateOracle(from.Address.String(), to.Address.String()) diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 60beec2721..14841c0fc2 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -1,10 +1,11 @@ package types import ( + "github.com/gogo/protobuf/proto" + "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/gogo/protobuf/proto" ) // ignoring RegisterLegacyAminoCodec registers all the necessary types and interfaces for the diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index 357196ad6a..cc90a6d87a 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -1,8 +1,9 @@ package types import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ paramtypes.ParamSet = (*Params)(nil) From 2759158b007c216a75b05e77a38ad337b7ecbefa Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 10 Aug 2023 16:19:15 -0400 Subject: [PATCH 58/96] Updated sim_test.go to add app state for icq. --- app/sim_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/sim_test.go b/app/sim_test.go index 16a6b3011d..a27739b512 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -13,6 +13,7 @@ import ( "testing" "time" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -72,6 +73,7 @@ func ProvAppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) s return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config) (json.RawMessage, []simtypes.Account, string, time.Time) { appState, simAccs, chainID, genesisTimestamp := sdksim.AppStateFn(cdc, simManager)(r, accs, config) appState = appStateWithICA(appState, cdc) + appState = appStateWithICQ(appState, cdc) return appState, simAccs, chainID, genesisTimestamp } } @@ -95,6 +97,25 @@ func appStateWithICA(appState json.RawMessage, cdc codec.JSONCodec) json.RawMess return appState } +// appStateWithICA checks the given appState for an ica entry. If it's not found, it's populated with the defaults. +func appStateWithICQ(appState json.RawMessage, cdc codec.JSONCodec) json.RawMessage { + rawState := make(map[string]json.RawMessage) + err := json.Unmarshal(appState, &rawState) + if err != nil { + panic(fmt.Sprintf("error unmarshalling 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 +} + func TestFullAppSimulation(t *testing.T) { config, db, dir, logger, skip, err := sdksim.SetupSimulation("leveldb-app-sim", "Simulation") if skip { From 8e4167430bfd96e279fc6d303e902cb3e0f5ec8d Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 10:37:10 -0400 Subject: [PATCH 59/96] Added saffron upgrade with oracle and icqhost configure. --- app/upgrades.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/upgrades.go b/app/upgrades.go index daf86fcdd0..59534a2344 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -14,7 +14,9 @@ import ( attributekeeper "github.com/provenance-io/provenance/x/attribute/keeper" attributetypes "github.com/provenance-io/provenance/x/attribute/types" msgfeetypes "github.com/provenance-io/provenance/x/msgfees/types" + oracletypes "github.com/provenance-io/provenance/x/oracle/types" triggertypes "github.com/provenance-io/provenance/x/trigger/types" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" ) // appUpgrade is an internal structure for defining all things for an upgrade. @@ -112,6 +114,20 @@ var upgrades = map[string]appUpgrade{ }, Added: []string{triggertypes.ModuleName}, }, + "saffron-rc1": { // upgrade for v1.16.0, + Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { + var err error + vm, err = runModuleMigrations(ctx, app, vm) + if err != nil { + return nil, err + } + + setupICQ(ctx, app) + + return vm, nil + }, + Added: []string{icqtypes.ModuleName, oracletypes.ModuleName}, + }, // TODO - Add new upgrade definitions here. } @@ -293,3 +309,11 @@ func fixNameIndexEntries(ctx sdk.Context, app *App) { func setAccountDataNameRecord(ctx sdk.Context, accountK attributetypes.AccountKeeper, nameK attributetypes.NameKeeper) (err error) { return attributekeeper.EnsureModuleAccountAndAccountDataNameRecord(ctx, accountK, nameK) } + +// setAccountDataNameRecord makes sure the account data name record exists, is restricted, +// and is owned by the attribute module. An error is returned if it fails to make it so. +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"})) + ctx.Logger().Info("Done updating ICQ params") +} From c4305c0ee47c7cfb003c40f698fc77c152017918 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 11:01:58 -0400 Subject: [PATCH 60/96] Did some linting on the code. --- proto/provenance/oracle/v1/query.proto | 1 - proto/provenance/oracle/v1/tx.proto | 2 - x/oracle/client/cli/tx.go | 2 +- x/oracle/keeper/keeper.go | 8 +-- x/oracle/keeper/params.go | 2 +- x/oracle/keeper/relay.go | 7 +-- x/oracle/module/module.go | 4 +- x/oracle/module/module_ibc.go | 73 +++++++++++++------------- x/oracle/simulation/decoder.go | 2 +- x/oracle/simulation/operations.go | 8 +-- x/oracle/types/expected_keepers.go | 4 +- x/oracle/types/keys.go | 8 --- x/oracle/types/query.pb.go | 58 ++++++++++---------- x/oracle/types/tx.pb.go | 62 ++++++++++------------ 14 files changed, 113 insertions(+), 128 deletions(-) diff --git a/proto/provenance/oracle/v1/query.proto b/proto/provenance/oracle/v1/query.proto index 3aa7b65d1c..d922616671 100644 --- a/proto/provenance/oracle/v1/query.proto +++ b/proto/provenance/oracle/v1/query.proto @@ -4,7 +4,6 @@ package provenance.oracle.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos_proto/cosmos.proto"; -import "google/protobuf/any.proto"; option go_package = "github.com/provenance-io/provenance/x/oracle/types"; option java_package = "io.provenance.oracle.v1"; diff --git a/proto/provenance/oracle/v1/tx.proto b/proto/provenance/oracle/v1/tx.proto index 19752ee2a2..ff1a03d0f6 100644 --- a/proto/provenance/oracle/v1/tx.proto +++ b/proto/provenance/oracle/v1/tx.proto @@ -3,8 +3,6 @@ package provenance.oracle.v1; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "google/protobuf/any.proto"; option go_package = "github.com/provenance-io/provenance/x/oracle/types"; option java_package = "io.provenance.oracle.v1"; diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 172f0986ac..ce3b88b990 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -110,7 +110,7 @@ func GetCmdSendQuery() *cobra.Command { queryData, err := decoder.DecodeString(args[1]) if err != nil { - return fmt.Errorf("decode query: %s", err) + return fmt.Errorf("decode query: %w", err) } if !json.Valid(queryData) { return errors.New("query data must be json") diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 7e06919833..7c42221f6c 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -93,13 +93,13 @@ func (k Keeper) SetPort(ctx sdk.Context, portID string) { } // AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function -func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { - return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) +func (k Keeper) AuthenticateCapability(ctx sdk.Context, capability *capabilitytypes.Capability, name string) bool { + return k.scopedKeeper.AuthenticateCapability(ctx, capability, name) } // ClaimCapability wraps the scopedKeeper's ClaimCapability function -func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { - return k.scopedKeeper.ClaimCapability(ctx, cap, name) +func (k Keeper) ClaimCapability(ctx sdk.Context, capability *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, capability, name) } // GetAuthority returns the module's authority address diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index b483062da7..3ff11b6b72 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -7,7 +7,7 @@ import ( ) // GetParams get all parameters as types.Params -func (k Keeper) GetParams(ctx sdk.Context) types.Params { +func (k Keeper) GetParams(_ sdk.Context) types.Params { return types.NewParams() } diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index 3c9dfede49..9771decaee 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -7,6 +7,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" + cerrs "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -28,7 +29,7 @@ func (k Keeper) SendQuery( ) (uint64, error) { sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) if !found { - return 0, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) + return 0, cerrs.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) } destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() @@ -62,7 +63,7 @@ func (k Keeper) createOutgoingPacket( // get the next sequence sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) if !found { - return 0, sdkerrors.Wrapf(channeltypes.ErrSequenceSendNotFound, "failed to retrieve next sequence send for channel %s on port %s", sourceChannel, sourcePort) + return 0, cerrs.Wrapf(channeltypes.ErrSequenceSendNotFound, "failed to retrieve next sequence send for channel %s on port %s", sourceChannel, sourcePort) } packet := channeltypes.NewPacket( @@ -106,7 +107,7 @@ func (k Keeper) OnAcknowledgementPacket( var r types.QueryOracleResponse if err := k.cdc.Unmarshal(resps[0].Value, &r); err != nil { - return sdkerrors.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) + return cerrs.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) } k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index b9da5ad9b5..1e10bcf1f4 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -182,12 +182,12 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock is the `BeginBlocker` function run at the beginning of each block to // process oracle module updates. -func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) { } // EndBlock The `EndBlocker` abci call is ran at the end of each block. The `EventManager` is monitored // and `Qualifying Actions` are deduced from newly created events and prior internal state. -func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index 786e5ab7a5..bb29c1608d 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -1,6 +1,7 @@ package oracle import ( + cerrs "cosmossdk.io/errors" icqtypes "github.com/strangelove-ventures/async-icq/v6/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,22 +18,22 @@ import ( // OnChanOpenInit implements the IBCModule interface func (am AppModule) OnChanOpenInit( ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, + _ channeltypes.Order, + _ []string, portID string, channelID string, chanCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, + _ channeltypes.Counterparty, version string, ) (string, error) { // Require portID is the portID module is bound to boundPort := am.keeper.GetPort(ctx) if boundPort != portID { - return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + return "", cerrs.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } if version != types.Version { - return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) + return "", cerrs.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) } // Claim channel capability passed back by IBC module @@ -46,22 +47,22 @@ func (am AppModule) OnChanOpenInit( // OnChanOpenTry implements the IBCModule interface func (am AppModule) OnChanOpenTry( ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, + _ channeltypes.Order, + _ []string, portID, channelID string, chanCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, + _ channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { // Require portID is the portID module is bound to boundPort := am.keeper.GetPort(ctx) if boundPort != portID { - return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + return "", cerrs.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } if counterpartyVersion != types.Version { - return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", counterpartyVersion, types.Version) + return "", cerrs.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", counterpartyVersion, types.Version) } // Module may have already claimed capability in OnChanOpenInit in the case of crossing hellos @@ -80,32 +81,32 @@ func (am AppModule) OnChanOpenTry( // OnChanOpenAck implements the IBCModule interface func (am AppModule) OnChanOpenAck( - ctx sdk.Context, - portID, - channelID string, - counterpartyChannelID string, + _ sdk.Context, + _, + _ string, + _ string, counterpartyVersion string, ) error { if counterpartyVersion != types.Version { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version) + return cerrs.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version) } return nil } // OnChanOpenConfirm implements the IBCModule interface func (am AppModule) OnChanOpenConfirm( - ctx sdk.Context, - portID, - channelID string, + _ sdk.Context, + _, + _ string, ) error { return nil } // OnChanCloseInit implements the IBCModule interface func (am AppModule) OnChanCloseInit( - ctx sdk.Context, - portID, - channelID string, + _ sdk.Context, + _, + _ string, ) error { // Disallow user-initiated channel closing for channels return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") @@ -113,20 +114,20 @@ func (am AppModule) OnChanCloseInit( // OnChanCloseConfirm implements the IBCModule interface func (am AppModule) OnChanCloseConfirm( - ctx sdk.Context, - portID, - channelID string, + _ sdk.Context, + _, + _ string, ) error { return nil } // OnRecvPacket implements the IBCModule interface func (am AppModule) OnRecvPacket( - ctx sdk.Context, - modulePacket channeltypes.Packet, - relayer sdk.AccAddress, + _ sdk.Context, + _ channeltypes.Packet, + _ sdk.AccAddress, ) ibcexported.Acknowledgement { - return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrapf(icqtypes.ErrInvalidChannelFlow, "oracle module can not receive packets")) + return channeltypes.NewErrorAcknowledgement(cerrs.Wrapf(icqtypes.ErrInvalidChannelFlow, "oracle module can not receive packets")) } // OnAcknowledgementPacket implements the IBCModule interface @@ -134,11 +135,11 @@ func (am AppModule) OnAcknowledgementPacket( ctx sdk.Context, modulePacket channeltypes.Packet, acknowledgement []byte, - relayer sdk.AccAddress, + _ sdk.AccAddress, ) error { var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet acknowledgement: %v", err) + return cerrs.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet acknowledgement: %v", err) } return am.keeper.OnAcknowledgementPacket(ctx, modulePacket, ack) @@ -148,17 +149,17 @@ func (am AppModule) OnAcknowledgementPacket( func (am AppModule) OnTimeoutPacket( ctx sdk.Context, modulePacket channeltypes.Packet, - relayer sdk.AccAddress, + _ sdk.AccAddress, ) error { return am.keeper.OnTimeoutPacket(ctx, modulePacket) } func (am AppModule) NegotiateAppVersion( - ctx sdk.Context, - order channeltypes.Order, - connectionID string, - portID string, - counterparty channeltypes.Counterparty, + _ sdk.Context, + _ channeltypes.Order, + _ string, + _ string, + _ channeltypes.Counterparty, proposedVersion string, ) (version string, err error) { return proposedVersion, nil diff --git a/x/oracle/simulation/decoder.go b/x/oracle/simulation/decoder.go index 6c80a74134..2c32a9ca64 100644 --- a/x/oracle/simulation/decoder.go +++ b/x/oracle/simulation/decoder.go @@ -14,7 +14,7 @@ import ( // NewDecodeStore returns a decoder function closure that unmarshalls the KVPair's // Value -func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { +func NewDecodeStore(_ codec.Codec) func(kvA, kvB kv.Pair) string { return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.OracleStoreKey): diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index d77704d387..cefe40035f 100644 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -62,7 +62,7 @@ func WeightedOperations( } // SimulateMsgCreateTrigger sends a MsgUpdateOracle. -func SimulateMsgUpdateOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation { +func SimulateMsgUpdateOracle(_ keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -82,7 +82,7 @@ func SimulateMsgUpdateOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, bk b } // SimulateMsgSendQueryOracle sends a MsgSendQueryOracle. -func SimulateMsgSendQueryOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, ck channelkeeper.Keeper) simtypes.Operation { +func SimulateMsgSendQueryOracle(_ keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, ck channelkeeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -97,7 +97,7 @@ func SimulateMsgSendQueryOracle(k keeper.Keeper, ak authkeeper.AccountKeeperI, b if err != nil { return simtypes.NoOpMsg(sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), sdk.MsgTypeURL(&types.MsgSendQueryOracleRequest{}), err.Error()), nil, nil } - query := randomQuery(r, ctx) + query := randomQuery(r) msg := types.NewMsgSendQueryOracle(addr.Address.String(), channel, query) return Dispatch(r, app, ctx, addr, chainID, msg, ak, bk, nil) @@ -180,7 +180,7 @@ func randomChannel(r *rand.Rand, ctx sdk.Context, ck channelkeeper.Keeper) (stri return channels[idx].String(), nil } -func randomQuery(r *rand.Rand, ctx sdk.Context) []byte { +func randomQuery(r *rand.Rand) []byte { queryType := randIntBetween(r, 0, 3) var query string if queryType == 0 { diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go index 16a7ee1883..0cfd062c03 100644 --- a/x/oracle/types/expected_keepers.go +++ b/x/oracle/types/expected_keepers.go @@ -35,6 +35,6 @@ type PortKeeper interface { // ScopedKeeper defines the expected x/capability scoped keeper interface type ScopedKeeper interface { GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) - AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool - ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error + AuthenticateCapability(ctx sdk.Context, capability *capabilitytypes.Capability, name string) bool + ClaimCapability(ctx sdk.Context, capability *capabilitytypes.Capability, name string) error } diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index bbbd7e7cd7..cdf37b5b72 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -1,8 +1,6 @@ package types import ( - "encoding/binary" - icqtypes "github.com/strangelove-ventures/async-icq/v6/types" ) @@ -61,9 +59,3 @@ func GetPortStoreKey() []byte { func GetLastQueryPacketSeqKey() []byte { return LastQueryPacketSeqKey } - -func uint64ToBytes(num uint64) []byte { - result := make([]byte, 8) - binary.BigEndian.PutUint64(result, uint64(num)) - return result -} diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 4b1fc85efc..d30296b904 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -217,35 +216,34 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/query.proto", fileDescriptor_169907f611744c57) } var fileDescriptor_169907f611744c57 = []byte{ - // 434 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x8f, 0xd3, 0x30, - 0x18, 0xc6, 0xeb, 0x13, 0x77, 0x08, 0x0b, 0x16, 0x53, 0x89, 0xbb, 0x70, 0x0a, 0xa7, 0xe8, 0x84, - 0x0e, 0x89, 0x8b, 0xb9, 0x32, 0x31, 0x30, 0xd0, 0x9b, 0x11, 0xd7, 0x74, 0x40, 0x62, 0xa9, 0xdc, - 0xc4, 0xb8, 0x91, 0x1a, 0xbf, 0x69, 0xec, 0xf4, 0xcf, 0x0a, 0x5f, 0x00, 0x89, 0x2f, 0xc0, 0x47, - 0x60, 0xe0, 0x43, 0x30, 0x56, 0xb0, 0x30, 0x21, 0xd4, 0xf2, 0x29, 0x98, 0x50, 0x6d, 0x47, 0x6d, - 0xa5, 0x00, 0x1d, 0x98, 0x6a, 0xf7, 0x7d, 0xde, 0xe7, 0xf7, 0xe4, 0x7d, 0x8d, 0x4f, 0xf2, 0x02, - 0xc6, 0x5c, 0x32, 0x19, 0x73, 0x0a, 0x05, 0x8b, 0x87, 0x9c, 0x8e, 0x2f, 0xe8, 0xa8, 0xe4, 0xc5, - 0x2c, 0xcc, 0x0b, 0xd0, 0x40, 0x9a, 0x6b, 0x45, 0x68, 0x15, 0xe1, 0xf8, 0xc2, 0x6b, 0x0a, 0x10, - 0x60, 0x04, 0x74, 0x75, 0xb2, 0x5a, 0xef, 0x58, 0x00, 0x88, 0x21, 0xa7, 0x2c, 0x4f, 0x29, 0x93, - 0x12, 0x34, 0xd3, 0x29, 0x48, 0xe5, 0xaa, 0x47, 0x31, 0xa8, 0x0c, 0x54, 0xcf, 0xb6, 0xd9, 0x4b, - 0x55, 0x72, 0x8d, 0xe6, 0xd6, 0x2f, 0x5f, 0x53, 0x26, 0x1d, 0x3f, 0xb8, 0x8b, 0x8f, 0x3a, 0xab, - 0x38, 0x2f, 0x0c, 0xfb, 0x59, 0x92, 0x14, 0x5c, 0xa9, 0x88, 0x8f, 0x4a, 0xae, 0x74, 0x70, 0x85, - 0xbd, 0xba, 0xa2, 0xca, 0x41, 0x2a, 0x4e, 0x5a, 0xf8, 0x3a, 0xb3, 0x7f, 0x1d, 0xa2, 0x13, 0x74, - 0x76, 0xa3, 0x7d, 0xf8, 0xe5, 0xd3, 0x79, 0xd3, 0x81, 0x9d, 0xb8, 0xab, 0x8b, 0x54, 0x8a, 0xa8, - 0x12, 0x06, 0x29, 0x26, 0x1b, 0x8e, 0x8e, 0x43, 0xba, 0x78, 0xdf, 0xcc, 0xc4, 0xf8, 0xdc, 0x6c, - 0x3f, 0xfd, 0xf5, 0xfd, 0xde, 0x13, 0x91, 0xea, 0x41, 0xd9, 0x0f, 0x63, 0xc8, 0xe8, 0x25, 0xa8, - 0xec, 0x25, 0x53, 0x19, 0x9d, 0x30, 0x95, 0x25, 0x74, 0x6a, 0x7e, 0xa9, 0x9e, 0xe5, 0x5c, 0x85, - 0x11, 0x9b, 0x5c, 0x82, 0xd4, 0x05, 0x8b, 0xf5, 0x73, 0xae, 0x14, 0x13, 0x3c, 0xb2, 0x5e, 0xc1, - 0x00, 0xdf, 0xde, 0x42, 0xb9, 0xd4, 0x1d, 0x7c, 0x2d, 0x61, 0x9a, 0xfd, 0x1f, 0x94, 0xb1, 0x6a, - 0x7d, 0xdc, 0xc3, 0xfb, 0x06, 0x45, 0x3e, 0x20, 0x7c, 0x6b, 0x6b, 0x58, 0x84, 0x86, 0x75, 0x0b, - 0x0e, 0xff, 0x38, 0x73, 0xef, 0xd1, 0xee, 0x0d, 0xf6, 0x8b, 0x82, 0x87, 0x6f, 0xbe, 0xfe, 0x7c, - 0xbf, 0x77, 0x9f, 0x9c, 0xd2, 0xda, 0xd7, 0x66, 0x4f, 0x3d, 0xb7, 0x01, 0xf2, 0x16, 0xe1, 0x03, - 0xeb, 0x43, 0xce, 0xfe, 0x89, 0xaa, 0x42, 0x3d, 0xd8, 0x41, 0xe9, 0xd2, 0x9c, 0x9a, 0x34, 0x3e, - 0x39, 0xfe, 0x5b, 0x9a, 0xb6, 0xf8, 0xbc, 0xf0, 0xd1, 0x7c, 0xe1, 0xa3, 0x1f, 0x0b, 0x1f, 0xbd, - 0x5b, 0xfa, 0x8d, 0xf9, 0xd2, 0x6f, 0x7c, 0x5b, 0xfa, 0x0d, 0x7c, 0x27, 0x85, 0x5a, 0xd8, 0x15, - 0x7a, 0xd5, 0xda, 0x58, 0xd4, 0x5a, 0x72, 0x9e, 0xc2, 0x26, 0x6a, 0x5a, 0xc1, 0xcc, 0xd2, 0xfa, - 0x07, 0xe6, 0x99, 0x3f, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xb3, 0xbd, 0x64, 0x4f, 0x8a, 0x03, - 0x00, 0x00, + // 422 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xbf, 0xae, 0xd3, 0x30, + 0x14, 0xc6, 0xeb, 0x2b, 0xee, 0x45, 0x58, 0xb0, 0x98, 0x4a, 0xdc, 0x1b, 0xaa, 0x50, 0x45, 0x15, + 0x2a, 0x12, 0x8d, 0x69, 0x99, 0x18, 0x18, 0x68, 0x67, 0x44, 0x9b, 0x0e, 0x48, 0x2c, 0x95, 0x9b, + 0x58, 0x6e, 0xa4, 0xc6, 0x27, 0x8d, 0xdd, 0x7f, 0x2b, 0xbc, 0x00, 0x12, 0x2f, 0xc0, 0x23, 0x30, + 0xf0, 0x10, 0x8c, 0x15, 0x2c, 0x4c, 0x08, 0xb5, 0x3c, 0x05, 0x13, 0xaa, 0x9d, 0xaa, 0xad, 0x14, + 0xa0, 0xc3, 0x9d, 0xe2, 0xf8, 0x7c, 0xfe, 0x7e, 0x9f, 0x7d, 0x0e, 0xae, 0xa6, 0x19, 0xcc, 0xb8, + 0x64, 0x32, 0xe4, 0x14, 0x32, 0x16, 0x8e, 0x39, 0x9d, 0x35, 0xe9, 0x64, 0xca, 0xb3, 0xa5, 0x9f, + 0x66, 0xa0, 0x81, 0x94, 0xf7, 0x0a, 0xdf, 0x2a, 0xfc, 0x59, 0xd3, 0x29, 0x0b, 0x10, 0x60, 0x04, + 0x74, 0xbb, 0xb2, 0x5a, 0xa7, 0x22, 0x00, 0xc4, 0x98, 0x53, 0x96, 0xc6, 0x94, 0x49, 0x09, 0x9a, + 0xe9, 0x18, 0xa4, 0xca, 0xab, 0x57, 0x21, 0xa8, 0x04, 0xd4, 0xc0, 0x1e, 0xb3, 0x3f, 0xb6, 0xe4, + 0xdd, 0xc7, 0x57, 0xbd, 0x2d, 0xf3, 0x95, 0x01, 0xbc, 0x88, 0xa2, 0x8c, 0x2b, 0x15, 0xf0, 0xc9, + 0x94, 0x2b, 0xed, 0x75, 0xb1, 0x53, 0x54, 0x54, 0x29, 0x48, 0xc5, 0x49, 0x0b, 0xdf, 0x64, 0x76, + 0xeb, 0x12, 0x55, 0x51, 0xfd, 0x56, 0xfb, 0xf2, 0xeb, 0xe7, 0x46, 0x39, 0x77, 0xcf, 0xc5, 0x7d, + 0x9d, 0xc5, 0x52, 0x04, 0x3b, 0xa1, 0x17, 0x63, 0x72, 0xe0, 0x98, 0x73, 0x48, 0x1f, 0x9f, 0x9b, + 0x8b, 0x1b, 0x9f, 0xdb, 0xed, 0xe7, 0xbf, 0x7f, 0x3c, 0x78, 0x26, 0x62, 0x3d, 0x9a, 0x0e, 0xfd, + 0x10, 0x12, 0xda, 0x01, 0x95, 0xbc, 0x66, 0x2a, 0xa1, 0x73, 0xa6, 0x92, 0x88, 0x2e, 0xcc, 0x97, + 0xea, 0x65, 0xca, 0x95, 0x1f, 0xb0, 0x79, 0x07, 0xa4, 0xce, 0x58, 0xa8, 0x5f, 0x72, 0xa5, 0x98, + 0xe0, 0x81, 0xf5, 0xf2, 0x46, 0xf8, 0xee, 0x11, 0x2a, 0x4f, 0xdd, 0xc3, 0x37, 0x22, 0xa6, 0xd9, + 0xf5, 0xa0, 0x8c, 0x55, 0xeb, 0xd3, 0x19, 0x3e, 0x37, 0x28, 0xf2, 0x11, 0xe1, 0x3b, 0x47, 0x8f, + 0x45, 0xa8, 0x5f, 0xd4, 0x45, 0xff, 0xaf, 0x6f, 0xee, 0x3c, 0x39, 0xfd, 0x80, 0xbd, 0x91, 0xf7, + 0xf8, 0xed, 0xb7, 0x5f, 0x1f, 0xce, 0x1e, 0x92, 0x1a, 0x2d, 0x1c, 0x29, 0xbb, 0x1a, 0xe4, 0x1d, + 0x20, 0xef, 0x10, 0xbe, 0xb0, 0x3e, 0xa4, 0xfe, 0x5f, 0xd4, 0x2e, 0xd4, 0xa3, 0x13, 0x94, 0x79, + 0x9a, 0x9a, 0x49, 0xe3, 0x92, 0xca, 0xbf, 0xd2, 0xb4, 0xc5, 0x97, 0xb5, 0x8b, 0x56, 0x6b, 0x17, + 0xfd, 0x5c, 0xbb, 0xe8, 0xfd, 0xc6, 0x2d, 0xad, 0x36, 0x6e, 0xe9, 0xfb, 0xc6, 0x2d, 0xe1, 0x7b, + 0x31, 0x14, 0xc2, 0xba, 0xe8, 0x4d, 0xeb, 0xa0, 0x51, 0x7b, 0x49, 0x23, 0x86, 0x43, 0xd4, 0x62, + 0x07, 0x33, 0x4d, 0x1b, 0x5e, 0x98, 0x31, 0x7f, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0x4f, 0x78, + 0xa0, 0x70, 0x6f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 87214b42d0..348db4fe6a 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -8,8 +8,6 @@ import ( fmt "fmt" github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/codec/types" - _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -244,37 +242,35 @@ func init() { func init() { proto.RegisterFile("provenance/oracle/v1/tx.proto", fileDescriptor_66a39dda41c6a784) } var fileDescriptor_66a39dda41c6a784 = []byte{ - // 480 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0xed, 0xd2, 0x42, 0xdb, 0x55, 0x25, 0x24, 0x2b, 0xa2, 0x8e, 0x25, 0x9c, 0x2a, 0xa7, 0x0a, - 0x11, 0x2f, 0x09, 0x12, 0x02, 0x24, 0x0e, 0xa4, 0xe7, 0x08, 0x70, 0x84, 0x90, 0xb8, 0xa0, 0xb5, - 0xbd, 0x6c, 0x2c, 0xe2, 0x1d, 0xd7, 0xb3, 0x4e, 0x93, 0x9f, 0x40, 0x1c, 0x39, 0xf6, 0x23, 0xf8, - 0x02, 0x4e, 0x1c, 0x2b, 0x4e, 0x9c, 0x10, 0x4a, 0x2e, 0xfd, 0x06, 0x4e, 0x28, 0xbb, 0x09, 0x49, - 0xc1, 0xa0, 0x9c, 0xec, 0xb7, 0xef, 0xcd, 0xdb, 0x79, 0xa3, 0x59, 0x7a, 0x3b, 0x2f, 0x60, 0x24, - 0x14, 0x57, 0xb1, 0x60, 0x50, 0xf0, 0x78, 0x28, 0xd8, 0xa8, 0xcd, 0xf4, 0x38, 0xc8, 0x0b, 0xd0, - 0xe0, 0xd4, 0x56, 0x74, 0x60, 0xe9, 0x60, 0xd4, 0xf6, 0xea, 0x31, 0x60, 0x06, 0xf8, 0xc6, 0x68, - 0x98, 0x05, 0xb6, 0xc0, 0xab, 0x49, 0x90, 0x60, 0xcf, 0xe7, 0x7f, 0x8b, 0xd3, 0x3b, 0x56, 0xc3, - 0x22, 0x8e, 0x82, 0x9d, 0x96, 0xa2, 0x98, 0xb0, 0x51, 0x3b, 0x12, 0x9a, 0xb7, 0x59, 0xce, 0x65, - 0xaa, 0xb8, 0x4e, 0x41, 0x2d, 0xb4, 0x75, 0x09, 0x20, 0x87, 0x82, 0x19, 0x14, 0x95, 0x6f, 0x19, - 0x57, 0x13, 0x4b, 0x35, 0x3f, 0x13, 0x5a, 0xef, 0xa1, 0xec, 0x0b, 0x95, 0xbc, 0x98, 0x9b, 0x3c, - 0x33, 0x1d, 0x85, 0xe2, 0xb4, 0x14, 0xa8, 0x9d, 0x3e, 0xbd, 0x6e, 0xac, 0x5d, 0x72, 0x44, 0x8e, - 0x0f, 0xba, 0x4f, 0x7e, 0x7e, 0x6f, 0x3c, 0x92, 0xa9, 0x1e, 0x94, 0x51, 0x10, 0x43, 0xc6, 0x4e, - 0x00, 0xb3, 0x57, 0x1c, 0x33, 0x76, 0xc6, 0x31, 0x4b, 0xd8, 0xd8, 0x7c, 0x99, 0x9e, 0xe4, 0x02, - 0x83, 0x90, 0x9f, 0x9d, 0x80, 0xd2, 0x05, 0x8f, 0x75, 0x4f, 0x20, 0x72, 0x29, 0x42, 0xeb, 0xe5, - 0xb8, 0x74, 0x37, 0x1e, 0x70, 0xa5, 0xc4, 0xd0, 0xdd, 0x3e, 0x22, 0xc7, 0xfb, 0xe1, 0x12, 0x3a, - 0x0f, 0xe8, 0x3e, 0x2f, 0xf5, 0x00, 0x8a, 0x54, 0x4f, 0xdc, 0x9d, 0x39, 0xd7, 0x75, 0xbf, 0x7e, - 0x6a, 0xd5, 0x16, 0xe3, 0x78, 0x9a, 0x24, 0x85, 0x40, 0xec, 0xeb, 0x22, 0x55, 0x32, 0x5c, 0x49, - 0x9b, 0x0f, 0xa9, 0x57, 0x95, 0x01, 0x73, 0x50, 0x28, 0x1c, 0x8f, 0xee, 0xe1, 0x3c, 0x8f, 0x8a, - 0x85, 0xc9, 0xb1, 0x13, 0xfe, 0xc6, 0xcd, 0xf7, 0x84, 0xde, 0xea, 0xa1, 0x7c, 0x99, 0x27, 0x5c, - 0x8b, 0xab, 0xd9, 0x3b, 0x74, 0x97, 0xdb, 0x0b, 0x4d, 0xd5, 0xff, 0x5a, 0x59, 0x0a, 0xaf, 0x06, - 0xb8, 0xb6, 0x71, 0x80, 0xc7, 0x7b, 0x1f, 0xcf, 0x1b, 0xe4, 0xf2, 0xbc, 0x41, 0x9a, 0x75, 0x7a, - 0xf8, 0x57, 0x3f, 0x36, 0x47, 0xe7, 0x92, 0xd0, 0xed, 0x1e, 0x4a, 0xe7, 0x1d, 0x3d, 0x58, 0xe7, - 0x9d, 0xbb, 0x41, 0xd5, 0x46, 0x05, 0xd5, 0xb1, 0xbc, 0xd6, 0x86, 0xea, 0xc5, 0xf0, 0x34, 0xbd, - 0xf9, 0xc7, 0x5c, 0x1d, 0xf6, 0x4f, 0x87, 0xea, 0x2d, 0xf2, 0xee, 0x6d, 0x5e, 0x60, 0x6f, 0xed, - 0xca, 0x2f, 0x53, 0x9f, 0x5c, 0x4c, 0x7d, 0xf2, 0x63, 0xea, 0x93, 0x0f, 0x33, 0x7f, 0xeb, 0x62, - 0xe6, 0x6f, 0x7d, 0x9b, 0xf9, 0x5b, 0xf4, 0x30, 0x85, 0x4a, 0xb7, 0xe7, 0xe4, 0x75, 0x67, 0x6d, - 0x33, 0x57, 0x92, 0x56, 0x0a, 0x6b, 0x88, 0x8d, 0x97, 0x4f, 0xd2, 0x6c, 0x69, 0x74, 0xc3, 0xbc, - 0x82, 0xfb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xd9, 0x47, 0x26, 0xb4, 0x03, 0x00, 0x00, + // 443 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x6b, 0x36, 0xd8, 0x66, 0x4d, 0x42, 0xb2, 0x2a, 0x96, 0x46, 0x22, 0x9d, 0x72, 0xda, + 0x81, 0xc6, 0xac, 0x48, 0x08, 0x90, 0x38, 0xd0, 0x9d, 0x23, 0x20, 0x15, 0x42, 0xe2, 0x82, 0xbc, + 0xc4, 0x72, 0x23, 0x16, 0x3b, 0xf3, 0x73, 0xba, 0xf6, 0x4b, 0x20, 0x8e, 0x1c, 0xf7, 0x21, 0xf8, + 0x04, 0x9c, 0x38, 0x56, 0x9c, 0x38, 0x21, 0xd4, 0x5e, 0xfa, 0x19, 0x38, 0xa1, 0xc4, 0x2d, 0x6d, + 0x21, 0xa0, 0x9e, 0x92, 0xf7, 0xde, 0xff, 0x3d, 0xfb, 0x67, 0xfd, 0x1f, 0xbe, 0x9b, 0x6b, 0x35, + 0xe4, 0x92, 0xc9, 0x98, 0x53, 0xa5, 0x59, 0x7c, 0xc1, 0xe9, 0xf0, 0x94, 0x9a, 0x51, 0x90, 0x6b, + 0x65, 0x14, 0x69, 0xae, 0xca, 0x81, 0x2d, 0x07, 0xc3, 0x53, 0xb7, 0x15, 0x2b, 0xc8, 0x14, 0xbc, + 0xad, 0x34, 0xd4, 0x06, 0xb6, 0xc1, 0x6d, 0x0a, 0x25, 0x94, 0xcd, 0x97, 0x7f, 0x36, 0xeb, 0x7f, + 0x46, 0xb8, 0x15, 0x82, 0xe8, 0x73, 0x99, 0xbc, 0x2c, 0xb8, 0x1e, 0x3f, 0xaf, 0x46, 0x45, 0xfc, + 0xb2, 0xe0, 0x60, 0x48, 0x1f, 0xdf, 0xbc, 0x2c, 0xb3, 0x0e, 0x3a, 0x46, 0x27, 0x87, 0xbd, 0xa7, + 0x3f, 0xbf, 0xb7, 0x1f, 0x8b, 0xd4, 0x0c, 0x8a, 0xf3, 0x20, 0x56, 0x19, 0x3d, 0x53, 0x90, 0xbd, + 0x66, 0x90, 0xd1, 0x2b, 0x06, 0x59, 0x42, 0x47, 0xd5, 0x97, 0x9a, 0x71, 0xce, 0x21, 0x88, 0xd8, + 0xd5, 0x99, 0x92, 0x46, 0xb3, 0xd8, 0x84, 0x1c, 0x80, 0x09, 0x1e, 0xd9, 0x59, 0xc4, 0xc1, 0x7b, + 0xf1, 0x80, 0x49, 0xc9, 0x2f, 0x9c, 0x9d, 0x63, 0x74, 0x72, 0x10, 0x2d, 0x43, 0xf2, 0x10, 0x1f, + 0xb0, 0xc2, 0x0c, 0x94, 0x4e, 0xcd, 0xd8, 0xd9, 0x2d, 0x6b, 0x3d, 0xe7, 0xeb, 0xa7, 0x4e, 0x73, + 0xc1, 0xf1, 0x2c, 0x49, 0x34, 0x07, 0xe8, 0x1b, 0x9d, 0x4a, 0x11, 0xad, 0xa4, 0xfe, 0x23, 0xec, + 0xd6, 0x31, 0x40, 0xae, 0x24, 0x70, 0xe2, 0xe2, 0x7d, 0x28, 0x79, 0x64, 0xcc, 0x2b, 0x8e, 0xdd, + 0xe8, 0x77, 0xec, 0xbf, 0x47, 0xf8, 0x4e, 0x08, 0xe2, 0x55, 0x9e, 0x30, 0xc3, 0x37, 0xd9, 0xbb, + 0x78, 0x8f, 0xd9, 0x03, 0xab, 0xae, 0xff, 0x5d, 0x65, 0x29, 0xdc, 0x04, 0xb8, 0xb1, 0x35, 0xc0, + 0x93, 0xfd, 0x8f, 0xd7, 0x6d, 0x34, 0xbf, 0x6e, 0x23, 0xbf, 0x85, 0x8f, 0xfe, 0xba, 0x8f, 0xe5, + 0xe8, 0xce, 0x11, 0xde, 0x09, 0x41, 0x90, 0x77, 0xf8, 0x70, 0xbd, 0x4e, 0xee, 0x05, 0x75, 0x56, + 0x08, 0xea, 0xb1, 0xdc, 0xce, 0x96, 0xea, 0xc5, 0xe3, 0x19, 0x7c, 0xfb, 0x8f, 0x77, 0x25, 0xf4, + 0x9f, 0x13, 0xea, 0x5d, 0xe4, 0xde, 0xdf, 0xbe, 0xc1, 0x9e, 0xda, 0x13, 0x5f, 0xa6, 0x1e, 0x9a, + 0x4c, 0x3d, 0xf4, 0x63, 0xea, 0xa1, 0x0f, 0x33, 0xaf, 0x31, 0x99, 0x79, 0x8d, 0x6f, 0x33, 0xaf, + 0x81, 0x8f, 0x52, 0x55, 0x3b, 0xed, 0x05, 0x7a, 0xd3, 0x5d, 0x73, 0xe6, 0x4a, 0xd2, 0x49, 0xd5, + 0x5a, 0x44, 0x47, 0xcb, 0x5d, 0xaa, 0x5c, 0x7a, 0x7e, 0xab, 0xda, 0x82, 0x07, 0xbf, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x49, 0x33, 0xee, 0xe2, 0x6d, 0x03, 0x00, 0x00, } func (this *MsgUpdateOracleRequest) Equal(that interface{}) bool { From 642988835b25c352fbb86904eb1dadee790cd5cf Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 11:11:04 -0400 Subject: [PATCH 61/96] Fixed some more linting issues. --- x/oracle/keeper/keeper.go | 4 ++-- x/oracle/keeper/msg_server.go | 4 ++-- x/oracle/keeper/relay.go | 12 ++++++------ x/oracle/simulation/operations.go | 9 +++++---- x/oracle/types/msgs.go | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 7c42221f6c..655f9e7a99 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -70,8 +70,8 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // BindPort stores the provided portID and binds to it, returning the associated capability func (k Keeper) BindPort(ctx sdk.Context, portID string) error { - cap := k.portKeeper.BindPort(ctx, portID) - return k.ClaimCapability(ctx, cap, host.PortPath(portID)) + capability := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, capability, host.PortPath(portID)) } // IsBound checks if the interchain query already bound to the desired port diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 029ee6228d..106dcc3333 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -42,10 +42,10 @@ func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracl } // SendQueryOracle sends an icq to another chain's oracle -func (k msgServer) SendQueryOracle(goCtx context.Context, msg *types.MsgSendQueryOracleRequest) (*types.MsgSendQueryOracleResponse, error) { +func (s msgServer) SendQueryOracle(goCtx context.Context, msg *types.MsgSendQueryOracleRequest) (*types.MsgSendQueryOracleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - seq, err := k.QueryOracle(ctx, msg.Query, msg.Channel) + seq, err := s.QueryOracle(ctx, msg.Query, msg.Channel) if err != nil { return nil, err } diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index 9771decaee..d8c57cecc4 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -24,7 +24,7 @@ func (k Keeper) SendQuery( sourceChannel string, chanCap *capabilitytypes.Capability, reqs []abci.RequestQuery, - timeoutHeight clienttypes.Height, + _ clienttypes.Height, timeoutTimestamp uint64, ) (uint64, error) { sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) @@ -37,7 +37,7 @@ func (k Keeper) SendQuery( data, err := icqtypes.SerializeCosmosQuery(reqs) if err != nil { - return 0, sdkerrors.Wrap(err, "could not serialize reqs into cosmos query") + return 0, cerrs.Wrap(err, "could not serialize reqs into cosmos query") } icqPacketData := icqtypes.InterchainQueryPacketData{ Data: data, @@ -57,7 +57,7 @@ func (k Keeper) createOutgoingPacket( timeoutTimestamp uint64, ) (uint64, error) { if err := icqPacketData.ValidateBasic(); err != nil { - return 0, sdkerrors.Wrap(err, "invalid interchain query packet data") + return 0, cerrs.Wrap(err, "invalid interchain query packet data") } // get the next sequence @@ -94,15 +94,15 @@ func (k Keeper) OnAcknowledgementPacket( case *channeltypes.Acknowledgement_Result: var ackData icqtypes.InterchainQueryPacketAck if err := icqtypes.ModuleCdc.UnmarshalJSON(resp.Result, &ackData); err != nil { - return sdkerrors.Wrap(err, "failed to unmarshal interchain query packet ack") + return cerrs.Wrap(err, "failed to unmarshal interchain query packet ack") } resps, err := icqtypes.DeserializeCosmosResponse(ackData.Data) if err != nil { - return sdkerrors.Wrap(err, "could not deserialize data to cosmos response") + return cerrs.Wrap(err, "could not deserialize data to cosmos response") } if len(resps) < 1 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") + return cerrs.Wrap(sdkerrors.ErrInvalidRequest, "no responses in interchain query packet ack") } var r types.QueryOracleResponse diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index cefe40035f..89cdfda811 100644 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -183,13 +183,14 @@ func randomChannel(r *rand.Rand, ctx sdk.Context, ck channelkeeper.Keeper) (stri func randomQuery(r *rand.Rand) []byte { queryType := randIntBetween(r, 0, 3) var query string - if queryType == 0 { + switch queryType { + case 0: query = "" - } else if queryType == 1 { + case 1: query = "{}" - } else if queryType == 2 { + case 2: query = "{\"version\":{}}" - } else { + default: query = "xyz" } diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index a52bf43075..41d6f92289 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -10,10 +10,10 @@ import ( var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgSendQueryOracleRequest{} // NewMsgSendQueryOracle creates a new MsgSendQueryOracleRequest -func NewMsgSendQueryOracle(creator, channelId string, query []byte) *MsgSendQueryOracleRequest { +func NewMsgSendQueryOracle(creator, channelID string, query []byte) *MsgSendQueryOracleRequest { return &MsgSendQueryOracleRequest{ Authority: creator, - Channel: channelId, + Channel: channelID, Query: query, } } From 672e524e74352ac6a8cd83900eb25ada73575cfc Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 11:12:32 -0400 Subject: [PATCH 62/96] Ran lint fix on modules. --- app/upgrades.go | 3 ++- x/oracle/keeper/relay.go | 1 + x/oracle/module/module_ibc.go | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 59534a2344..2ad7717b74 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -3,6 +3,8 @@ package app import ( "fmt" + icqtypes "github.com/strangelove-ventures/async-icq/v6/types" + "github.com/cosmos/cosmos-sdk/baseapp" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,7 +18,6 @@ import ( msgfeetypes "github.com/provenance-io/provenance/x/msgfees/types" oracletypes "github.com/provenance-io/provenance/x/oracle/types" triggertypes "github.com/provenance-io/provenance/x/trigger/types" - icqtypes "github.com/strangelove-ventures/async-icq/v6/types" ) // appUpgrade is an internal structure for defining all things for an upgrade. diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index d8c57cecc4..f799a3a86e 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -8,6 +8,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" cerrs "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index bb29c1608d..529a447833 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -1,9 +1,10 @@ package oracle import ( - cerrs "cosmossdk.io/errors" icqtypes "github.com/strangelove-ventures/async-icq/v6/types" + cerrs "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" From d65def2ca039c9ed07afc5180d5648e0d9b05cda Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 11:19:22 -0400 Subject: [PATCH 63/96] Added error checking for emitted typed events. --- x/oracle/keeper/relay.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index f799a3a86e..f4496cfcb3 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -113,21 +113,31 @@ func (k Keeper) OnAcknowledgementPacket( k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) - ctx.EventManager().EmitTypedEvent(&types.EventOracleQuerySuccess{ + 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 response", "sequence", modulePacket.Sequence, "response", r) + 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 cerrs.Wrapf(err, "failed to emit event %w", err) + } case *channeltypes.Acknowledgement_Error: - ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryError{ + err := ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryError{ SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), Error: resp.Error, Channel: modulePacket.DestinationChannel, }) - k.Logger(ctx).Error("interchain query response", "sequence", modulePacket.Sequence, "error", resp.Error) + k.Logger(ctx).Error("interchain query ack error response", "sequence", modulePacket.Sequence, "error", resp.Error) + + if err != nil { + k.Logger(ctx).Error("interchain query ack error response was unable to emit event", "sequence", modulePacket.Sequence, "error", err) + return cerrs.Wrapf(err, "failed to emit event %w", err) + } } return nil } @@ -137,12 +147,17 @@ func (k Keeper) OnTimeoutPacket( ctx sdk.Context, modulePacket channeltypes.Packet, ) error { - ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryTimeout{ + err := ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryTimeout{ SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), Channel: modulePacket.DestinationChannel, }) k.Logger(ctx).Error("Packet timeout", "sequence", modulePacket.Sequence) + if err != nil { + k.Logger(ctx).Error("interchain query timeout was unable to emit event", "sequence", modulePacket.Sequence, "error", err) + return cerrs.Wrapf(err, "failed to emit event %w", err) + } + return nil } From 1b3ff9f0e2eef6815df4c6a223387583445bf079 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 11:28:54 -0400 Subject: [PATCH 64/96] Fixed some more linting issues. --- x/oracle/keeper/icq.go | 4 ++-- x/oracle/keeper/relay.go | 8 ++++---- x/oracle/module/module_ibc.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x/oracle/keeper/icq.go b/x/oracle/keeper/icq.go index b0bf0c25ba..4176370efd 100644 --- a/x/oracle/keeper/icq.go +++ b/x/oracle/keeper/icq.go @@ -3,12 +3,12 @@ package keeper import ( "time" + cerrs "cosmossdk.io/errors" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" abcitypes "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" @@ -20,7 +20,7 @@ import ( func (k Keeper) QueryOracle(ctx sdk.Context, query wasmtypes.RawContractMessage, channel string) (uint64, error) { chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(k.GetPort(ctx), channel)) if !found { - return 0, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + return 0, cerrs.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") } q := types.QueryOracleRequest{ diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index f4496cfcb3..b8410e5a6e 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -107,7 +107,7 @@ func (k Keeper) OnAcknowledgementPacket( } var r types.QueryOracleResponse - if err := k.cdc.Unmarshal(resps[0].Value, &r); err != nil { + 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) } @@ -123,7 +123,7 @@ func (k Keeper) OnAcknowledgementPacket( if err != nil { k.Logger(ctx).Error("interchain query ack response was unable to emit event", "sequence", modulePacket.Sequence, "error", err) - return cerrs.Wrapf(err, "failed to emit event %w", err) + return err } case *channeltypes.Acknowledgement_Error: err := ctx.EventManager().EmitTypedEvent(&types.EventOracleQueryError{ @@ -136,7 +136,7 @@ func (k Keeper) OnAcknowledgementPacket( if err != nil { k.Logger(ctx).Error("interchain query ack error response was unable to emit event", "sequence", modulePacket.Sequence, "error", err) - return cerrs.Wrapf(err, "failed to emit event %w", err) + return err } } return nil @@ -156,7 +156,7 @@ func (k Keeper) OnTimeoutPacket( if err != nil { k.Logger(ctx).Error("interchain query timeout was unable to emit event", "sequence", modulePacket.Sequence, "error", err) - return cerrs.Wrapf(err, "failed to emit event %w", err) + return err } return nil diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index 529a447833..cf7562d903 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -110,7 +110,7 @@ func (am AppModule) OnChanCloseInit( _ string, ) error { // Disallow user-initiated channel closing for channels - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") + return cerrs.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") } // OnChanCloseConfirm implements the IBCModule interface From be17d454bcf31fe05daf35b371a6243e665307f1 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 11:31:38 -0400 Subject: [PATCH 65/96] Fixed linting on file with gci. --- x/oracle/keeper/icq.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/oracle/keeper/icq.go b/x/oracle/keeper/icq.go index 4176370efd..1845db6ff4 100644 --- a/x/oracle/keeper/icq.go +++ b/x/oracle/keeper/icq.go @@ -3,11 +3,12 @@ package keeper import ( "time" - cerrs "cosmossdk.io/errors" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" abcitypes "github.com/tendermint/tendermint/abci/types" + cerrs "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" From 14bd60dc150eab1a3d27f79824ae8abdc24bf09c Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 11:47:38 -0400 Subject: [PATCH 66/96] Added saffron and saffron-rc1 release. Added upgrade tests for them. --- app/upgrades.go | 3 ++- app/upgrades_test.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/upgrades.go b/app/upgrades.go index 2ad7717b74..fa19259100 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -115,7 +115,7 @@ var upgrades = map[string]appUpgrade{ }, Added: []string{triggertypes.ModuleName}, }, - "saffron-rc1": { // upgrade for v1.16.0, + "saffron": { // upgrade for v1.17.0, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error vm, err = runModuleMigrations(ctx, app, vm) @@ -129,6 +129,7 @@ var upgrades = map[string]appUpgrade{ }, Added: []string{icqtypes.ModuleName, oracletypes.ModuleName}, }, + "saffron-rc1": {}, // TODO - Add new upgrade definitions here. } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 6e12490449..c6aa9d1752 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -415,6 +415,19 @@ func (s *UpgradeTestSuite) TestRust() { s.AssertUpgradeHandlerLogs("rust", expInLog, expNotInLog) } +func (s *UpgradeTestSuite) TestSaffron() { + // Each part is (hopefully) tested thoroughly on its own. + // So for this test, just make sure there's log entries for each part being done. + + expInLog := []string{ + "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", + "INF Updating ICQ params", + "INF Done updating ICQ params", + } + + s.AssertUpgradeHandlerLogs("saffron", expInLog, nil) +} + func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() { addr1 := s.CreateAndFundAccount(sdk.NewInt64Coin("stake", 1000000)) addr2 := s.CreateAndFundAccount(sdk.NewInt64Coin("stake", 1000000)) From ee771cb748df6ab374df53a460b206cbd4dcd2b3 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 14:40:18 -0400 Subject: [PATCH 67/96] Added logic for testnet in upgrade handler. --- app/upgrades.go | 15 ++++++++++++++- app/upgrades_test.go | 13 +++++++++++++ go.mod | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index fa19259100..dcbd8da1ce 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -129,7 +129,20 @@ var upgrades = map[string]appUpgrade{ }, Added: []string{icqtypes.ModuleName, oracletypes.ModuleName}, }, - "saffron-rc1": {}, + "saffron-rc1": { // upgrade for v1.17.0, + Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { + var err error + vm, err = runModuleMigrations(ctx, app, vm) + if err != nil { + return nil, err + } + + setupICQ(ctx, app) + + return vm, nil + }, + Added: []string{icqtypes.ModuleName, oracletypes.ModuleName}, + }, // TODO - Add new upgrade definitions here. } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index c6aa9d1752..9b3ec058c3 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -428,6 +428,19 @@ func (s *UpgradeTestSuite) TestSaffron() { s.AssertUpgradeHandlerLogs("saffron", expInLog, nil) } +func (s *UpgradeTestSuite) TestSaffronRC1() { + // Each part is (hopefully) tested thoroughly on its own. + // So for this test, just make sure there's log entries for each part being done. + + expInLog := []string{ + "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", + "INF Updating ICQ params", + "INF Done updating ICQ params", + } + + s.AssertUpgradeHandlerLogs("saffron-rc1", expInLog, nil) +} + func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() { addr1 := s.CreateAndFundAccount(sdk.NewInt64Coin("stake", 1000000)) addr2 := s.CreateAndFundAccount(sdk.NewInt64Coin("stake", 1000000)) diff --git a/go.mod b/go.mod index ee1f12d26e..e5c307f87d 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,6 @@ require ( golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0 golang.org/x/text v0.12.0 google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e - google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 @@ -168,6 +167,7 @@ require ( google.golang.org/api v0.122.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230629202037-9506855d4529 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect From e9f098e967cb2093632c6b3737a33a92081ef086 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 14:41:25 -0400 Subject: [PATCH 68/96] Fixed comment. --- app/upgrades.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index dcbd8da1ce..2a391dcd9c 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -325,8 +325,7 @@ func setAccountDataNameRecord(ctx sdk.Context, accountK attributetypes.AccountKe return attributekeeper.EnsureModuleAccountAndAccountDataNameRecord(ctx, accountK, nameK) } -// setAccountDataNameRecord makes sure the account data name record exists, is restricted, -// and is owned by the attribute module. An error is returned if it fails to make it so. +// setupICQ sets the correct default values for ICQKeeper 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"})) From 653717cd9897af0f9e49e9f06b5ea04d16b96823 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:05:54 -0400 Subject: [PATCH 69/96] Removed params. --- app/app.go | 1 - docs/proto-docs.md | 30 -- .../metadata/v1/specification.proto | 2 +- proto/provenance/oracle/v1/genesis.proto | 7 +- proto/provenance/oracle/v1/params.proto | 14 - x/oracle/client/cli/cli_test.go | 3 - x/oracle/keeper/genesis.go | 2 - x/oracle/keeper/genesis_test.go | 14 +- x/oracle/keeper/keeper.go | 20 +- x/oracle/keeper/params.go | 17 -- x/oracle/keeper/params_test.go | 8 - x/oracle/simulation/genesis.go | 4 +- x/oracle/types/genesis.go | 7 +- x/oracle/types/genesis.pb.go | 84 ++---- x/oracle/types/genesis_test.go | 16 +- x/oracle/types/params.go | 40 --- x/oracle/types/params.pb.go | 265 ------------------ 17 files changed, 42 insertions(+), 492 deletions(-) delete mode 100644 proto/provenance/oracle/v1/params.proto delete mode 100644 x/oracle/keeper/params.go delete mode 100644 x/oracle/keeper/params_test.go delete mode 100644 x/oracle/types/params.go delete mode 100644 x/oracle/types/params.pb.go diff --git a/app/app.go b/app/app.go index a8903b5b28..595d2169e9 100644 --- a/app/app.go +++ b/app/app.go @@ -578,7 +578,6 @@ func New( appCodec, keys[oracletypes.StoreKey], keys[oracletypes.MemStoreKey], - app.GetSubspace(icqtypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, diff --git a/docs/proto-docs.md b/docs/proto-docs.md index 07e56ec9eb..457cdb8321 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -437,9 +437,6 @@ - [EventOracleQuerySuccess](#provenance.oracle.v1.EventOracleQuerySuccess) - [EventOracleQueryTimeout](#provenance.oracle.v1.EventOracleQueryTimeout) -- [provenance/oracle/v1/params.proto](#provenance/oracle/v1/params.proto) - - [Params](#provenance.oracle.v1.Params) - - [provenance/oracle/v1/genesis.proto](#provenance/oracle/v1/genesis.proto) - [GenesisState](#provenance.oracle.v1.GenesisState) @@ -6808,32 +6805,6 @@ EventOracleQueryTimeout is an event for when the chain receives a timeout from a - - - - - - - - - - - -

Top

- -## provenance/oracle/v1/params.proto - - - - - -### Params -Params defines the parameters for the module. - - - - - @@ -6860,7 +6831,6 @@ GenesisState defines the oracle module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `sequence` | [uint64](#uint64) | | Sequence is the next auto incremented id to be assigned to the next query | -| `params` | [Params](#provenance.oracle.v1.Params) | | Params are the parameters that the module uses | | `port_id` | [string](#string) | | The port to assign to the module | | `oracle` | [string](#string) | | The address of the oracle | diff --git a/proto/provenance/metadata/v1/specification.proto b/proto/provenance/metadata/v1/specification.proto index d820cb09db..374b95b151 100644 --- a/proto/provenance/metadata/v1/specification.proto +++ b/proto/provenance/metadata/v1/specification.proto @@ -79,7 +79,7 @@ message ContractSpecification { // the address of a record on chain that represents this contract bytes resource_id = 5 [ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"resource_id\"" + (gogoproto.moretags) = "yaml:\"resource_id\"" ]; // the hash of contract binary (off-chain instance) string hash = 6; diff --git a/proto/provenance/oracle/v1/genesis.proto b/proto/provenance/oracle/v1/genesis.proto index 9989a28c7a..c4d598c573 100644 --- a/proto/provenance/oracle/v1/genesis.proto +++ b/proto/provenance/oracle/v1/genesis.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package provenance.oracle.v1; import "gogoproto/gogo.proto"; -import "provenance/oracle/v1/params.proto"; option go_package = "github.com/provenance-io/provenance/x/oracle/types"; option java_package = "io.provenance.oracle.v1"; @@ -15,10 +14,8 @@ message GenesisState { // Sequence is the next auto incremented id to be assigned to the next query uint64 sequence = 1; - // Params are the parameters that the module uses - Params params = 2 [(gogoproto.nullable) = false]; // The port to assign to the module - string port_id = 3; + string port_id = 2; // The address of the oracle - string oracle = 4; + string oracle = 3; } \ No newline at end of file diff --git a/proto/provenance/oracle/v1/params.proto b/proto/provenance/oracle/v1/params.proto deleted file mode 100644 index edb16fe947..0000000000 --- a/proto/provenance/oracle/v1/params.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; -package provenance.oracle.v1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/provenance-io/provenance/x/oracle/types"; - -option java_package = "io.provenance.oracle.v1"; -option java_multiple_files = true; - -// Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; -} \ No newline at end of file diff --git a/x/oracle/client/cli/cli_test.go b/x/oracle/client/cli/cli_test.go index a9dd376946..bca6f2a6fe 100644 --- a/x/oracle/client/cli/cli_test.go +++ b/x/oracle/client/cli/cli_test.go @@ -38,7 +38,6 @@ type IntegrationTestSuite struct { accountKey *secp256k1.PrivKey accountAddresses []sdk.AccAddress - params oracletypes.Params sequence uint64 port string oracle string @@ -88,13 +87,11 @@ func (s *IntegrationTestSuite) SetupSuite() { genesisState[authtypes.ModuleName] = authDataBz s.sequence = uint64(1) - s.params = oracletypes.DefaultParams() s.port = oracletypes.PortID s.oracle = "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma" oracleData := oracletypes.NewGenesisState( s.port, - s.params, s.sequence, s.oracle, ) diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 9c6d3c213b..66546e8397 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -11,7 +11,6 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { oracle, _ := k.GetOracle(ctx) return &types.GenesisState{ Sequence: k.GetLastQueryPacketSeq(ctx), - Params: k.GetParams(ctx), PortId: k.GetPort(ctx), Oracle: oracle.String(), } @@ -31,7 +30,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { } } - k.SetParams(ctx, genState.Params) k.SetLastQueryPacketSeq(ctx, genState.Sequence) var oracle sdk.AccAddress if len(genState.Oracle) == 0 { diff --git a/x/oracle/keeper/genesis_test.go b/x/oracle/keeper/genesis_test.go index 0fa0a2c87f..0dea7531cf 100644 --- a/x/oracle/keeper/genesis_test.go +++ b/x/oracle/keeper/genesis_test.go @@ -6,7 +6,6 @@ import ( func (s *KeeperTestSuite) TestExportGenesis() { genesis := s.app.OracleKeeper.ExportGenesis(s.ctx) - s.Assert().Equal(types.DefaultParams(), genesis.Params, "should export the correct params") s.Assert().Equal("oracle", genesis.PortId, "should export the correct port") s.Assert().Equal(int(1), int(genesis.Sequence), "should export the correct sequence number") s.Assert().Equal("", genesis.Oracle, "should export the correct oracle address") @@ -20,30 +19,30 @@ func (s *KeeperTestSuite) TestInitGenesis() { }{ { name: "success - valid genesis state", - genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + genesis: types.NewGenesisState("jackthecat", 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), }, { name: "success - valid genesis state with empty oracle", - genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1, ""), + genesis: types.NewGenesisState("jackthecat", 1, ""), }, { name: "failure - invalid sequence number", - genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 0, ""), + genesis: types.NewGenesisState("jackthecat", 0, ""), err: "sequence 0 is invalid, must be greater than 0", }, { name: "failure - invalid port", - genesis: types.NewGenesisState("", types.DefaultParams(), 1, ""), + genesis: types.NewGenesisState("", 1, ""), err: "identifier cannot be blank: invalid identifier", }, { name: "failure - invalid oracle", - genesis: types.NewGenesisState("jackthecat", types.DefaultParams(), 1, "abc"), + genesis: types.NewGenesisState("jackthecat", 1, "abc"), err: "decoding bech32 failed: invalid bech32 string length 3", }, { name: "success - works with existing port", - genesis: types.NewGenesisState("oracle", types.DefaultParams(), 1, ""), + genesis: types.NewGenesisState("oracle", 1, ""), }, } @@ -57,7 +56,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { } else { s.app.OracleKeeper.InitGenesis(s.ctx, tc.genesis) oracle, _ := s.app.OracleKeeper.GetOracle(s.ctx) - s.Assert().Equal(tc.genesis.Params, s.app.OracleKeeper.GetParams(s.ctx), "should correctly set params") s.Assert().Equal(tc.genesis.PortId, s.app.OracleKeeper.GetPort(s.ctx), "should correctly set the port") s.Assert().True(s.app.OracleKeeper.IsBound(s.ctx, tc.genesis.PortId), "should bind the port") s.Assert().Equal(int(tc.genesis.Sequence), int(s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx)), "should set the last sequence number") diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 655f9e7a99..e180127dfb 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -11,17 +11,15 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" "github.com/provenance-io/provenance/x/oracle/types" ) type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey ics4Wrapper types.ICS4Wrapper channelKeeper types.ChannelKeeper @@ -37,22 +35,16 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, - ps paramtypes.Subspace, ics4Wrapper types.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, scopedKeeper types.ScopedKeeper, wasmQueryServer wasmtypes.QueryServer, ) *Keeper { - if !ps.HasKeyTable() { - ps = ps.WithKeyTable(types.ParamKeyTable()) - } - return &Keeper{ - storeKey: storeKey, - cdc: cdc, - memKey: memKey, - paramstore: ps, + storeKey: storeKey, + cdc: cdc, + memKey: memKey, ics4Wrapper: ics4Wrapper, channelKeeper: channelKeeper, diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go deleted file mode 100644 index 3ff11b6b72..0000000000 --- a/x/oracle/keeper/params.go +++ /dev/null @@ -1,17 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/provenance-io/provenance/x/oracle/types" -) - -// GetParams get all parameters as types.Params -func (k Keeper) GetParams(_ sdk.Context) types.Params { - return types.NewParams() -} - -// SetParams set the params -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) -} diff --git a/x/oracle/keeper/params_test.go b/x/oracle/keeper/params_test.go deleted file mode 100644 index 3ac56dfd0d..0000000000 --- a/x/oracle/keeper/params_test.go +++ /dev/null @@ -1,8 +0,0 @@ -package keeper_test - -import "github.com/provenance-io/provenance/x/oracle/types" - -func (s *KeeperTestSuite) TestGetParams() { - params := s.app.OracleKeeper.GetParams(s.ctx) - s.Assert().Equal(types.NewParams(), params, "should return correct params") -} diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 0178087cc1..9de3c03bca 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -54,15 +54,13 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { port = PortFn(r) }, ) - params := types.DefaultParams() - var oracle string simState.AppParams.GetOrGenerate( simState.Cdc, Port, &port, simState.Rand, func(r *rand.Rand) { oracle = OracleFn(r, simState.Accounts) }, ) - genesis := types.NewGenesisState(port, params, sequenceID, oracle) + genesis := types.NewGenesisState(port, sequenceID, oracle) simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(genesis) bz, err := json.MarshalIndent(simState.GenState[types.ModuleName], "", " ") diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 08e074b083..5c6d913edb 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -7,10 +7,9 @@ import ( host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -func NewGenesisState(port string, params Params, sequence uint64, oracle string) *GenesisState { +func NewGenesisState(port string, sequence uint64, oracle string) *GenesisState { return &GenesisState{ PortId: port, - Params: params, Sequence: sequence, Oracle: oracle, } @@ -18,7 +17,7 @@ func NewGenesisState(port string, params Params, sequence uint64, oracle string) // DefaultGenesis returns the default oracle genesis state func DefaultGenesis() *GenesisState { - return NewGenesisState(PortID, DefaultParams(), 1, "") + return NewGenesisState(PortID, 1, "") } // Validate performs basic genesis state validation returning an error upon any @@ -37,5 +36,5 @@ func (gs GenesisState) Validate() error { return err } - return gs.Params.Validate() + return nil } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index f5455b5c32..76233c5d8a 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -27,12 +27,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // Sequence is the next auto incremented id to be assigned to the next query Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` - // Params are the parameters that the module uses - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` // The port to assign to the module - PortId string `protobuf:"bytes,3,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` // The address of the oracle - Oracle string `protobuf:"bytes,4,opt,name=oracle,proto3" json:"oracle,omitempty"` + Oracle string `protobuf:"bytes,3,opt,name=oracle,proto3" json:"oracle,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -77,25 +75,22 @@ func init() { } var fileDescriptor_f8d8aecd974cfd80 = []byte{ - // 274 bytes of a gzipped FileDescriptorProto + // 232 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, - 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0xa5, 0x14, 0xb1, 0x9a, 0x57, 0x90, 0x58, 0x94, 0x98, 0x0b, 0x35, - 0x4e, 0x69, 0x21, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0x82, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x29, - 0x2e, 0x8e, 0xe2, 0xd4, 0xc2, 0xd2, 0xd4, 0xbc, 0xe4, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x96, - 0x20, 0x38, 0x5f, 0xc8, 0x8a, 0x8b, 0x0d, 0xa2, 0x59, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, - 0x46, 0x0f, 0x9b, 0x63, 0xf4, 0x02, 0xc0, 0x6a, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, - 0xea, 0x10, 0x12, 0xe7, 0x62, 0x2f, 0xc8, 0x2f, 0x2a, 0x89, 0xcf, 0x4c, 0x91, 0x60, 0x56, 0x60, - 0xd4, 0xe0, 0x0c, 0x62, 0x03, 0x71, 0x3d, 0x53, 0x84, 0xc4, 0xb8, 0xd8, 0x20, 0x5a, 0x25, 0x58, - 0x20, 0xe2, 0x10, 0x9e, 0x15, 0x47, 0xc7, 0x02, 0x79, 0x86, 0x17, 0x0b, 0xe4, 0x19, 0x9c, 0xd2, - 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, - 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x81, 0x4b, 0x3c, 0x33, 0x1f, 0xab, 0x13, - 0x02, 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, - 0x4a, 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0xb0, 0x60, 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, - 0x62, 0x03, 0x87, 0x89, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x98, 0xea, 0xb1, 0x01, 0x88, 0x01, - 0x00, 0x00, + 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0x95, 0x52, 0xb9, 0x78, 0xdc, 0x21, 0x9a, 0x83, 0x4b, 0x12, 0x4b, + 0x52, 0x85, 0xa4, 0xb8, 0x38, 0x8a, 0x53, 0x0b, 0x4b, 0x53, 0xf3, 0x92, 0x53, 0x25, 0x18, 0x15, + 0x18, 0x35, 0x58, 0x82, 0xe0, 0x7c, 0x21, 0x71, 0x2e, 0xf6, 0x82, 0xfc, 0xa2, 0x92, 0xf8, 0xcc, + 0x14, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x36, 0x10, 0xd7, 0x33, 0x45, 0x48, 0x8c, 0x8b, + 0x0d, 0x62, 0x8f, 0x04, 0x33, 0x44, 0x1c, 0xc2, 0xb3, 0xe2, 0xe8, 0x58, 0x20, 0xcf, 0xf0, 0x62, + 0x81, 0x3c, 0x83, 0x53, 0xfa, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, + 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x70, 0x89, + 0x67, 0x82, 0x9d, 0x82, 0xe1, 0xde, 0x00, 0xc6, 0x28, 0xa3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, + 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x84, 0x12, 0xdd, 0xcc, 0x7c, 0x24, 0x9e, 0x7e, 0x05, 0x2c, 0x18, + 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xde, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, + 0x17, 0x35, 0x99, 0x25, 0x28, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -123,25 +118,15 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Oracle) i = encodeVarintGenesis(dAtA, i, uint64(len(m.Oracle))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if len(m.PortId) > 0 { i -= len(m.PortId) copy(dAtA[i:], m.PortId) i = encodeVarintGenesis(dAtA, i, uint64(len(m.PortId))) i-- - dAtA[i] = 0x1a - } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if m.Sequence != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.Sequence)) i-- @@ -170,8 +155,6 @@ func (m *GenesisState) Size() (n int) { if m.Sequence != 0 { n += 1 + sovGenesis(uint64(m.Sequence)) } - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) l = len(m.PortId) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) @@ -238,39 +221,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) } @@ -302,7 +252,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.PortId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Oracle", wireType) } diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go index 2f05108c6e..dbaf20357b 100644 --- a/x/oracle/types/genesis_test.go +++ b/x/oracle/types/genesis_test.go @@ -8,23 +8,19 @@ import ( func TestNewGenesisState(t *testing.T) { port := "random" - params := DefaultParams() sequence := uint64(10) oracle := "oracle" - genesis := NewGenesisState(port, params, sequence, oracle) + genesis := NewGenesisState(port, sequence, oracle) assert.Equal(t, port, genesis.PortId, "port id must match") - assert.Equal(t, params, genesis.Params, "params must match") assert.Equal(t, int(sequence), int(genesis.Sequence), "sequence must match") assert.Equal(t, oracle, genesis.Oracle, "oracle must match") } func TestDefaultGenesis(t *testing.T) { genesis := DefaultGenesis() - params := DefaultParams() assert.Equal(t, PortID, genesis.PortId, "port id must match") - assert.Equal(t, params, genesis.Params, "params must match") assert.Equal(t, int(1), int(genesis.Sequence), "sequence must be 1") assert.Equal(t, "", genesis.Oracle, "oracle must match") } @@ -37,25 +33,25 @@ func TestGenesisValidate(t *testing.T) { }{ { name: "success - all fields are valid", - state: NewGenesisState(PortID, DefaultParams(), 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + state: NewGenesisState(PortID, 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), }, { name: "success - all fields are valid with empty oracle", - state: NewGenesisState(PortID, DefaultParams(), 1, ""), + state: NewGenesisState(PortID, 1, ""), }, { name: "failure - port id is invalid", - state: NewGenesisState("x", DefaultParams(), 1, ""), + state: NewGenesisState("x", 1, ""), err: "identifier x has invalid length: 1, must be between 2-128 characters: invalid identifier", }, { name: "failure - sequence id is invalid", - state: NewGenesisState(PortID, DefaultParams(), 0, ""), + state: NewGenesisState(PortID, 0, ""), err: "sequence 0 is invalid, must be greater than 0", }, { name: "failure - oracle is invalid", - state: NewGenesisState(PortID, DefaultParams(), 1, "abc"), + state: NewGenesisState(PortID, 1, "abc"), err: "decoding bech32 failed: invalid bech32 string length 3", }, } diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go deleted file mode 100644 index cc90a6d87a..0000000000 --- a/x/oracle/types/params.go +++ /dev/null @@ -1,40 +0,0 @@ -package types - -import ( - "gopkg.in/yaml.v2" - - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// NewParams creates a new Params instance -func NewParams() Params { - return Params{} -} - -// DefaultParams returns a default set of parameters -func DefaultParams() Params { - return NewParams() -} - -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - -// Validate validates the set of params -func (p Params) Validate() error { - return nil -} - -// String implements the Stringer interface. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} diff --git a/x/oracle/types/params.pb.go b/x/oracle/types/params.pb.go deleted file mode 100644 index c50a7a6feb..0000000000 --- a/x/oracle/types/params.pb.go +++ /dev/null @@ -1,265 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: provenance/oracle/v1/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params defines the parameters for the module. -type Params struct { -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_8b65391c48f11fe8, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Params)(nil), "provenance.oracle.v1.Params") -} - -func init() { proto.RegisterFile("provenance/oracle/v1/params.proto", fileDescriptor_8b65391c48f11fe8) } - -var fileDescriptor_8b65391c48f11fe8 = []byte{ - // 166 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0x28, 0xca, 0x2f, - 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, - 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, - 0x28, 0xd1, 0x83, 0x28, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, - 0x07, 0xb1, 0x20, 0x6a, 0x95, 0xf8, 0xb8, 0xd8, 0x02, 0xc0, 0x7a, 0xad, 0x58, 0x66, 0x2c, 0x90, - 0x67, 0x70, 0x4a, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, - 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, 0xf1, 0x4c, - 0xb0, 0x1e, 0x0c, 0x83, 0x03, 0x18, 0xa3, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, - 0xf3, 0x73, 0xf5, 0x11, 0x4a, 0x74, 0x33, 0xf3, 0x91, 0x78, 0xfa, 0x15, 0x30, 0xe7, 0x96, 0x54, - 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xed, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x59, - 0xfc, 0x5f, 0xd0, 0x00, 0x00, 0x00, -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) From d299eac6532b926541bebcdb3cb894ec612548f6 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:06:49 -0400 Subject: [PATCH 70/96] Updated comment for BindPort. --- x/oracle/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index e180127dfb..de8c6d8a87 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -60,7 +60,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } -// BindPort stores the provided portID and binds to it, returning the associated capability +// BindPort stores the provided portID and binds to it func (k Keeper) BindPort(ctx sdk.Context, portID string) error { capability := k.portKeeper.BindPort(ctx, portID) return k.ClaimCapability(ctx, capability, host.PortPath(portID)) From 6822542cad94a779c66adaa4792435ee641fd29e Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:10:07 -0400 Subject: [PATCH 71/96] Split interface check on multiple lines. --- x/oracle/types/msgs.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 41d6f92289..54af560e7c 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -7,7 +7,10 @@ import ( host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -var _, _ sdk.Msg = &MsgUpdateOracleRequest{}, &MsgSendQueryOracleRequest{} +var ( + _ sdk.Msg = &MsgUpdateOracleRequest{} + _ sdk.Msg = &MsgSendQueryOracleRequest{} +) // NewMsgSendQueryOracle creates a new MsgSendQueryOracleRequest func NewMsgSendQueryOracle(creator, channelID string, query []byte) *MsgSendQueryOracleRequest { From 83b87e8fe6702bea3de36803435219950847a274 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:11:22 -0400 Subject: [PATCH 72/96] Moved methods up. --- x/oracle/types/msgs.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 54af560e7c..04b593dcb2 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -21,45 +21,45 @@ func NewMsgSendQueryOracle(creator, channelID string, query []byte) *MsgSendQuer } } -// NewMsgUpdateOracle creates a new MsgUpdateOracleRequest -func NewMsgUpdateOracle(creator, addr string) *MsgUpdateOracleRequest { - return &MsgUpdateOracleRequest{ - Authority: creator, - Address: addr, - } -} - // GetSigners indicates that the message must have been signed by the parent. -func (msg MsgUpdateOracleRequest) GetSigners() []sdk.AccAddress { +func (msg MsgSendQueryOracleRequest) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sdk.MustAccAddressFromBech32(msg.Authority)} } // ValidateBasic runs stateless validation checks on the message. -func (msg MsgUpdateOracleRequest) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { - return fmt.Errorf("invalid address for oracle: %w", err) +func (msg MsgSendQueryOracleRequest) ValidateBasic() error { + if err := host.ChannelIdentifierValidator(msg.Channel); err != nil { + return fmt.Errorf("invalid channel id") } if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return fmt.Errorf("invalid authority address: %w", err) } + if err := msg.Query.ValidateBasic(); err != nil { + return fmt.Errorf("invalid query data: %w", err) + } return nil } +// NewMsgUpdateOracle creates a new MsgUpdateOracleRequest +func NewMsgUpdateOracle(creator, addr string) *MsgUpdateOracleRequest { + return &MsgUpdateOracleRequest{ + Authority: creator, + Address: addr, + } +} + // GetSigners indicates that the message must have been signed by the parent. -func (msg MsgSendQueryOracleRequest) GetSigners() []sdk.AccAddress { +func (msg MsgUpdateOracleRequest) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sdk.MustAccAddressFromBech32(msg.Authority)} } // ValidateBasic runs stateless validation checks on the message. -func (msg MsgSendQueryOracleRequest) ValidateBasic() error { - if err := host.ChannelIdentifierValidator(msg.Channel); err != nil { - return fmt.Errorf("invalid channel id") +func (msg MsgUpdateOracleRequest) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { + return fmt.Errorf("invalid address for oracle: %w", err) } if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return fmt.Errorf("invalid authority address: %w", err) } - if err := msg.Query.ValidateBasic(); err != nil { - return fmt.Errorf("invalid query data: %w", err) - } return nil } From deaeec0aa9f450d1eeadd4914df122da88689dc9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:12:24 -0400 Subject: [PATCH 73/96] Moved saffron-rc1 upgrade up 1. --- app/upgrades.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 2a391dcd9c..3889cc3606 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -115,7 +115,7 @@ var upgrades = map[string]appUpgrade{ }, Added: []string{triggertypes.ModuleName}, }, - "saffron": { // upgrade for v1.17.0, + "saffron-rc1": { // upgrade for v1.17.0, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error vm, err = runModuleMigrations(ctx, app, vm) @@ -129,7 +129,7 @@ var upgrades = map[string]appUpgrade{ }, Added: []string{icqtypes.ModuleName, oracletypes.ModuleName}, }, - "saffron-rc1": { // upgrade for v1.17.0, + "saffron": { // upgrade for v1.17.0, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error vm, err = runModuleMigrations(ctx, app, vm) From f94ef41f80b0a3b6b99b3930268f4a7c83c42b3d Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:17:31 -0400 Subject: [PATCH 74/96] Added removeInactiveValidatorDelegations. --- app/upgrades.go | 4 ++-- app/upgrades_test.go | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 3889cc3606..f3b6ac922d 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -122,7 +122,7 @@ var upgrades = map[string]appUpgrade{ if err != nil { return nil, err } - + removeInactiveValidatorDelegations(ctx, app) setupICQ(ctx, app) return vm, nil @@ -136,7 +136,7 @@ var upgrades = map[string]appUpgrade{ if err != nil { return nil, err } - + removeInactiveValidatorDelegations(ctx, app) setupICQ(ctx, app) return vm, nil diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 9b3ec058c3..830827f87b 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -415,30 +415,32 @@ func (s *UpgradeTestSuite) TestRust() { s.AssertUpgradeHandlerLogs("rust", expInLog, expNotInLog) } -func (s *UpgradeTestSuite) TestSaffron() { +func (s *UpgradeTestSuite) TestSaffronRC1() { // Each part is (hopefully) tested thoroughly on its own. // So for this test, just make sure there's log entries for each part being done. expInLog := []string{ "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", + "INF removing all delegations from validators that have been inactive (unbonded) for 21 days", "INF Updating ICQ params", "INF Done updating ICQ params", } - s.AssertUpgradeHandlerLogs("saffron", expInLog, nil) + s.AssertUpgradeHandlerLogs("saffron-rc1", expInLog, nil) } -func (s *UpgradeTestSuite) TestSaffronRC1() { +func (s *UpgradeTestSuite) TestSaffron() { // Each part is (hopefully) tested thoroughly on its own. // So for this test, just make sure there's log entries for each part being done. expInLog := []string{ "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", + "INF removing all delegations from validators that have been inactive (unbonded) for 21 days", "INF Updating ICQ params", "INF Done updating ICQ params", } - s.AssertUpgradeHandlerLogs("saffron-rc1", expInLog, nil) + s.AssertUpgradeHandlerLogs("saffron", expInLog, nil) } func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() { From 3c71f1597a4339a5137da74489ed6c273bb14530 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:21:56 -0400 Subject: [PATCH 75/96] Changed Equal(0) test to .Empty --- x/oracle/keeper/msg_server_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index ffcb8dbd1f..07c09cb93e 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -50,7 +50,7 @@ func (s *KeeperTestSuite) TestUpdateOracle() { s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events") s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event") } else { - s.Assert().Equal(0, len(s.ctx.EventManager().Events()), "should not emit events") + s.Assert().Empty(s.ctx.EventManager().Events(), "should not emit events") } if len(tc.err) > 0 { @@ -117,7 +117,7 @@ func (s *KeeperTestSuite) TestSendQueryOracle() { s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events") s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event") } else { - s.Assert().Equal(0, len(s.ctx.EventManager().Events()), "should not emit events") + s.Assert().Empty(s.ctx.EventManager().Events(), "should not emit events") } if len(tc.err) > 0 { From 0dc658c6d69c19aedc589605a42d0c9106a040a3 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 15:27:13 -0400 Subject: [PATCH 76/96] Removed nil check. --- x/oracle/keeper/query_server.go | 5 ----- x/oracle/keeper/query_server_test.go | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index 6627d12a34..b181e4546e 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -16,13 +16,8 @@ var _ types.QueryServer = Keeper{} // QueryAddress returns the address of the module's oracle func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddressRequest) (*types.QueryOracleAddressResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } ctx := sdk.UnwrapSDKContext(goCtx) - oracle, _ := k.GetOracle(ctx) - return &types.QueryOracleAddressResponse{Address: oracle.String()}, nil } diff --git a/x/oracle/keeper/query_server_test.go b/x/oracle/keeper/query_server_test.go index 26020e7c10..0cf109bc6f 100644 --- a/x/oracle/keeper/query_server_test.go +++ b/x/oracle/keeper/query_server_test.go @@ -17,8 +17,7 @@ func (s *KeeperTestSuite) TestOracleAddress() { { name: "failure - should handle nil request", req: nil, - expected: nil, - err: "rpc error: code = InvalidArgument desc = invalid request", + expected: &types.QueryOracleAddressResponse{Address: ""}, }, { name: "success - should return correct oracle address", From 0bf7f23645abed7fe3113d073ff00cc278f0bc1a Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 16:31:36 -0400 Subject: [PATCH 77/96] Updated comments. --- x/oracle/module/module_ibc.go | 1 + x/oracle/simulation/operations.go | 2 +- x/oracle/types/expected_keepers.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index cf7562d903..e044c8cbd2 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -155,6 +155,7 @@ func (am AppModule) OnTimeoutPacket( return am.keeper.OnTimeoutPacket(ctx, modulePacket) } +// NegotiateAppVersion implements the IBCModule interface func (am AppModule) NegotiateAppVersion( _ sdk.Context, _ channeltypes.Order, diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index 89cdfda811..73fe4036e1 100644 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -61,7 +61,7 @@ func WeightedOperations( } } -// SimulateMsgCreateTrigger sends a MsgUpdateOracle. +// SimulateMsgUpdateOracle sends a MsgUpdateOracle. func SimulateMsgUpdateOracle(_ keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go index 0cfd062c03..cf3dbc6cf5 100644 --- a/x/oracle/types/expected_keepers.go +++ b/x/oracle/types/expected_keepers.go @@ -20,7 +20,7 @@ type ICS4Wrapper interface { ) (sequence uint64, err error) } -// Channel defines the expected IBC channel keeper +// ChannelKeeper defines the expected IBC channel keeper type ChannelKeeper interface { GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) From e8a202bc65eef676cc06c508330f85f19d95f818 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 11 Aug 2023 16:33:03 -0400 Subject: [PATCH 78/96] Removed unused error and fixed linting issue with unused param. --- x/oracle/keeper/query_server.go | 2 +- x/oracle/types/errors.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/x/oracle/keeper/query_server.go b/x/oracle/keeper/query_server.go index b181e4546e..c69b59ae49 100644 --- a/x/oracle/keeper/query_server.go +++ b/x/oracle/keeper/query_server.go @@ -15,7 +15,7 @@ import ( var _ types.QueryServer = Keeper{} // QueryAddress returns the address of the module's oracle -func (k Keeper) OracleAddress(goCtx context.Context, req *types.QueryOracleAddressRequest) (*types.QueryOracleAddressResponse, error) { +func (k Keeper) OracleAddress(goCtx context.Context, _ *types.QueryOracleAddressRequest) (*types.QueryOracleAddressResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) oracle, _ := k.GetOracle(ctx) return &types.QueryOracleAddressResponse{Address: oracle.String()}, nil diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index f6e1d27111..78debf6fbf 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -5,7 +5,6 @@ import ( ) var ( - ErrSample = cerrs.Register(ModuleName, 2, "sample error") ErrInvalidPacketTimeout = cerrs.Register(ModuleName, 3, "invalid packet timeout") ErrInvalidVersion = cerrs.Register(ModuleName, 4, "invalid version") ErrMissingOracleAddress = cerrs.Register(ModuleName, 5, "missing oracle address") From 15048e678c0158404fc43566189b595999a549d5 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Aug 2023 09:44:57 -0400 Subject: [PATCH 79/96] Removed the LastSequenceNumber because it is no longer used. --- docs/proto-docs.md | 1 - proto/provenance/oracle/v1/genesis.proto | 2 - x/oracle/client/cli/cli_test.go | 7 +--- x/oracle/keeper/genesis.go | 6 +-- x/oracle/keeper/genesis_test.go | 17 +++----- x/oracle/keeper/query.go | 24 ----------- x/oracle/keeper/query_test.go | 9 ---- x/oracle/keeper/relay.go | 2 - x/oracle/simulation/genesis.go | 16 +------- x/oracle/types/genesis.go | 15 ++----- x/oracle/types/genesis.pb.go | 52 +++++------------------- x/oracle/types/genesis_test.go | 18 +++----- 12 files changed, 31 insertions(+), 138 deletions(-) delete mode 100644 x/oracle/keeper/query.go delete mode 100644 x/oracle/keeper/query_test.go diff --git a/docs/proto-docs.md b/docs/proto-docs.md index bc93d4a5cc..16f5046bcf 100644 --- a/docs/proto-docs.md +++ b/docs/proto-docs.md @@ -6981,7 +6981,6 @@ GenesisState defines the oracle module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sequence` | [uint64](#uint64) | | Sequence is the next auto incremented id to be assigned to the next query | | `port_id` | [string](#string) | | The port to assign to the module | | `oracle` | [string](#string) | | The address of the oracle | diff --git a/proto/provenance/oracle/v1/genesis.proto b/proto/provenance/oracle/v1/genesis.proto index c4d598c573..596b05daef 100644 --- a/proto/provenance/oracle/v1/genesis.proto +++ b/proto/provenance/oracle/v1/genesis.proto @@ -12,8 +12,6 @@ message GenesisState { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // Sequence is the next auto incremented id to be assigned to the next query - uint64 sequence = 1; // The port to assign to the module string port_id = 2; // The address of the oracle diff --git a/x/oracle/client/cli/cli_test.go b/x/oracle/client/cli/cli_test.go index bca6f2a6fe..123c23837c 100644 --- a/x/oracle/client/cli/cli_test.go +++ b/x/oracle/client/cli/cli_test.go @@ -38,9 +38,8 @@ type IntegrationTestSuite struct { accountKey *secp256k1.PrivKey accountAddresses []sdk.AccAddress - sequence uint64 - port string - oracle string + port string + oracle string } func TestIntegrationTestSuite(t *testing.T) { @@ -86,13 +85,11 @@ func (s *IntegrationTestSuite) SetupSuite() { s.Require().NoError(err, "should be able to marshal auth genesis state when setting up suite") genesisState[authtypes.ModuleName] = authDataBz - s.sequence = uint64(1) s.port = oracletypes.PortID s.oracle = "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma" oracleData := oracletypes.NewGenesisState( s.port, - s.sequence, s.oracle, ) diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 66546e8397..1f1044fe67 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -10,9 +10,8 @@ import ( func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { oracle, _ := k.GetOracle(ctx) return &types.GenesisState{ - Sequence: k.GetLastQueryPacketSeq(ctx), - PortId: k.GetPort(ctx), - Oracle: oracle.String(), + PortId: k.GetPort(ctx), + Oracle: oracle.String(), } } @@ -30,7 +29,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { } } - k.SetLastQueryPacketSeq(ctx, genState.Sequence) var oracle sdk.AccAddress if len(genState.Oracle) == 0 { oracle = sdk.AccAddress{} diff --git a/x/oracle/keeper/genesis_test.go b/x/oracle/keeper/genesis_test.go index 0dea7531cf..02243be14c 100644 --- a/x/oracle/keeper/genesis_test.go +++ b/x/oracle/keeper/genesis_test.go @@ -7,7 +7,6 @@ import ( func (s *KeeperTestSuite) TestExportGenesis() { genesis := s.app.OracleKeeper.ExportGenesis(s.ctx) s.Assert().Equal("oracle", genesis.PortId, "should export the correct port") - s.Assert().Equal(int(1), int(genesis.Sequence), "should export the correct sequence number") s.Assert().Equal("", genesis.Oracle, "should export the correct oracle address") } @@ -19,30 +18,25 @@ func (s *KeeperTestSuite) TestInitGenesis() { }{ { name: "success - valid genesis state", - genesis: types.NewGenesisState("jackthecat", 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + genesis: types.NewGenesisState("jackthecat", "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), }, { name: "success - valid genesis state with empty oracle", - genesis: types.NewGenesisState("jackthecat", 1, ""), - }, - { - name: "failure - invalid sequence number", - genesis: types.NewGenesisState("jackthecat", 0, ""), - err: "sequence 0 is invalid, must be greater than 0", + genesis: types.NewGenesisState("jackthecat", ""), }, { name: "failure - invalid port", - genesis: types.NewGenesisState("", 1, ""), + genesis: types.NewGenesisState("", ""), err: "identifier cannot be blank: invalid identifier", }, { name: "failure - invalid oracle", - genesis: types.NewGenesisState("jackthecat", 1, "abc"), + genesis: types.NewGenesisState("jackthecat", "abc"), err: "decoding bech32 failed: invalid bech32 string length 3", }, { name: "success - works with existing port", - genesis: types.NewGenesisState("oracle", 1, ""), + genesis: types.NewGenesisState("oracle", ""), }, } @@ -58,7 +52,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { oracle, _ := s.app.OracleKeeper.GetOracle(s.ctx) s.Assert().Equal(tc.genesis.PortId, s.app.OracleKeeper.GetPort(s.ctx), "should correctly set the port") s.Assert().True(s.app.OracleKeeper.IsBound(s.ctx, tc.genesis.PortId), "should bind the port") - s.Assert().Equal(int(tc.genesis.Sequence), int(s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx)), "should set the last sequence number") s.Assert().Equal(tc.genesis.Oracle, oracle.String(), "should get the correct oracle address") } }) diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go deleted file mode 100644 index a0e216aa96..0000000000 --- a/x/oracle/keeper/query.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - gogotypes "github.com/gogo/protobuf/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/provenance-io/provenance/x/oracle/types" -) - -// GetLastQueryPacketSeq return the id from the last query request -func (k Keeper) GetLastQueryPacketSeq(ctx sdk.Context) uint64 { - bz := ctx.KVStore(k.storeKey).Get(types.GetLastQueryPacketSeqKey()) - uintV := gogotypes.UInt64Value{} - k.cdc.MustUnmarshalLengthPrefixed(bz, &uintV) - return uintV.GetValue() -} - -// SetLastQueryPacketSeq saves the id from the last query request -func (k Keeper) SetLastQueryPacketSeq(ctx sdk.Context, packetSequence uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.GetLastQueryPacketSeqKey(), - k.cdc.MustMarshalLengthPrefixed(&gogotypes.UInt64Value{Value: packetSequence})) -} diff --git a/x/oracle/keeper/query_test.go b/x/oracle/keeper/query_test.go deleted file mode 100644 index 26622f04f4..0000000000 --- a/x/oracle/keeper/query_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package keeper_test - -func (s *KeeperTestSuite) TestSetGetLastQueryPacketSeq() { - sequence := s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx) - s.Assert().Equal(int(1), int(sequence), "should have the correct initial sequence") - s.app.OracleKeeper.SetLastQueryPacketSeq(s.ctx, 5) - sequence = s.app.OracleKeeper.GetLastQueryPacketSeq(s.ctx) - s.Assert().Equal(int(5), int(sequence), "should have the correct updated sequence") -} diff --git a/x/oracle/keeper/relay.go b/x/oracle/keeper/relay.go index b8410e5a6e..22be438729 100644 --- a/x/oracle/keeper/relay.go +++ b/x/oracle/keeper/relay.go @@ -111,8 +111,6 @@ func (k Keeper) OnAcknowledgementPacket( return cerrs.Wrapf(err, "failed to unmarshal interchain query response to type %T", resp) } - k.SetLastQueryPacketSeq(ctx, modulePacket.Sequence) - err = ctx.EventManager().EmitTypedEvent(&types.EventOracleQuerySuccess{ SequenceId: strconv.FormatUint(modulePacket.Sequence, 10), Result: string(resp.Result), diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 9de3c03bca..38669733c5 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -13,15 +13,9 @@ import ( ) const ( - SequenceID = "sequence_id" - Port = "port" + Port = "port" ) -// SequenceIDFn randomized sequence id -func SequenceIDFn(r *rand.Rand) uint64 { - return uint64(randIntBetween(r, 0, 10000000000)) -} - // PortFn randomized port name func PortFn(r *rand.Rand) string { if r.Intn(2) > 0 { @@ -42,12 +36,6 @@ func OracleFn(r *rand.Rand, accs []simtypes.Account) string { // RandomizedGenState generates a random GenesisState for trigger func RandomizedGenState(simState *module.SimulationState) { - var sequenceID uint64 - simState.AppParams.GetOrGenerate( - simState.Cdc, SequenceID, &sequenceID, simState.Rand, - func(r *rand.Rand) { sequenceID = SequenceIDFn(r) }, - ) - var port string simState.AppParams.GetOrGenerate( simState.Cdc, Port, &port, simState.Rand, @@ -60,7 +48,7 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { oracle = OracleFn(r, simState.Accounts) }, ) - genesis := types.NewGenesisState(port, sequenceID, oracle) + genesis := types.NewGenesisState(port, oracle) simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(genesis) bz, err := json.MarshalIndent(simState.GenState[types.ModuleName], "", " ") diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 5c6d913edb..c87f3f2456 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -1,32 +1,25 @@ package types import ( - fmt "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) -func NewGenesisState(port string, sequence uint64, oracle string) *GenesisState { +func NewGenesisState(port string, oracle string) *GenesisState { return &GenesisState{ - PortId: port, - Sequence: sequence, - Oracle: oracle, + PortId: port, + Oracle: oracle, } } // DefaultGenesis returns the default oracle genesis state func DefaultGenesis() *GenesisState { - return NewGenesisState(PortID, 1, "") + return NewGenesisState(PortID, "") } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - if gs.Sequence == 0 { - return fmt.Errorf("sequence %d is invalid, must be greater than 0", int(gs.Sequence)) - } - if err := host.PortIdentifierValidator(gs.PortId); err != nil { return err } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index 76233c5d8a..9cb13dfa61 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -25,8 +25,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the oracle module's genesis state. type GenesisState struct { - // Sequence is the next auto incremented id to be assigned to the next query - Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` // The port to assign to the module PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` // The address of the oracle @@ -75,22 +73,21 @@ func init() { } var fileDescriptor_f8d8aecd974cfd80 = []byte{ - // 232 bytes of a gzipped FileDescriptorProto + // 211 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0x28, 0xca, 0x2f, 0x4b, 0xcd, 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, - 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0x95, 0x52, 0xb9, 0x78, 0xdc, 0x21, 0x9a, 0x83, 0x4b, 0x12, 0x4b, - 0x52, 0x85, 0xa4, 0xb8, 0x38, 0x8a, 0x53, 0x0b, 0x4b, 0x53, 0xf3, 0x92, 0x53, 0x25, 0x18, 0x15, - 0x18, 0x35, 0x58, 0x82, 0xe0, 0x7c, 0x21, 0x71, 0x2e, 0xf6, 0x82, 0xfc, 0xa2, 0x92, 0xf8, 0xcc, - 0x14, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x36, 0x10, 0xd7, 0x33, 0x45, 0x48, 0x8c, 0x8b, - 0x0d, 0x62, 0x8f, 0x04, 0x33, 0x44, 0x1c, 0xc2, 0xb3, 0xe2, 0xe8, 0x58, 0x20, 0xcf, 0xf0, 0x62, - 0x81, 0x3c, 0x83, 0x53, 0xfa, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, - 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x70, 0x89, - 0x67, 0x82, 0x9d, 0x82, 0xe1, 0xde, 0x00, 0xc6, 0x28, 0xa3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, - 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x84, 0x12, 0xdd, 0xcc, 0x7c, 0x24, 0x9e, 0x7e, 0x05, 0x2c, 0x18, - 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xde, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, - 0x17, 0x35, 0x99, 0x25, 0x28, 0x01, 0x00, 0x00, + 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0x95, 0x3c, 0xb9, 0x78, 0xdc, 0x21, 0x9a, 0x83, 0x4b, 0x12, 0x4b, + 0x52, 0x85, 0xc4, 0xb9, 0xd8, 0x0b, 0xf2, 0x8b, 0x4a, 0xe2, 0x33, 0x53, 0x24, 0x98, 0x14, 0x18, + 0x35, 0x38, 0x83, 0xd8, 0x40, 0x5c, 0xcf, 0x14, 0x21, 0x31, 0x2e, 0x36, 0x88, 0x59, 0x12, 0xcc, + 0x10, 0x71, 0x08, 0xcf, 0x8a, 0xa3, 0x63, 0x81, 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x0c, 0x4e, 0xe9, + 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, + 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0xc0, 0x25, 0x9e, 0x09, 0xb6, 0x0e, 0xc3, + 0x4d, 0x01, 0x8c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, + 0x08, 0x25, 0xba, 0x99, 0xf9, 0x48, 0x3c, 0xfd, 0x0a, 0x98, 0x57, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, + 0x93, 0xd8, 0xc0, 0x4e, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x6d, 0x21, 0xbd, 0x0c, + 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -127,11 +124,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if m.Sequence != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } @@ -152,9 +144,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if m.Sequence != 0 { - n += 1 + sovGenesis(uint64(m.Sequence)) - } l = len(m.PortId) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) @@ -201,25 +190,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) - } - m.Sequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Sequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go index dbaf20357b..026e55dd36 100644 --- a/x/oracle/types/genesis_test.go +++ b/x/oracle/types/genesis_test.go @@ -8,12 +8,10 @@ import ( func TestNewGenesisState(t *testing.T) { port := "random" - sequence := uint64(10) oracle := "oracle" - genesis := NewGenesisState(port, sequence, oracle) + genesis := NewGenesisState(port, oracle) assert.Equal(t, port, genesis.PortId, "port id must match") - assert.Equal(t, int(sequence), int(genesis.Sequence), "sequence must match") assert.Equal(t, oracle, genesis.Oracle, "oracle must match") } @@ -21,7 +19,6 @@ func TestDefaultGenesis(t *testing.T) { genesis := DefaultGenesis() assert.Equal(t, PortID, genesis.PortId, "port id must match") - assert.Equal(t, int(1), int(genesis.Sequence), "sequence must be 1") assert.Equal(t, "", genesis.Oracle, "oracle must match") } @@ -33,25 +30,20 @@ func TestGenesisValidate(t *testing.T) { }{ { name: "success - all fields are valid", - state: NewGenesisState(PortID, 1, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), + state: NewGenesisState(PortID, "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"), }, { name: "success - all fields are valid with empty oracle", - state: NewGenesisState(PortID, 1, ""), + state: NewGenesisState(PortID, ""), }, { name: "failure - port id is invalid", - state: NewGenesisState("x", 1, ""), + state: NewGenesisState("x", ""), err: "identifier x has invalid length: 1, must be between 2-128 characters: invalid identifier", }, - { - name: "failure - sequence id is invalid", - state: NewGenesisState(PortID, 0, ""), - err: "sequence 0 is invalid, must be greater than 0", - }, { name: "failure - oracle is invalid", - state: NewGenesisState(PortID, 1, "abc"), + state: NewGenesisState(PortID, "abc"), err: "decoding bech32 failed: invalid bech32 string length 3", }, } From 644454d75e44972c95147811e708af86b0ff1bf3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 14:45:02 -0600 Subject: [PATCH 80/96] Bump bufbuild/buf-setup-action from 1.26.0 to 1.26.1 (#1650) Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.26.0 to 1.26.1. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.26.0...v1.26.1) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/proto-registry.yml | 2 +- .github/workflows/proto.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/proto-registry.yml b/.github/workflows/proto-registry.yml index 4dee4fa0e9..ca0dd098fd 100644 --- a/.github/workflows/proto-registry.yml +++ b/.github/workflows/proto-registry.yml @@ -30,7 +30,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Buf setup action - uses: bufbuild/buf-setup-action@v1.26.0 + uses: bufbuild/buf-setup-action@v1.26.1 - name: Buf push 'third_party/proto' uses: bufbuild/buf-push-action@v1 with: diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index ce982768a6..7487499bff 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -40,7 +40,7 @@ jobs: fi echo "Setting output: base-branch=$branch" echo "base-branch=$branch" >> "$GITHUB_OUTPUT" - - uses: bufbuild/buf-setup-action@v1.26.0 + - uses: bufbuild/buf-setup-action@v1.26.1 - uses: bufbuild/buf-lint-action@v1.0.3 if: always() with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b0006ea55..6d924af2db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -158,7 +158,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Buf setup action - uses: bufbuild/buf-setup-action@v1.26.0 + uses: bufbuild/buf-setup-action@v1.26.1 - name: Buf push 'proto/' uses: bufbuild/buf-push-action@v1 with: From fe82397629da4adc63ae5700e36e983ff4ee680f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 20:46:54 +0000 Subject: [PATCH 81/96] Bump golangci/golangci-lint-action from 3.6.0 to 3.7.0 (#1651) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.6.0 to 3.7.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.6.0...v3.7.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9f8d0e22c9..47b61bf4a4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,7 +30,7 @@ jobs: if: env.GIT_DIFF with: go-version: '1.20' - - uses: golangci/golangci-lint-action@v3.6.0 + - uses: golangci/golangci-lint-action@v3.7.0 if: env.GIT_DIFF with: # If you change this version, be sure to also change it in contrib/devtools/Makefile. From 2e1e7cb6c9cd0692682a9eb05f9bc153fb2ecebc Mon Sep 17 00:00:00 2001 From: Daniel Wedul Date: Thu, 17 Aug 2023 18:27:42 -0600 Subject: [PATCH 82/96] Allow restricted coins to be quarantined (#1652) * [1626]: Add a whitelist to the marker keeper. * [1626]: Change name to the more descriptive reqAttrBypassAddrs (from whitelistAddrs). * [1626]: Update validateSendDenom to check for bypassing and apply it appropriately. * [1626]: Tweak a couple comments. * [1626]: Add unit tests. * [1626]: Expand on the comment of the reqAttrBypassAddrs field. * [1626]: Add changelog entry. * [1626]: Add some unit tests dealing with marker/quarantine restriction interaction. * [1626]: Add an empty expected send error to highlight that the test expects the send to pass, but accept to fail. * [1626]: Add some spec docs about transfers. * [1626]: Copy the reqAttrBypassAddrs slice in NewKeeper so that nothing can change the list from outside the keeper. * [1626]: Fix the distribution module entry comment. * [1626]: nil-in-nil-out the deepCopyAccAddresses function. * [1626]: Prevent forced transfers from module accounts and smart contracts. * [1626]: add changelog entry about the module accounts thing. * [1626]: Yay misspell. Pro tip, it's not transfered. * [1626]: make update-tocs. * [1626]: Fix denomloop background color. * [1626]: Clarify some documentation. * [1626]: Updates to the spec docs from feedback. * [1626]: Create an ImmutableAccAddresses type and use that for reqAttrBypassAddrs for even more immutability protection. * [1626]: In the MsgTransferRequest workflow diagram, clarify that the blocked address check is related to the bank module. --- CHANGELOG.md | 2 + app/app.go | 13 +- x/marker/keeper/export_test.go | 5 + x/marker/keeper/keeper.go | 19 ++ x/marker/keeper/keeper_test.go | 281 ++++++++++++++++-- x/marker/keeper/marker.go | 25 +- x/marker/keeper/proposal_handler_test.go | 2 +- x/marker/keeper/send_restrictions.go | 24 +- x/marker/keeper/send_restrictions_test.go | 296 +++++++++++++++++++ x/marker/simulation/proposals_test.go | 1 + x/marker/spec/03_messages.md | 1 + x/marker/spec/12_transfers.md | 316 +++++++++++++++++++++ x/marker/spec/README.md | 3 +- x/marker/types/immutable_addresses.go | 48 ++++ x/marker/types/immutable_addresses_test.go | 183 ++++++++++++ 15 files changed, 1192 insertions(+), 27 deletions(-) create mode 100644 x/marker/spec/12_transfers.md create mode 100644 x/marker/types/immutable_addresses.go create mode 100644 x/marker/types/immutable_addresses_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 4259dc6397..55530ab805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Fix ibcnet relayer creating multiple connections on restart [#1620](https://github.com/provenance-io/provenance/issues/1620). * Fix for incorrect resource-id type casting on contract specification [#1647](https://github.com/provenance-io/provenance/issues/1647). +* Allow restricted coins to be quarantined [#1626](https://github.com/provenance-io/provenance/issues/1626). +* Prevent marker forced transfers from module accounts [#1626](https://github.com/provenance-io/provenance/issues/1626). ### Client Breaking diff --git a/app/app.go b/app/app.go index b12b7c85e4..65727fc9c8 100644 --- a/app/app.go +++ b/app/app.go @@ -496,8 +496,19 @@ func New( appCodec, keys[metadatatypes.StoreKey], app.GetSubspace(metadatatypes.ModuleName), app.AccountKeeper, app.AuthzKeeper, app.AttributeKeeper, ) + markerReqAttrBypassAddrs := []sdk.AccAddress{ + authtypes.NewModuleAddress(authtypes.FeeCollectorName), // Allow collecting fees in restricted coins. + authtypes.NewModuleAddress(rewardtypes.ModuleName), // Allow rewards to hold onto restricted coins. + authtypes.NewModuleAddress(quarantine.ModuleName), // Allow quarantine to hold onto restricted coins. + authtypes.NewModuleAddress(govtypes.ModuleName), // Allow restricted coins in deposits. + authtypes.NewModuleAddress(distrtypes.ModuleName), // Allow fee denoms to be restricted coins. + authtypes.NewModuleAddress(stakingtypes.BondedPoolName), // Allow bond denom to be a restricted coin. + authtypes.NewModuleAddress(stakingtypes.NotBondedPoolName), // Allow bond denom to be a restricted coin. + } app.MarkerKeeper = markerkeeper.NewKeeper( - appCodec, keys[markertypes.StoreKey], app.GetSubspace(markertypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.AuthzKeeper, app.FeeGrantKeeper, app.AttributeKeeper, app.NameKeeper, app.TransferKeeper, + appCodec, keys[markertypes.StoreKey], app.GetSubspace(markertypes.ModuleName), + app.AccountKeeper, app.BankKeeper, app.AuthzKeeper, app.FeeGrantKeeper, + app.AttributeKeeper, app.NameKeeper, app.TransferKeeper, markerReqAttrBypassAddrs, ) pioMessageRouter := MessageRouterFunc(func(msg sdk.Msg) baseapp.MsgServiceHandler { diff --git a/x/marker/keeper/export_test.go b/x/marker/keeper/export_test.go index b27ba88de9..712d1af8da 100644 --- a/x/marker/keeper/export_test.go +++ b/x/marker/keeper/export_test.go @@ -14,3 +14,8 @@ func (k Keeper) GetMarkerModuleAddr() sdk.AccAddress { func (k Keeper) GetIbcTransferModuleAddr() sdk.AccAddress { return k.ibcTransferModuleAddr } + +// CanForceTransferFrom is a TEST ONLY exposure of the canForceTransferFrom value. +func (k Keeper) CanForceTransferFrom(ctx sdk.Context, from sdk.AccAddress) bool { + return k.canForceTransferFrom(ctx, from) +} diff --git a/x/marker/keeper/keeper.go b/x/marker/keeper/keeper.go index e9946ed428..c6e744f3a0 100644 --- a/x/marker/keeper/keeper.go +++ b/x/marker/keeper/keeper.go @@ -77,6 +77,13 @@ type Keeper struct { // Used to transfer the ibc marker ibcTransferServer types.IbcTransferMsgServer + + // reqAttrBypassAddrs is a set of addresses that are allowed to bypass the required attribute check. + // When sending to one of these, if there are required attributes, it behaves as if the addr has them; + // if there aren't required attributes, the sender still needs transfer permission. + // When sending from one of these, if there are required attributes, the destination must have them; + // if there aren't required attributes, it behaves as if the sender has transfer permission. + reqAttrBypassAddrs types.ImmutableAccAddresses } // NewKeeper returns a marker keeper. It handles: @@ -95,6 +102,7 @@ func NewKeeper( attrKeeper types.AttrKeeper, nameKeeper types.NameKeeper, ibcTransferServer types.IbcTransferMsgServer, + reqAttrBypassAddrs []sdk.AccAddress, ) Keeper { if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) @@ -114,6 +122,7 @@ func NewKeeper( markerModuleAddr: authtypes.NewModuleAddress(types.CoinPoolName), ibcTransferModuleAddr: authtypes.NewModuleAddress(ibctypes.ModuleName), ibcTransferServer: ibcTransferServer, + reqAttrBypassAddrs: types.NewImmutableAccAddresses(reqAttrBypassAddrs), } bankKeeper.AppendSendRestriction(rv.SendRestrictionFn) return rv @@ -207,3 +216,13 @@ func (k Keeper) RemoveSendDeny(ctx sdk.Context, markerAddr, senderAddr sdk.AccAd store := ctx.KVStore(k.storeKey) store.Delete(types.DenySendKey(markerAddr, senderAddr)) } + +// GetReqAttrBypassAddrs returns a deep copy of the addresses that bypass the required attributes checking. +func (k Keeper) GetReqAttrBypassAddrs() []sdk.AccAddress { + return k.reqAttrBypassAddrs.GetSlice() +} + +// IsReqAttrBypassAddr returns true if the provided addr can bypass the required attributes checking. +func (k Keeper) IsReqAttrBypassAddr(addr sdk.AccAddress) bool { + return k.reqAttrBypassAddrs.Has(addr) +} diff --git a/x/marker/keeper/keeper_test.go b/x/marker/keeper/keeper_test.go index 1833fa24c4..84bafa6bce 100644 --- a/x/marker/keeper/keeper_test.go +++ b/x/marker/keeper/keeper_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "context" "fmt" "testing" "time" @@ -13,8 +14,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/feegrant" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/cosmos/cosmos-sdk/x/quarantine" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -22,6 +28,7 @@ import ( simapp "github.com/provenance-io/provenance/app" markerkeeper "github.com/provenance-io/provenance/x/marker/keeper" "github.com/provenance-io/provenance/x/marker/types" + rewardtypes "github.com/provenance-io/provenance/x/reward/types" ) func TestAccountMapperGetSet(t *testing.T) { @@ -514,8 +521,17 @@ func TestAccountInsufficientExisting(t *testing.T) { func TestAccountImplictControl(t *testing.T) { app := simapp.Setup(t) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + setAcc := func(addr sdk.AccAddress, sequence uint64) { + acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) + require.NoError(t, acc.SetSequence(sequence), "%s.SetSequence(%d)", string(addr), sequence) + app.AccountKeeper.SetAccount(ctx, acc) + } + user := testUserAddress("test") user2 := testUserAddress("test2") + setAcc(user, 1) + setAcc(user2, 1) // create account and check default values mac := types.NewEmptyMarkerAccount("testcoin", user.String(), []types.AccessGrant{*types.NewAccessGrant(user, @@ -581,14 +597,24 @@ func TestAccountImplictControl(t *testing.T) { require.Error(t, app.MarkerKeeper.TransferCoin(ctx, granter, user2, grantee, sdk.NewCoin("testcoin", sdk.NewInt(5)))) // succeeds when admin user (grantee with authz permissions) has transfer authority with receiver is on allowed list require.NoError(t, app.MarkerKeeper.TransferCoin(ctx, granter, user, grantee, sdk.NewCoin("testcoin", sdk.NewInt(5)))) - } func TestForceTransfer(t *testing.T) { app := simapp.Setup(t) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + setAcc := func(addr sdk.AccAddress, sequence uint64) { + acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) + require.NoError(t, acc.SetSequence(sequence), "%s.SetSequence(%d)", string(addr), sequence) + app.AccountKeeper.SetAccount(ctx, acc) + } + admin := sdk.AccAddress("admin_account_______") other := sdk.AccAddress("other_account_______") + seq0 := sdk.AccAddress("sequence_0__________") + setAcc(admin, 1) + setAcc(other, 1) + setAcc(seq0, 0) // Shorten up the lines making Coins. cz := func(coins ...sdk.Coin) sdk.Coins { @@ -644,39 +670,99 @@ func TestForceTransfer(t *testing.T) { require.NoError(t, app.MarkerKeeper.AddFinalizeAndActivateMarker(ctx, wForceMac), "AddFinalizeAndActivateMarker with force transfer") - requireBalances := func(tt *testing.T, desc string, noForceBal, wForceBal, adminBal, otherBal sdk.Coins) { + noForceBal := cz(noForceMac.GetSupply()) + wForceBal := cz(wForceMac.GetSupply()) + var adminBal, otherBal, seq0Bal sdk.Coins + requireBalances := func(tt *testing.T, desc string) { tt.Helper() - ok := assert.Equal(tt, noForceBal, app.BankKeeper.GetAllBalances(ctx, noForceAddr), - "%s no-force-transfer marker balance", desc) - ok = assert.Equal(tt, wForceBal, app.BankKeeper.GetAllBalances(ctx, wForceAddr), - "%s with-force-transfer marker balance", desc) && ok - ok = assert.Equal(tt, adminBal, app.BankKeeper.GetAllBalances(ctx, admin), - "%s admin balance", desc) && ok - ok = assert.Equal(tt, otherBal, app.BankKeeper.GetAllBalances(ctx, other), - "%s other balance", desc) && ok + ok := assert.Equal(tt, noForceBal.String(), app.BankKeeper.GetAllBalances(ctx, noForceAddr).String(), + "%s: no-force-transfer marker balance", desc) + ok = assert.Equal(tt, wForceBal.String(), app.BankKeeper.GetAllBalances(ctx, wForceAddr).String(), + "%s: with-force-transfer marker balance", desc) && ok + ok = assert.Equal(tt, adminBal.String(), app.BankKeeper.GetAllBalances(ctx, admin).String(), + "%s: admin balance", desc) && ok + ok = assert.Equal(tt, otherBal.String(), app.BankKeeper.GetAllBalances(ctx, other).String(), + "%s: other balance", desc) && ok + ok = assert.Equal(tt, seq0Bal.String(), app.BankKeeper.GetAllBalances(ctx, seq0).String(), + "%s: sequence 0 balance", desc) && ok if !ok { tt.FailNow() } } - requireBalances(t, "starting", cz(noForceCoin(1111)), cz(wForceCoin(2222)), cz(), cz()) + requireBalances(t, "starting") // Have the admin withdraw funds of each to the other account. - require.NoError(t, app.MarkerKeeper.WithdrawCoins(ctx, admin, other, noForceDenom, cz(noForceCoin(111))), + toWithdraw := cz(noForceCoin(111)) + otherBal = otherBal.Add(toWithdraw...) + noForceBal = noForceBal.Sub(toWithdraw...) + require.NoError(t, app.MarkerKeeper.WithdrawCoins(ctx, admin, other, noForceDenom, toWithdraw), "withdraw 500noforceback to other") - require.NoError(t, app.MarkerKeeper.WithdrawCoins(ctx, admin, other, wForceDenom, cz(wForceCoin(222))), + toWithdraw = cz(wForceCoin(222)) + otherBal = otherBal.Add(toWithdraw...) + wForceBal = wForceBal.Sub(toWithdraw...) + require.NoError(t, app.MarkerKeeper.WithdrawCoins(ctx, admin, other, wForceDenom, toWithdraw), "withdraw 500wforceback to other") - requireBalances(t, "after withdraws", cz(noForceCoin(1000)), cz(wForceCoin(2000)), cz(), cz(noForceCoin(111), wForceCoin(222))) + requireBalances(t, "after withdraws") // Have the admin try a transfer of the no-force-transfer from that other account to itself. It should fail. assert.EqualError(t, app.MarkerKeeper.TransferCoin(ctx, other, admin, admin, noForceCoin(11)), fmt.Sprintf("%s account has not been granted authority to withdraw from %s account", admin, other), "transfer of non-force-transfer coin from other account back to admin") - requireBalances(t, "after failed transfer", cz(noForceCoin(1000)), cz(wForceCoin(2000)), cz(), cz(noForceCoin(111), wForceCoin(222))) + requireBalances(t, "after failed transfer") // Have the admin try a transfer of the w/force transfer from that other account to itself. It should go through. - assert.NoError(t, app.MarkerKeeper.TransferCoin(ctx, other, admin, admin, wForceCoin(22)), + transferCoin := wForceCoin(22) + assert.NoError(t, app.MarkerKeeper.TransferCoin(ctx, other, admin, admin, transferCoin), "transfer of force-transferrable coin from other account back to admin") - requireBalances(t, "after successful transfer", cz(noForceCoin(1000)), cz(wForceCoin(2000)), cz(wForceCoin(22)), cz(noForceCoin(111), wForceCoin(200))) + otherBal = otherBal.Sub(transferCoin) + adminBal = adminBal.Add(transferCoin) + requireBalances(t, "after successful transfer") + + // Fund the sequence 0 account and have the admin try a transfer of the w/force transfer from there to itself. This should fail. + seq0Bal = cz(wForceCoin(5)) + wForceBal = wForceBal.Sub(seq0Bal...) + require.NoError(t, app.MarkerKeeper.WithdrawCoins(ctx, admin, seq0, wForceDenom, seq0Bal), + "withdraw 500wforceback to other") + requireBalances(t, "funds withdrawn to sequence 0 address") + assert.EqualError(t, app.MarkerKeeper.TransferCoin(ctx, seq0, admin, admin, wForceCoin(2)), + fmt.Sprintf("funds are not allowed to be removed from %s", seq0), + "transfer of force-transfer coin from account with sequence 0 back to admin", + ) + requireBalances(t, "after failed force transfer") +} + +func TestCanForceTransferFrom(t *testing.T) { + app := simapp.Setup(t) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + setAcc := func(addr sdk.AccAddress, sequence uint64) { + acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) + require.NoError(t, acc.SetSequence(sequence), "%s.SetSequence(%d)", string(addr), sequence) + app.AccountKeeper.SetAccount(ctx, acc) + } + + addrNoAcc := sdk.AccAddress("addrNoAcc___________") + addrSeq0 := sdk.AccAddress("addrSeq0____________") + addrSeq1 := sdk.AccAddress("addrSeq1____________") + setAcc(addrSeq0, 0) + setAcc(addrSeq1, 1) + + tests := []struct { + name string + from sdk.AccAddress + exp bool + }{ + {name: "address without an account", from: addrNoAcc, exp: true}, + {name: "address with sequence 0", from: addrSeq0, exp: false}, + {name: "address with sequence 1", from: addrSeq1, exp: true}, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + actual := app.MarkerKeeper.CanForceTransferFrom(ctx, tc.from) + assert.Equal(t, tc.exp, actual, "canForceTransferFrom") + }) + } } func TestMarkerFeeGrant(t *testing.T) { @@ -1488,3 +1574,164 @@ func TestUpdateSendDenyList(t *testing.T) { }) } } + +func TestReqAttrBypassAddrs(t *testing.T) { + // Tests both GetReqAttrBypassAddrs and IsReqAttrBypassAddr. + expectedNames := []string{ + authtypes.FeeCollectorName, + rewardtypes.ModuleName, + quarantine.ModuleName, + govtypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.BondedPoolName, + stakingtypes.NotBondedPoolName, + } + + incByte := func(b byte) byte { + if b == 0xFF { + return 0x00 + } + return b + 1 + } + + app := simapp.Setup(t) + + for _, name := range expectedNames { + t.Run(fmt.Sprintf("get: contains %s", name), func(t *testing.T) { + expAddr := authtypes.NewModuleAddress(name) + actual := app.MarkerKeeper.GetReqAttrBypassAddrs() + assert.Contains(t, actual, expAddr, "GetReqAttrBypassAddrs()") + }) + } + t.Run("get: only has expected entries", func(t *testing.T) { + // This assumes each expectedNames test passed. This is designed to fail if a new entry + // is added to the list (in app.go). When that happens, update the expectedNames with + // the new entry so it's harder for it to accidentally go missing. + actual := app.MarkerKeeper.GetReqAttrBypassAddrs() + assert.Len(t, actual, len(expectedNames), "GetReqAttrBypassAddrs()") + }) + + t.Run("get: called twice equal but not same", func(t *testing.T) { + expected := app.MarkerKeeper.GetReqAttrBypassAddrs() + actual := app.MarkerKeeper.GetReqAttrBypassAddrs() + if assert.Equal(t, expected, actual, "GetReqAttrBypassAddrs()") { + if assert.NotSame(t, expected, actual, "GetReqAttrBypassAddrs()") { + for i := range expected { + assert.NotSame(t, expected[i], actual[i], "GetReqAttrBypassAddrs()[%d]", i) + } + } + } + }) + + t.Run("get: changes to result not reflected in next result", func(t *testing.T) { + actual1 := app.MarkerKeeper.GetReqAttrBypassAddrs() + origActual100 := actual1[0][0] + actual1[0][0] = incByte(origActual100) + actual2 := app.MarkerKeeper.GetReqAttrBypassAddrs() + actual200 := actual2[0][0] + assert.Equal(t, origActual100, actual200, "first byte of first address after changing it in an earlier result") + }) + + for _, name := range expectedNames { + t.Run(fmt.Sprintf("is: %s", name), func(t *testing.T) { + addr := authtypes.NewModuleAddress(name) + actual := app.MarkerKeeper.IsReqAttrBypassAddr(addr) + assert.True(t, actual, "IsReqAttrBypassAddr(NewModuleAddress(%q))", name) + }) + } + + almostName0 := authtypes.NewModuleAddress(expectedNames[0]) + almostName0[0] = incByte(almostName0[0]) + + negativeIsTests := []struct { + name string + addr sdk.AccAddress + }{ + {name: "nil address", addr: nil}, + {name: "empty address", addr: sdk.AccAddress{}}, + {name: "zerod address", addr: make(sdk.AccAddress, 20)}, + {name: "almost " + expectedNames[0], addr: almostName0}, + {name: "short " + expectedNames[0], addr: authtypes.NewModuleAddress(expectedNames[0])[:19]}, + {name: "long " + expectedNames[0], addr: append(authtypes.NewModuleAddress(expectedNames[0]), 0x00)}, + } + + for _, tc := range negativeIsTests { + t.Run(tc.name, func(t *testing.T) { + actual := app.MarkerKeeper.IsReqAttrBypassAddr(tc.addr) + assert.False(t, actual, "IsReqAttrBypassAddr(...)") + }) + } +} + +// dummyBankKeeper satisfies the types.BankKeeper interface but does nothing. +type dummyBankKeeper struct{} + +var _ types.BankKeeper = (*dummyBankKeeper)(nil) + +func (d dummyBankKeeper) GetAllBalances(_ sdk.Context, _ sdk.AccAddress) sdk.Coins { return nil } + +func (d dummyBankKeeper) GetBalance(_ sdk.Context, _ sdk.AccAddress, denom string) sdk.Coin { + return sdk.Coin{} +} + +func (d dummyBankKeeper) GetSupply(_ sdk.Context, _ string) sdk.Coin { return sdk.Coin{} } + +func (d dummyBankKeeper) DenomOwners(_ context.Context, _ *banktypes.QueryDenomOwnersRequest) (*banktypes.QueryDenomOwnersResponse, error) { + return nil, nil +} + +func (d dummyBankKeeper) SendCoins(_ sdk.Context, _, _ sdk.AccAddress, amt sdk.Coins) error { + return nil +} + +func (d dummyBankKeeper) SendCoinsFromModuleToAccount(_ sdk.Context, _ string, _ sdk.AccAddress, _ sdk.Coins) error { + return nil +} + +func (d dummyBankKeeper) SendCoinsFromAccountToModule(_ sdk.Context, _ sdk.AccAddress, _ string, _ sdk.Coins) error { + return nil +} + +func (d dummyBankKeeper) MintCoins(_ sdk.Context, _ string, _ sdk.Coins) error { return nil } + +func (d dummyBankKeeper) BurnCoins(_ sdk.Context, _ string, _ sdk.Coins) error { return nil } + +func (d dummyBankKeeper) AppendSendRestriction(_ banktypes.SendRestrictionFn) {} + +func (d dummyBankKeeper) BlockedAddr(_ sdk.AccAddress) bool { return false } + +func (d dummyBankKeeper) GetDenomMetaData(_ sdk.Context, _ string) (banktypes.Metadata, bool) { + return banktypes.Metadata{}, false +} + +func (d dummyBankKeeper) SetDenomMetaData(_ sdk.Context, _ banktypes.Metadata) {} + +func (d dummyBankKeeper) IterateAllBalances(_ sdk.Context, _ func(sdk.AccAddress, sdk.Coin) bool) {} + +func (d dummyBankKeeper) GetAllSendEnabledEntries(_ sdk.Context) []banktypes.SendEnabled { return nil } + +func (d dummyBankKeeper) DeleteSendEnabled(_ sdk.Context, _ string) {} + +func TestBypassAddrsLocked(t *testing.T) { + // This test makes sure that the keeper's copy of reqAttrBypassAddrs + // isn't changed if the originally provided value is changed. + + addrs := []sdk.AccAddress{ + sdk.AccAddress("addrs[0]____________"), + sdk.AccAddress("addrs[1]____________"), + sdk.AccAddress("addrs[2]____________"), + sdk.AccAddress("addrs[3]____________"), + sdk.AccAddress("addrs[4]____________"), + } + + mk := markerkeeper.NewKeeper(nil, nil, paramtypes.NewSubspace(nil, nil, nil, nil, "test"), nil, &dummyBankKeeper{}, nil, nil, nil, nil, nil, addrs) + + // Now that the keeper has been created using the provided addresses, change the first byte of + // the first address to something else. Then, get the addresses back from the keeper and make + // sure that change didn't affect what's in the keeper. + orig00 := addrs[0][0] + addrs[0][0] = 'b' + kAddrs := mk.GetReqAttrBypassAddrs() + act00 := kAddrs[0][0] + assert.Equal(t, orig00, act00, "first byte of first address returned by GetReqAttrBypassAddrs") +} diff --git a/x/marker/keeper/marker.go b/x/marker/keeper/marker.go index 6f2a8c62a1..014b008a05 100644 --- a/x/marker/keeper/marker.go +++ b/x/marker/keeper/marker.go @@ -634,10 +634,15 @@ func (k Keeper) TransferCoin(ctx sdk.Context, from, to, admin sdk.AccAddress, am if !m.AddressHasAccess(admin, types.Access_Transfer) { return fmt.Errorf("%s is not allowed to broker transfers", admin.String()) } - if !admin.Equals(from) && !m.AllowsForcedTransfer() { - err = k.authzHandler(ctx, admin, from, to, amount) - if err != nil { - return err + if !admin.Equals(from) { + switch { + case !m.AllowsForcedTransfer(): + err = k.authzHandler(ctx, admin, from, to, amount) + if err != nil { + return err + } + case !k.canForceTransferFrom(ctx, from): + return fmt.Errorf("funds are not allowed to be removed from %s", from) } } if k.bankKeeper.BlockedAddr(to) { @@ -660,6 +665,18 @@ func (k Keeper) TransferCoin(ctx sdk.Context, from, to, admin sdk.AccAddress, am return ctx.EventManager().EmitTypedEvent(markerTransferEvent) } +// canForceTransferFrom returns true if funds can be forcefully transferred out of the provided address. +func (k Keeper) canForceTransferFrom(ctx sdk.Context, from sdk.AccAddress) bool { + acc := k.authKeeper.GetAccount(ctx, from) + // If acc is nil, there's no funds in it, so the transfer will fail anyway. + // In that case, return true from here so it can fail later with a more accurate message. + // If there is an account, only allow force transfers if the sequence number isn't zero. + // This is to prevent forced transfer from module accounts and smart contracts. + // It will also block forced transfers from new or dead accounts, though. + // If the forced transfer is absolutely required, use a governance proposal with a MsgSend. + return acc == nil || acc.GetSequence() != 0 +} + // IbcTransferCoin transfers restricted coins between two chains when the administrator account holds the transfer // access right and the marker type is restricted_coin func (k Keeper) IbcTransferCoin( diff --git a/x/marker/keeper/proposal_handler_test.go b/x/marker/keeper/proposal_handler_test.go index 8967c4233c..a6a62a4869 100644 --- a/x/marker/keeper/proposal_handler_test.go +++ b/x/marker/keeper/proposal_handler_test.go @@ -34,7 +34,7 @@ type IntegrationTestSuite struct { func (s *IntegrationTestSuite) SetupSuite() { s.app = provenance.Setup(s.T()) s.ctx = s.app.BaseApp.NewContext(false, tmproto.Header{}) - s.k = markerkeeper.NewKeeper(s.app.AppCodec(), s.app.GetKey(markertypes.ModuleName), s.app.GetSubspace(markertypes.ModuleName), s.app.AccountKeeper, s.app.BankKeeper, s.app.AuthzKeeper, s.app.FeeGrantKeeper, s.app.AttributeKeeper, s.app.NameKeeper, s.app.TransferKeeper) + s.k = markerkeeper.NewKeeper(s.app.AppCodec(), s.app.GetKey(markertypes.ModuleName), s.app.GetSubspace(markertypes.ModuleName), s.app.AccountKeeper, s.app.BankKeeper, s.app.AuthzKeeper, s.app.FeeGrantKeeper, s.app.AttributeKeeper, s.app.NameKeeper, s.app.TransferKeeper, nil) s.accountAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) } diff --git a/x/marker/keeper/send_restrictions.go b/x/marker/keeper/send_restrictions.go index bd7e06a54e..8ef4bd3c45 100644 --- a/x/marker/keeper/send_restrictions.go +++ b/x/marker/keeper/send_restrictions.go @@ -69,13 +69,31 @@ func (k Keeper) validateSendDenom(ctx sdk.Context, fromAddr, toAddr sdk.AccAddre reqAttr := marker.GetRequiredAttributes() - // If there aren't any required attributes, or it's going to marker, then + // If going to a marker, transfer permission is required regardless of whether it's coming from a bypass. + // If someone wants to deposit funds from a bypass account, they can either send the funds to a valid + // intermediary account and deposit them from there, or give the bypass account deposit and transfer permissions. + // It's assumed that a marker address cannot be in the bypass list. + if toMarker != nil { + return fmt.Errorf("%s does not have transfer permissions", fromAddr.String()) + } - // transfers are only allowed by those with transfer permission. - if len(reqAttr) == 0 || toMarker != nil { + // If there aren't any required attributes, transfer permission is required unless coming from a bypass account. + // It's assumed that the only way the restricted coins without required attributes can got into a bypass + // account is by someone with transfer permission, which is then conveyed for this transfer too. + if len(reqAttr) == 0 { + if k.IsReqAttrBypassAddr(fromAddr) { + return nil + } return fmt.Errorf("%s does not have transfer permissions", fromAddr.String()) } + // At this point, we know there are required attributes and that fromAddr does not have transfer permission. + // If the toAddress has a bypass, skip checking the attributes and allow the transfer. + // When these funds are then being moved out of the bypass account, attributes are checked on that destination. + if k.IsReqAttrBypassAddr(toAddr) { + return nil + } + attributes, err := k.attrKeeper.GetAllAttributesAddr(ctx, toAddr) if err != nil { return fmt.Errorf("could not get attributes for %s: %w", toAddr.String(), err) diff --git a/x/marker/keeper/send_restrictions_test.go b/x/marker/keeper/send_restrictions_test.go index 719c95157e..718d97a399 100644 --- a/x/marker/keeper/send_restrictions_test.go +++ b/x/marker/keeper/send_restrictions_test.go @@ -61,6 +61,11 @@ func TestSendRestrictionFn(t *testing.T) { addrWithDeposit := sdk.AccAddress("addrWithDeposit_____") addrWithTranDep := sdk.AccAddress("addrWithTranDep_____") addrWithDenySend := sdk.AccAddress("addrWithDenySend_____") + addrOther := sdk.AccAddress("addrOther___________") + + bypassAddrs := app.MarkerKeeper.GetReqAttrBypassAddrs() + addrWithBypass := bypassAddrs[0] + addrWithBypassNoDep := bypassAddrs[1] coin := types.MarkerType_Coin restricted := types.MarkerType_RestrictedCoin @@ -75,6 +80,8 @@ func TestSendRestrictionFn(t *testing.T) { {Address: addrWithTransfer.String(), Permissions: types.AccessList{types.Access_Transfer}}, {Address: addrWithDeposit.String(), Permissions: types.AccessList{types.Access_Deposit}}, {Address: addrWithTranDep.String(), Permissions: types.AccessList{types.Access_Deposit, types.Access_Transfer}}, + // It's silly to give any permissions to a bypass address, but I do so in here to hit some test cases. + {Address: addrWithBypass.String(), Permissions: types.AccessList{types.Access_Deposit}}, } } rv := types.NewMarkerAccount( @@ -308,6 +315,85 @@ func TestSendRestrictionFn(t *testing.T) { amt: cz(c(1, nrDenom)), expErr: "", }, + { + name: "to a marker from addr with bypass but no deposit", + from: addrWithBypassNoDep, + to: rMarkerNoAttr.GetAddress(), + amt: cz(c(1, rDenomNoAttr)), + expErr: fmt.Sprintf("%s does not have deposit access for %s (%s)", + addrWithBypassNoDep, rMarkerNoAttr.GetAddress().String(), rDenomNoAttr), + }, + { + name: "to a marker with req attrs from an addr with bypass", + from: addrWithBypass, + to: rMarker1Attr.GetAddress(), + amt: cz(c(1, rDenom1Attr)), + expErr: addrWithBypass.String() + " does not have transfer permissions", + }, + { + name: "to marker without req attrs from addr with bypass", + from: addrWithBypass, + to: rMarkerNoAttr.GetAddress(), + amt: cz(c(1, rDenomNoAttr)), + expErr: addrWithBypass.String() + " does not have transfer permissions", + }, + { + name: "no req attrs from addr with bypass", + from: addrWithBypass, + to: addrOther, + amt: cz(c(3, rDenomNoAttr)), + expErr: "", + }, + { + name: "with req attrs from addr with bypass", + from: addrWithBypass, + to: addrOther, + amt: cz(c(1, rDenom1AttrNoOneHas)), + expErr: fmt.Sprintf("address %s does not contain the %q required attribute: \"some.attribute.that.i.require\"", + addrOther, rDenom1AttrNoOneHas), + }, + { + name: "no req attrs to addr with bypass from without transfer", + from: addrOther, + to: addrWithBypass, + amt: cz(c(1, rDenomNoAttr)), + expErr: addrOther.String() + " does not have transfer permissions", + }, + { + name: "no req attrs to addr with bypass from with transfer", + from: addrWithTransfer, + to: addrWithBypass, + amt: cz(c(1, rDenomNoAttr)), + expErr: "", + }, + { + name: "with req attrs to addr with bypass from without transfer", + from: addrOther, + to: addrWithBypass, + amt: cz(c(1, rDenom1AttrNoOneHas)), + expErr: "", + }, + { + name: "with req attrs to addr with bypass from with transfer", + from: addrWithTransfer, + to: addrWithBypass, + amt: cz(c(1, rDenom1AttrNoOneHas)), + expErr: "", + }, + { + name: "with req attrs between bypass addrs", + from: addrWithBypass, + to: addrWithBypassNoDep, + amt: cz(c(1, rDenom1AttrNoOneHas)), + expErr: "", + }, + { + name: "without req attrs between bypass addrs", + from: addrWithBypass, + to: addrWithBypassNoDep, + amt: cz(c(1, rDenomNoAttr)), + expErr: "", + }, } for _, tc := range testCases { @@ -712,3 +798,213 @@ func TestMatchAttribute(t *testing.T) { }) } } + +func TestQuarantineOfRestrictedCoins(t *testing.T) { + // Directly tests the bug described in https://github.com/provenance-io/provenance/issues/1626 + + app := simapp.Setup(t) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + owner := sdk.AccAddress("owner_address_______") + app.AccountKeeper.SetAccount(ctx, app.AccountKeeper.NewAccountWithAddress(ctx, owner)) + reqAttr := "quarantinetest.provenance.io" + require.NoError(t, app.NameKeeper.SetNameRecord(ctx, reqAttr, owner, false), "SetNameRecord(%q)", reqAttr) + + // Two source addresses, one with transfer on both markers, one without on either. + addrWithTransfer := sdk.AccAddress("addrWithTransfer____") + addrWithWithdraw := sdk.AccAddress("addrWithWithdraw____") + addrWithoutTransfer := sdk.AccAddress("addrWithoutTransfer_") + + newMarker := func(denom string, reqAttrs []string) *types.MarkerAccount { + rv := types.NewMarkerAccount( + app.AccountKeeper.NewAccountWithAddress(ctx, types.MustGetMarkerAddress(denom)).(*authtypes.BaseAccount), + sdk.NewInt64Coin(denom, 1000), + owner, + []types.AccessGrant{ + {Address: addrWithTransfer.String(), Permissions: types.AccessList{types.Access_Transfer}}, + {Address: addrWithWithdraw.String(), Permissions: types.AccessList{types.Access_Withdraw}}, + }, + types.StatusProposed, + types.MarkerType_RestrictedCoin, + true, // supply fixed + true, // allow gov + false, // no force transfer + reqAttrs, + ) + err := app.MarkerKeeper.AddFinalizeAndActivateMarker(ctx, rv) + require.NoError(t, err, "AddFinalizeAndActivateMarker(%s)", denom) + return rv + } + + // Two markers, one with a required attribute, one without any. + denomNoReqAttr := "denomNoReqAttr" + denom1ReqAttr := "denom1ReqAttr" + + coinsNoReqAttr := sdk.NewCoins(sdk.NewInt64Coin(denomNoReqAttr, 3)) + coins1ReqAttr := sdk.NewCoins(sdk.NewInt64Coin(denom1ReqAttr, 2)) + + newMarker(denomNoReqAttr, nil) + newMarker(denom1ReqAttr, []string{reqAttr}) + + mustWithdraw := func(recipient sdk.AccAddress, denom string) { + coins := sdk.NewCoins(sdk.NewInt64Coin(denom, 100)) + err := app.MarkerKeeper.WithdrawCoins(ctx, addrWithWithdraw, recipient, denom, coins) + require.NoError(t, err, "WithdrawCoins(%q, %q)", string(recipient), coins) + } + mustWithdraw(addrWithTransfer, denomNoReqAttr) + mustWithdraw(addrWithTransfer, denom1ReqAttr) + mustWithdraw(addrWithoutTransfer, denomNoReqAttr) + mustWithdraw(addrWithoutTransfer, denom1ReqAttr) + + // Create two quarantined address: one with the required attributes, one without. + optIn := func(t *testing.T, addr sdk.AccAddress) { + require.NoError(t, app.QuarantineKeeper.SetOptIn(ctx, addr), "SetOptIn(%q)", string(addr)) + } + addrQWithAttr := sdk.AccAddress("addrQWithReqAttrs____") + addrQWithoutAttr := sdk.AccAddress("addrQWithoutReqAttrs____") + optIn(t, addrQWithAttr) + optIn(t, addrQWithoutAttr) + + attrVal := []byte("string value") + setAttr := func(t *testing.T, addr sdk.AccAddress) { + attr := attrTypes.Attribute{ + Name: reqAttr, + Value: attrVal, + Address: addr.String(), + AttributeType: attrTypes.AttributeType_String, + } + err := app.AttributeKeeper.SetAttribute(ctx, attr, owner) + require.NoError(t, err, "SetAttribute(%q, %q)", string(addr), attr.Name) + } + setAttr(t, addrQWithAttr) + + noTransErr := addrWithoutTransfer.String() + " does not have transfer permissions" + noAttrErr := func(addr sdk.AccAddress) string { + return fmt.Sprintf("address %s does not contain the %q required attribute: %q", addr, denom1ReqAttr, reqAttr) + } + + quarantineModAddr := authtypes.NewModuleAddress("quarantine") + + tests := []struct { + name string + fromAddr sdk.AccAddress + toAddr sdk.AccAddress + amt sdk.Coins + expSendErr string + expAcceptErr string + }{ + { + name: "no req attrs from addr with transfer to quarantined", + fromAddr: addrWithTransfer, + toAddr: addrQWithoutAttr, + amt: coinsNoReqAttr, + }, + { + name: "no req attrs from addr without transfer to quarantined", + fromAddr: addrWithoutTransfer, + toAddr: addrQWithoutAttr, + amt: coinsNoReqAttr, + expSendErr: noTransErr, + }, + { + name: "with req attrs from addr with transfer to quarantined without attrs", + fromAddr: addrWithTransfer, + toAddr: addrQWithoutAttr, + amt: coins1ReqAttr, + expSendErr: "", + expAcceptErr: noAttrErr(addrQWithoutAttr), + }, + { + name: "with req attrs from addr with transfer to quarantined with attrs", + fromAddr: addrWithTransfer, + toAddr: addrQWithAttr, + amt: coins1ReqAttr, + }, + { + name: "with req attrs from addr without transfer to quarantined without attrs", + fromAddr: addrWithoutTransfer, + toAddr: addrQWithoutAttr, + amt: coins1ReqAttr, + expSendErr: noAttrErr(addrQWithoutAttr), + }, + { + name: "with req attrs from addr without transfer to quarantined with attrs", + fromAddr: addrWithoutTransfer, + toAddr: addrQWithAttr, + amt: coins1ReqAttr, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + defer func() { + if t.Failed() { + t.Logf("fromAddr: %s", tc.fromAddr) + t.Logf(" toAddr: %s", tc.toAddr) + t.Logf("quarantine module address: %s", quarantineModAddr) + } + }() + sendErr := app.BankKeeper.SendCoins(ctx, tc.fromAddr, tc.toAddr, tc.amt) + if len(tc.expSendErr) != 0 { + require.EqualError(t, sendErr, tc.expSendErr, "SendCoins") + } else { + require.NoError(t, sendErr, "SendCoins") + } + if sendErr != nil { + return + } + amt, acceptErr := app.QuarantineKeeper.AcceptQuarantinedFunds(ctx, tc.toAddr, tc.fromAddr) + if len(tc.expAcceptErr) != 0 { + require.EqualError(t, acceptErr, tc.expAcceptErr, "AcceptQuarantinedFunds") + } else { + require.NoError(t, acceptErr, "AcceptQuarantinedFunds") + assert.Equal(t, tc.amt.String(), amt.String(), "accepted quarantined funds") + } + }) + } + + t.Run("attr deleted after funds quarantined", func(t *testing.T) { + fromAddr := addrWithoutTransfer + toAddr := sdk.AccAddress("addr_attr_del_______") + amt := coins1ReqAttr + optIn(t, toAddr) + setAttr(t, toAddr) + sendErr := app.BankKeeper.SendCoins(ctx, fromAddr, toAddr, amt) + require.NoError(t, sendErr, "SendCoins") + delErr := app.AttributeKeeper.DeleteAttribute(ctx, toAddr.String(), reqAttr, &attrVal, owner) + require.NoError(t, delErr, "DeleteAttribute") + expAcceptErr := noAttrErr(toAddr) + _, acceptErr := app.QuarantineKeeper.AcceptQuarantinedFunds(ctx, toAddr, fromAddr) + require.EqualError(t, acceptErr, expAcceptErr, "AcceptQuarantinedFunds") + }) + + t.Run("attr added after funds quarantined", func(t *testing.T) { + fromAddr := addrWithTransfer + toAddr := sdk.AccAddress("addr_attr_add_______") + amt := coins1ReqAttr + optIn(t, toAddr) + sendErr := app.BankKeeper.SendCoins(ctx, fromAddr, toAddr, amt) + require.NoError(t, sendErr, "SendCoins") + setAttr(t, toAddr) + acceptedAmt, acceptErr := app.QuarantineKeeper.AcceptQuarantinedFunds(ctx, toAddr, fromAddr) + require.NoError(t, acceptErr, "AcceptQuarantinedFunds error") + assert.Equal(t, amt.String(), acceptedAmt.String(), "AcceptQuarantinedFunds amount") + }) + + t.Run("marker restriction applied before quarantine", func(t *testing.T) { + // This test makes sure that the marker SendRestrictionFn is being applied before the quarantine one. + // If the quarantine one is applied first, then the toAddr in the marker's restriction will be the + // quarantine module, which will have a bypass. + // So we attempt to send from the addr without transfer permission to the address without the required attribute. + // If we get an error about the attribute not being there, we're good. + // If we don't get an error, the toAddr was probably the quarantine module which bypasses that attribute check. + fromAddr := addrWithoutTransfer + toAddr := addrQWithoutAttr + amt := coins1ReqAttr + + err := app.BankKeeper.SendCoins(ctx, fromAddr, toAddr, amt) + require.Error(t, err, "SendCoins error\n"+ + "If this assertion fails, it's probably because the quarantine\n"+ + "SendRestrictionFn is being applied before the marker's") + require.EqualError(t, err, noAttrErr(toAddr)) + }) +} diff --git a/x/marker/simulation/proposals_test.go b/x/marker/simulation/proposals_test.go index 1358f28d76..4b1747786d 100644 --- a/x/marker/simulation/proposals_test.go +++ b/x/marker/simulation/proposals_test.go @@ -42,6 +42,7 @@ func TestProposalContents(t *testing.T) { app.AttributeKeeper, app.NameKeeper, app.TransferKeeper, + nil, ), ) require.Len(t, weightedProposalContent, 6) diff --git a/x/marker/spec/03_messages.md b/x/marker/spec/03_messages.md index 673ac569bd..12128c9834 100644 --- a/x/marker/spec/03_messages.md +++ b/x/marker/spec/03_messages.md @@ -22,6 +22,7 @@ All created/modified state objects specified by each message are defined within - [Msg/GrantAllowanceRequest](#msggrantallowancerequest) - [Msg/SupplyIncreaseProposalRequest](#msgsupplyincreaseproposalrequest) - [Msg/UpdateRequiredAttributesRequest](#msgupdaterequiredattributesrequest) + - [Msg/UpdateSendDenyListRequest](#msgupdatesenddenylistrequest) - [Msg/UpdateForcedTransferRequest](#msgupdateforcedtransferrequest) - [Msg/SetAccountDataRequest](#msgsetaccountdatarequest) diff --git a/x/marker/spec/12_transfers.md b/x/marker/spec/12_transfers.md new file mode 100644 index 0000000000..39ed8c6cfa --- /dev/null +++ b/x/marker/spec/12_transfers.md @@ -0,0 +1,316 @@ +# Transfers + +There are some complex interactions involved with transfers of restricted coins. + + + - [General](#general) + - [Definitions](#definitions) + - [Transfer Permission](#transfer-permission) + - [Forced Transfers](#forced-transfers) + - [Required Attributes](#required-attributes) + - [Individuality](#individuality) + - [Deposits](#deposits) + - [Bypass Accounts](#bypass-accounts) + - [Send Restrictions](#send-restrictions) + - [Flowcharts](#flowcharts) + - [Quarantine Complexities](#quarantine-complexities) + +## General + +Accounting of restricted coins is handled by the bank module. Restricted funds can be moved using the bank module's `MsgSend` or `MsgMutliSend`. They can also be moved using the marker module's `MsgTransferRequest`. + +During such transfers several things are checked using a `SendRestrictionFn` injected into the bank module. This restriction is applied in almost all instances when funds are being moved between accounts. The exceptions are delegations, undelegations, minting, burning, and marker withdrawals. A `MsgTransferRequest` also bypasses the `SendRestrictionFn` in order to include the `admin` account in the logic. + + + +## Definitions + +### Transfer Permission + +One permission that can be granted to an address is `transfer`. The `transfer` permission is granted to accounts that represent a "Transfer Agent" or "Transfer Authority" for restricted marker tokens. An address with `transfer` permission can utilize `MsgTransferRequest` to move restricted funds from one account to another. If the marker allows forced transfer, the source account can be any account, otherwise, it must be the admin's own account. + +`MsgSend` and `MsgMultiSend` can also be used by an address with `transfer` permission to move funds out of their own account. + +### Forced Transfers + +A restricted coin marker can be configured to allow forced transfers. If allowed, an account with `transfer` permission can use a `MsgTransferRequest` to transfer the restricted coins out of almost any account to another. Forced transfer cannot be used to move restricted coins out of module accounts or smart contract accounts, though. + +### Required Attributes + +Required attributes allow a marker Transfer Authority to define a set of account attestations created with the name/attribute modules to certify an account as an approved holder of the token. Accounts that possess all of the required attributes are considered authorized by the Transfer Authority to receive the token from normal bank send operations without a specific Transfer Authority approval. Required attributes are only supported on restricted markers. + +For example, say account A has some restricted coins of a marker that has required attributes. Also say account B has all of those required attributes, and account C does not. Account A could use a `MsgSend` to send those restricted coins to account B. However, account B could not send them to account C (unless B also has `transfer` permission). + +If a restricted coin marker does not have any required attributes defined, the only way the funds can be moved is by someone with `transfer` permisison. + +### Individuality + +If multiple restricted coin denoms are being moved at once, each denom is considered separately. +For example, if the sender has `transfer` permission on one of them, it does not also apply to the other(s). + +### Deposits + +A deposit is when any funds are being sent to a marker's account. The funds being sent do not have to be in the denom of the destination marker. + +Whenever funds are being deposited into a marker, the sender must have `deposit` permission on the target marker. If the funds to deposit are restricted coins, the sender also needs `transfer` permission on the funds being moved; required attributes are not taken into account. + +### Bypass Accounts + +There are several hard-coded module account addresses that are given special consideration in the marker module's `SendRestrictionFn`: + +* `authtypes.FeeCollectorName` - Allows paying fees with restricted coins. +* `reward` - Allows reward programs to use restricted coins. +* `quarantine` - Allows quarantine and acceptance of quarantined coins. +* `gov` - Allows deposits to have quarantined coins. +* `distribution` - Allows collection of delegation rewards in restricted coins. +* `stakingtypes.BondedPoolName` - Allows delegation of restricted coins. +* `stakingtypes.NotBondedPoolName` - Allows delegation of restricted coins. + +All of these are treated equally in the application of a marker's send restrictions. + +For restricted markers without required attributes: +* If the `toAddr` is a bypass account, the `fromAddr` must have transfer authority. +* If the `fromAddr` is a bypass account, it's assumed that the funds got where they currently are because someone with transfer authority got them there, so this transfer is allowed. + +For restricted markers with required attributes: +* If the `toAddr` is a bypass account, the transfer is allowed regardless of whether the `fromAddr` has transfer authority. It's assumed that the next destination's attributes will be properly checked before allowing the funds to leave the bypass account. +* If the `fromAddr` is a bypass account, the `toAddr` must have the required attributes. + +Bypass accounts are not considered during a `MsgTransferRequest`. + +## Send Restrictions + +The marker module injects a `SendRestrictionFn` into the bank module. This function is responsible for deciding whether any given transfer is allowed from the marker module's point of view. However, it is bypassed during a `MsgTransfer`. + +### Flowcharts + +#### The SendRestrictionFn + +This `SendRestrictionFn` uses the following flow. + +```mermaid +%%{ init: { 'flowchart': { 'curve': 'monotoneY'} } }%% +flowchart TD + start[["SendRestrictionFn(Sender, Receiver, Amount)"]] + qhasbp{{"Does context have bypass?"}} + nextd["Get next Denom from Amount."] + vsd[["validateSendDenom(Sender, Receiver, Denom)"]] + isdok{{"Is Denom transfer allowed?"}} + mored{{"Does Amount have another Denom?"}} + ok(["Send allowed."]) + style ok fill:#bbffaa,stroke:#1b8500,stroke-width:3px + denied(["Send denied."]) + style denied fill:#ffaaaa,stroke:#b30000,stroke-width:3px + start --> qhasbp + qhasbp ------>|yes| ok + qhasbp -.->|no| denomloop + subgraph denomloop ["Denom Loop"] + isdok -->|yes| mored + vsd --> isdok + mored -->|yes| nextd + nextd --> vsd + end + mored -.->|no| ok + isdok -.->|no| denied + + style denomloop fill:#bbffff + linkStyle 8 stroke:#b30000,color:#b30000 + linkStyle 1,7 stroke:#1b8500,color:#1b8500 +``` + +#### validateSendDenom + +Each `Denom` is checked using `validateSendDenom`, which has this flow: + +```mermaid +%%{ init: { 'flowchart': { 'curve': 'monotoneY'} } }%% +flowchart TD + start[["validateSendDenom(Sender, Receiver, Denom)"]] + qisrdep{{"Is Receiver a restricted coin marker account?"}} + qhasdep{{"Does Sender have Deposit\non Receiver marker?"}} + qisrc{{"Is Denom a restricted coin?"}} + qisdeny{{"Is Sender on marker's deny list?"}} + qhastrans{{"Does Sender have\ntransfer for Denom?"}} + qisdep{{"Is Receiver a marker account?"}} + qmhasattr{{"Does Denom have\nrequired attributes?"}} + qissbp{{"Is Sender a\nbypass account?"}} + qisrbp{{"Is Receiver a\nbypass account?"}} + qrhasattr{{"Does Receiver have\nthe required attributes?"}} + ok(["Denom transfer allowed."]) + style ok fill:#bbffaa,stroke:#1b8500,stroke-width:3px + denied(["Send denied."]) + style denied fill:#ffaaaa,stroke:#b30000,stroke-width:3px + start --> qisrdep + qisrdep -->|yes| qhasdep + qisrdep -.->|no| qisrc + qhasdep -.->|no| denied + qhasdep -->|yes| qisrc + qisrc -->|yes| qisdeny + qisrc -.->|no| ok + qisdeny -->|yes| denied + qisdeny -.->|no| qhastrans + qhastrans -.->|no| qisdep + qhastrans -->|yes| ok + qisdep -->|yes| denied + qisdep -.->|no| qmhasattr + qmhasattr -.->|no| qissbp + qmhasattr -->|yes| qisrbp + qissbp -..->|no| denied + qissbp --->|yes| ok + qisrbp -.->|no| qrhasattr + qisrbp -->|yes| ok + qrhasattr -.->|no| denied + qrhasattr -->|yes| ok + + linkStyle 3,7,11,15,19 stroke:#b30000,color:#b30000 + linkStyle 6,10,16,18,20 stroke:#1b8500,color:#1b8500 +``` + +#### MsgTransferRequest + +A `MsgTransferRequest` bypasses the `SendRestrictionFn` and applies its own logic. A `MsgTransferRequest` only allows for a single coin amount, i.e. there's only one `Denom` to consider. + +```mermaid +%%{ init: { 'flowchart': { 'curve': 'monotoneY'} } }%% +flowchart TD + start[["TransferCoin(Sender, Receiver, Admin)"]] + qisrc{{"Is Denom a restricted coin?"}} + qhast{{"Does Admin have transfer for Denom?"}} + qadminfrom{{"Does Sender == Admin?"}} + qallowft{{"Is forced transfer allowed for Denom?"}} + qauthz{{"Has Sender granted Admin\npermission with authz?"}} + qmodacc{{"Is Sender a\nmodule account?"}} + qblocked{{"Is Receiver an\naddress blocked by\nthe bank module?"}} + ok(["Transfer allowed."]) + style ok fill:#bbffaa,stroke:#1b8500,stroke-width:3px + denied(["Transfer denied."]) + style denied fill:#ffaaaa,stroke:#b30000,stroke-width:3px + start --> qisrc + qisrc -->|yes| qhast + qisrc -.->|no| denied + qhast -->|yes| qadminfrom + qhast -.->|no| denied + qadminfrom -->|yes| qblocked + qadminfrom -.->|no| qallowft + qallowft -->|yes| qmodacc + qallowft -.->|no| qauthz + qmodacc -.->|no| qblocked + qmodacc -->|yes| denied + qauthz -->|yes| qblocked + qauthz -.->|no| denied + qblocked -.->|no| ok + qblocked -->|yes| denied + + linkStyle 2,4,10,12,14 stroke:#b30000,color:#b30000 + linkStyle 13 stroke:#1b8500,color:#1b8500 +``` + +### Quarantine Complexities + +There are some noteable complexities involving restricted coins and quarantined accounts. + +#### Sending Restricted Coins to a Quarantined Account + +The marker module's `SendRestrictionFn` is applied before the quarantine module's. So, when funds are being sent to a quarantined account, the marker module runs its check using the original `Sender` and `Receiver` (i.e. the `Receiver` is not `QFH`). + +If the `Receiver` is a quarantined account, we can assume that it is neither a marker, nor a bypass account. Then, assuming the `Sender` is not on the deny list, the `validateSendDenom` flow can be simplified to this for restricted coins. + +```mermaid +%%{ init: { 'flowchart': { 'curve': 'monotoneY'} } }%% +flowchart LR + vsd[["validateSendDenom(Sender, Receiver, Denom)"]] + transq{{"Does Sender have\ntransfer for Denom?"}} + mreqattr{{"Does Denom have\nrequired attributes?"}} + treqattr{{"Does Receiver have\nthose attributes?"}} + ok(["Denom transfer allowed."]) + style ok fill:#bbffaa,stroke:#1b8500,stroke-width:3px + denied(["Send denied."]) + style denied fill:#ffaaaa,stroke:#b30000,stroke-width:3px + transq -->|yes| ok + transq -.->|no| mreqattr + mreqattr -->|yes| treqattr + mreqattr -.->|no| denied + treqattr -->|yes| ok + treqattr -.->|no| denied + + linkStyle 3,5 stroke:#b30000,color:#b30000 + linkStyle 0,4 stroke:#1b8500,color:#1b8500 +``` + +If the `Send` is allowed, and the `Receiver` is a quarantined account, the quarantine module's `SendRestrictionFn` will then change the `Send`'s destination to `QFH` (the Quarantined-funds-holder account) and make a record of the transfer. The `Send` then transfers funds from the `Sender` to `QFH`. + +The marker's `SendRestrictionFn` should never have `QFH` as a `Receiver`. The only way this would happen is if `MsgSend` is used to send funds directly to `QFH`. + +If `MsgTransferRequest` is used to transfer a restricted coin to a quarantined account, the standard `MsgTransferRequest` logic is applied (bypassing the marker module's `SendRestrictionFn`). The quarantine module's `SendRestrictionFn` is not bypassed, though, so the funds still go to the `QFH`. + +#### Accepting Quarantined Restricted Coins + +Once funds have been sent to `QFH`, the `Receiver` will probably want to accept them, and have them sent to their account. They issue an `Accept` to the quarantine module which utilizes the bank module's `Send` functionality to try to transfer funds from `QFH` to the `Receiver`. + +`QFH` is a bypass account. Since `Receiver` is a quarantined account, we can assume that it is neither a marker nor bypass account. So, the `validateSendDenom` flow can be simplified to this for restricted coins. + +```mermaid +%%{ init: { 'flowchart': { 'curve': 'monotoneY'} } }%% +flowchart LR + vsd[["validateSendDenom(Sender, Receiver, Denom)"]] + mreqattr{{"Does Denom have\nrequired attributes?"}} + treqattr{{"Does Receiver have\nthose attributes?"}} + ok(["Denom transfer allowed."]) + style ok fill:#bbffaa,stroke:#1b8500,stroke-width:3px + denied(["Send denied."]) + style denied fill:#ffaaaa,stroke:#b30000,stroke-width:3px + mreqattr -->|yes| treqattr + mreqattr -.->|no| ok + treqattr -->|yes| ok + treqattr -.->|no| denied + + linkStyle 3 stroke:#b30000,color:#b30000 + linkStyle 1,2 stroke:#1b8500,color:#1b8500 + +``` + +If the `Send` is allowed, the requested funds are transferred from `QFH` to `Receiver`. + +If the `Send` is denied, the funds remain with `QFH`. + +An important subtle part of this process is the rechecking of `Receiver` attributes. It's possible for the initial send to be okay (causing funds to be quarantined), then later, during this `Accept`, the send is not okay, and the quarantined funds are effectively locked with`QFH` until the `Receiver` gets the required attributes. + +If the marker does not have required attributes though, it's assumed that they were originally sent by someone with transfer authority, so they are allowed to continue from here too. + +#### Successful Quarantine and Accept Sequence + +When restricted coin funds are sent to a quarantined account (1), the marker's `SendRestrictionFn` is called using the original `Sender` and `Receiver` (2). Then, the quarantine's `SendRestrictionFn` is called (4) which will return `QFH` for the new destination (5). Funds are then transferred from `Sender` to `QFH` (6). + +When the `Receiver` attempts to `Accept` those quarantined funds (7), the marker's `SendRestrictionFn` is called again, this time using `QFH` (as the sender) and `Receiver` (9). The quarantine's `SendRestrictionFn` is bypassed (11), so the destination is not changed (12). Funds are then transferred from `QFH` to `Receiver` (13). + +```mermaid +sequenceDiagram + autonumber + actor Sender + actor Receiver + participant Bank Module + participant Quarantine Module + participant Marker Restriction + participant Quarantine Restriction + participant QFH + Sender ->>+ Bank Module: Send(sender, receiver) + Bank Module ->>+ Marker Restriction: Is this send from Sender to Receiver allowed? + Marker Restriction -->>- Bank Module: Yes + Bank Module ->>+ Quarantine Restriction: Is Receiver quarantined? + Quarantine Restriction -->>- Bank Module: Yes. Change destination to QFH. + Sender ->> QFH: Funds transferred from Sender to QFH. + deactivate Bank Module + + Note over Sender,QFH: Some Time Later + + Receiver ->>+ Quarantine Module: Accept(receiver, sender) + Quarantine Module ->> Bank Module: Send(QFH, receiver) + activate Bank Module + Bank Module ->>+ Marker Restriction: Is this send from QFH to Receiver allowed? + Marker Restriction -->>- Bank Module: Yes + Bank Module ->>+ Quarantine Restriction: Is Receiver quarantined? + Quarantine Restriction -->>- Bank Module: Restriction bypassed. No change. + QFH ->> Receiver: Funds transferred from QFH to Receiver. + deactivate Bank Module + deactivate Quarantine Module +``` diff --git a/x/marker/spec/README.md b/x/marker/spec/README.md index c31c33f1ee..899d791e7f 100644 --- a/x/marker/spec/README.md +++ b/x/marker/spec/README.md @@ -40,4 +40,5 @@ transfer by the marker itself when invoked by a user/process with appropriate pe 1. **[Telemetry](08_telemetry.md)** 1. **[Params](09_params.md)** 1. **[Governance](10_governance.md)** -1. **[Authorization](11_authorization.md)** \ No newline at end of file +1. **[Authorization](11_authorization.md)** +1. **[Transfers](12_transfers.md)** diff --git a/x/marker/types/immutable_addresses.go b/x/marker/types/immutable_addresses.go new file mode 100644 index 0000000000..9455a28644 --- /dev/null +++ b/x/marker/types/immutable_addresses.go @@ -0,0 +1,48 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +// ImmutableAccAddresses holds some AccAddresses in a way that they cannot be changed after creation. +type ImmutableAccAddresses struct { + // addrsSlice is a deep copy of the originally provided addresses slice. + addrsSlice []sdk.AccAddress + // addrsMap contains the same addresses as addrsSlice for easier checking. + // Each key is an sdk.AccAddress cast to a string (not converted to bech32). + addrsMap map[string]bool +} + +// NewImmutableAccAddresses creates a new ImmutableAccAddresses containing the provided addresses. +func NewImmutableAccAddresses(addrs []sdk.AccAddress) ImmutableAccAddresses { + rv := ImmutableAccAddresses{ + addrsSlice: deepCopyAccAddresses(addrs), + addrsMap: make(map[string]bool), + } + for _, addr := range addrs { + rv.addrsMap[string(addr)] = true + } + return rv +} + +// GetSlice returns a copy of the addresses known to this ImmutableAccAddresses. +func (i ImmutableAccAddresses) GetSlice() []sdk.AccAddress { + return deepCopyAccAddresses(i.addrsSlice) +} + +// Has returns true if the provided address is known to this ImmutableAccAddresses. +func (i ImmutableAccAddresses) Has(addr sdk.AccAddress) bool { + return i.addrsMap[string(addr)] +} + +// deepCopyAccAddresses creates a deep copy of the provided slice of acc addresses. +// A copy of each entry is made and placed into a new slice. +func deepCopyAccAddresses(orig []sdk.AccAddress) []sdk.AccAddress { + if orig == nil { + return nil + } + rv := make([]sdk.AccAddress, len(orig)) + for i, addr := range orig { + rv[i] = make(sdk.AccAddress, len(addr)) + copy(rv[i], addr) + } + return rv +} diff --git a/x/marker/types/immutable_addresses_test.go b/x/marker/types/immutable_addresses_test.go new file mode 100644 index 0000000000..ab66027407 --- /dev/null +++ b/x/marker/types/immutable_addresses_test.go @@ -0,0 +1,183 @@ +package types + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// newAddr creates a new sdk.AccAddress for the given index. +func newAddr(i int) sdk.AccAddress { + return sdk.AccAddress(fmt.Sprintf("addr_%d______________", i))[:20] +} + +// addrz creates a new slice of addresses with the given number of entries. +func addrz(count int) []sdk.AccAddress { + rv := make([]sdk.AccAddress, count) + for i := range rv { + rv[i] = newAddr(i + 1) + } + return rv +} + +func TestImmutableAccAddresses(t *testing.T) { + newGetTests := []struct { + name string + addrs []sdk.AccAddress + }{ + {name: "nil", addrs: nil}, + {name: "empty", addrs: []sdk.AccAddress{}}, + {name: "one addr", addrs: addrz(1)}, + {name: "two addr", addrs: addrz(2)}, + {name: "five addrs", addrs: addrz(5)}, + } + + for _, tc := range newGetTests { + t.Run("new+get:"+tc.name, func(t *testing.T) { + var iAddrs ImmutableAccAddresses + testFunc := func() { + iAddrs = NewImmutableAccAddresses(tc.addrs) + } + require.NotPanics(t, testFunc, "NewImmutableAccAddresses") + + // Get the addrs and make sure the result is equal to what we provided, + // but isn't the exact same slice that we provided. Also make sure each + // address was copied to a new slice too. + addrs := iAddrs.GetSlice() + require.Equal(t, tc.addrs, addrs, "GetSlice() compared to expected") + require.NotSame(t, tc.addrs, addrs, "GetSlice() compared to expected") + for i := range tc.addrs { + require.NotSame(t, tc.addrs[i], addrs[i], "GetSlice()[%d] compared to expected", i) + } + + // Get the slice five more times and make sure each one is a fresh copy. + for x := 1; x <= 5; x++ { + addrs2 := iAddrs.GetSlice() + require.Equal(t, addrs, addrs2, "[%d]: GetSlice() compared to previous result", x) + require.NotSame(t, addrs, addrs2, "[%d]: GetSlice() compared to previous result", x) + for i := range tc.addrs { + require.NotSame(t, addrs[i], addrs2[i], "[%d]: GetSlice()[%d] compared to previous result", x, i) + } + addrs = addrs2 + } + }) + } + + firstWDiffFirst := newAddr(1) + firstWDiffFirst[0] = 'b' + firstWDiffLast := newAddr(1) + firstWDiffLast[len(firstWDiffLast)-1]++ + firstWDiffMiddle := newAddr(1) + firstWDiffMiddle[12]-- + + iAddrsHasTester := NewImmutableAccAddresses(addrz(5)) + + hasTests := []struct { + name string + addr sdk.AccAddress + exp bool + }{ + {name: "nil", addr: nil, exp: false}, + {name: "empty", addr: sdk.AccAddress{}, exp: false}, + {name: "zeroth address", addr: newAddr(0), exp: false}, + {name: "first address", addr: newAddr(1), exp: true}, + {name: "second address", addr: newAddr(2), exp: true}, + {name: "third address", addr: newAddr(3), exp: true}, + {name: "fourth address", addr: newAddr(4), exp: true}, + {name: "fifth address", addr: newAddr(5), exp: true}, + {name: "sixth address", addr: newAddr(6), exp: false}, + {name: "first address without last byte", addr: newAddr(1)[:19], exp: false}, + {name: "first address without first byte", addr: newAddr(1)[1:], exp: false}, + {name: "first address with first byte changed", addr: firstWDiffFirst, exp: false}, + {name: "first address with last byte changed", addr: firstWDiffLast, exp: false}, + {name: "first address with a middle byte changed", addr: firstWDiffMiddle, exp: false}, + {name: "first address with extra byte at end", addr: append(newAddr(1), '_'), exp: false}, + {name: "first address with extra byte at start", addr: append(sdk.AccAddress{'_'}, newAddr(1)...), exp: false}, + } + + for _, tc := range hasTests { + t.Run("has:"+tc.name, func(t *testing.T) { + var has bool + testFunc := func() { + has = iAddrsHasTester.Has(tc.addr) + } + require.NotPanics(t, testFunc, "Has") + assert.Equal(t, tc.exp, has, "Has") + }) + } + + t.Run("change to slice provided to NewImmutableAccAddresses", func(t *testing.T) { + // This test makes sure that a change to the slice provided to NewImmutableAccAddresses + // does not alter anything inside the resulting ImmutableAccAddresses. + input := addrz(3) + expected00 := input[0][0] + iaddrs := NewImmutableAccAddresses(input) + input[0][0] = 'b' + addrs := iaddrs.GetSlice() + actual00 := addrs[0][0] + assert.Equal(t, expected00, actual00, "first byte of first address returned by GetSlice()") + hasChanged := iaddrs.Has(input[0]) + assert.False(t, hasChanged, "Has(address that was changed)") + hasOrig := iaddrs.Has(newAddr(1)) + assert.True(t, hasOrig, "Has(address before it was changed)") + }) + + t.Run("change to slice returned by GetSlice", func(t *testing.T) { + // This test makes sure that a change to the result of a GetSlice() + // doesn't somehow change anything in the ImmutableAccAddresses. + iaddrs := NewImmutableAccAddresses(addrz(4)) + addrs := iaddrs.GetSlice() + expected00 := addrs[0][0] + addrs[0][0] = 'b' + actual := iaddrs.GetSlice() + actual00 := actual[0][0] + assert.Equal(t, expected00, actual00, "first byte of first address returned by GetSlice()") + hasChanged := iaddrs.Has(addrs[0]) + assert.False(t, hasChanged, "Has(address that was changed)") + hasOrig := iaddrs.Has(newAddr(1)) + assert.True(t, hasOrig, "Has(address before it was changed)") + }) +} + +func TestDeepCopyAccAddresses(t *testing.T) { + tests := []struct { + name string + orig []sdk.AccAddress + }{ + {name: "nil", orig: nil}, + {name: "empty", orig: []sdk.AccAddress{}}, + {name: "one address", orig: addrz(1)}, + {name: "two address", orig: addrz(2)}, + {name: "five address", orig: addrz(5)}, + {name: "same address 3 times", orig: []sdk.AccAddress{newAddr(1), newAddr(1), newAddr(1)}}, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + expCap := len(tc.orig) // Result should not have extra capacity. + var actual []sdk.AccAddress + testFunc := func() { + actual = deepCopyAccAddresses(tc.orig) + } + require.NotPanics(t, testFunc, "deepCopyAccAddresses") + + // Make sure the result is equal to what was provided, but in a different slice. + // Also make sure each entry slice was also copied. + if assert.Equal(t, tc.orig, actual, "deepCopyAccAddresses result") { + if assert.NotSame(t, tc.orig, actual, "deepCopyAccAddresses result") { + for i := range tc.orig { + assert.NotSame(t, tc.orig[i], actual[i], "deepCopyAccAddresses result[%d]", i) + } + } + } + + // Make sure there isn't any extra capacity + actualCap := cap(actual) + assert.Equal(t, expCap, actualCap, "capacity of deepCopyAccAddresses result") + }) + } +} From cc6ed009992ebb15b005929472c3da1c91c190c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 08:43:35 -0600 Subject: [PATCH 83/96] Bump github.com/google/uuid from 1.3.0 to 1.3.1 (#1657) Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/google/uuid/releases) - [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: github.com/google/uuid dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 2bb7f376f5..98005eb43a 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/cosmos/ibc-go/v6 v6.2.0 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.3 - github.com/google/uuid v1.3.0 + github.com/google/uuid v1.3.1 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/otiai10/copy v1.12.0 diff --git a/go.sum b/go.sum index 2561333185..852eee555f 100644 --- a/go.sum +++ b/go.sum @@ -632,8 +632,9 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= From f8ee015ae5f9bd1430853250c4c42dbf7352272b Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Aug 2023 10:23:36 -0400 Subject: [PATCH 84/96] Updated dependencies. --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 98005eb43a..027d4361ce 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0 - cosmossdk.io/math v1.0.1 + cosmossdk.io/math v1.1.2 github.com/99designs/keyring v1.2.1 github.com/CosmWasm/wasmd v0.29.0 github.com/CosmWasm/wasmvm v1.2.4 diff --git a/go.sum b/go.sum index 852eee555f..6a125a0a3c 100644 --- a/go.sum +++ b/go.sum @@ -194,8 +194,8 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= -cosmossdk.io/math v1.0.1 h1:Qx3ifyOPaMLNH/89WeZFH268yCvU4xEcnPLu3sJqPPg= -cosmossdk.io/math v1.0.1/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= +cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= +cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= From 0cb49864b0ff00b49e9263795d814cf7fc5d4eac Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Aug 2023 10:40:07 -0400 Subject: [PATCH 85/96] Updated specs for Oracle module. --- x/oracle/spec/01_concepts.md | 2 -- x/oracle/spec/02_state.md | 1 - x/oracle/spec/04_queries.md | 5 ----- x/oracle/spec/05_events.md | 1 - x/oracle/spec/06_genesis.md | 1 - 5 files changed, 10 deletions(-) diff --git a/x/oracle/spec/01_concepts.md b/x/oracle/spec/01_concepts.md index 51017bde06..87592f9431 100644 --- a/x/oracle/spec/01_concepts.md +++ b/x/oracle/spec/01_concepts.md @@ -7,10 +7,8 @@ order: 1 The oracle module is very minimal, but users should understand what the `Oracle` is and how it interacts with `ICQ`. -- [Concepts](#concepts) - [Oracle](#oracle) - [Interchain Queries (ICQ)](#interchain-queries-icq) - - [Note](#note) --- diff --git a/x/oracle/spec/02_state.md b/x/oracle/spec/02_state.md index d67e125fce..8ca44e41a0 100644 --- a/x/oracle/spec/02_state.md +++ b/x/oracle/spec/02_state.md @@ -7,7 +7,6 @@ order: 2 The oracle module manages the address of the Oracle and the ICQ state. -- [State](#state) - [Oracle](#oracle) - [IBC](#ibc) diff --git a/x/oracle/spec/04_queries.md b/x/oracle/spec/04_queries.md index f28ec59ddc..c41647b124 100644 --- a/x/oracle/spec/04_queries.md +++ b/x/oracle/spec/04_queries.md @@ -7,13 +7,8 @@ order: 4 In this section we describe the queries available for looking up oracle information. -- [Queries](#queries) - [Query Oracle Address](#query-oracle-address) - - [Request](#request) - - [Response](#response) - [Query Oracle](#query-oracle) - - [Request](#request-1) - - [Response](#response-1) --- ## Query Oracle Address diff --git a/x/oracle/spec/05_events.md b/x/oracle/spec/05_events.md index 7a4c2a7716..736ff720c5 100644 --- a/x/oracle/spec/05_events.md +++ b/x/oracle/spec/05_events.md @@ -7,7 +7,6 @@ order: 5 The oracle module emits the following events: -- [Events](#events) - [EventOracleQuerySuccess](#eventoraclequerysuccess) - [EventOracleQueryError](#eventoraclequeryerror) - [EventOracleQueryTimeout](#eventoraclequerytimeout) diff --git a/x/oracle/spec/06_genesis.md b/x/oracle/spec/06_genesis.md index 8e67f3ef5f..7d5e744a0f 100644 --- a/x/oracle/spec/06_genesis.md +++ b/x/oracle/spec/06_genesis.md @@ -7,7 +7,6 @@ order: 6 In this section we describe the processing of the oracle messages and the corresponding updates to the state. -- [Oracle Genesis](#oracle-genesis) - [Msg/GenesisState](#msggenesisstate) From a2995ba69be1be9efcf6d4d8ae49b6b7bd6aada3 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Aug 2023 12:04:58 -0400 Subject: [PATCH 86/96] Simplified tx and removed useless gov flag. --- x/oracle/client/cli/cli_test.go | 2 +- x/oracle/client/cli/tx.go | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/x/oracle/client/cli/cli_test.go b/x/oracle/client/cli/cli_test.go index 123c23837c..fd36b1cfd6 100644 --- a/x/oracle/client/cli/cli_test.go +++ b/x/oracle/client/cli/cli_test.go @@ -182,7 +182,7 @@ func (s *IntegrationTestSuite) TestOracleUpdate() { { name: "failure - unable to pass validate basic with bad address", address: "badaddress", - expectErrMsg: "invalid address for oracle: decoding bech32 failed: invalid separator index -1", + expectErrMsg: "msg: 0, err: invalid address for oracle: decoding bech32 failed: invalid separator index -1: invalid proposal message", signer: s.accountAddresses[0].String(), }, } diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index ce3b88b990..05fda6fa23 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -22,9 +22,6 @@ import ( "github.com/provenance-io/provenance/x/oracle/types" ) -// The flag to specify that the command should be ran as a gov proposal -const FlagGovProposal = "gov-proposal" - // NewTxCmd is the top-level command for oracle CLI transactions. func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ @@ -70,21 +67,15 @@ func GetCmdOracleUpdate() *cobra.Command { if govErr != nil { return govErr } - anys, govErr := sdktx.SetMsgs([]sdk.Msg{msg}) + proposal.Messages, govErr = sdktx.SetMsgs([]sdk.Msg{msg}) if govErr != nil { return govErr } - proposal.Messages = anys - var req sdk.Msg = proposal - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), req) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposal) }, } - cmd.Flags().Bool(FlagGovProposal, false, "Run transaction as gov proposal") govcli.AddGovPropFlagsToCmd(cmd) flags.AddTxFlagsToCmd(cmd) From f0ba8961ea7404190eaf8dd8d9808f4fd522f9e6 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Aug 2023 13:19:53 -0400 Subject: [PATCH 87/96] Removed multiple decoders. --- x/oracle/client/cli/tx.go | 46 +-------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 05fda6fa23..ff1a63f0d3 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -1,8 +1,6 @@ package cli import ( - "encoding/base64" - "encoding/hex" "encoding/json" "errors" "fmt" @@ -84,7 +82,6 @@ func GetCmdOracleUpdate() *cobra.Command { // GetCmdSendQuery is a command to send a query to another chain's oracle func GetCmdSendQuery() *cobra.Command { - decoder := newArgDecoder(asciiDecodeString) cmd := &cobra.Command{ Use: "send-query ", Short: "Send a query to an oracle on a remote chain via IBC", @@ -99,10 +96,7 @@ func GetCmdSendQuery() *cobra.Command { channelID := args[0] - queryData, err := decoder.DecodeString(args[1]) - if err != nil { - return fmt.Errorf("decode query: %w", err) - } + queryData := []byte(args[1]) if !json.Valid(queryData) { return errors.New("query data must be json") } @@ -123,41 +117,3 @@ func GetCmdSendQuery() *cobra.Command { return cmd } - -type argumentDecoder struct { - // dec is the default decoder - dec func(string) ([]byte, error) - asciiF, hexF, b64F bool -} - -func newArgDecoder(def func(string) ([]byte, error)) *argumentDecoder { - return &argumentDecoder{dec: def} -} - -// DecodeString decodes the supplied json string -func (a *argumentDecoder) DecodeString(s string) ([]byte, error) { - found := -1 - for i, v := range []*bool{&a.asciiF, &a.hexF, &a.b64F} { - if !*v { - continue - } - if found != -1 { - return nil, errors.New("multiple decoding flags used") - } - found = i - } - switch found { - case 0: - return asciiDecodeString(s) - case 1: - return hex.DecodeString(s) - case 2: - return base64.StdEncoding.DecodeString(s) - default: - return a.dec(s) - } -} - -func asciiDecodeString(s string) ([]byte, error) { - return []byte(s), nil -} From 4ed48ad0653a1dec2ec6b9b20e738508ad18fedd Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Aug 2023 14:14:13 -0400 Subject: [PATCH 88/96] Removed pointer arg since it was only needed for tests. Updated tests to use With instead. --- app/app.go | 4 +-- x/oracle/keeper/icq_test.go | 42 ++++++++++++++-------------- x/oracle/keeper/mocks_test.go | 12 +++++--- x/oracle/keeper/msg_server_test.go | 6 ++-- x/oracle/keeper/query_server_test.go | 2 +- x/oracle/keeper/relay_test.go | 4 +-- x/oracle/module/module.go | 8 +++--- 7 files changed, 41 insertions(+), 37 deletions(-) diff --git a/app/app.go b/app/app.go index 9102a3b0e8..1b28831531 100644 --- a/app/app.go +++ b/app/app.go @@ -643,7 +643,7 @@ func New( scopedOracleKeeper, wasmkeeper.Querier(app.WasmKeeper), ) - oracleModule := oraclemodule.NewAppModule(appCodec, &app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper) + oracleModule := oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper) unsanctionableAddrs := make([]sdk.AccAddress, 0, len(maccPerms)+1) for mName := range maccPerms { @@ -934,7 +934,7 @@ func New( msgfeesmodule.NewAppModule(appCodec, app.MsgFeesKeeper, app.interfaceRegistry), rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper), triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper), - oraclemodule.NewAppModule(appCodec, &app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper), + oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper), provwasm.NewWrapper(appCodec, app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper), // IBC diff --git a/x/oracle/keeper/icq_test.go b/x/oracle/keeper/icq_test.go index cb006bc79b..cde6f6e8ce 100644 --- a/x/oracle/keeper/icq_test.go +++ b/x/oracle/keeper/icq_test.go @@ -11,8 +11,9 @@ func (s *KeeperTestSuite) TestQueryOracle() { channel string sequence uint64 err string - setMocks bool - setIcs4Mock bool + scopeMock bool + channelMock bool + ics4Mock bool }{ { name: "failure - missing channel capability", @@ -22,36 +23,35 @@ func (s *KeeperTestSuite) TestQueryOracle() { err: "module does not own channel capability: channel capability not found", }, { - name: "failure - unable to send", - query: []byte("{}"), - channel: "channel-1", - sequence: 0, - err: "channel-1: channel not found", - setMocks: true, + name: "failure - unable to send", + query: []byte("{}"), + channel: "channel-1", + sequence: 0, + err: "channel-1: channel not found", + scopeMock: true, + channelMock: true, }, { name: "success - should send a packet", query: []byte("{}"), channel: "channel-1", - sequence: 2, - setIcs4Mock: true, - }, - { - name: "success - should send a packet with the next sequence", - query: []byte("{}"), - channel: "channel-1", - sequence: 3, + sequence: 1, + scopeMock: true, + channelMock: true, + ics4Mock: true, }, } for _, tc := range tests { s.Run(tc.name, func() { - if tc.setMocks { - s.app.OracleKeeper.SetMockScopedKeeper(keeper.MockScopedKeeper{}) - s.app.OracleKeeper.SetMockChannelKeeper(&keeper.MockChannelKeeper{}) + if tc.scopeMock { + s.app.OracleKeeper = s.app.OracleKeeper.WithMockScopedKeeper(keeper.MockScopedKeeper{}) + } + if tc.channelMock { + s.app.OracleKeeper = s.app.OracleKeeper.WithMockChannelKeeper(&keeper.MockChannelKeeper{}) } - if tc.setIcs4Mock { - s.app.OracleKeeper.SetMockICS4Wrapper(keeper.MockICS4Wrapper{}) + if tc.ics4Mock { + s.app.OracleKeeper = s.app.OracleKeeper.WithMockICS4Wrapper(&keeper.MockICS4Wrapper{}) } sequence, err := s.app.OracleKeeper.QueryOracle(s.ctx, tc.query, tc.channel) s.Assert().Equal(int(tc.sequence), int(sequence), "should have correct sequence") diff --git a/x/oracle/keeper/mocks_test.go b/x/oracle/keeper/mocks_test.go index 3ac532e587..06719d7eda 100644 --- a/x/oracle/keeper/mocks_test.go +++ b/x/oracle/keeper/mocks_test.go @@ -17,8 +17,9 @@ import ( type MockWasmServer struct { } -func (k *Keeper) SetWasmQueryServer(server wasmtypes.QueryServer) { +func (k Keeper) WithWasmQueryServer(server wasmtypes.QueryServer) Keeper { k.wasmQueryServer = server + return k } func (m MockWasmServer) ContractInfo(context.Context, *wasmtypes.QueryContractInfoRequest) (*wasmtypes.QueryContractInfoResponse, error) { @@ -71,8 +72,9 @@ type MockICS4Wrapper struct { counter uint64 } -func (k *Keeper) SetMockICS4Wrapper(ics4wrapper types.ICS4Wrapper) { +func (k Keeper) WithMockICS4Wrapper(ics4wrapper types.ICS4Wrapper) Keeper { k.ics4Wrapper = ics4wrapper + return k } func (k MockICS4Wrapper) SendPacket( @@ -92,8 +94,9 @@ type MockChannelKeeper struct { counter uint64 } -func (k *Keeper) SetMockChannelKeeper(channelKeeper types.ChannelKeeper) { +func (k Keeper) WithMockChannelKeeper(channelKeeper types.ChannelKeeper) Keeper { k.channelKeeper = channelKeeper + return k } func (m *MockChannelKeeper) GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) { @@ -108,8 +111,9 @@ func (m *MockChannelKeeper) GetNextSequenceSend(ctx sdk.Context, portID, channel type MockScopedKeeper struct { } -func (k *Keeper) SetMockScopedKeeper(scopedKeeper types.ScopedKeeper) { +func (k Keeper) WithMockScopedKeeper(scopedKeeper types.ScopedKeeper) Keeper { k.scopedKeeper = scopedKeeper + return k } func (m MockScopedKeeper) GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) { diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index 07c09cb93e..10a5f16b92 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -70,8 +70,8 @@ func (s *KeeperTestSuite) TestSendQueryOracle() { sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), ) - s.app.OracleKeeper.SetMockICS4Wrapper(keeper.MockICS4Wrapper{}) - s.app.OracleKeeper.SetMockScopedKeeper(keeper.MockScopedKeeper{}) + s.app.OracleKeeper = s.app.OracleKeeper.WithMockICS4Wrapper(keeper.MockICS4Wrapper{}) + s.app.OracleKeeper = s.app.OracleKeeper.WithMockScopedKeeper(keeper.MockScopedKeeper{}) tests := []struct { name string @@ -109,7 +109,7 @@ func (s *KeeperTestSuite) TestSendQueryOracle() { for _, tc := range tests { s.Run(tc.name, func() { if tc.mockChannel { - s.app.OracleKeeper.SetMockChannelKeeper(&keeper.MockChannelKeeper{}) + s.app.OracleKeeper = s.app.OracleKeeper.WithMockChannelKeeper(&keeper.MockChannelKeeper{}) } res, err := s.msgServer.SendQueryOracle(s.ctx, tc.req) diff --git a/x/oracle/keeper/query_server_test.go b/x/oracle/keeper/query_server_test.go index 0cf109bc6f..ade936d750 100644 --- a/x/oracle/keeper/query_server_test.go +++ b/x/oracle/keeper/query_server_test.go @@ -108,7 +108,7 @@ func (s *KeeperTestSuite) TestOracle() { for _, tc := range tests { s.Run(tc.name, func() { if tc.mockEnabled { - s.app.OracleKeeper.SetWasmQueryServer(keeper.MockWasmServer{}) + s.app.OracleKeeper = s.app.OracleKeeper.WithWasmQueryServer(keeper.MockWasmServer{}) } if len(tc.oracle) > 0 { diff --git a/x/oracle/keeper/relay_test.go b/x/oracle/keeper/relay_test.go index a4316d2a75..492d7e8ac6 100644 --- a/x/oracle/keeper/relay_test.go +++ b/x/oracle/keeper/relay_test.go @@ -41,8 +41,8 @@ func (s *KeeperTestSuite) TestSendQuery() { for _, tc := range tests { s.Run(tc.name, func() { if tc.enableMocks { - s.app.OracleKeeper.SetMockChannelKeeper(&keeper.MockChannelKeeper{}) - s.app.OracleKeeper.SetMockICS4Wrapper(&keeper.MockICS4Wrapper{}) + s.app.OracleKeeper = s.app.OracleKeeper.WithMockChannelKeeper(&keeper.MockChannelKeeper{}) + s.app.OracleKeeper = s.app.OracleKeeper.WithMockICS4Wrapper(&keeper.MockICS4Wrapper{}) } sequence, err := s.app.OracleKeeper.SendQuery(s.ctx, "port", "channel", nil, tc.req, clienttypes.ZeroHeight(), 0) if len(tc.err) > 0 { diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index 1e10bcf1f4..6566a401bd 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -94,14 +94,14 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { // AppModule implements the sdk.AppModule interface type AppModule struct { AppModuleBasic - keeper *keeper.Keeper + keeper keeper.Keeper accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper channelKeeper channelkeeper.Keeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, channelKeeper channelkeeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, channelKeeper channelkeeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, @@ -136,7 +136,7 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { // WeightedOperations returns simulation operations (i.e msgs) with their respective weight func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, *am.keeper, am.accountKeeper, am.bankKeeper, am.channelKeeper, + simState.AppParams, simState.Cdc, am.keeper, am.accountKeeper, am.bankKeeper, am.channelKeeper, ) } @@ -194,6 +194,6 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } From ed6eba55c370ec6caef9b06d6da022c7d2a96245 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Aug 2023 09:27:15 -0400 Subject: [PATCH 89/96] Removed 99designs keyring dependency and replaced it with cosmos keyring. --- go.mod | 2 +- x/oracle/keeper/keeper_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 5c43b4097b..ef06fec792 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/math v1.1.2 - github.com/99designs/keyring v1.2.1 github.com/CosmWasm/wasmd v0.29.0 github.com/CosmWasm/wasmvm v1.2.4 github.com/armon/go-metrics v0.4.1 @@ -47,6 +46,7 @@ require ( cloud.google.com/go/storage v1.28.1 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect + github.com/99designs/keyring v1.2.1 // indirect github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect github.com/aws/aws-sdk-go v1.44.122 // indirect diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index 93ae2ef28d..cf82a3cba9 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/99designs/keyring" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/provenance-io/provenance/app" From a7bd8ad6c779f192f15cf0c5161b2470538c69cf Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 1 Sep 2023 12:16:34 -0400 Subject: [PATCH 90/96] Remove remaining references to LastQuerySequence. --- x/oracle/simulation/decoder.go | 6 ------ x/oracle/spec/02_state.md | 6 +++--- x/oracle/types/keys.go | 14 ++------------ x/oracle/types/keys_test.go | 5 ----- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/x/oracle/simulation/decoder.go b/x/oracle/simulation/decoder.go index 2c32a9ca64..9b65480cc3 100644 --- a/x/oracle/simulation/decoder.go +++ b/x/oracle/simulation/decoder.go @@ -2,7 +2,6 @@ package simulation import ( "bytes" - "encoding/binary" "fmt" "github.com/cosmos/cosmos-sdk/codec" @@ -20,11 +19,6 @@ func NewDecodeStore(_ codec.Codec) func(kvA, kvB kv.Pair) string { case bytes.Equal(kvA.Key[:1], types.OracleStoreKey): var attribA, attribB sdk.AccAddress = kvA.Value, kvB.Value return fmt.Sprintf("Oracle Address: A:[%v] B:[%v]\n", attribA, attribB) - case bytes.Equal(kvA.Key[:1], types.LastQueryPacketSeqKey): - attribA := binary.BigEndian.Uint64(kvA.Value) - attribB := binary.BigEndian.Uint64(kvB.Value) - - return fmt.Sprintf("Last Query Packet Sequence: A:[%v] B:[%v]\n", attribA, attribB) case bytes.Equal(kvA.Key[:1], types.PortStoreKey): attribA := string(kvA.Value) attribB := string(kvB.Value) diff --git a/x/oracle/spec/02_state.md b/x/oracle/spec/02_state.md index 8ca44e41a0..9f66f30ddb 100644 --- a/x/oracle/spec/02_state.md +++ b/x/oracle/spec/02_state.md @@ -7,6 +7,7 @@ order: 2 The oracle module manages the address of the Oracle and the ICQ state. +- [State](#state) - [Oracle](#oracle) - [IBC](#ibc) @@ -21,7 +22,6 @@ The `Oracle` is a CosmWasm smart contract that the module forwards its queries t --- ## IBC -`IBC` communication exists between the `oracle` and `icqhost` modules. The `oracle` module tracks its channel's `port` in state. It also ensures that each `ICQ` packet has a unique `sequence number` by trackinig this in state. +`IBC` communication exists between the `oracle` and `icqhost` modules. The `oracle` module tracks its channel's `port` in state. -* Port `0x03 -> []byte{}` -* Last Query Sequence Number `0x02 -> uint64` +* Port `0x02 -> []byte{}` diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index cdf37b5b72..105475d81f 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -29,20 +29,15 @@ const ( // - 0x01: sdk.AccAddress // | 1 | // -// LastQueryPacketSeqKey -// - 0x02: uint64 -// | 1 | // // PortStoreKey -// - 0x03: string +// - 0x02: string // | 1 | var ( // OracleStoreKey is the key for the module's oracle address OracleStoreKey = []byte{0x01} - // LastQueryPacketSeqKey is the key for the last packet sequence - LastQueryPacketSeqKey = []byte{0x02} // PortStoreKey defines the key to store the port ID in store - PortStoreKey = []byte{0x03} + PortStoreKey = []byte{0x02} ) // GetOracleStoreKey is a function to get the key for the oracle's address in store @@ -54,8 +49,3 @@ func GetOracleStoreKey() []byte { func GetPortStoreKey() []byte { return PortStoreKey } - -// GetLastQueryPacketSeqKey is a function to get the key for the last query packet sequence in store -func GetLastQueryPacketSeqKey() []byte { - return LastQueryPacketSeqKey -} diff --git a/x/oracle/types/keys_test.go b/x/oracle/types/keys_test.go index 472b012246..8aed3ea1c6 100644 --- a/x/oracle/types/keys_test.go +++ b/x/oracle/types/keys_test.go @@ -15,8 +15,3 @@ func TestGetPortStoreKey(t *testing.T) { key := GetPortStoreKey() assert.EqualValues(t, PortStoreKey, key[0:1], "must return correct port key") } - -func TestGetLastQueryPacketSeqKey(t *testing.T) { - key := GetLastQueryPacketSeqKey() - assert.EqualValues(t, LastQueryPacketSeqKey, key[0:1], "must return correct last query packet sequence key") -} From 0876fc42dac07b0f80adcfe68db32e54917d8279 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 1 Sep 2023 12:17:03 -0400 Subject: [PATCH 91/96] Add decoder test that was missing. --- x/oracle/simulation/decoder_test.go | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 x/oracle/simulation/decoder_test.go diff --git a/x/oracle/simulation/decoder_test.go b/x/oracle/simulation/decoder_test.go new file mode 100644 index 0000000000..1d5013e5e2 --- /dev/null +++ b/x/oracle/simulation/decoder_test.go @@ -0,0 +1,57 @@ +package simulation_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/types/kv" + + "github.com/provenance-io/provenance/testutil/assertions" + "github.com/provenance-io/provenance/x/oracle/simulation" + "github.com/provenance-io/provenance/x/oracle/types" +) + +func TestDecodeStore(t *testing.T) { + cdc := simapp.MakeTestEncodingConfig().Codec + dec := simulation.NewDecodeStore(cdc) + + tests := []struct { + name string + kvA kv.Pair + kvB kv.Pair + exp string + expPanic string + }{ + { + name: "failure - unknown key type", + kvA: kv.Pair{Key: []byte{0x9a}, Value: []byte{0x9b}}, + kvB: kv.Pair{Key: []byte{0x9c}, Value: []byte{0x9d}}, + expPanic: "unexpected oracle key 9A (\x9a)", + }, + { + name: "success - OracleStoreKey", + kvA: kv.Pair{Key: types.GetOracleStoreKey(), Value: []byte("99")}, + kvB: kv.Pair{Key: types.GetOracleStoreKey(), Value: []byte("88")}, + exp: "Oracle Address: A:[3939] B:[3838]\n", + }, + { + name: "success - PortStoreKey", + kvA: kv.Pair{Key: types.GetPortStoreKey(), Value: []byte("99")}, + kvB: kv.Pair{Key: types.GetPortStoreKey(), Value: []byte("88")}, + exp: "Port: A:[99] B:[88]\n", + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + var actual string + testFunc := func() { + actual = dec(tc.kvA, tc.kvB) + } + assertions.RequirePanicEquals(t, testFunc, tc.expPanic, "running decoder") + assert.Equal(t, tc.exp, actual, "decoder result") + }) + } +} From e999a923a74b1633b09f6e9007653982c24d6d26 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 1 Sep 2023 14:41:13 -0400 Subject: [PATCH 92/96] Add genesis_tests for simulation. --- x/oracle/keeper/genesis_test.go | 11 +- x/oracle/simulation/genesis_test.go | 164 ++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 x/oracle/simulation/genesis_test.go diff --git a/x/oracle/keeper/genesis_test.go b/x/oracle/keeper/genesis_test.go index 02243be14c..ad4136331c 100644 --- a/x/oracle/keeper/genesis_test.go +++ b/x/oracle/keeper/genesis_test.go @@ -12,9 +12,10 @@ func (s *KeeperTestSuite) TestExportGenesis() { func (s *KeeperTestSuite) TestInitGenesis() { tests := []struct { - name string - genesis *types.GenesisState - err string + name string + genesis *types.GenesisState + err string + mockPort bool }{ { name: "success - valid genesis state", @@ -42,7 +43,9 @@ func (s *KeeperTestSuite) TestInitGenesis() { for _, tc := range tests { s.Run(tc.name, func() { - + if tc.mockPort { + s.app.OracleKeeper.BindPort(s.ctx, "test") + } if len(tc.err) > 0 { s.Assert().PanicsWithError(tc.err, func() { s.app.OracleKeeper.InitGenesis(s.ctx, tc.genesis) diff --git a/x/oracle/simulation/genesis_test.go b/x/oracle/simulation/genesis_test.go new file mode 100644 index 0000000000..7486b29f82 --- /dev/null +++ b/x/oracle/simulation/genesis_test.go @@ -0,0 +1,164 @@ +package simulation_test + +import ( + "encoding/json" + "math/rand" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/provenance-io/provenance/x/oracle/simulation" + "github.com/provenance-io/provenance/x/oracle/types" + "github.com/stretchr/testify/assert" +) + +func TestPortFn(t *testing.T) { + tests := []struct { + name string + seed int64 + expected string + }{ + { + name: "success - returns a random port that is not the oracle", + seed: 0, + expected: "vipxlpbshz", + }, + { + name: "success - returns the oracle port", + seed: 1, + expected: "oracle", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + r := rand.New(rand.NewSource(tc.seed)) + port := simulation.PortFn(r) + assert.Equal(t, tc.expected, port, "should return correct random port") + }) + } +} + +func TestOracleFn(t *testing.T) { + accs := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 3) + + tests := []struct { + name string + seed int64 + expected string + accounts []simtypes.Account + }{ + { + name: "success - returns an empty account", + seed: 0, + accounts: accs, + expected: "", + }, + { + name: "success - returns a random account", + seed: 3, + accounts: accs, + expected: "cosmos1tp4es44j4vv8m59za3z0tm64dkmlnm8wg2frhc", + }, + { + name: "success - returns a different random account", + seed: 2, + accounts: accs, + expected: "cosmos12jszjrc0qhjt0ugt2uh4ptwu0h55pq6qfp9ecl", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + r := rand.New(rand.NewSource(tc.seed)) + port := simulation.OracleFn(r, tc.accounts) + assert.Equal(t, tc.expected, port, "should return correct random oracle") + }) + } +} + +func TestRandomizedGenState(t *testing.T) { + accs := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 3) + tests := []struct { + name string + seed int64 + expOracleGen *types.GenesisState + accounts []simtypes.Account + }{ + { + name: "success - can handle no accounts", + seed: 0, + accounts: nil, + expOracleGen: &types.GenesisState{ + PortId: "vipxlpbshz", + Oracle: "", + }, + }, + { + name: "success - can handle accounts", + seed: 1, + accounts: accs, + expOracleGen: &types.GenesisState{ + PortId: "oracle", + Oracle: "", + }, + }, + { + name: "success - has different output", + seed: 2, + accounts: accs, + expOracleGen: &types.GenesisState{ + PortId: "knxndtw", + Oracle: "cosmos10gqqppkly524p6v7hypvvl8sn7wky85jajrph0", + }, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + simState := &module.SimulationState{ + AppParams: make(simtypes.AppParams), + Cdc: codec.NewProtoCodec(codectypes.NewInterfaceRegistry()), + Rand: rand.New(rand.NewSource(tc.seed)), + GenState: make(map[string]json.RawMessage), + Accounts: tc.accounts, + } + simulation.RandomizedGenState(simState) + + if assert.NotEmpty(t, simState.GenState[types.ModuleName]) { + oracleGenState := &types.GenesisState{} + err := simState.Cdc.UnmarshalJSON(simState.GenState[types.ModuleName], oracleGenState) + if assert.NoError(t, err, "UnmarshalJSON(oracle gen state)") { + assert.Equal(t, tc.expOracleGen, oracleGenState, "hold oracle state") + } + } + }) + } +} + +func TestRandomChannel(t *testing.T) { + + tests := []struct { + name string + seed int64 + expected string + }{ + { + name: "success - returns a random channel", + seed: 3, + expected: "channel-8", + }, + { + name: "success - returns a different random channel", + seed: 2, + expected: "channel-786", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + r := rand.New(rand.NewSource(tc.seed)) + port := simulation.RandomChannel(r) + assert.Equal(t, tc.expected, port, "should return correct random channel") + }) + } +} From 82937f44b7ebafc2c4883b74ecb3cde46eea065a Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 5 Sep 2023 09:51:18 -0400 Subject: [PATCH 93/96] Removed paramspace. --- app/app.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/app.go b/app/app.go index 82b42914ec..5912fb379f 100644 --- a/app/app.go +++ b/app/app.go @@ -1267,7 +1267,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(wasm.ModuleName) paramsKeeper.Subspace(rewardtypes.ModuleName) paramsKeeper.Subspace(triggertypes.ModuleName) - paramsKeeper.Subspace(oracletypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) From 3782a95cd1adec17e32b3efb57eef84d3f874891 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 5 Sep 2023 09:51:38 -0400 Subject: [PATCH 94/96] Fix test name. --- x/oracle/keeper/query_server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/oracle/keeper/query_server_test.go b/x/oracle/keeper/query_server_test.go index ade936d750..5a528810a9 100644 --- a/x/oracle/keeper/query_server_test.go +++ b/x/oracle/keeper/query_server_test.go @@ -78,7 +78,7 @@ func (s *KeeperTestSuite) TestOracle() { err: "missing oracle address", }, { - name: "success - should handle error from contract", + name: "failure - should handle error from contract", req: &types.QueryOracleRequest{ Query: []byte("{}"), }, From 2903377b50334f3e007f8e8d4018af6049e91910 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 5 Sep 2023 09:52:15 -0400 Subject: [PATCH 95/96] Move tested pieces into variables. --- x/oracle/keeper/msg_server_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index 10a5f16b92..3397bac147 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -45,12 +45,14 @@ func (s *KeeperTestSuite) TestUpdateOracle() { for _, tc := range tests { s.Run(tc.name, func() { res, err := s.msgServer.UpdateOracle(s.ctx, tc.req) + events := s.ctx.EventManager().Events() + numEvents := len(events) if tc.event != nil { - s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events") - s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event") + s.Assert().Equal(1, numEvents, "should emit the correct number of events") + s.Assert().Equal(*tc.event, events[0], "should emit the correct event") } else { - s.Assert().Empty(s.ctx.EventManager().Events(), "should not emit events") + s.Assert().Empty(events, "should not emit events") } if len(tc.err) > 0 { @@ -112,12 +114,14 @@ func (s *KeeperTestSuite) TestSendQueryOracle() { s.app.OracleKeeper = s.app.OracleKeeper.WithMockChannelKeeper(&keeper.MockChannelKeeper{}) } res, err := s.msgServer.SendQueryOracle(s.ctx, tc.req) + events := s.ctx.EventManager().Events() + numEvents := len(events) if tc.event != nil { - s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events") - s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event") + s.Assert().Equal(1, numEvents, "should emit the correct number of events") + s.Assert().Equal(*tc.event, events[0], "should emit the correct event") } else { - s.Assert().Empty(s.ctx.EventManager().Events(), "should not emit events") + s.Assert().Empty(events, "should not emit events") } if len(tc.err) > 0 { From 42b0c72e53928e64cc50b0c203e271a648d3bb46 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 5 Sep 2023 09:55:29 -0400 Subject: [PATCH 96/96] Remove State from TOC. --- x/oracle/spec/02_state.md | 1 - 1 file changed, 1 deletion(-) diff --git a/x/oracle/spec/02_state.md b/x/oracle/spec/02_state.md index 9f66f30ddb..a2933086fe 100644 --- a/x/oracle/spec/02_state.md +++ b/x/oracle/spec/02_state.md @@ -7,7 +7,6 @@ order: 2 The oracle module manages the address of the Oracle and the ICQ state. -- [State](#state) - [Oracle](#oracle) - [IBC](#ibc)