diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..b82a78a3 Binary files /dev/null and b/.DS_Store differ diff --git a/app/app.go b/app/app.go index 1ff3e3dc..31336128 100644 --- a/app/app.go +++ b/app/app.go @@ -75,6 +75,7 @@ import ( ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper" ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" oraclemodulekeeper "github.com/onomyprotocol/reserve/x/oracle/keeper" @@ -141,6 +142,8 @@ type App struct { ScopedIBCTransferKeeper capabilitykeeper.ScopedKeeper ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + ScopedKeepers map[string]capabilitykeeper.ScopedKeeper + // ScopedOracleKeeper capabilitykeeper.ScopedKeeper OracleKeeper oraclemodulekeeper.Keeper VaultsKeeper vaultskeeper.Keeper @@ -213,7 +216,7 @@ func New( baseAppOptions ...func(*baseapp.BaseApp), ) (*App, error) { var ( - app = &App{} + app = &App{ScopedKeepers: make(map[string]capabilitykeeper.ScopedKeeper)} appBuilder *runtime.AppBuilder // merge the AppConfig and other configuration in one config @@ -438,7 +441,12 @@ func (app *App) GetIBCKeeper() *ibckeeper.Keeper { // GetCapabilityScopedKeeper returns the capability scoped keeper. func (app *App) GetCapabilityScopedKeeper(moduleName string) capabilitykeeper.ScopedKeeper { - return app.CapabilityKeeper.ScopeToModule(moduleName) + sk, ok := app.ScopedKeepers[moduleName] + if !ok { + sk = app.CapabilityKeeper.ScopeToModule(moduleName) + app.ScopedKeepers[moduleName] = sk + } + return sk } // SimulationManager implements the SimulationApp interface. @@ -459,6 +467,18 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig docs.RegisterOpenAPIService(Name, apiSvr.Router) } +func (app *App) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } + +func (app *App) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { + return app.ScopedIBCKeeper +} + +func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper { + return app.StakingKeeper +} + +func (app *App) GetTxConfig() client.TxConfig { return app.txConfig } + // GetMaccPerms returns a copy of the module account permissions // // NOTE: This is solely to be used for testing purposes. diff --git a/app/ibc.go b/app/ibc.go index fc62eeae..b0d01695 100644 --- a/app/ibc.go +++ b/app/ibc.go @@ -35,9 +35,9 @@ import ( solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - // this line is used by starport scaffolding # ibc/app/import - oraclemodule "github.com/onomyprotocol/reserve/x/oracle/module" + oracle "github.com/onomyprotocol/reserve/x/oracle" oraclemoduletypes "github.com/onomyprotocol/reserve/x/oracle/types" + oraclemodule "github.com/onomyprotocol/reserve/x/oracle/module" ) // registerIBCModules register IBC keepers and non dependency inject modules. @@ -93,7 +93,8 @@ func (app *App) registerIBCModules() error { // by granting the governance module the right to execute the message. // See: https://docs.cosmos.network/main/modules/gov#proposal-messages govRouter := govv1beta1.NewRouter() - govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler) + govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). + AddRoute(oraclemoduletypes.RouterKey, oracle.NewOracleProposalHandler(app.OracleKeeper)) app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( app.appCodec, app.GetKey(ibcfeetypes.StoreKey), @@ -161,6 +162,12 @@ func (app *App) registerIBCModules() error { AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) oracleIBCModule := ibcfee.NewIBCMiddleware(oraclemodule.NewIBCModule(app.OracleKeeper), app.IBCFeeKeeper) + // oracleStack, err := app.registerOracleModule() + // if err != nil { + // return err + // } + + // ibcRouter.AddRoute(oraclemoduletypes.ModuleName, oracleStack) ibcRouter.AddRoute(oraclemoduletypes.ModuleName, oracleIBCModule) // this line is used by starport scaffolding # ibc/app/module @@ -199,6 +206,8 @@ func RegisterIBC(registry cdctypes.InterfaceRegistry) map[string]appmodule.AppMo capabilitytypes.ModuleName: capability.AppModule{}, ibctm.ModuleName: ibctm.AppModule{}, solomachine.ModuleName: solomachine.AppModule{}, + + // oraclemoduletypes.ModuleName: oraclemodule.AppModule{}, } for name, m := range modules { diff --git a/app/oracle.go b/app/oracle.go new file mode 100644 index 00000000..e882f392 --- /dev/null +++ b/app/oracle.go @@ -0,0 +1,56 @@ +package app + +// import ( +// storetypes "cosmossdk.io/store/types" +// oraclekeeper "github.com/onomyprotocol/reserve/x/oracle/keeper" +// oraclemodule "github.com/onomyprotocol/reserve/x/oracle/module" +// oracletypes "github.com/onomyprotocol/reserve/x/oracle/types" +// "github.com/cosmos/cosmos-sdk/runtime" +// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +// ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" +// porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" +// ) + +// // registerOracleModule register Oracle keepers and non dependency inject modules. +// func (app *App) registerOracleModule() (porttypes.IBCModule, error) { +// // set up non depinject support modules store keys +// if err := app.RegisterStores( +// storetypes.NewKVStoreKey(oracletypes.StoreKey), +// ); err != nil { +// panic(err) +// } + +// // register the key tables for legacy param subspaces +// app.ParamsKeeper.Subspace(oracletypes.ModuleName).WithKeyTable(oracletypes.ParamKeyTable()) +// // add capability keeper and ScopeToModule for oracle ibc module +// scopedOralceKeeper := app.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName) + +// app.OracleKeeper = oraclekeeper.NewKeeper( +// app.AppCodec(), +// runtime.NewKVStoreService(app.GetKey(oracletypes.StoreKey)), +// app.Logger(), +// authtypes.NewModuleAddress(oracletypes.ModuleName).String(), +// app.GetIBCKeeper, +// scopedOralceKeeper, +// ) + +// // register IBC modules +// if err := app.RegisterModules( +// oraclemodule.NewAppModule( +// app.AppCodec(), +// app.OracleKeeper, +// app.AccountKeeper, +// app.BankKeeper, +// )); err != nil { +// return nil, err +// } + +// app.ScopedOracleKeeper = scopedOralceKeeper + +// // Create fee enabled ibc stack for oracel +// var oracleStack porttypes.IBCModule +// oracleStack = oraclemodule.NewIBCModule(app.OracleKeeper) +// oracleStack = ibcfee.NewIBCMiddleware(oracleStack, app.IBCFeeKeeper) + +// return oracleStack, nil +// } diff --git a/app/test_helpers.go b/app/test_helpers.go index 45258412..ceb93e9d 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -3,6 +3,7 @@ package app import ( "encoding/json" "testing" + "os" abci "github.com/cometbft/cometbft/abci/types" cmtjson "github.com/cometbft/cometbft/libs/json" @@ -209,3 +210,7 @@ func initAccountWithCoins(app *App, ctx sdk.Context, addr sdk.AccAddress, coins panic(err) } } + +func Cleanup(app *App) { // release cosmwasm instance cache lock + _ = os.RemoveAll(DefaultNodeHome) // remove default dir, if it was overridden during test Setup, it's a responsibility of the sender to remove the folder +} \ No newline at end of file diff --git a/go.mod b/go.mod index bd63cd4d..bd9545c1 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( cosmossdk.io/x/evidence v0.1.0 cosmossdk.io/x/feegrant v0.1.0 cosmossdk.io/x/nft v0.1.0 + cosmossdk.io/x/tx v0.13.1 cosmossdk.io/x/upgrade v0.1.1 github.com/bufbuild/buf v1.30.0 github.com/cometbft/cometbft v0.38.6 @@ -37,6 +38,9 @@ require ( github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 + github.com/pkg/errors v0.9.1 + github.com/rakyll/statik v0.1.7 + github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 @@ -46,6 +50,7 @@ require ( google.golang.org/grpc v1.64.1 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 google.golang.org/protobuf v1.34.2 + gopkg.in/yaml.v2 v2.4.0 ) require ( @@ -56,7 +61,6 @@ require ( cloud.google.com/go/storage v1.38.0 // indirect connectrpc.com/connect v1.15.0 // indirect connectrpc.com/otelconnect v0.7.0 // indirect - cosmossdk.io/x/tx v0.13.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -190,7 +194,6 @@ require ( github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pkg/profile v1.7.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.18.0 // indirect @@ -208,7 +211,6 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.6.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect @@ -245,7 +247,6 @@ require ( google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.6 // indirect diff --git a/go.sum b/go.sum index 557c30ce..b9c3670e 100644 --- a/go.sum +++ b/go.sum @@ -991,6 +991,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= +github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= diff --git a/proto/reserve/oracle/events.proto b/proto/reserve/oracle/events.proto new file mode 100644 index 00000000..7fd5231d --- /dev/null +++ b/proto/reserve/oracle/events.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package reserve.oracle; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/onomyprotocol/reserve/x/oracle/types"; + +message EventBandAckSuccess { + string ack_result = 1; + int64 client_id = 2; + } + +message EventBandAckError { +string ack_error = 1; +int64 client_id = 2; +} + +message EventBandResponseTimeout { int64 client_id = 1; } + +message SetBandPriceEvent { + string relayer = 1; + repeated string symbols = 2; + repeated string prices = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + uint64 resolve_time = 4; + uint64 request_id = 5; + int64 client_id = 6; +} \ No newline at end of file diff --git a/proto/reserve/oracle/genesis.proto b/proto/reserve/oracle/genesis.proto index f67cecee..48a5241f 100644 --- a/proto/reserve/oracle/genesis.proto +++ b/proto/reserve/oracle/genesis.proto @@ -5,6 +5,7 @@ package reserve.oracle; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "reserve/oracle/params.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/onomyprotocol/reserve/x/oracle/types"; @@ -14,5 +15,110 @@ message GenesisState { // params defines all the parameters of the module. Params params = 1 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - string port_id = 2; + BandParams band_params = 2 [ (gogoproto.nullable) = false ]; + repeated BandPriceState band_price_states = 3; + repeated BandOracleRequest band_oracle_requests = 4; + uint64 band_latest_client_id = 5; + repeated CalldataRecord calldata_records = 6; + uint64 band_latest_request_id = 7; + BandOracleRequestParams band_oracle_request_params = 8 [ (gogoproto.nullable) = false ]; +} + +message BandOracleRequest { + // Unique Identifier for band ibc oracle request + uint64 request_id = 1; + + // OracleScriptID is the unique identifier of the oracle script to be + // executed. + int64 oracle_script_id = 2; + + // Symbols is the list of symbols to prepare in the calldata + repeated string symbols = 3; + + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + uint64 ask_count = 4; + + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + uint64 min_count = 5; + + // FeeLimit is the maximum tokens that will be paid to all data source + // providers. + repeated cosmos.base.v1beta1.Coin fee_limit = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + + // PrepareGas is amount of gas to pay to prepare raw requests + uint64 prepare_gas = 7; + // ExecuteGas is amount of gas to reserve for executing + uint64 execute_gas = 8; + // MinSourceCount is the minimum number of data sources that must be used by + // each validator + uint64 min_source_count = 9; +} + +message BandOracleRequestParams { + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + uint64 ask_count = 1; + + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + uint64 min_count = 2; + + // FeeLimit is the maximum tokens that will be paid to all data source + // providers. + repeated cosmos.base.v1beta1.Coin fee_limit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + + // PrepareGas is amount of gas to pay to prepare raw requests + uint64 prepare_gas = 4; + // ExecuteGas is amount of gas to reserve for executing + uint64 execute_gas = 5; + // MinSourceCount is the minimum number of data sources that must be used by + // each validator + uint64 min_source_count = 6; +} + +message BandParams { + // block request interval to send Band IBC prices + int64 ibc_request_interval = 2; + // band IBC source channel + string ibc_source_channel = 3; + // band IBC version + string ibc_version = 4; + // band IBC portID + string ibc_port_id = 5; + // legacy oracle scheme ids + repeated int64 legacy_oracle_ids = 6; +} + +message BandPriceState { + string symbol = 1; + string rate = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + uint64 resolve_time = 3; + uint64 request_ID = 4; + PriceState price_state = 5 [ (gogoproto.nullable) = false ]; +} + +message PriceState { + string price = 1 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + int64 timestamp = 2; +} + +message CalldataRecord { + uint64 client_id = 1; + bytes calldata = 2; } diff --git a/proto/reserve/oracle/packet.proto b/proto/reserve/oracle/packet.proto index 5d68eaec..938efca2 100644 --- a/proto/reserve/oracle/packet.proto +++ b/proto/reserve/oracle/packet.proto @@ -3,8 +3,82 @@ package reserve.oracle; option go_package = "github.com/onomyprotocol/reserve/x/oracle/types"; -message OraclePacketData { - oneof packet { NoData noData = 1; } +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// ResolveStatus encodes the status of an oracle request. +enum ResolveStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // Open - the request is not yet resolved. + RESOLVE_STATUS_OPEN_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = "RESOLVE_STATUS_OPEN" ]; + // Success - the request has been resolved successfully with no errors. + RESOLVE_STATUS_SUCCESS = 1 + [ (gogoproto.enumvalue_customname) = "RESOLVE_STATUS_SUCCESS" ]; + // Failure - an error occured during the request's resolve call. + RESOLVE_STATUS_FAILURE = 2 + [ (gogoproto.enumvalue_customname) = "RESOLVE_STATUS_FAILURE" ]; + // Expired - the request does not get enough reports from validator within the + // timeframe. + RESOLVE_STATUS_EXPIRED = 3 + [ (gogoproto.enumvalue_customname) = "RESOLVE_STATUS_EXPIRED" ]; } -message NoData {} +message OracleRequestPacketData { + option (gogoproto.equal) = true; + // ClientID is the unique identifier of this oracle request, as specified by + // the client. This same unique ID will be sent back to the requester with the + // oracle response. + string client_id = 1 [ (gogoproto.customname) = "ClientID" ]; + // OracleScriptID is the unique identifier of the oracle script to be + // executed. + uint64 oracle_script_id = 2 [ (gogoproto.customname) = "OracleScriptID" ]; + // Calldata is the OBI-encoded calldata bytes available for oracle executor to + // read. + bytes calldata = 3; + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + uint64 ask_count = 4; + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + uint64 min_count = 5; + // FeeLimit is the maximum tokens that will be paid to all data source + // providers. + repeated cosmos.base.v1beta1.Coin fee_limit = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // PrepareGas is amount of gas to pay to prepare raw requests + uint64 prepare_gas = 7; + // ExecuteGas is amount of gas to reserve for executing + uint64 execute_gas = 8; +} + +// OracleResponsePacketData encodes an oracle response from BandChain to the +// requester. +message OracleResponsePacketData { + option (gogoproto.equal) = true; + // ClientID is the unique identifier matched with that of the oracle request + // packet. + string client_id = 1 [ (gogoproto.customname) = "ClientID" ]; + // RequestID is BandChain's unique identifier for this oracle request. + uint64 request_id = 2 [ (gogoproto.customname) = "RequestID" ]; + // AnsCount is the number of validators among to the asked validators that + // actually responded to this oracle request prior to this oracle request + // being resolved. + uint64 ans_count = 3; + // RequestTime is the UNIX epoch time at which the request was sent to + // BandChain. + int64 request_time = 4; + // ResolveTime is the UNIX epoch time at which the request was resolved to the + // final result. + int64 resolve_time = 5; + // ResolveStatus is the status of this oracle request, which can be OK, + // FAILURE, or EXPIRED. + ResolveStatus resolve_status = 6; + // Result is the final aggregated value encoded in OBI format. Only available + // if status if OK. + bytes result = 7; +} diff --git a/proto/reserve/oracle/params.proto b/proto/reserve/oracle/params.proto index e438e6eb..6b8880c0 100644 --- a/proto/reserve/oracle/params.proto +++ b/proto/reserve/oracle/params.proto @@ -10,4 +10,4 @@ option go_package = "github.com/onomyprotocol/reserve/x/oracle/types"; message Params { option (amino.name) = "reserve/x/oracle/Params"; option (gogoproto.equal) = true; -} \ No newline at end of file +} diff --git a/proto/reserve/oracle/proposal.proto b/proto/reserve/oracle/proposal.proto new file mode 100644 index 00000000..34aab324 --- /dev/null +++ b/proto/reserve/oracle/proposal.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; +package reserve.oracle; + +import "reserve/oracle/genesis.proto"; +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/onomyprotocol/reserve/x/oracle/types"; + +message UpdateBandParamsProposal { + option (amino.name) = "oracle/UpdateBandParamsProposal"; + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; + + string title = 1; + string description = 2; + + BandParams band_params = 3 [ (gogoproto.nullable) = false ]; +} + +message UpdateBandOracleRequestProposal { + option (amino.name) = "oracle/UpdateBandOracleRequestProposal"; + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; + + string title = 1; + string description = 2; + BandOracleRequest update_oracle_request = 4; +} + +message DeleteBandOracleRequestProposal { + option (amino.name) = "oracle/UpdateBandOracleRequestProposal"; + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; + + string title = 1; + string description = 2; + repeated uint64 delete_request_ids = 3; +} diff --git a/proto/reserve/oracle/query.proto b/proto/reserve/oracle/query.proto index 8e783c54..b264f68f 100644 --- a/proto/reserve/oracle/query.proto +++ b/proto/reserve/oracle/query.proto @@ -5,6 +5,7 @@ import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "reserve/oracle/params.proto"; +import "reserve/oracle/genesis.proto"; option go_package = "github.com/onomyprotocol/reserve/x/oracle/types"; @@ -14,6 +15,12 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/reserve/oracle/params"; } + // Retrieves the state for all band price feeds + rpc BandPriceStates(QueryBandPriceStatesRequest) + returns (QueryBandPriceStatesResponse) { + option (google.api.http).get = + "/reserve/oracle/band_price_states"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -24,4 +31,14 @@ message QueryParamsResponse { // params holds all the parameters of this module. Params params = 1 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; -} \ No newline at end of file +} + +// QueryBandPriceStatesRequest is the request type for the +// Query/BandPriceStates RPC method. +message QueryBandPriceStatesRequest {} + +// QueryBandPriceStatesResponse is the response type for the +// Query/BandPriceStates RPC method. +message QueryBandPriceStatesResponse { + repeated BandPriceState price_states = 1; +} diff --git a/proto/reserve/oracle/tx.proto b/proto/reserve/oracle/tx.proto index 78587a50..ae46bce4 100644 --- a/proto/reserve/oracle/tx.proto +++ b/proto/reserve/oracle/tx.proto @@ -16,6 +16,8 @@ service Msg { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + rpc RequestBandRates(MsgRequestBandRates) returns (MsgRequestBandRatesResponse); } // MsgUpdateParams is the Msg/UpdateParams request type. @@ -36,4 +38,19 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} + +// MsgRequestBandRates defines a SDK message for requesting data from +// BandChain using IBC. +message MsgRequestBandRates { + option (amino.name) = "oracle/MsgRequestBandRates"; + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "sender"; + + string sender = 1; + uint64 request_id = 2; +} + +// MsgRequestBandRatesResponse defines the Msg/RequestBandRates response type. +message MsgRequestBandRatesResponse {} diff --git a/testutil/keeper/oracle.go b/testutil/keeper/oracle.go index 472c498d..ca8b0fca 100644 --- a/testutil/keeper/oracle.go +++ b/testutil/keeper/oracle.go @@ -57,6 +57,7 @@ func OracleKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { func(string) capabilitykeeper.ScopedKeeper { return scopeModule }, + // scopedKeeper, ) ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) diff --git a/x/.DS_Store b/x/.DS_Store new file mode 100644 index 00000000..987402a5 Binary files /dev/null and b/x/.DS_Store differ diff --git a/x/auction/module/genesis_test.go b/x/auction/module/genesis_test.go index 6410bd4e..5919085b 100644 --- a/x/auction/module/genesis_test.go +++ b/x/auction/module/genesis_test.go @@ -14,7 +14,6 @@ import ( func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ Params: types.DefaultParams(), - PortId: types.PortID, // this line is used by starport scaffolding # genesis/test/state } @@ -26,7 +25,5 @@ func TestGenesis(t *testing.T) { nullify.Fill(&genesisState) nullify.Fill(got) - require.Equal(t, genesisState.PortId, got.PortId) - // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/auction/module/simulation.go b/x/auction/module/simulation.go index b5c5a658..755c2b82 100644 --- a/x/auction/module/simulation.go +++ b/x/auction/module/simulation.go @@ -9,13 +9,11 @@ import ( "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/onomyprotocol/reserve/testutil/sample" - oraclesimulation "github.com/onomyprotocol/reserve/x/oracle/simulation" "github.com/onomyprotocol/reserve/x/oracle/types" ) // avoid unused import issue var ( - _ = oraclesimulation.FindAccount _ = rand.Rand{} _ = sample.AccAddress _ = sdk.AccAddress{} @@ -34,7 +32,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } oracleGenesis := types.GenesisState{ Params: types.DefaultParams(), - PortId: types.PortID, // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&oracleGenesis) diff --git a/x/oracle/.DS_Store b/x/oracle/.DS_Store new file mode 100644 index 00000000..9efb7099 Binary files /dev/null and b/x/oracle/.DS_Store differ diff --git a/x/oracle/bandchain/oracle/types/error.go b/x/oracle/bandchain/oracle/types/error.go new file mode 100644 index 00000000..df4885ca --- /dev/null +++ b/x/oracle/bandchain/oracle/types/error.go @@ -0,0 +1,59 @@ +package types + +import ( + "cosmossdk.io/errors" +) + +var ( + ErrOwasmCompilation = errors.Register(ModuleName, 1, "owasm compilation failed") + ErrBadWasmExecution = errors.Register(ModuleName, 2, "bad wasm execution") + ErrDataSourceNotFound = errors.Register(ModuleName, 3, "data source not found") + ErrOracleScriptNotFound = errors.Register(ModuleName, 4, "oracle script not found") + ErrRequestNotFound = errors.Register(ModuleName, 5, "request not found") + ErrRawRequestNotFound = errors.Register(ModuleName, 6, "raw request not found") + ErrReporterNotFound = errors.Register(ModuleName, 7, "reporter not found") + ErrResultNotFound = errors.Register(ModuleName, 8, "result not found") + ErrReporterAlreadyExists = errors.Register(ModuleName, 9, "reporter already exists") + ErrValidatorNotRequested = errors.Register(ModuleName, 10, "validator not requested") + ErrValidatorAlreadyReported = errors.Register(ModuleName, 11, "validator already reported") + ErrInvalidReportSize = errors.Register(ModuleName, 12, "invalid report size") + ErrReporterNotAuthorized = errors.Register(ModuleName, 13, "reporter not authorized") + ErrEditorNotAuthorized = errors.Register(ModuleName, 14, "editor not authorized") + ErrValidatorAlreadyActive = errors.Register(ModuleName, 16, "validator already active") + ErrTooSoonToActivate = errors.Register(ModuleName, 17, "too soon to activate") + ErrTooLongName = errors.Register(ModuleName, 18, "too long name") + ErrTooLongDescription = errors.Register(ModuleName, 19, "too long description") + ErrEmptyExecutable = errors.Register(ModuleName, 20, "empty executable") + ErrEmptyWasmCode = errors.Register(ModuleName, 21, "empty wasm code") + ErrTooLargeExecutable = errors.Register(ModuleName, 22, "too large executable") + ErrTooLargeWasmCode = errors.Register(ModuleName, 23, "too large wasm code") + ErrInvalidMinCount = errors.Register(ModuleName, 24, "invalid min count") + ErrInvalidAskCount = errors.Register(ModuleName, 25, "invalid ask count") + ErrTooLargeCalldata = errors.Register(ModuleName, 26, "too large calldata") + ErrTooLongClientID = errors.Register(ModuleName, 27, "too long client id") + ErrEmptyRawRequests = errors.Register(ModuleName, 28, "empty raw requests") + ErrEmptyReport = errors.Register(ModuleName, 29, "empty report") + ErrDuplicateExternalID = errors.Register(ModuleName, 30, "duplicate external id") + ErrTooLongSchema = errors.Register(ModuleName, 31, "too long schema") + ErrTooLongURL = errors.Register(ModuleName, 32, "too long url") + ErrTooLargeRawReportData = errors.Register(ModuleName, 33, "too large raw report data") + ErrInsufficientValidators = errors.Register(ModuleName, 34, "insufficient available validators") + ErrCreateWithDoNotModify = errors.Register(ModuleName, 35, "cannot create with [do-not-modify] content") + ErrSelfReferenceAsReporter = errors.Register(ModuleName, 36, "cannot reference self as reporter") + ErrOBIDecode = errors.Register(ModuleName, 37, "obi decode failed") + ErrUncompressionFailed = errors.Register(ModuleName, 38, "uncompression failed") + ErrRequestAlreadyExpired = errors.Register(ModuleName, 39, "request already expired") + ErrBadDrbgInitialization = errors.Register(ModuleName, 40, "bad drbg initialization") + ErrMaxOracleChannels = errors.Register(ModuleName, 41, "max oracle channels") + ErrInvalidVersion = errors.Register(ModuleName, 42, "invalid ICS20 version") + ErrNotEnoughFee = errors.Register(ModuleName, 43, "not enough fee") + ErrInvalidOwasmGas = errors.Register(ModuleName, 44, "invalid owasm gas") + ErrIBCRequestDisabled = errors.Register(ModuleName, 45, "sending oracle request via IBC is disabled") + ErrInvalidRequestKey = errors.Register(ModuleName, 46, "invalid request key") + ErrTooLongRequestKey = errors.Register(ModuleName, 47, "too long request key") +) + +// WrapMaxError wraps an error message with additional info of the current and max values. +func WrapMaxError(err error, got, maximum int) error { + return errors.Wrapf(err, "got: %d, maximum: %d", got, maximum) +} diff --git a/x/oracle/bandchain/oracle/types/id.go b/x/oracle/bandchain/oracle/types/id.go new file mode 100644 index 00000000..84a427d9 --- /dev/null +++ b/x/oracle/bandchain/oracle/types/id.go @@ -0,0 +1,13 @@ +package types + +// DataSourceID is the type-safe unique identifier type for data sources. +type DataSourceID int64 + +// OracleScriptID is the type-safe unique identifier type for oracle scripts. +type OracleScriptID int64 + +// RequestID is the type-safe unique identifier type for data requests. +type RequestID int64 + +// ExternalID is the type-safe unique identifier type for raw data requests. +type ExternalID int64 diff --git a/x/oracle/bandchain/oracle/types/keys.go b/x/oracle/bandchain/oracle/types/keys.go new file mode 100644 index 00000000..404b6841 --- /dev/null +++ b/x/oracle/bandchain/oracle/types/keys.go @@ -0,0 +1,124 @@ +package types + +import ( + "crypto/sha256" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName is the name of the module. + ModuleName = "bandoracle" + + // Version defines the current version the IBC oracle module supports + Version = "bandchain-1" + + // StoreKey to be used when creating the KVStore. + StoreKey = ModuleName + + // QuerierRoute is the querier route for the oracle module + QuerierRoute = ModuleName + + // RouterKey is the msg router key for the oracle module + RouterKey = ModuleName + + // PortID is the default port id that oracle module binds to. + PortID = ModuleName +) + +var ( + // RollingSeedSizeInBytes is the size of rolling block hash for random seed. + RollingSeedSizeInBytes = 32 + // GlobalStoreKeyPrefix is the prefix for global primitive state variables. + GlobalStoreKeyPrefix = []byte{0x00} + // RollingSeedStoreKey is the key that keeps the seed based on the first 8-bit of the most recent 32 block hashes. + RollingSeedStoreKey = append(GlobalStoreKeyPrefix, []byte("RollingSeed")...) + // RequestCountStoreKey is the key that keeps the total request count. + RequestCountStoreKey = append(GlobalStoreKeyPrefix, []byte("RequestCount")...) + // RequestLastExpiredStoreKey is the key that keeps the ID of the last expired request, or 0 if none. + RequestLastExpiredStoreKey = append(GlobalStoreKeyPrefix, []byte("RequestLastExpired")...) + // PendingResolveListStoreKey is the key that keeps the list of pending-resolve requests. + PendingResolveListStoreKey = append(GlobalStoreKeyPrefix, []byte("PendingList")...) + // DataSourceCountStoreKey is the key that keeps the total data source count. + DataSourceCountStoreKey = append(GlobalStoreKeyPrefix, []byte("DataSourceCount")...) + // OracleScriptCountStoreKey is the key that keeps the total oracle sciprt count. + OracleScriptCountStoreKey = append(GlobalStoreKeyPrefix, []byte("OracleScriptCount")...) + + // RequestStoreKeyPrefix is the prefix for request store. + RequestStoreKeyPrefix = []byte{0x01} + // ReportStoreKeyPrefix is the prefix for report store. + ReportStoreKeyPrefix = []byte{0x02} + // DataSourceStoreKeyPrefix is the prefix for data source store. + DataSourceStoreKeyPrefix = []byte{0x03} + // OracleScriptStoreKeyPrefix is the prefix for oracle script store. + OracleScriptStoreKeyPrefix = []byte{0x04} + // ReporterStoreKeyPrefix is the prefix for reporter store. + ReporterStoreKeyPrefix = []byte{0x05} + // ValidatorStatusKeyPrefix is the prefix for validator status store. + ValidatorStatusKeyPrefix = []byte{0x06} + // ResultStoreKeyPrefix is the prefix for request result store. + ResultStoreKeyPrefix = []byte{0xff} + + // PortKey defines the key to store the port ID in store + PortKey = []byte{0xf0} +) + +// RequestStoreKey returns the key to retrieve a specific request from the store. +func RequestStoreKey(requestID RequestID) []byte { + return append(RequestStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(requestID))...) +} + +// ReportStoreKey returns the key to retrieve all data reports for a request. +func ReportStoreKey(requestID RequestID) []byte { + return append(ReportStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(requestID))...) +} + +// DataSourceStoreKey returns the key to retrieve a specific data source from the store. +func DataSourceStoreKey(dataSourceID DataSourceID) []byte { + return append(DataSourceStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(dataSourceID))...) +} + +// OracleScriptStoreKey returns the key to retrieve a specific oracle script from the store. +func OracleScriptStoreKey(oracleScriptID OracleScriptID) []byte { + return append(OracleScriptStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(oracleScriptID))...) +} + +// ReporterStoreKey returns the key to check whether an address is a reporter of a validator. +func ReporterStoreKey(validatorAddress sdk.ValAddress, reporterAddress sdk.AccAddress) []byte { + return append(append(ReporterStoreKeyPrefix, []byte(validatorAddress)...), []byte(reporterAddress)...) +} + +// ValidatorStatusStoreKey returns the key to a validator's status. +func ValidatorStatusStoreKey(v sdk.ValAddress) []byte { + return append(ValidatorStatusKeyPrefix, v.Bytes()...) +} + +// ResultStoreKey returns the key to a request result in the store. +func ResultStoreKey(requestID RequestID) []byte { + return append(ResultStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(requestID))...) +} + +// ReportsOfValidatorPrefixKey returns the prefix key to get all reports for a request from a validator. +func ReportsOfValidatorPrefixKey(reqID RequestID, val sdk.ValAddress) []byte { + return append(append(ReportStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(reqID))...), val.Bytes()...) +} + +// ReportersOfValidatorPrefixKey returns the prefix key to get all reporters of a validator. +func ReportersOfValidatorPrefixKey(val sdk.ValAddress) []byte { + return append(ReporterStoreKeyPrefix, val.Bytes()...) +} + +// GetEscrowAddress returns the escrow address for the specified channel and request key. +// The escrow address follows the format as outlined in ADR 028: +// https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-028-public-key-addresses.md +func GetEscrowAddress(requestKey, portID, channelID string) sdk.AccAddress { + contents := fmt.Sprintf("%s/%s/%s", requestKey, portID, channelID) + + // ADR 028 AddressHash construction + preImage := []byte(Version) + preImage = append(preImage, 0) + preImage = append(preImage, contents...) + hash := sha256.Sum256(preImage) + return hash[:20] +} diff --git a/x/oracle/bandtesting/.DS_Store b/x/oracle/bandtesting/.DS_Store new file mode 100644 index 00000000..defd879a Binary files /dev/null and b/x/oracle/bandtesting/.DS_Store differ diff --git a/x/oracle/bandtesting/app/app.go b/x/oracle/bandtesting/app/app.go new file mode 100644 index 00000000..62325aec --- /dev/null +++ b/x/oracle/bandtesting/app/app.go @@ -0,0 +1,795 @@ +package band + +import ( + "encoding/json" + "github.com/cosmos/cosmos-sdk/runtime" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" + "io" + "net/http" + "os" + "path/filepath" + + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + + reserverapp "github.com/onomyprotocol/reserve/app" + + storetypes "cosmossdk.io/store/types" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" + + "cosmossdk.io/log" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" + abci "github.com/cometbft/cometbft/abci/types" + tmos "github.com/cometbft/cometbft/libs/os" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/server/api" + "github.com/cosmos/cosmos-sdk/server/config" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" + "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + + "github.com/gorilla/mux" + "github.com/rakyll/statik/fs" + "github.com/spf13/cast" + + "cosmossdk.io/x/evidence" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/x/authz" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + "github.com/cosmos/cosmos-sdk/x/crisis" + crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/gov" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/cosmos-sdk/x/mint" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/cosmos/cosmos-sdk/x/params" + paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/cosmos/cosmos-sdk/x/slashing" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + + // unnamed import of statik for swagger UI support + // "github.com/cosmos/cosmos-sdk/client/docs/statik" + + bandoracletypes "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle" + oraclekeeper "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/keeper" +) + +const appName = "BandApp" + +var ( + // DefaultNodeHome default home directories for the application daemon + DefaultNodeHome string + + // ModuleBasics defines the module BasicManager is in charge of setting up basic, + // non-dependant module elements, such as codec registration + // and genesis verification. + ModuleBasics = module.NewBasicManager( + auth.AppModuleBasic{}, + genutil.AppModuleBasic{}, + bank.AppModuleBasic{}, + capability.AppModuleBasic{}, + staking.AppModuleBasic{}, + mint.AppModuleBasic{}, + distr.AppModuleBasic{}, + gov.NewAppModuleBasic( + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + // upgradeclient.LegacyProposalHandler, + // upgradeclient.LegacyCancelProposalHandler, + }, + ), + params.AppModuleBasic{}, + crisis.AppModuleBasic{}, + slashing.AppModuleBasic{}, + ibc.AppModuleBasic{}, + ibctm.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + evidence.AppModuleBasic{}, + vesting.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, + transfer.AppModuleBasic{}, + oracle.AppModuleBasic{}, + ) + // module account permissions + maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + } +) + +var ( + _ runtime.AppI = (*BandApp)(nil) +) + +// BandApp is the application of BandChain, extended base ABCI application. +type BandApp struct { + *baseapp.BaseApp + legacyAmino *codec.LegacyAmino + appCodec codec.Codec + interfaceRegistry types.InterfaceRegistry + + invCheckPeriod uint + // keys to access the substores. + keys map[string]*storetypes.KVStoreKey + tkeys map[string]*storetypes.TransientStoreKey + memKeys map[string]*storetypes.MemoryStoreKey + + // keepers + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper *crisiskeeper.Keeper + UpgradeKeeper *upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + EvidenceKeeper evidencekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + AuthzKeeper authzkeeper.Keeper + OracleKeeper oraclekeeper.Keeper + + // make scoped keepers public for test purposes + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedOracleKeeper capabilitykeeper.ScopedKeeper + + // the module manager + mm *module.Manager + BasicModuleManager module.BasicManager + + sm *module.SimulationManager + + // module configurator + configurator module.Configurator +} + +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, ".band") +} + +// NewBandApp returns a reference to an initialized BandApp. +func NewBandApp( + logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool, + homePath string, invCheckPeriod uint, encodingConfig EncodingConfig, + appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), +) *BandApp { + + appCodec := encodingConfig.Marshaler + legacyAmino := encodingConfig.Amino + interfaceRegistry := encodingConfig.InterfaceRegistry + + bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) + bApp.SetCommitMultiStoreTracer(traceStore) + bApp.SetVersion(version.Version) + bApp.SetInterfaceRegistry(interfaceRegistry) + + keys := storetypes.NewKVStoreKeys( + authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, + minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, + evidencetypes.StoreKey, capabilitytypes.StoreKey, + feegrant.StoreKey, + authzkeeper.StoreKey, + bandoracletypes.StoreKey, + ibcexported.StoreKey, + ibctransfertypes.ModuleName, + crisistypes.StoreKey, + consensustypes.StoreKey, + ) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() + + app := &BandApp{ + BaseApp: bApp, + legacyAmino: legacyAmino, + appCodec: appCodec, + interfaceRegistry: interfaceRegistry, + invCheckPeriod: invCheckPeriod, + keys: keys, + tkeys: tkeys, + memKeys: memKeys, + } + + app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + + // todo put in app + consensusParamsKeeper := consensusparamkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[consensustypes.StoreKey]), + authority, + runtime.EventService{}, + ) + // set the BaseApp's parameter store + bApp.SetParamStore(consensusParamsKeeper.ParamsStore) + + app.UpgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), + appCodec, + homePath, + app.BaseApp, + authority, + ) + + app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) + scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) + scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedOracleKeeper := app.CapabilityKeeper.ScopeToModule(bandoracletypes.ModuleName) + + app.CapabilityKeeper.Seal() + + // add keepers + app.AccountKeeper = authkeeper.NewAccountKeeper( + appCodec, + runtime.NewKVStoreService(keys[authtypes.StoreKey]), + authtypes.ProtoBaseAccount, + maccPerms, + authcodec.NewBech32Codec(reserverapp.AccountAddressPrefix), + reserverapp.AccountAddressPrefix, + authority, + ) + + blockedAddresses := make(map[string]bool) + app.BankKeeper = bankkeeper.NewBaseKeeper( + appCodec, + runtime.NewKVStoreService(keys[banktypes.StoreKey]), + app.AccountKeeper, + blockedAddresses, + authority, + logger, + ) + + stakingKeeper := stakingkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), + app.AccountKeeper, + app.BankKeeper, + authority, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + ) + + app.MintKeeper = mintkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[minttypes.StoreKey]), + stakingKeeper, + app.AccountKeeper, + app.BankKeeper, + authtypes.FeeCollectorName, + authority, + ) + + app.DistrKeeper = distrkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), + app.AccountKeeper, + app.BankKeeper, + stakingKeeper, + authtypes.FeeCollectorName, + authority, + ) + + app.SlashingKeeper = slashingkeeper.NewKeeper( + appCodec, + encodingConfig.Amino, + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), + stakingKeeper, + authority, + ) + + app.CrisisKeeper = crisiskeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), + invCheckPeriod, + app.BankKeeper, + authtypes.FeeCollectorName, + authority, + app.AccountKeeper.AddressCodec(), + ) + + // register the staking hooks + // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks + stakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), + ) + + app.StakingKeeper = *stakingKeeper + + // create IBC Keeper + app.IBCKeeper = ibckeeper.NewKeeper( + appCodec, + keys[ibcexported.StoreKey], + app.GetSubspace(ibcexported.ModuleName), + app.StakingKeeper, + app.UpgradeKeeper, + scopedIBCKeeper, + authority, + ) + + // create evidence keeper with router + evidenceKeeper := evidencekeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), + app.StakingKeeper, + app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), + ) + // If evidence needs to be handled for the app, set routes in router here and seal + app.EvidenceKeeper = *evidenceKeeper + + feegrantKeeper := feegrantkeeper.NewKeeper( + appCodec, runtime.NewKVStoreService(keys[feegrant.StoreKey]), &app.AccountKeeper, + ) + app.FeeGrantKeeper = feegrantKeeper + + authzKeeper := authzkeeper.NewKeeper( + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper, + ) + app.AuthzKeeper = authzKeeper + + // register the proposal types + govRouter := govv1beta1.NewRouter(). + AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) + + govKeeper := govkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[govtypes.StoreKey]), + app.AccountKeeper, + app.BankKeeper, + stakingKeeper, + app.DistrKeeper, + app.MsgServiceRouter(), + govtypes.DefaultConfig(), + authority, + ) + + govKeeper.SetLegacyRouter(govRouter) + + app.GovKeeper = *govKeeper.SetHooks( + govtypes.NewMultiGovHooks( + // register the governance hooks + ), + ) + + // TODO: "the IBC transfer module account has not been set" + // Create Transfer Keepers + app.TransferKeeper = ibctransferkeeper.NewKeeper( + appCodec, + keys[ibctransfertypes.StoreKey], + app.GetSubspace(ibctransfertypes.ModuleName), + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.PortKeeper, + app.AccountKeeper, + app.BankKeeper, + scopedTransferKeeper, + authority, + ) + transferModule := transfer.NewAppModule(app.TransferKeeper) + transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) + + app.OracleKeeper = oraclekeeper.NewKeeper( + appCodec, + keys[bandoracletypes.StoreKey], + app.GetSubspace(bandoracletypes.ModuleName), + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.PortKeeper, + scopedOracleKeeper, + ) + + oracleModule := oracle.NewAppModule(app.OracleKeeper) + + // Create static IBC router, add transfer route, then set and seal it + ibcRouter := porttypes.NewRouter() + ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + ibcRouter.AddRoute(bandoracletypes.ModuleName, oracleModule) + + // Setting Router will finalize all routes by sealing router + // No more routes can be added + app.IBCKeeper.SetRouter(ibcRouter) + + /**** Module Options ****/ + + // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment + // we prefer to be more strict in what arguments the modules expect. + var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + + // NOTE: Any module instantiated in the module manager that is later modified + // must be passed by reference here. + app.mm = module.NewManager( + genutil.NewAppModule( + app.AccountKeeper, app.StakingKeeper, app, + encodingConfig.TxConfig, + ), + auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), + capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), + crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), + gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), + upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), + evidence.NewAppModule(app.EvidenceKeeper), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), + staking.NewAppModule(appCodec, &app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + ibc.NewAppModule(app.IBCKeeper), + params.NewAppModule(app.ParamsKeeper), + transferModule, + oracleModule, + ) + + app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) + app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) + + // NOTE: upgrade module is required to be prioritized + app.mm.SetOrderPreBlockers( + upgradetypes.ModuleName, + ) + + // During begin block slashing happens after distr.BeginBlocker so that + // there is nothing left over in the validator fee pool, so as to keep the + // CanWithdrawInvariant invariant. + // NOTE: staking module is required if HistoricalEntries param > 0 + app.mm.SetOrderBeginBlockers( + evidencetypes.ModuleName, feegrant.ModuleName, + capabilitytypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, authtypes.ModuleName, govtypes.ModuleName, + paramstypes.ModuleName, vestingtypes.ModuleName, banktypes.ModuleName, authz.ModuleName, ibctransfertypes.ModuleName, + minttypes.ModuleName, bandoracletypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, + stakingtypes.ModuleName, ibcexported.ModuleName, + ) + app.mm.SetOrderEndBlockers( + crisistypes.ModuleName, + genutiltypes.ModuleName, vestingtypes.ModuleName, + paramstypes.ModuleName, authtypes.ModuleName, + feegrant.ModuleName, banktypes.ModuleName, authz.ModuleName, ibctransfertypes.ModuleName, + minttypes.ModuleName, slashingtypes.ModuleName, ibctransfertypes.ModuleName, evidencetypes.ModuleName, + capabilitytypes.ModuleName, distrtypes.ModuleName, ibcexported.ModuleName, upgradetypes.ModuleName, + + govtypes.ModuleName, stakingtypes.ModuleName, bandoracletypes.ModuleName, + ) + app.mm.SetOrderMigrations( + crisistypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, authtypes.ModuleName, + banktypes.ModuleName, authz.ModuleName, ibctransfertypes.ModuleName, + minttypes.ModuleName, slashingtypes.ModuleName, ibctransfertypes.ModuleName, evidencetypes.ModuleName, + capabilitytypes.ModuleName, distrtypes.ModuleName, ibcexported.ModuleName, upgradetypes.ModuleName, + govtypes.ModuleName, stakingtypes.ModuleName, bandoracletypes.ModuleName, feegrant.ModuleName, vestingtypes.ModuleName, + ) + + // NOTE: The genutils module must occur after staking so that pools are + // properly initialized with tokens from genesis accounts. + // NOTE: Capability module must occur first so that it can initialize any capabilities + // so that other modules that want to create or claim capabilities afterwards in InitChain + // can do so safely. + app.mm.SetOrderInitGenesis( + capabilitytypes.ModuleName, + upgradetypes.ModuleName, + evidencetypes.ModuleName, feegrant.ModuleName, + authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, + slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, ibcexported.ModuleName, ibctransfertypes.ModuleName, bandoracletypes.ModuleName, crisistypes.ModuleName, + genutiltypes.ModuleName, authz.ModuleName, vestingtypes.ModuleName, paramstypes.ModuleName, + ) + + app.mm.RegisterInvariants(app.CrisisKeeper) + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + err := app.mm.RegisterServices(app.configurator) + if err != nil { + panic(err) + } + + // add test gRPC service for testing gRPC queries in isolation + testdata.RegisterQueryServer(app.GRPCQueryRouter(), testdata.QueryImpl{}) + + overrideModules := map[string]module.AppModuleSimulation{ + authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), + } + app.sm = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules) + app.sm.RegisterStoreDecoders() + + // initialize stores + app.MountKVStores(keys) + app.MountTransientStores(tkeys) + app.MountMemoryStores(memKeys) + + // initialize BaseApp + app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(app.PreBlocker) + app.SetBeginBlocker(app.BeginBlocker) + + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + ) + + if err != nil { + panic(err) + } + app.SetAnteHandler(anteHandler) + app.SetEndBlocker(app.EndBlocker) + if loadLatest { + if err := app.LoadLatestVersion(); err != nil { + tmos.Exit(err.Error()) + } + } + + // app.CapabilityKeeper.Seal() + + app.ScopedIBCKeeper = scopedIBCKeeper + app.ScopedTransferKeeper = scopedTransferKeeper + app.ScopedOracleKeeper = scopedOracleKeeper + + return app +} + +func (app *BandApp) SimulationManager() *module.SimulationManager { + return app.sm +} + +func (app *BandApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (servertypes.ExportedApp, error) { + return servertypes.ExportedApp{}, nil +} + +func (app *BandApp) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } + +func (app *BandApp) GetStakingKeeper() ibctestingtypes.StakingKeeper { return app.StakingKeeper } + +func (app *BandApp) GetIBCKeeper() *ibckeeper.Keeper { return app.IBCKeeper } + +func (app *BandApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { + return app.ScopedIBCKeeper +} + +func (app *BandApp) GetTxConfig() client.TxConfig { return MakeEncodingConfig().TxConfig } + +// Name returns the name of the App +func (app *BandApp) Name() string { return app.BaseApp.Name() } + +// BeginBlocker application updates every begin block +func (app *BandApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.mm.BeginBlock(ctx) +} + +// PreBlocker application updates every pre block +func (app *BandApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.mm.PreBlock(ctx) +} + +// EndBlocker application updates every end block +func (app *BandApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.mm.EndBlock(ctx) +} + +// InitChainer application update at chain initialization +func (app *BandApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { + var genesisState GenesisState + if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { + panic(err) + } + return app.mm.InitGenesis(ctx, app.appCodec, genesisState) +} + +// LoadHeight loads a particular height +func (app *BandApp) LoadHeight(height int64) error { + return app.LoadVersion(height) +} + +// ModuleAccountAddrs returns all the app's module account addresses. +func (app *BandApp) ModuleAccountAddrs() map[string]bool { + modAccAddrs := make(map[string]bool) + for acc := range maccPerms { + modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true + } + + return modAccAddrs +} + +// LegacyAmino returns BandApp's amino codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *BandApp) LegacyAmino() *codec.LegacyAmino { + return app.legacyAmino +} + +// AppCodec returns BandApp's app codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *BandApp) AppCodec() codec.Codec { + return app.appCodec +} + +// InterfaceRegistry returns BandApp's InterfaceRegistry +func (app *BandApp) InterfaceRegistry() types.InterfaceRegistry { + return app.interfaceRegistry +} + +// GetKey returns the KVStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (app *BandApp) GetKey(storeKey string) *storetypes.KVStoreKey { + return app.keys[storeKey] +} + +// GetTKey returns the TransientStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (app *BandApp) GetTKey(storeKey string) *storetypes.TransientStoreKey { + return app.tkeys[storeKey] +} + +// GetMemKey returns the MemStoreKey for the provided mem key. +// +// NOTE: This is solely used for testing purposes. +func (app *BandApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { + return app.memKeys[storeKey] +} + +// GetSubspace returns a param subspace for a given module name. +// +// NOTE: This is solely to be used for testing purposes. +func (app *BandApp) GetSubspace(moduleName string) paramstypes.Subspace { + subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) + return subspace +} + +func (app *BandApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) +} + +// RegisterAPIRoutes registers all application module routes with the provided +// API server. +func (app *BandApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { + clientCtx := apiSvr.ClientCtx + + // Register new tx routes from grpc-gateway. + authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + // Register new tendermint queries routes from grpc-gateway. + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // Register grpc-gateway routes for all modules. + ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // register swagger API from root so that other applications can override easily + if apiConfig.Swagger { + RegisterSwaggerAPI(clientCtx, apiSvr.Router) + } +} + +// RegisterTxService implements the Application.RegisterTxService method. +func (app *BandApp) RegisterTxService(clientCtx client.Context) { + authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) +} + +// RegisterTendermintService implements the Application.RegisterTendermintService method. +func (app *BandApp) RegisterTendermintService(clientCtx client.Context) { + cmtservice.RegisterTendermintService( + clientCtx, + app.BaseApp.GRPCQueryRouter(), + app.interfaceRegistry, + app.Query, + ) +} + +// RegisterSwaggerAPI registers swagger route with API Server +func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) { + statikFS, err := fs.New() + if err != nil { + panic(err) + } + + staticServer := http.FileServer(statikFS) + rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer)) +} + +// GetMaccPerms returns a mapping of the application's module account permissions. +func GetMaccPerms() map[string][]string { + modAccPerms := make(map[string][]string) + for k, v := range maccPerms { + modAccPerms[k] = v + } + return modAccPerms +} + +// initParamsKeeper init params keeper and its subspaces +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { + paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) + + paramsKeeper.Subspace(authtypes.ModuleName) + paramsKeeper.Subspace(banktypes.ModuleName) + paramsKeeper.Subspace(stakingtypes.ModuleName) + paramsKeeper.Subspace(minttypes.ModuleName) + paramsKeeper.Subspace(distrtypes.ModuleName) + paramsKeeper.Subspace(slashingtypes.ModuleName) + paramsKeeper.Subspace(govtypes.ModuleName) + paramsKeeper.Subspace(crisistypes.ModuleName) + paramsKeeper.Subspace(ibcexported.ModuleName) + paramsKeeper.Subspace(ibctransfertypes.ModuleName) + paramsKeeper.Subspace(bandoracletypes.ModuleName) + + return paramsKeeper +} diff --git a/x/oracle/bandtesting/app/encoding.go b/x/oracle/bandtesting/app/encoding.go new file mode 100644 index 00000000..b52952d8 --- /dev/null +++ b/x/oracle/bandtesting/app/encoding.go @@ -0,0 +1,61 @@ +package band + +import ( + "cosmossdk.io/x/tx/signing" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + sdkcodec "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/std" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + "github.com/cosmos/gogoproto/proto" +) + +// EncodingConfig specifies the concrete encoding types to use for a given app. +// This is provided for compatibility between protobuf and amino implementations. +type EncodingConfig struct { + InterfaceRegistry types.InterfaceRegistry + Marshaler codec.Codec + TxConfig client.TxConfig + Amino *codec.LegacyAmino +} + +// MakeEncodingConfig creates an EncodingConfig for testing +func MakeEncodingConfig() EncodingConfig { + interfaceRegistry := NewInterfaceRegistry() + marshaler := sdkcodec.NewProtoCodec(interfaceRegistry) + + encodingConfig := EncodingConfig{ + InterfaceRegistry: interfaceRegistry, + Marshaler: marshaler, + TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes), + Amino: sdkcodec.NewLegacyAmino(), + } + + std.RegisterLegacyAminoCodec(encodingConfig.Amino) + std.RegisterInterfaces(encodingConfig.InterfaceRegistry) + ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) + ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) + return encodingConfig +} + +// NewInterfaceRegistry returns a new InterfaceRegistry +func NewInterfaceRegistry() types.InterfaceRegistry { + registry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, + }) + if err != nil { + panic(err) + } + return registry +} \ No newline at end of file diff --git a/x/oracle/bandtesting/app/genesis.go b/x/oracle/bandtesting/app/genesis.go new file mode 100644 index 00000000..4a8ae852 --- /dev/null +++ b/x/oracle/bandtesting/app/genesis.go @@ -0,0 +1,14 @@ +package band + +import ( + "encoding/json" +) + +// GenesisState defines a type alias for the Band genesis application state. +type GenesisState map[string]json.RawMessage + +// NewDefaultGenesisState generates the default state for the application. +func NewDefaultGenesisState() GenesisState { + encCfg := MakeEncodingConfig() + return ModuleBasics.DefaultGenesis(encCfg.Marshaler) +} diff --git a/x/oracle/bandtesting/x/oracle/abci.go b/x/oracle/bandtesting/x/oracle/abci.go new file mode 100644 index 00000000..1eb2640b --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/abci.go @@ -0,0 +1,17 @@ +package oracle + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/keeper" +) + +// handleEndBlock cleans up the state during end block. See comment in the implementation! +func handleEndBlock(ctx sdk.Context, k keeper.Keeper) { + // Loops through all requests to resolve all of them! + requests := k.GetAllRequests(ctx) + for i := range requests { + k.ProcessRequest(ctx, requests[i]) + } + k.DeleteAllRequests(ctx) +} diff --git a/x/oracle/bandtesting/x/oracle/genesis.go b/x/oracle/bandtesting/x/oracle/genesis.go new file mode 100644 index 00000000..d2097585 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/genesis.go @@ -0,0 +1,30 @@ +package oracle + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/keeper" + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" +) + +// InitGenesis performs genesis initialization for the oracle module. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { + k.SetPort(ctx, types.PortID) + // Only try to bind to port if it is not already bound, since we may already own + // port capability from capability InitGenesis + if !k.IsBound(ctx, types.PortID) { + // transfer module binds to the transfer port on InitChain + // and claims the returned capability + err := k.BindPort(ctx, types.PortID) + if err != nil { + panic(fmt.Sprintf("could not claim port capability: %v", err)) + } + } +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + return &types.GenesisState{} +} diff --git a/x/oracle/bandtesting/x/oracle/keeper/keeper.go b/x/oracle/bandtesting/x/oracle/keeper/keeper.go new file mode 100644 index 00000000..0339ee0f --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/keeper/keeper.go @@ -0,0 +1,86 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + paramstore paramtypes.Subspace + + channelKeeper types.ChannelKeeper + portKeeper types.PortKeeper + scopedKeeper capabilitykeeper.ScopedKeeper +} + +// NewKeeper creates a new oracle Keeper instance. +func NewKeeper( + cdc codec.BinaryCodec, + key storetypes.StoreKey, + ps paramtypes.Subspace, + channelKeeper types.ChannelKeeper, + portKeeper types.PortKeeper, + scopeKeeper capabilitykeeper.ScopedKeeper, +) Keeper { + return Keeper{ + storeKey: key, + cdc: cdc, + paramstore: ps, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + scopedKeeper: scopeKeeper, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// IsBound checks if the transfer module is 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 +} + +// BindPort defines a wrapper function for the ort Keeper's function in +// order to expose it to module's InitGenesis function +func (k Keeper) BindPort(ctx sdk.Context, portID string) error { + capability := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, capability, host.PortPath(portID)) +} + +// 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, capability *capabilitytypes.Capability, name string) bool { + return k.scopedKeeper.AuthenticateCapability(ctx, capability, name) +} + +// ClaimCapability allows the transfer module that can claim a capability that IBC module +// passes to it +func (k Keeper) ClaimCapability(ctx sdk.Context, capability *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, capability, name) +} diff --git a/x/oracle/bandtesting/x/oracle/keeper/owasm.go b/x/oracle/bandtesting/x/oracle/keeper/owasm.go new file mode 100644 index 00000000..2d74d9d2 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/keeper/owasm.go @@ -0,0 +1,27 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" +) + +// PrepareRequest takes an request specification object, performs the prepare call, and saves +// the request object to store. Also emits events related to the request. +func (k Keeper) PrepareRequest( + ctx sdk.Context, + r types.RequestSpec, + ibcChannel *types.IBCChannel, +) (types.RequestID, error) { + + // Create a request object. Note that RawRequestIDs will be populated after preparation is done. + req := types.NewRequest( + r.GetOracleScriptID(), r.GetCalldata(), nil, r.GetMinCount(), + ctx.BlockHeight(), ctx.BlockTime(), r.GetClientID(), nil, ibcChannel, r.GetExecuteGas(), + ) + + // We now have everything we need to the request, so let's add it to the store. + id := k.AddRequest(ctx, req) + + return id, nil +} diff --git a/x/oracle/bandtesting/x/oracle/keeper/relay.go b/x/oracle/bandtesting/x/oracle/keeper/relay.go new file mode 100644 index 00000000..3d820566 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/keeper/relay.go @@ -0,0 +1,20 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" +) + +// OnRecvPacket processes a cross chain oracle request. Data source fees +// are collected from an escrowAddress corresponding to the given requestKey. +func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data types.OracleRequestPacketData) (types.RequestID, error) { + if err := data.ValidateBasic(); err != nil { + return 0, err + } + + ibcChannel := types.NewIBCChannel(packet.DestinationPort, packet.DestinationChannel) + + return k.PrepareRequest(ctx, &data, &ibcChannel) +} diff --git a/x/oracle/bandtesting/x/oracle/keeper/request.go b/x/oracle/bandtesting/x/oracle/keeper/request.go new file mode 100644 index 00000000..f49f73c2 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/keeper/request.go @@ -0,0 +1,91 @@ +package keeper + +import ( + "fmt" + + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" +) + +// GetRequestCount returns the current number of all requests ever exist. +func (k Keeper) GetRequestCount(ctx sdk.Context) uint64 { + bz := ctx.KVStore(k.storeKey).Get(types.RequestCountStoreKey) + return sdk.BigEndianToUint64(bz) +} + +// GetNextRequestID increments and returns the current number of requests. +func (k Keeper) GetNextRequestID(ctx sdk.Context) types.RequestID { + requestNumber := k.GetRequestCount(ctx) + bz := sdk.Uint64ToBigEndian(requestNumber + 1) + ctx.KVStore(k.storeKey).Set(types.RequestCountStoreKey, bz) + return types.RequestID(requestNumber + 1) +} + +// HasRequest checks if the request of this ID exists in the storage. +func (k Keeper) HasRequest(ctx sdk.Context, id types.RequestID) bool { + return ctx.KVStore(k.storeKey).Has(types.RequestStoreKey(id)) +} + +// GetRequest returns the request struct for the given ID or error if not exists. +func (k Keeper) GetRequest(ctx sdk.Context, id types.RequestID) (types.Request, error) { + bz := ctx.KVStore(k.storeKey).Get(types.RequestStoreKey(id)) + if bz == nil { + return types.Request{}, fmt.Errorf("request not found, id: %d", id) + } + var request types.Request + k.cdc.MustUnmarshal(bz, &request) + return request, nil +} + +// MustGetRequest returns the request struct for the given ID. Panics error if not exists. +func (k Keeper) MustGetRequest(ctx sdk.Context, id types.RequestID) types.Request { + request, err := k.GetRequest(ctx, id) + if err != nil { + panic(err) + } + return request +} + +// SetRequest saves the given data request to the store without performing any validation. +func (k Keeper) SetRequest(ctx sdk.Context, id types.RequestID, request types.Request) { + ctx.KVStore(k.storeKey).Set(types.RequestStoreKey(id), k.cdc.MustMarshal(&request)) +} + +// DeleteRequest removes the given data request from the store. +func (k Keeper) DeleteRequest(ctx sdk.Context, id types.RequestID) { + ctx.KVStore(k.storeKey).Delete(types.RequestStoreKey(id)) +} + +// AddRequest attempts to create and save a new request. +func (k Keeper) AddRequest(ctx sdk.Context, req types.Request) types.RequestID { + id := k.GetNextRequestID(ctx) + k.SetRequest(ctx, id, req) + return id +} + +// GetAllRequests returns all requests +func (k Keeper) GetAllRequests(ctx sdk.Context) []types.Request { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.RequestStoreKeyPrefix) + defer iterator.Close() + + requests := []types.Request{} + for ; iterator.Valid(); iterator.Next() { + var request types.Request + k.cdc.MustUnmarshal(iterator.Value(), &request) + requests = append(requests, request) + } + return requests +} + +// DeleteAllRequests delete all requests +func (k Keeper) DeleteAllRequests(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.RequestStoreKeyPrefix) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + store.Delete(iterator.Key()) + } +} diff --git a/x/oracle/bandtesting/x/oracle/keeper/result.go b/x/oracle/bandtesting/x/oracle/keeper/result.go new file mode 100644 index 00000000..239b3cc3 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/keeper/result.go @@ -0,0 +1,61 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" +) + +// ProcessRequest process request. +func (k Keeper) ProcessRequest(ctx sdk.Context, r types.Request) { + if r.IBCChannel != nil { + sourceChannel := r.IBCChannel.ChannelId + sourcePort := r.IBCChannel.PortId + sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) + if !found { + return + } + destinationPort := sourceChannelEnd.Counterparty.PortId + destinationChannel := sourceChannelEnd.Counterparty.ChannelId + sequence, found := k.channelKeeper.GetNextSequenceSend( + ctx, sourcePort, sourceChannel, + ) + if !found { + return + } + channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePort, sourceChannel)) + if !ok { + return + } + + packetData := types.NewOracleResponsePacketData( + r.ClientID, 1, 0, 1577923380, 1577923405, 1, []byte("beeb"), + ) + + packet := channeltypes.NewPacket( + packetData.GetBytes(), + sequence, + sourcePort, + sourceChannel, + destinationPort, + destinationChannel, + clienttypes.ZeroHeight(), + 1577924005000000000, + ) + + if _, err := k.channelKeeper.SendPacket( + ctx, + channelCap, + packet.SourcePort, + packet.SourceChannel, + packet.TimeoutHeight, + packet.TimeoutTimestamp, + packet.Data, + ); err != nil { + panic(err) + } + } +} diff --git a/x/oracle/bandtesting/x/oracle/module.go b/x/oracle/bandtesting/x/oracle/module.go new file mode 100644 index 00000000..930d0e44 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/module.go @@ -0,0 +1,325 @@ +package oracle + +import ( + "context" + "encoding/json" + "fmt" + "math" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "cosmossdk.io/errors" + abci "github.com/cometbft/cometbft/abci/types" + "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" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/module" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + "github.com/cosmos/ibc-go/v8/modules/core/exported" + + oraclekeeper "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/keeper" + "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" + +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic is Band Oracle's module basic object. +type AppModuleBasic struct{} + +// Name returns this module's name - "oracle" (SDK AppModuleBasic interface). +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the oracle module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns the default genesis state as raw bytes. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// Validation check of the Genesis +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var gs types.GenesisState + err := cdc.UnmarshalJSON(bz, &gs) + if err != nil { + return err + } + return gs.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the oracle module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serverMux *runtime.ServeMux) { +} + +// GetTxCmd returns cobra CLI command to send txs for this module (SDK AppModuleBasic interface). +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns cobra CLI command to query chain state (SDK AppModuleBasic interface). +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return nil +} + +// AppModule represents the AppModule for this module. +type AppModule struct { + AppModuleBasic + keeper oraclekeeper.Keeper +} + +// NewAppModule creates a new AppModule object. +func NewAppModule(k oraclekeeper.Keeper) AppModule { + return AppModule{ + keeper: k, + } +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (AppModule) IsAppModule() {} + +// RegisterInvariants is a noop function to satisfy SDK AppModule interface. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} + +// QuerierRoute returns the oracle module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { +} + +// BeginBlock processes ABCI begin block message for this oracle module (SDK AppModule interface). +func (am AppModule) BeginBlock(_ context.Context) error { + return nil +} + +// EndBlock processes ABCI end block message for this oracle module (SDK AppModule interface). +func (am AppModule) EndBlock(ctx context.Context) error { + handleEndBlock(sdk.UnwrapSDKContext(ctx), am.keeper) + return nil +} + +// InitGenesis performs genesis initialization for the oracle module. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + InitGenesis(ctx, am.keeper, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the current state as genesis raw bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(gs) +} + +// ____________________________________________________________________________ + +// ValidateOracleChannelParams does validation of a newly created oracle channel. A oracle +// channel must be UNORDERED, use the correct port (by default 'oracle'), and use the current +// supported version. Only 2^32 channels are allowed to be created. +func ValidateOracleChannelParams( + ctx sdk.Context, + keeper oraclekeeper.Keeper, + order channeltypes.Order, + portID string, + channelID string, +) error { + // NOTE: for escrow address security only 2^32 channels are allowed to be created + // Issue: https://github.com/cosmos/cosmos-sdk/issues/7737 + channelSequence, err := channeltypes.ParseChannelSequence(channelID) + if err != nil { + return err + } + if channelSequence > uint64(math.MaxUint32) { + return fmt.Errorf("channel sequence %d is greater than max allowed oracle channels %d", channelSequence, uint64(math.MaxUint32)) + } + if order != channeltypes.UNORDERED { + return errors.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s ", channeltypes.UNORDERED, order) + } + + // Require portID is the portID oracle module is bound to + boundPort := keeper.GetPort(ctx) + if boundPort != portID { + return errors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + } + + return nil +} + +// OnChanOpenInit implements the IBCModule interface +func (am AppModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + if err := ValidateOracleChannelParams(ctx, am.keeper, order, portID, channelID); err != nil { + return "", err + } + + if version != types.Version { + return "", fmt.Errorf("got %s, expected %s", version, types.Version) + } + + // Claim channel capability passed back by IBC module + if err := am.keeper.ClaimCapability(ctx, channelCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + + return version, 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) { + if err := ValidateOracleChannelParams(ctx, am.keeper, order, portID, channelID); err != nil { + return "", err + } + + if counterpartyVersion != types.Version { + return "", fmt.Errorf("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 fmt.Errorf("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 oracle channels + return errors.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, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) exported.Acknowledgement { + + var data types.OracleRequestPacketData + if err := types.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { + return channeltypes.NewErrorAcknowledgement(fmt.Errorf("cannot unmarshal oracle request packet data: %w", err)) + } + + cacheCtx, writeFn := ctx.CacheContext() + id, err := am.keeper.OnRecvPacket(cacheCtx, packet, data) + + var acknowledgement channeltypes.Acknowledgement + if err != nil { + acknowledgement = channeltypes.NewErrorAcknowledgement(err) + } else { + writeFn() + acknowledgement = channeltypes.NewResultAcknowledgement(types.ModuleCdc.MustMarshalJSON(types.NewOracleRequestPacketAcknowledgement(id))) + } + + // NOTE: acknowledgement will be written synchronously during IBC handler execution. + return acknowledgement +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (am AppModule) OnAcknowledgementPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + // Do nothing for out-going packet + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (am AppModule) OnTimeoutPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + relayer sdk.AccAddress, +) error { + // Do nothing for out-going packet + return nil +} + +func (am AppModule) ConsensusVersion() uint64 { + return 1 +} diff --git a/x/oracle/bandtesting/x/oracle/types/channel.go b/x/oracle/bandtesting/x/oracle/types/channel.go new file mode 100644 index 00000000..33aa45b3 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/channel.go @@ -0,0 +1,9 @@ +package types + +// NewIBCChannel creates a new IBCChannel instance. +func NewIBCChannel(portId, channelId string) IBCChannel { + return IBCChannel{ + PortId: portId, + ChannelId: channelId, + } +} diff --git a/x/oracle/bandtesting/x/oracle/types/codec.go b/x/oracle/bandtesting/x/oracle/types/codec.go new file mode 100644 index 00000000..400740fa --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/codec.go @@ -0,0 +1,39 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// RegisterLegacyAminoCodec registers the necessary x/oracle interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + // nolint:all + // cdc.RegisterConcrete(OracleRequestPacketData{}, "oracle/OracleRequestPacketData", nil) + // cdc.RegisterConcrete(OracleResponsePacketData{}, "oracle/OracleResponsePacketData", nil) +} + +// RegisterInterfaces register the oracle module interfaces to protobuf Any. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil)) +} + +var ( + // ModuleCdc references the global x/oracle module codec. Note, the codec + // should ONLY be used in certain instances of tests and for JSON encoding. + // + // The actual codec used for serialization should be provided to x/oracle and + // defined at the application level. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino json compatible msgs. + AminoCdc = codec.NewLegacyAmino() +) + +func init() { + RegisterLegacyAminoCodec(AminoCdc) + cryptocodec.RegisterCrypto(AminoCdc) + AminoCdc.Seal() +} diff --git a/x/oracle/bandtesting/x/oracle/types/constants.go b/x/oracle/bandtesting/x/oracle/types/constants.go new file mode 100644 index 00000000..ed87dec1 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/constants.go @@ -0,0 +1,23 @@ +package types + +// nolint +const ( + DoNotModify = "[do-not-modify]" + + MaxNameLength = 128 + MaxDescriptionLength = 4096 + MaxClientIDLength = 128 + MaxSchemaLength = 512 + MaxURLLength = 128 + + MaxExecutableSize = 8 * 1024 // 8kB + MaxWasmCodeSize = 512 * 1024 // 512kB + MaxCompiledWasmCodeSize = 1 * 1024 * 1024 // 1MB + + MaximumOwasmGas = 8000000 // The same as block gas limit +) + +// nolint +var ( + DoNotModifyBytes = []byte(DoNotModify) +) diff --git a/x/oracle/bandtesting/x/oracle/types/expected_keepers.go b/x/oracle/bandtesting/x/oracle/types/expected_keepers.go new file mode 100644 index 00000000..82907899 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/expected_keepers.go @@ -0,0 +1,28 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" +) + +// ChannelKeeper defines the expected IBC channel keeper +type ChannelKeeper interface { + GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) + SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + data []byte, + ) (sequence uint64, err error) +} + +// PortKeeper defines the expected IBC port keeper +type PortKeeper interface { + BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability +} diff --git a/x/oracle/bandtesting/x/oracle/types/genesis.go b/x/oracle/bandtesting/x/oracle/types/genesis.go new file mode 100644 index 00000000..8ecefb48 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/genesis.go @@ -0,0 +1,40 @@ +package types + +import ( + "encoding/json" + + "github.com/cosmos/cosmos-sdk/codec" +) + +// NewGenesisState creates a new GenesisState instanc e +func NewGenesisState(params Params, dataSources []DataSource, oracleScripts []OracleScript) *GenesisState { + return &GenesisState{ + Params: params, + DataSources: dataSources, + OracleScripts: oracleScripts, + } +} + +// DefaultGenesisState returns the default oracle genesis state. +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + DataSources: []DataSource{}, + OracleScripts: []OracleScript{}, + } +} + +// GetGenesisStateFromAppState returns oracle GenesisState given raw application genesis state. +func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState { + var genesisState GenesisState + + if appState[ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) + } + + return &genesisState +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (g GenesisState) Validate() error { return nil } diff --git a/x/oracle/bandtesting/x/oracle/types/genesis.pb.go b/x/oracle/bandtesting/x/oracle/types/genesis.pb.go new file mode 100644 index 00000000..86c995dd --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/genesis.pb.go @@ -0,0 +1,453 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: oracle/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 { + // Params defines all the paramaters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // DataSources are data sources to be installed during genesis phase + DataSources []DataSource `protobuf:"bytes,2,rep,name=data_sources,json=dataSources,proto3" json:"data_sources"` + // OracleScripts are list of oracle scripts to be installed during genesis + // phase + OracleScripts []OracleScript `protobuf:"bytes,3,rep,name=oracle_scripts,json=oracleScripts,proto3" json:"oracle_scripts"` +} + +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_14b982a0a6345d1d, []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 (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetDataSources() []DataSource { + if m != nil { + return m.DataSources + } + return nil +} + +func (m *GenesisState) GetOracleScripts() []OracleScript { + if m != nil { + return m.OracleScripts + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "oracle.v1.GenesisState") +} + +func init() { proto.RegisterFile("oracle/v1/genesis.proto", fileDescriptor_14b982a0a6345d1d) } + +var fileDescriptor_14b982a0a6345d1d = []byte{ + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x2f, 0x4a, 0x4c, + 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0x48, 0xe8, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, + 0x83, 0x45, 0xf5, 0x41, 0x2c, 0x88, 0x02, 0x29, 0x31, 0x84, 0x4e, 0xa8, 0x52, 0xb0, 0xb8, 0xd2, + 0x51, 0x46, 0x2e, 0x1e, 0x77, 0x88, 0x51, 0xc1, 0x25, 0x89, 0x25, 0xa9, 0x42, 0xfa, 0x5c, 0x6c, + 0x05, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x82, 0x7a, 0x70, + 0xa3, 0xf5, 0x02, 0xc0, 0x12, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x95, 0x09, 0xd9, + 0x71, 0xf1, 0xa4, 0x24, 0x96, 0x24, 0xc6, 0x17, 0xe7, 0x97, 0x16, 0x25, 0xa7, 0x16, 0x4b, 0x30, + 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x89, 0x22, 0x69, 0x73, 0x49, 0x2c, 0x49, 0x0c, 0x06, 0xcb, 0x42, + 0xb5, 0x72, 0xa7, 0xc0, 0x45, 0x8a, 0x85, 0x5c, 0xb8, 0xf8, 0x20, 0x4a, 0xe3, 0x8b, 0x93, 0x8b, + 0x32, 0x0b, 0x4a, 0x8a, 0x25, 0x98, 0xc1, 0x26, 0x88, 0x23, 0x99, 0xe0, 0x0f, 0x66, 0x05, 0x83, + 0xe5, 0xa1, 0x66, 0xf0, 0xe6, 0x23, 0x89, 0x15, 0x3b, 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, + 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, + 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, + 0x7e, 0x52, 0x62, 0x5e, 0x0a, 0xd8, 0xdf, 0xc9, 0xf9, 0x39, 0xfa, 0xc9, 0x19, 0x89, 0x99, 0x79, + 0xfa, 0x15, 0xd0, 0xf0, 0xd0, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x4b, 0x1b, 0x03, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x21, 0x1c, 0xeb, 0x6a, 0x01, 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 len(m.OracleScripts) > 0 { + for iNdEx := len(m.OracleScripts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OracleScripts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.DataSources) > 0 { + for iNdEx := len(m.DataSources) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DataSources[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + 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 + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.DataSources) > 0 { + for _, e := range m.DataSources { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OracleScripts) > 0 { + for _, e := range m.OracleScripts { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + 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 != 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DataSources", 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 + } + m.DataSources = append(m.DataSources, DataSource{}) + if err := m.DataSources[len(m.DataSources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScripts", 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 + } + m.OracleScripts = append(m.OracleScripts, OracleScript{}) + if err := m.OracleScripts[len(m.OracleScripts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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/bandtesting/x/oracle/types/id.go b/x/oracle/bandtesting/x/oracle/types/id.go new file mode 100644 index 00000000..a9348da2 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/id.go @@ -0,0 +1,13 @@ +package types + +// DataSourceID is the type-safe unique identifier type for data sources. +type DataSourceID uint64 + +// OracleScriptID is the type-safe unique identifier type for oracle scripts. +type OracleScriptID uint64 + +// RequestID is the type-safe unique identifier type for data requests. +type RequestID uint64 + +// ExternalID is the type-safe unique identifier type for raw data requests. +type ExternalID uint64 diff --git a/x/oracle/bandtesting/x/oracle/types/keys.go b/x/oracle/bandtesting/x/oracle/types/keys.go new file mode 100644 index 00000000..b46c3538 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/keys.go @@ -0,0 +1,98 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName is the name of the module. + ModuleName = "oracle" + + // Version defines the current version the IBC oracle module supports + Version = "bandchain-1" + + // StoreKey to be used when creating the KVStore. + StoreKey = ModuleName + + // QuerierRoute is the querier route for the oracle module + QuerierRoute = ModuleName + + // RouterKey is the msg router key for the oracle module + RouterKey = ModuleName + + // PortID is the default port id that oracle module binds to. + PortID = ModuleName +) + +var ( + // RollingSeedSizeInBytes is the size of rolling block hash for random seed. + RollingSeedSizeInBytes = 32 + // GlobalStoreKeyPrefix is the prefix for global primitive state variables. + GlobalStoreKeyPrefix = []byte{0x00} + // RollingSeedStoreKey is the key that keeps the seed based on the first 8-bit of the most recent 32 block hashes. + RollingSeedStoreKey = append(GlobalStoreKeyPrefix, []byte("RollingSeed")...) + // RequestCountStoreKey is the key that keeps the total request count. + RequestCountStoreKey = append(GlobalStoreKeyPrefix, []byte("RequestCount")...) + // RequestLastExpiredStoreKey is the key that keeps the ID of the last expired request, or 0 if none. + RequestLastExpiredStoreKey = append(GlobalStoreKeyPrefix, []byte("RequestLastExpired")...) + // PendingResolveListStoreKey is the key that keeps the list of pending-resolve requests. + PendingResolveListStoreKey = append(GlobalStoreKeyPrefix, []byte("PendingList")...) + // DataSourceCountStoreKey is the key that keeps the total data source count. + DataSourceCountStoreKey = append(GlobalStoreKeyPrefix, []byte("DataSourceCount")...) + // OracleScriptCountStoreKey is the key that keeps the total oracle sciprt count. + OracleScriptCountStoreKey = append(GlobalStoreKeyPrefix, []byte("OracleScriptCount")...) + + // RequestStoreKeyPrefix is the prefix for request store. + RequestStoreKeyPrefix = []byte{0x01} + // ReportStoreKeyPrefix is the prefix for report store. + ReportStoreKeyPrefix = []byte{0x02} + // DataSourceStoreKeyPrefix is the prefix for data source store. + DataSourceStoreKeyPrefix = []byte{0x03} + // OracleScriptStoreKeyPrefix is the prefix for oracle script store. + OracleScriptStoreKeyPrefix = []byte{0x04} + // ValidatorStatusKeyPrefix is the prefix for validator status store. + ValidatorStatusKeyPrefix = []byte{0x05} + // ResultStoreKeyPrefix is the prefix for request result store. + ResultStoreKeyPrefix = []byte{0xff} + + // PortKey defines the key to store the port ID in store + PortKey = []byte{0xf0} +) + +// RequestStoreKey returns the key to retrieve a specific request from the store. +func RequestStoreKey(requestID RequestID) []byte { + return append(RequestStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(requestID))...) +} + +// ReportStoreKey returns the key to retrieve all data reports for a request. +func ReportStoreKey(requestID RequestID) []byte { + return append(ReportStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(requestID))...) +} + +// DataSourceStoreKey returns the key to retrieve a specific data source from the store. +func DataSourceStoreKey(dataSourceID DataSourceID) []byte { + return append(DataSourceStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(dataSourceID))...) +} + +// OracleScriptStoreKey returns the key to retrieve a specific oracle script from the store. +func OracleScriptStoreKey(oracleScriptID OracleScriptID) []byte { + return append(OracleScriptStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(oracleScriptID))...) +} + +// ValidatorStatusStoreKey returns the key to a validator's status. +func ValidatorStatusStoreKey(v sdk.ValAddress) []byte { + return append(ValidatorStatusKeyPrefix, v.Bytes()...) +} + +// ResultStoreKey returns the key to a request result in the store. +func ResultStoreKey(requestID RequestID) []byte { + return append(ResultStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(requestID))...) +} + +// ReportsOfValidatorPrefixKey returns the prefix key to get all reports for a request from a validator. +func ReportsOfValidatorPrefixKey(reqID RequestID, val sdk.ValAddress) []byte { + buf := ReportStoreKeyPrefix + buf = append(buf, sdk.Uint64ToBigEndian(uint64(reqID))...) + buf = append(buf, val.Bytes()...) + return buf +} diff --git a/x/oracle/bandtesting/x/oracle/types/oracle.pb.go b/x/oracle/bandtesting/x/oracle/types/oracle.pb.go new file mode 100644 index 00000000..2b50fe4b --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/oracle.pb.go @@ -0,0 +1,6774 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: oracle/v1/oracle.proto + +package types + +import ( + bytes "bytes" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_gogo_protobuf_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 + +// ResolveStatus encodes the status of an oracle request. +type ResolveStatus int32 + +const ( + // Open - the request is not yet resolved. + RESOLVE_STATUS_OPEN ResolveStatus = 0 + // Success - the request has been resolved successfully with no errors. + RESOLVE_STATUS_SUCCESS ResolveStatus = 1 + // Failure - an error occured during the request's resolve call. + RESOLVE_STATUS_FAILURE ResolveStatus = 2 + // Expired - the request does not get enough reports from validator within the + // timeframe. + RESOLVE_STATUS_EXPIRED ResolveStatus = 3 +) + +var ResolveStatus_name = map[int32]string{ + 0: "RESOLVE_STATUS_OPEN_UNSPECIFIED", + 1: "RESOLVE_STATUS_SUCCESS", + 2: "RESOLVE_STATUS_FAILURE", + 3: "RESOLVE_STATUS_EXPIRED", +} + +var ResolveStatus_value = map[string]int32{ + "RESOLVE_STATUS_OPEN_UNSPECIFIED": 0, + "RESOLVE_STATUS_SUCCESS": 1, + "RESOLVE_STATUS_FAILURE": 2, + "RESOLVE_STATUS_EXPIRED": 3, +} + +func (x ResolveStatus) String() string { + return proto.EnumName(ResolveStatus_name, int32(x)) +} + +func (ResolveStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{0} +} + +// DataSource is the data structure for storing data sources in the storage. +type DataSource struct { + // Owner is an address of the account who own the data source + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // Name is data source name used for display + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Description is data source description used for display + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // Filename is string of file name used as reference for locating + // data source file stored in bandchain nodes + Filename string `protobuf:"bytes,4,opt,name=filename,proto3" json:"filename,omitempty"` + // Treasury is the account address who receive data source fee from requester. + Treasury string `protobuf:"bytes,5,opt,name=treasury,proto3" json:"treasury,omitempty"` + // Fee is the data source fee per ask_count that data provider will receive + // from requester. + Fee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=fee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee"` +} + +func (m *DataSource) Reset() { *m = DataSource{} } +func (m *DataSource) String() string { return proto.CompactTextString(m) } +func (*DataSource) ProtoMessage() {} +func (*DataSource) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{0} +} +func (m *DataSource) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DataSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DataSource.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 *DataSource) XXX_Merge(src proto.Message) { + xxx_messageInfo_DataSource.Merge(m, src) +} +func (m *DataSource) XXX_Size() int { + return m.Size() +} +func (m *DataSource) XXX_DiscardUnknown() { + xxx_messageInfo_DataSource.DiscardUnknown(m) +} + +var xxx_messageInfo_DataSource proto.InternalMessageInfo + +func (m *DataSource) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *DataSource) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *DataSource) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *DataSource) GetFilename() string { + if m != nil { + return m.Filename + } + return "" +} + +func (m *DataSource) GetTreasury() string { + if m != nil { + return m.Treasury + } + return "" +} + +func (m *DataSource) GetFee() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Fee + } + return nil +} + +// OracleScript is the data structure for storing oracle scripts in the storage. +type OracleScript struct { + // Owner is an address of the account who own the oracle script + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // Name is oracle script name used for display + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Description is oracle script description used for display + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // Filename is string of file name used as reference for locating + // compiled oracle script WASM file stored in bandchain nodes + Filename string `protobuf:"bytes,4,opt,name=filename,proto3" json:"filename,omitempty"` + // Schema is the schema of the oracle script input/output + // which is formatted in OBI format e.g. + // "{symbol:string,multiplier:u64}/{px:u64}" + Schema string `protobuf:"bytes,5,opt,name=schema,proto3" json:"schema,omitempty"` + // SourceCodeURL is the URL of oracle script's source code. + // It is recommendded to store source code on IPFS and get its URL to preserve + // decentralization. + SourceCodeURL string `protobuf:"bytes,6,opt,name=source_code_url,json=sourceCodeUrl,proto3" json:"source_code_url,omitempty"` +} + +func (m *OracleScript) Reset() { *m = OracleScript{} } +func (m *OracleScript) String() string { return proto.CompactTextString(m) } +func (*OracleScript) ProtoMessage() {} +func (*OracleScript) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{1} +} +func (m *OracleScript) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleScript) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleScript.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 *OracleScript) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleScript.Merge(m, src) +} +func (m *OracleScript) XXX_Size() int { + return m.Size() +} +func (m *OracleScript) XXX_DiscardUnknown() { + xxx_messageInfo_OracleScript.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleScript proto.InternalMessageInfo + +func (m *OracleScript) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *OracleScript) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *OracleScript) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *OracleScript) GetFilename() string { + if m != nil { + return m.Filename + } + return "" +} + +func (m *OracleScript) GetSchema() string { + if m != nil { + return m.Schema + } + return "" +} + +func (m *OracleScript) GetSourceCodeURL() string { + if m != nil { + return m.SourceCodeURL + } + return "" +} + +// RawRequest is the data structure for storing raw requests in the storage. +type RawRequest struct { + // ExternalID is an ID of the raw request + ExternalID ExternalID `protobuf:"varint,1,opt,name=external_id,json=externalId,proto3,casttype=ExternalID" json:"external_id,omitempty"` + // DataSourceID is an ID of data source script that relates to the raw request + DataSourceID DataSourceID `protobuf:"varint,2,opt,name=data_source_id,json=dataSourceId,proto3,casttype=DataSourceID" json:"data_source_id,omitempty"` + // Calldata is the data used as argument params for executing data source + // script + Calldata []byte `protobuf:"bytes,3,opt,name=calldata,proto3" json:"calldata,omitempty"` +} + +func (m *RawRequest) Reset() { *m = RawRequest{} } +func (m *RawRequest) String() string { return proto.CompactTextString(m) } +func (*RawRequest) ProtoMessage() {} +func (*RawRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{2} +} +func (m *RawRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawRequest.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 *RawRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawRequest.Merge(m, src) +} +func (m *RawRequest) XXX_Size() int { + return m.Size() +} +func (m *RawRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RawRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RawRequest proto.InternalMessageInfo + +func (m *RawRequest) GetExternalID() ExternalID { + if m != nil { + return m.ExternalID + } + return 0 +} + +func (m *RawRequest) GetDataSourceID() DataSourceID { + if m != nil { + return m.DataSourceID + } + return 0 +} + +func (m *RawRequest) GetCalldata() []byte { + if m != nil { + return m.Calldata + } + return nil +} + +// RawRequest is the data structure for storing raw reporter in the storage. +type RawReport struct { + // ExternalID is an ID of the raw request + ExternalID ExternalID `protobuf:"varint,1,opt,name=external_id,json=externalId,proto3,casttype=ExternalID" json:"external_id,omitempty"` + // ExitCode is status code provided by validators to specify error, if any. + // Exit code is usually filled by the exit code returned from execution of + // specified data source script. With code 0 means there is no error. + ExitCode uint32 `protobuf:"varint,2,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` + // Data is raw result provided by validators. + // It is usually filled by the result from execution of specified data source + // script. + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *RawReport) Reset() { *m = RawReport{} } +func (m *RawReport) String() string { return proto.CompactTextString(m) } +func (*RawReport) ProtoMessage() {} +func (*RawReport) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{3} +} +func (m *RawReport) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawReport) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawReport.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 *RawReport) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawReport.Merge(m, src) +} +func (m *RawReport) XXX_Size() int { + return m.Size() +} +func (m *RawReport) XXX_DiscardUnknown() { + xxx_messageInfo_RawReport.DiscardUnknown(m) +} + +var xxx_messageInfo_RawReport proto.InternalMessageInfo + +func (m *RawReport) GetExternalID() ExternalID { + if m != nil { + return m.ExternalID + } + return 0 +} + +func (m *RawReport) GetExitCode() uint32 { + if m != nil { + return m.ExitCode + } + return 0 +} + +func (m *RawReport) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +// Request is the data structure for storing requests in the storage. +type Request struct { + // OracleScriptID is ID of an oracle script + OracleScriptID OracleScriptID `protobuf:"varint,1,opt,name=oracle_script_id,json=oracleScriptId,proto3,casttype=OracleScriptID" json:"oracle_script_id,omitempty"` + // Calldata is the data used as argument params for the oracle script + Calldata []byte `protobuf:"bytes,2,opt,name=calldata,proto3" json:"calldata,omitempty"` + // RequestedValidators is a list of validator addresses that are assigned for + // fulfilling the request + RequestedValidators []string `protobuf:"bytes,3,rep,name=requested_validators,json=requestedValidators,proto3" json:"requested_validators,omitempty"` + // MinCount is minimum number of validators required for fulfilling the + // request + MinCount uint64 `protobuf:"varint,4,opt,name=min_count,json=minCount,proto3" json:"min_count,omitempty"` + // RequestHeight is block height that the request has been created + RequestHeight int64 `protobuf:"varint,5,opt,name=request_height,json=requestHeight,proto3" json:"request_height,omitempty"` + // RequestTime is timestamp of the chain's block which contains the request + RequestTime int64 `protobuf:"varint,6,opt,name=request_time,json=requestTime,proto3" json:"request_time,omitempty"` + // ClientID is arbitrary id provided by requester. + // It is used by client-side for referencing the request + ClientID string `protobuf:"bytes,7,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // RawRequests is a list of raw requests specified by execution of oracle + // script + RawRequests []RawRequest `protobuf:"bytes,8,rep,name=raw_requests,json=rawRequests,proto3" json:"raw_requests"` + // IBCChannel is an IBC channel info of the other chain, which contains a + // channel and a port to allow bandchain connect to that chain. This field + // allows other chain be able to request data from bandchain via IBC. + IBCChannel *IBCChannel `protobuf:"bytes,9,opt,name=ibc_channel,json=ibcChannel,proto3" json:"ibc_channel,omitempty"` + // ExecuteGas is amount of gas to reserve for executing + ExecuteGas uint64 `protobuf:"varint,10,opt,name=execute_gas,json=executeGas,proto3" json:"execute_gas,omitempty"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} +func (*Request) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{4} +} +func (m *Request) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Request.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 *Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Request.Merge(m, src) +} +func (m *Request) XXX_Size() int { + return m.Size() +} +func (m *Request) XXX_DiscardUnknown() { + xxx_messageInfo_Request.DiscardUnknown(m) +} + +var xxx_messageInfo_Request proto.InternalMessageInfo + +func (m *Request) GetOracleScriptID() OracleScriptID { + if m != nil { + return m.OracleScriptID + } + return 0 +} + +func (m *Request) GetCalldata() []byte { + if m != nil { + return m.Calldata + } + return nil +} + +func (m *Request) GetRequestedValidators() []string { + if m != nil { + return m.RequestedValidators + } + return nil +} + +func (m *Request) GetMinCount() uint64 { + if m != nil { + return m.MinCount + } + return 0 +} + +func (m *Request) GetRequestHeight() int64 { + if m != nil { + return m.RequestHeight + } + return 0 +} + +func (m *Request) GetRequestTime() int64 { + if m != nil { + return m.RequestTime + } + return 0 +} + +func (m *Request) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *Request) GetRawRequests() []RawRequest { + if m != nil { + return m.RawRequests + } + return nil +} + +func (m *Request) GetIBCChannel() *IBCChannel { + if m != nil { + return m.IBCChannel + } + return nil +} + +func (m *Request) GetExecuteGas() uint64 { + if m != nil { + return m.ExecuteGas + } + return 0 +} + +// Report is the data structure for storing reports in the storage. +type Report struct { + // Validator is a validator address who submit the report + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // InBeforeResolve indicates whether the report is submitted before the + // request resolved + InBeforeResolve bool `protobuf:"varint,2,opt,name=in_before_resolve,json=inBeforeResolve,proto3" json:"in_before_resolve,omitempty"` + // RawReports is list of raw reports provided by the validator. + // Each raw report has different external ID + RawReports []RawReport `protobuf:"bytes,3,rep,name=raw_reports,json=rawReports,proto3" json:"raw_reports"` +} + +func (m *Report) Reset() { *m = Report{} } +func (m *Report) String() string { return proto.CompactTextString(m) } +func (*Report) ProtoMessage() {} +func (*Report) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{5} +} +func (m *Report) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Report) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Report.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 *Report) XXX_Merge(src proto.Message) { + xxx_messageInfo_Report.Merge(m, src) +} +func (m *Report) XXX_Size() int { + return m.Size() +} +func (m *Report) XXX_DiscardUnknown() { + xxx_messageInfo_Report.DiscardUnknown(m) +} + +var xxx_messageInfo_Report proto.InternalMessageInfo + +func (m *Report) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *Report) GetInBeforeResolve() bool { + if m != nil { + return m.InBeforeResolve + } + return false +} + +func (m *Report) GetRawReports() []RawReport { + if m != nil { + return m.RawReports + } + return nil +} + +// OracleRequestPacketData encodes an oracle request sent from other blockchains +// to BandChain. +type OracleRequestPacketData struct { + // ClientID is the unique identifier of this oracle request, as specified by + // the client. This same unique ID will be sent back to the requester with the + // oracle response. + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // OracleScriptID is the unique identifier of the oracle script to be + // executed. + OracleScriptID OracleScriptID `protobuf:"varint,2,opt,name=oracle_script_id,json=oracleScriptId,proto3,casttype=OracleScriptID" json:"oracle_script_id,omitempty"` + // Calldata is the OBI-encoded calldata bytes available for oracle executor to + // read. + Calldata []byte `protobuf:"bytes,3,opt,name=calldata,proto3" json:"calldata,omitempty"` + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + AskCount uint64 `protobuf:"varint,4,opt,name=ask_count,json=askCount,proto3" json:"ask_count,omitempty"` + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + MinCount uint64 `protobuf:"varint,5,opt,name=min_count,json=minCount,proto3" json:"min_count,omitempty"` + // FeeLimit is the maximum tokens that will be paid to all data source + // providers. + FeeLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=fee_limit,json=feeLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee_limit"` + // PrepareGas is amount of gas to pay to prepare raw requests + PrepareGas uint64 `protobuf:"varint,7,opt,name=prepare_gas,json=prepareGas,proto3" json:"prepare_gas,omitempty"` + // ExecuteGas is amount of gas to reserve for executing + ExecuteGas uint64 `protobuf:"varint,8,opt,name=execute_gas,json=executeGas,proto3" json:"execute_gas,omitempty"` +} + +func (m *OracleRequestPacketData) Reset() { *m = OracleRequestPacketData{} } +func (m *OracleRequestPacketData) String() string { return proto.CompactTextString(m) } +func (*OracleRequestPacketData) ProtoMessage() {} +func (*OracleRequestPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{6} +} +func (m *OracleRequestPacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleRequestPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleRequestPacketData.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 *OracleRequestPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleRequestPacketData.Merge(m, src) +} +func (m *OracleRequestPacketData) XXX_Size() int { + return m.Size() +} +func (m *OracleRequestPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_OracleRequestPacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleRequestPacketData proto.InternalMessageInfo + +func (m *OracleRequestPacketData) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *OracleRequestPacketData) GetOracleScriptID() OracleScriptID { + if m != nil { + return m.OracleScriptID + } + return 0 +} + +func (m *OracleRequestPacketData) GetCalldata() []byte { + if m != nil { + return m.Calldata + } + return nil +} + +func (m *OracleRequestPacketData) GetAskCount() uint64 { + if m != nil { + return m.AskCount + } + return 0 +} + +func (m *OracleRequestPacketData) GetMinCount() uint64 { + if m != nil { + return m.MinCount + } + return 0 +} + +func (m *OracleRequestPacketData) GetFeeLimit() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.FeeLimit + } + return nil +} + +func (m *OracleRequestPacketData) GetPrepareGas() uint64 { + if m != nil { + return m.PrepareGas + } + return 0 +} + +func (m *OracleRequestPacketData) GetExecuteGas() uint64 { + if m != nil { + return m.ExecuteGas + } + return 0 +} + +// OracleRequestPacketAcknowledgement encodes an oracle request acknowledgement +// send back to requester chain. +type OracleRequestPacketAcknowledgement struct { + // RequestID is BandChain's unique identifier for this oracle request. + RequestID RequestID `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3,casttype=RequestID" json:"request_id,omitempty"` +} + +func (m *OracleRequestPacketAcknowledgement) Reset() { *m = OracleRequestPacketAcknowledgement{} } +func (m *OracleRequestPacketAcknowledgement) String() string { return proto.CompactTextString(m) } +func (*OracleRequestPacketAcknowledgement) ProtoMessage() {} +func (*OracleRequestPacketAcknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{7} +} +func (m *OracleRequestPacketAcknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleRequestPacketAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleRequestPacketAcknowledgement.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 *OracleRequestPacketAcknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleRequestPacketAcknowledgement.Merge(m, src) +} +func (m *OracleRequestPacketAcknowledgement) XXX_Size() int { + return m.Size() +} +func (m *OracleRequestPacketAcknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_OracleRequestPacketAcknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleRequestPacketAcknowledgement proto.InternalMessageInfo + +func (m *OracleRequestPacketAcknowledgement) GetRequestID() RequestID { + if m != nil { + return m.RequestID + } + return 0 +} + +// OracleResponsePacketData encodes an oracle response from BandChain to the +// requester. +type OracleResponsePacketData struct { + // ClientID is the unique identifier matched with that of the oracle request + // packet. + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // RequestID is BandChain's unique identifier for this oracle request. + RequestID RequestID `protobuf:"varint,2,opt,name=request_id,json=requestId,proto3,casttype=RequestID" json:"request_id,omitempty"` + // AnsCount is the number of validators among to the asked validators that + // actually responded to this oracle request prior to this oracle request + // being resolved. + AnsCount uint64 `protobuf:"varint,3,opt,name=ans_count,json=ansCount,proto3" json:"ans_count,omitempty"` + // RequestTime is the UNIX epoch time at which the request was sent to + // BandChain. + RequestTime int64 `protobuf:"varint,4,opt,name=request_time,json=requestTime,proto3" json:"request_time,omitempty"` + // ResolveTime is the UNIX epoch time at which the request was resolved to the + // final result. + ResolveTime int64 `protobuf:"varint,5,opt,name=resolve_time,json=resolveTime,proto3" json:"resolve_time,omitempty"` + // ResolveStatus is the status of this oracle request, which can be OK, + // FAILURE, or EXPIRED. + ResolveStatus ResolveStatus `protobuf:"varint,6,opt,name=resolve_status,json=resolveStatus,proto3,enum=oracle.v1.ResolveStatus" json:"resolve_status,omitempty"` + // Result is the final aggregated value encoded in OBI format. Only available + // if status if OK. + Result []byte `protobuf:"bytes,7,opt,name=result,proto3" json:"result,omitempty"` +} + +func (m *OracleResponsePacketData) Reset() { *m = OracleResponsePacketData{} } +func (m *OracleResponsePacketData) String() string { return proto.CompactTextString(m) } +func (*OracleResponsePacketData) ProtoMessage() {} +func (*OracleResponsePacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{8} +} +func (m *OracleResponsePacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleResponsePacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleResponsePacketData.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 *OracleResponsePacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleResponsePacketData.Merge(m, src) +} +func (m *OracleResponsePacketData) XXX_Size() int { + return m.Size() +} +func (m *OracleResponsePacketData) XXX_DiscardUnknown() { + xxx_messageInfo_OracleResponsePacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleResponsePacketData proto.InternalMessageInfo + +func (m *OracleResponsePacketData) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *OracleResponsePacketData) GetRequestID() RequestID { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *OracleResponsePacketData) GetAnsCount() uint64 { + if m != nil { + return m.AnsCount + } + return 0 +} + +func (m *OracleResponsePacketData) GetRequestTime() int64 { + if m != nil { + return m.RequestTime + } + return 0 +} + +func (m *OracleResponsePacketData) GetResolveTime() int64 { + if m != nil { + return m.ResolveTime + } + return 0 +} + +func (m *OracleResponsePacketData) GetResolveStatus() ResolveStatus { + if m != nil { + return m.ResolveStatus + } + return RESOLVE_STATUS_OPEN +} + +func (m *OracleResponsePacketData) GetResult() []byte { + if m != nil { + return m.Result + } + return nil +} + +// Result encodes a result of request and store in chain +type Result struct { + // ClientID is the unique identifier of this oracle request, as specified by + // the client. This same unique ID will be sent back to the requester with the + // oracle response. + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // OracleScriptID is the unique identifier of the oracle script to be + // executed. + OracleScriptID OracleScriptID `protobuf:"varint,2,opt,name=oracle_script_id,json=oracleScriptId,proto3,casttype=OracleScriptID" json:"oracle_script_id,omitempty"` + // Calldata is the calldata bytes available for oracle executor to read. + Calldata []byte `protobuf:"bytes,3,opt,name=calldata,proto3" json:"calldata,omitempty"` + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + AskCount uint64 `protobuf:"varint,4,opt,name=ask_count,json=askCount,proto3" json:"ask_count,omitempty"` + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + MinCount uint64 `protobuf:"varint,5,opt,name=min_count,json=minCount,proto3" json:"min_count,omitempty"` + // RequestID is BandChain's unique identifier for this oracle request. + RequestID RequestID `protobuf:"varint,6,opt,name=request_id,json=requestId,proto3,casttype=RequestID" json:"request_id,omitempty"` + // AnsCount is the number of validators among to the asked validators that + // actually responded to this oracle request prior to this oracle request + // being resolved. + AnsCount uint64 `protobuf:"varint,7,opt,name=ans_count,json=ansCount,proto3" json:"ans_count,omitempty"` + // RequestTime is the UNIX epoch time at which the request was sent to + // BandChain. + RequestTime int64 `protobuf:"varint,8,opt,name=request_time,json=requestTime,proto3" json:"request_time,omitempty"` + // ResolveTime is the UNIX epoch time at which the request was resolved to the + // final result. + ResolveTime int64 `protobuf:"varint,9,opt,name=resolve_time,json=resolveTime,proto3" json:"resolve_time,omitempty"` + // ResolveStatus is the status of this oracle request, which can be OK, + // FAILURE, or EXPIRED. + ResolveStatus ResolveStatus `protobuf:"varint,10,opt,name=resolve_status,json=resolveStatus,proto3,enum=oracle.v1.ResolveStatus" json:"resolve_status,omitempty"` + // Result is the final aggregated value only available if status if OK. + Result []byte `protobuf:"bytes,11,opt,name=result,proto3" json:"result,omitempty"` +} + +func (m *Result) Reset() { *m = Result{} } +func (m *Result) String() string { return proto.CompactTextString(m) } +func (*Result) ProtoMessage() {} +func (*Result) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{9} +} +func (m *Result) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Result.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 *Result) XXX_Merge(src proto.Message) { + xxx_messageInfo_Result.Merge(m, src) +} +func (m *Result) XXX_Size() int { + return m.Size() +} +func (m *Result) XXX_DiscardUnknown() { + xxx_messageInfo_Result.DiscardUnknown(m) +} + +var xxx_messageInfo_Result proto.InternalMessageInfo + +func (m *Result) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *Result) GetOracleScriptID() OracleScriptID { + if m != nil { + return m.OracleScriptID + } + return 0 +} + +func (m *Result) GetCalldata() []byte { + if m != nil { + return m.Calldata + } + return nil +} + +func (m *Result) GetAskCount() uint64 { + if m != nil { + return m.AskCount + } + return 0 +} + +func (m *Result) GetMinCount() uint64 { + if m != nil { + return m.MinCount + } + return 0 +} + +func (m *Result) GetRequestID() RequestID { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *Result) GetAnsCount() uint64 { + if m != nil { + return m.AnsCount + } + return 0 +} + +func (m *Result) GetRequestTime() int64 { + if m != nil { + return m.RequestTime + } + return 0 +} + +func (m *Result) GetResolveTime() int64 { + if m != nil { + return m.ResolveTime + } + return 0 +} + +func (m *Result) GetResolveStatus() ResolveStatus { + if m != nil { + return m.ResolveStatus + } + return RESOLVE_STATUS_OPEN +} + +func (m *Result) GetResult() []byte { + if m != nil { + return m.Result + } + return nil +} + +// ValidatorStatus maintains whether a validator is an active oracle provider. +type ValidatorStatus struct { + // IsActive is a boolean indicating active status of validator. + // The validator will be deactivated when they are unable to send reports + // to fulfill oracle request before the request expired. + IsActive bool `protobuf:"varint,1,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` + // Since is a block timestamp when validator has been activated/deactivated + Since time.Time `protobuf:"bytes,2,opt,name=since,proto3,stdtime" json:"since"` +} + +func (m *ValidatorStatus) Reset() { *m = ValidatorStatus{} } +func (m *ValidatorStatus) String() string { return proto.CompactTextString(m) } +func (*ValidatorStatus) ProtoMessage() {} +func (*ValidatorStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{10} +} +func (m *ValidatorStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorStatus.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 *ValidatorStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorStatus.Merge(m, src) +} +func (m *ValidatorStatus) XXX_Size() int { + return m.Size() +} +func (m *ValidatorStatus) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorStatus proto.InternalMessageInfo + +func (m *ValidatorStatus) GetIsActive() bool { + if m != nil { + return m.IsActive + } + return false +} + +func (m *ValidatorStatus) GetSince() time.Time { + if m != nil { + return m.Since + } + return time.Time{} +} + +// ActiveValidator is information of currently active validator +type ActiveValidator struct { + // Address is a validator address + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Power is an amount of token that the validator is holding + Power uint64 `protobuf:"varint,2,opt,name=power,proto3" json:"power,omitempty"` +} + +func (m *ActiveValidator) Reset() { *m = ActiveValidator{} } +func (m *ActiveValidator) String() string { return proto.CompactTextString(m) } +func (*ActiveValidator) ProtoMessage() {} +func (*ActiveValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{11} +} +func (m *ActiveValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ActiveValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ActiveValidator.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 *ActiveValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActiveValidator.Merge(m, src) +} +func (m *ActiveValidator) XXX_Size() int { + return m.Size() +} +func (m *ActiveValidator) XXX_DiscardUnknown() { + xxx_messageInfo_ActiveValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_ActiveValidator proto.InternalMessageInfo + +func (m *ActiveValidator) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *ActiveValidator) GetPower() uint64 { + if m != nil { + return m.Power + } + return 0 +} + +// Params is the data structure that keeps the parameters of the oracle module. +type Params struct { + // MaxRawRequestCount is the maximum number of data source raw requests a + // request can make. + MaxRawRequestCount uint64 `protobuf:"varint,1,opt,name=max_raw_request_count,json=maxRawRequestCount,proto3" json:"max_raw_request_count,omitempty"` + // MaxAskCount is the maximum number of validators a request can target. + MaxAskCount uint64 `protobuf:"varint,2,opt,name=max_ask_count,json=maxAskCount,proto3" json:"max_ask_count,omitempty"` + // MaxCalldataSize is the maximum size limit of calldata (bytes) in a request. + MaxCalldataSize uint64 `protobuf:"varint,3,opt,name=max_calldata_size,json=maxCalldataSize,proto3" json:"max_calldata_size,omitempty"` + // MaxReportDataSize is the maximum size limit of report data (bytes) in a + // report. + MaxReportDataSize uint64 `protobuf:"varint,4,opt,name=max_report_data_size,json=maxReportDataSize,proto3" json:"max_report_data_size,omitempty"` + // ExpirationBlockCount is the number of blocks a request stays valid before + // it gets expired due to insufficient reports. + ExpirationBlockCount uint64 `protobuf:"varint,5,opt,name=expiration_block_count,json=expirationBlockCount,proto3" json:"expiration_block_count,omitempty"` + // BaseOwasmGas is the base amount of Cosmos-SDK gas charged for owasm + // execution. + BaseOwasmGas uint64 `protobuf:"varint,6,opt,name=base_owasm_gas,json=baseOwasmGas,proto3" json:"base_owasm_gas,omitempty"` + // PerValidatorRequestGas is the amount of Cosmos-SDK gas charged per + // requested validator. + PerValidatorRequestGas uint64 `protobuf:"varint,7,opt,name=per_validator_request_gas,json=perValidatorRequestGas,proto3" json:"per_validator_request_gas,omitempty"` + // SamplingTryCount the number of validator sampling tries to pick the highest + // voting power subset of validators to perform an oracle task. + SamplingTryCount uint64 `protobuf:"varint,8,opt,name=sampling_try_count,json=samplingTryCount,proto3" json:"sampling_try_count,omitempty"` + // OracleRewardPercentage is the percentage of block rewards allocated to + // active oracle validators. + OracleRewardPercentage uint64 `protobuf:"varint,9,opt,name=oracle_reward_percentage,json=oracleRewardPercentage,proto3" json:"oracle_reward_percentage,omitempty"` + // InactivePenaltyDuration is the duration period where a validator cannot + // activate back after missing an oracle report. + InactivePenaltyDuration uint64 `protobuf:"varint,10,opt,name=inactive_penalty_duration,json=inactivePenaltyDuration,proto3" json:"inactive_penalty_duration,omitempty"` + // IBCRequestEnabled is a flag indicating whether sending oracle request via + // IBC is allowed + IBCRequestEnabled bool `protobuf:"varint,11,opt,name=ibc_request_enabled,json=ibcRequestEnabled,proto3" json:"ibc_request_enabled,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{12} +} +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 (m *Params) GetMaxRawRequestCount() uint64 { + if m != nil { + return m.MaxRawRequestCount + } + return 0 +} + +func (m *Params) GetMaxAskCount() uint64 { + if m != nil { + return m.MaxAskCount + } + return 0 +} + +func (m *Params) GetMaxCalldataSize() uint64 { + if m != nil { + return m.MaxCalldataSize + } + return 0 +} + +func (m *Params) GetMaxReportDataSize() uint64 { + if m != nil { + return m.MaxReportDataSize + } + return 0 +} + +func (m *Params) GetExpirationBlockCount() uint64 { + if m != nil { + return m.ExpirationBlockCount + } + return 0 +} + +func (m *Params) GetBaseOwasmGas() uint64 { + if m != nil { + return m.BaseOwasmGas + } + return 0 +} + +func (m *Params) GetPerValidatorRequestGas() uint64 { + if m != nil { + return m.PerValidatorRequestGas + } + return 0 +} + +func (m *Params) GetSamplingTryCount() uint64 { + if m != nil { + return m.SamplingTryCount + } + return 0 +} + +func (m *Params) GetOracleRewardPercentage() uint64 { + if m != nil { + return m.OracleRewardPercentage + } + return 0 +} + +func (m *Params) GetInactivePenaltyDuration() uint64 { + if m != nil { + return m.InactivePenaltyDuration + } + return 0 +} + +func (m *Params) GetIBCRequestEnabled() bool { + if m != nil { + return m.IBCRequestEnabled + } + return false +} + +// PendingResolveList is a list of requests that are waiting to be resolved +type PendingResolveList struct { + // RequestIDs is a list of request IDs that are waiting to be resolved + RequestIds []uint64 `protobuf:"varint,1,rep,packed,name=request_ids,json=requestIds,proto3" json:"request_ids,omitempty"` +} + +func (m *PendingResolveList) Reset() { *m = PendingResolveList{} } +func (m *PendingResolveList) String() string { return proto.CompactTextString(m) } +func (*PendingResolveList) ProtoMessage() {} +func (*PendingResolveList) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{13} +} +func (m *PendingResolveList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PendingResolveList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PendingResolveList.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 *PendingResolveList) XXX_Merge(src proto.Message) { + xxx_messageInfo_PendingResolveList.Merge(m, src) +} +func (m *PendingResolveList) XXX_Size() int { + return m.Size() +} +func (m *PendingResolveList) XXX_DiscardUnknown() { + xxx_messageInfo_PendingResolveList.DiscardUnknown(m) +} + +var xxx_messageInfo_PendingResolveList proto.InternalMessageInfo + +func (m *PendingResolveList) GetRequestIds() []uint64 { + if m != nil { + return m.RequestIds + } + return nil +} + +// IBCChannel is information of IBC protocol to allow communicating with other +// chain +type IBCChannel struct { + // PortID is port ID used for sending response packet when request is + // resolved. + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // ChannelID is channel ID used for sending response packet when request is + // resolved. + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *IBCChannel) Reset() { *m = IBCChannel{} } +func (m *IBCChannel) String() string { return proto.CompactTextString(m) } +func (*IBCChannel) ProtoMessage() {} +func (*IBCChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{14} +} +func (m *IBCChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCChannel.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 *IBCChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCChannel.Merge(m, src) +} +func (m *IBCChannel) XXX_Size() int { + return m.Size() +} +func (m *IBCChannel) XXX_DiscardUnknown() { + xxx_messageInfo_IBCChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCChannel proto.InternalMessageInfo + +func (m *IBCChannel) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +func (m *IBCChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +// RequestVerification is a message that is constructed and signed by a reporter +// to be used as a part of verification of oracle request. +type RequestVerification struct { + // ChainID is the ID of targeted chain + ChainID string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // Validator is an validator address + Validator string `protobuf:"bytes,2,opt,name=validator,proto3" json:"validator,omitempty"` + // RequestID is the targeted request ID + RequestID RequestID `protobuf:"varint,3,opt,name=request_id,json=requestId,proto3,casttype=RequestID" json:"request_id,omitempty"` + // ExternalID is the oracle's external ID of data source + ExternalID ExternalID `protobuf:"varint,4,opt,name=external_id,json=externalId,proto3,casttype=ExternalID" json:"external_id,omitempty"` +} + +func (m *RequestVerification) Reset() { *m = RequestVerification{} } +func (m *RequestVerification) String() string { return proto.CompactTextString(m) } +func (*RequestVerification) ProtoMessage() {} +func (*RequestVerification) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{15} +} +func (m *RequestVerification) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RequestVerification) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RequestVerification.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 *RequestVerification) XXX_Merge(src proto.Message) { + xxx_messageInfo_RequestVerification.Merge(m, src) +} +func (m *RequestVerification) XXX_Size() int { + return m.Size() +} +func (m *RequestVerification) XXX_DiscardUnknown() { + xxx_messageInfo_RequestVerification.DiscardUnknown(m) +} + +var xxx_messageInfo_RequestVerification proto.InternalMessageInfo + +func (m *RequestVerification) GetChainID() string { + if m != nil { + return m.ChainID + } + return "" +} + +func (m *RequestVerification) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *RequestVerification) GetRequestID() RequestID { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *RequestVerification) GetExternalID() ExternalID { + if m != nil { + return m.ExternalID + } + return 0 +} + +// PriceResult is a result from standard price reference +type PriceResult struct { + // Symbol is unit of data indicating what the data is. It is price currencies + // for this case. + Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` + // Multiplier is a number used for left-shifting value to eliminate decimal + // digits + Multiplier uint64 `protobuf:"varint,2,opt,name=multiplier,proto3" json:"multiplier,omitempty"` + // Px is the actual data, which is rate number multiplied by the multiplier. + Px uint64 `protobuf:"varint,3,opt,name=px,proto3" json:"px,omitempty"` + // RequestID is oracle request ID that contains this price + RequestID RequestID `protobuf:"varint,4,opt,name=request_id,json=requestId,proto3,casttype=RequestID" json:"request_id,omitempty"` + // ResolveTime is epoch timestamp indicating the time when the request had + // been resolved + ResolveTime int64 `protobuf:"varint,5,opt,name=resolve_time,json=resolveTime,proto3" json:"resolve_time,omitempty"` +} + +func (m *PriceResult) Reset() { *m = PriceResult{} } +func (m *PriceResult) String() string { return proto.CompactTextString(m) } +func (*PriceResult) ProtoMessage() {} +func (*PriceResult) Descriptor() ([]byte, []int) { + return fileDescriptor_652b57db11528d07, []int{16} +} +func (m *PriceResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PriceResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PriceResult.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 *PriceResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_PriceResult.Merge(m, src) +} +func (m *PriceResult) XXX_Size() int { + return m.Size() +} +func (m *PriceResult) XXX_DiscardUnknown() { + xxx_messageInfo_PriceResult.DiscardUnknown(m) +} + +var xxx_messageInfo_PriceResult proto.InternalMessageInfo + +func (m *PriceResult) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *PriceResult) GetMultiplier() uint64 { + if m != nil { + return m.Multiplier + } + return 0 +} + +func (m *PriceResult) GetPx() uint64 { + if m != nil { + return m.Px + } + return 0 +} + +func (m *PriceResult) GetRequestID() RequestID { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *PriceResult) GetResolveTime() int64 { + if m != nil { + return m.ResolveTime + } + return 0 +} + +func init() { + // proto.RegisterEnum("oracle.v1.ResolveStatus", ResolveStatus_name, ResolveStatus_value) + proto.RegisterType((*DataSource)(nil), "oracle.v1.DataSource") + proto.RegisterType((*OracleScript)(nil), "oracle.v1.OracleScript") + proto.RegisterType((*RawRequest)(nil), "oracle.v1.RawRequest") + proto.RegisterType((*RawReport)(nil), "oracle.v1.RawReport") + proto.RegisterType((*Request)(nil), "oracle.v1.Request") + proto.RegisterType((*Report)(nil), "oracle.v1.Report") + // proto.RegisterType((*OracleRequestPacketData)(nil), "oracle.v1.OracleRequestPacketData") + // proto.RegisterType((*OracleRequestPacketAcknowledgement)(nil), "oracle.v1.OracleRequestPacketAcknowledgement") + // proto.RegisterType((*OracleResponsePacketData)(nil), "oracle.v1.OracleResponsePacketData") + proto.RegisterType((*Result)(nil), "oracle.v1.Result") + proto.RegisterType((*ValidatorStatus)(nil), "oracle.v1.ValidatorStatus") + proto.RegisterType((*ActiveValidator)(nil), "oracle.v1.ActiveValidator") + proto.RegisterType((*Params)(nil), "oracle.v1.Params") + proto.RegisterType((*PendingResolveList)(nil), "oracle.v1.PendingResolveList") + proto.RegisterType((*IBCChannel)(nil), "oracle.v1.IBCChannel") + proto.RegisterType((*RequestVerification)(nil), "oracle.v1.RequestVerification") + proto.RegisterType((*PriceResult)(nil), "oracle.v1.PriceResult") +} + +func init() { proto.RegisterFile("oracle/v1/oracle.proto", fileDescriptor_652b57db11528d07) } + +var fileDescriptor_652b57db11528d07 = []byte{ + // 1740 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xcd, 0x6f, 0x23, 0x49, + 0x15, 0x4f, 0xdb, 0x4e, 0x62, 0x3f, 0x3b, 0x5f, 0x35, 0x99, 0x8c, 0xc7, 0xbb, 0xd8, 0x21, 0x5a, + 0xd0, 0x30, 0x5a, 0x6c, 0x32, 0x20, 0xc4, 0xcc, 0xf2, 0xa1, 0xd8, 0x71, 0x16, 0xa3, 0x68, 0xc6, + 0x2a, 0x27, 0x23, 0x84, 0x84, 0x5a, 0xe5, 0xee, 0x8a, 0x53, 0x4a, 0x7f, 0x51, 0xd5, 0x4e, 0x9c, + 0xbd, 0x71, 0x43, 0x7b, 0xda, 0x0b, 0x12, 0x07, 0x56, 0x5a, 0x89, 0x1b, 0x57, 0xc4, 0x3f, 0xc0, + 0x69, 0x6e, 0xec, 0x09, 0x21, 0x21, 0x79, 0x91, 0xe7, 0x02, 0x7f, 0x00, 0x17, 0xb8, 0xa0, 0xfa, + 0x68, 0xb7, 0x6d, 0x32, 0x0c, 0x19, 0x3e, 0x0e, 0x9c, 0xe2, 0xf7, 0x7b, 0xef, 0x75, 0xbf, 0x8f, + 0xdf, 0x7b, 0x55, 0x1d, 0xd8, 0x09, 0x39, 0x71, 0x3c, 0xda, 0xb8, 0xdc, 0x6f, 0xe8, 0x5f, 0xf5, + 0x88, 0x87, 0x71, 0x88, 0x0a, 0x46, 0xba, 0xdc, 0xaf, 0x6c, 0x0f, 0xc2, 0x41, 0xa8, 0xd0, 0x86, + 0xfc, 0xa5, 0x0d, 0x2a, 0xb5, 0x41, 0x18, 0x0e, 0x3c, 0xda, 0x50, 0x52, 0x7f, 0x78, 0xd6, 0x88, + 0x99, 0x4f, 0x45, 0x4c, 0xfc, 0xc8, 0x18, 0xdc, 0x5f, 0x34, 0x20, 0xc1, 0xb5, 0x51, 0x55, 0x9d, + 0x50, 0xf8, 0xa1, 0x68, 0xf4, 0x89, 0x90, 0x6f, 0xee, 0xd3, 0x98, 0xec, 0x37, 0x9c, 0x90, 0x05, + 0x5a, 0xbf, 0xf7, 0x17, 0x0b, 0xe0, 0x90, 0xc4, 0xa4, 0x17, 0x0e, 0xb9, 0x43, 0xd1, 0x36, 0x2c, + 0x87, 0x57, 0x01, 0xe5, 0x65, 0x6b, 0xd7, 0x7a, 0x50, 0xc0, 0x5a, 0x40, 0x08, 0x72, 0x01, 0xf1, + 0x69, 0x39, 0xa3, 0x40, 0xf5, 0x1b, 0xed, 0x42, 0xd1, 0xa5, 0xc2, 0xe1, 0x2c, 0x8a, 0x59, 0x18, + 0x94, 0xb3, 0x4a, 0x35, 0x0b, 0xa1, 0x0a, 0xe4, 0xcf, 0x98, 0x47, 0x95, 0x67, 0x4e, 0xa9, 0xa7, + 0xb2, 0xd4, 0xc5, 0x9c, 0x12, 0x31, 0xe4, 0xd7, 0xe5, 0x65, 0xad, 0x4b, 0x64, 0xf4, 0x43, 0xc8, + 0x9e, 0x51, 0x5a, 0x5e, 0xd9, 0xcd, 0x3e, 0x28, 0x3e, 0xba, 0x5f, 0xd7, 0x09, 0xd4, 0x65, 0x02, + 0x75, 0x93, 0x40, 0xbd, 0x15, 0xb2, 0xa0, 0xf9, 0x95, 0x17, 0xe3, 0xda, 0xd2, 0x2f, 0x3f, 0xab, + 0x3d, 0x18, 0xb0, 0xf8, 0x7c, 0xd8, 0xaf, 0x3b, 0xa1, 0xdf, 0x30, 0xd9, 0xea, 0x3f, 0x5f, 0x16, + 0xee, 0x45, 0x23, 0xbe, 0x8e, 0xa8, 0x50, 0x0e, 0x02, 0xcb, 0xe7, 0x3e, 0xc9, 0xfd, 0xe9, 0x93, + 0x9a, 0xb5, 0xf7, 0x5b, 0x0b, 0x4a, 0xcf, 0x54, 0xdd, 0x7b, 0x2a, 0xe0, 0xff, 0x59, 0xe6, 0x3b, + 0xb0, 0x22, 0x9c, 0x73, 0xea, 0x13, 0x93, 0xb7, 0x91, 0xd0, 0x63, 0xd8, 0x10, 0xaa, 0x07, 0xb6, + 0x13, 0xba, 0xd4, 0x1e, 0x72, 0xaf, 0xbc, 0x22, 0x0d, 0x9a, 0x5b, 0x93, 0x71, 0x6d, 0x4d, 0xb7, + 0xa7, 0x15, 0xba, 0xf4, 0x14, 0x1f, 0xe3, 0x35, 0x91, 0x8a, 0xdc, 0x33, 0x19, 0xfd, 0xda, 0x02, + 0xc0, 0xe4, 0x0a, 0xd3, 0x1f, 0x0d, 0xa9, 0x88, 0xd1, 0xb7, 0xa0, 0x48, 0x47, 0x31, 0xe5, 0x01, + 0xf1, 0x6c, 0xe6, 0xaa, 0xac, 0x72, 0xcd, 0xb7, 0x27, 0xe3, 0x1a, 0xb4, 0x0d, 0xdc, 0x39, 0xfc, + 0xeb, 0x9c, 0x84, 0x21, 0x71, 0xe8, 0xb8, 0xe8, 0x08, 0xd6, 0x5d, 0x12, 0x13, 0xdb, 0xc4, 0xc4, + 0x5c, 0x55, 0x82, 0x5c, 0x73, 0x77, 0x32, 0xae, 0x95, 0x52, 0xc2, 0xa8, 0x67, 0xcc, 0xc9, 0xb8, + 0xe4, 0xa6, 0x92, 0x2b, 0x4b, 0xe1, 0x10, 0xcf, 0x93, 0x98, 0xaa, 0x54, 0x09, 0x4f, 0x65, 0x13, + 0xf7, 0x8f, 0x2d, 0x28, 0xa8, 0xb8, 0xa3, 0x90, 0xff, 0xdb, 0x61, 0xbf, 0x05, 0x05, 0x3a, 0x62, + 0xb1, 0xaa, 0xa1, 0x8a, 0x78, 0x0d, 0xe7, 0x25, 0x20, 0x4b, 0x25, 0x9b, 0x39, 0x13, 0x47, 0x6e, + 0x26, 0x86, 0x3f, 0x67, 0x61, 0x35, 0x29, 0xdc, 0x53, 0xd8, 0xd4, 0x03, 0x69, 0xeb, 0x86, 0xa6, + 0x61, 0xbc, 0x33, 0x19, 0xd7, 0xd6, 0x67, 0x49, 0xa3, 0x42, 0x59, 0x40, 0xf0, 0x7a, 0x38, 0x2b, + 0xcf, 0x57, 0x20, 0x33, 0x5f, 0x01, 0xb4, 0x0f, 0xdb, 0x5c, 0xbf, 0x96, 0xba, 0xf6, 0x25, 0xf1, + 0x98, 0x4b, 0xe2, 0x90, 0x8b, 0x72, 0x76, 0x37, 0xfb, 0xa0, 0x80, 0xef, 0x4c, 0x75, 0xcf, 0xa7, + 0x2a, 0x99, 0xa1, 0xcf, 0x02, 0xdb, 0x09, 0x87, 0x41, 0xac, 0xc8, 0x95, 0xc3, 0x79, 0x9f, 0x05, + 0x2d, 0x29, 0xa3, 0x2f, 0xc0, 0xba, 0xf1, 0xb1, 0xcf, 0x29, 0x1b, 0x9c, 0xc7, 0x8a, 0x64, 0x59, + 0xbc, 0x66, 0xd0, 0xef, 0x2a, 0x10, 0x7d, 0x1e, 0x4a, 0x89, 0x99, 0x5c, 0x25, 0x8a, 0x68, 0x59, + 0x5c, 0x34, 0xd8, 0x09, 0xf3, 0x29, 0xfa, 0x12, 0x14, 0x1c, 0x8f, 0xd1, 0x40, 0xa5, 0xbf, 0xaa, + 0x88, 0x58, 0x9a, 0x8c, 0x6b, 0xf9, 0x96, 0x02, 0x3b, 0x87, 0x38, 0xaf, 0xd5, 0x1d, 0x17, 0x7d, + 0x1b, 0x4a, 0x9c, 0x5c, 0xd9, 0xc6, 0x5b, 0x94, 0xf3, 0x6a, 0x70, 0xef, 0xd6, 0xa7, 0x6b, 0xad, + 0x9e, 0xd2, 0xb2, 0x99, 0x93, 0x43, 0x8b, 0x8b, 0x7c, 0x8a, 0x08, 0x74, 0x04, 0x45, 0xd6, 0x77, + 0x6c, 0xe7, 0x9c, 0x04, 0x01, 0xf5, 0xca, 0x85, 0x5d, 0x6b, 0xc1, 0xbd, 0xd3, 0x6c, 0xb5, 0xb4, + 0xb2, 0xb9, 0x2e, 0x99, 0x90, 0xca, 0x18, 0x58, 0xdf, 0x31, 0xbf, 0x51, 0x4d, 0x52, 0x87, 0x3a, + 0xc3, 0x98, 0xda, 0x03, 0x22, 0xca, 0xa0, 0x6a, 0x03, 0x06, 0x7a, 0x9f, 0x08, 0xd3, 0xeb, 0x9f, + 0x5a, 0xb0, 0x62, 0xc8, 0xf6, 0x36, 0x14, 0xa6, 0x45, 0x37, 0x73, 0x9f, 0x02, 0xe8, 0x21, 0x6c, + 0xb1, 0xc0, 0xee, 0xd3, 0xb3, 0x90, 0x53, 0x9b, 0x53, 0x11, 0x7a, 0x97, 0x9a, 0x53, 0x79, 0xbc, + 0xc1, 0x82, 0xa6, 0xc2, 0xb1, 0x86, 0xd1, 0x7b, 0x50, 0xd4, 0x35, 0x90, 0xcf, 0xd5, 0xfd, 0x2b, + 0x3e, 0xda, 0x5e, 0x2c, 0x81, 0x54, 0x9a, 0x0a, 0x00, 0x4f, 0x80, 0x24, 0xae, 0x9f, 0x67, 0xe1, + 0x9e, 0xa6, 0x92, 0xa9, 0x4c, 0x97, 0x38, 0x17, 0x34, 0x96, 0xb3, 0x35, 0xdf, 0x0d, 0xeb, 0x9f, + 0x76, 0xe3, 0x26, 0xfa, 0x66, 0xfe, 0x43, 0xf4, 0x5d, 0x18, 0x60, 0xc9, 0x45, 0x22, 0x2e, 0xe6, + 0xb9, 0x48, 0xc4, 0x85, 0xe6, 0xe2, 0x1c, 0x51, 0x97, 0x17, 0x88, 0x7a, 0x0e, 0x85, 0x33, 0x4a, + 0x6d, 0x8f, 0xf9, 0x2c, 0xfe, 0x6f, 0x6c, 0xfa, 0xfc, 0x19, 0xa5, 0xc7, 0xf2, 0xe1, 0x92, 0x15, + 0x11, 0xa7, 0x11, 0xe1, 0x9a, 0x15, 0xab, 0x9a, 0x15, 0x06, 0x7a, 0x9f, 0x88, 0x45, 0xda, 0xe4, + 0x5f, 0x41, 0x1b, 0x0a, 0x7b, 0x37, 0x74, 0xe7, 0xc0, 0xb9, 0x08, 0xc2, 0x2b, 0x8f, 0xba, 0x03, + 0xea, 0xd3, 0x20, 0x46, 0x8f, 0x01, 0x92, 0xc9, 0x9a, 0xae, 0x8d, 0xca, 0x64, 0x5c, 0x2b, 0x18, + 0x2f, 0x55, 0xf2, 0x54, 0xc0, 0x05, 0x63, 0xdd, 0x71, 0xcd, 0x6b, 0x7e, 0x93, 0x81, 0x72, 0xf2, + 0x1e, 0x11, 0x85, 0x81, 0xa0, 0x6f, 0x46, 0x83, 0xf9, 0x40, 0x32, 0xb7, 0x08, 0x44, 0x75, 0x35, + 0x10, 0xa6, 0x71, 0x59, 0xd3, 0xd5, 0x40, 0xe8, 0xc6, 0x2d, 0xae, 0x8e, 0xdc, 0x3f, 0xae, 0x0e, + 0x65, 0xa2, 0xc6, 0x42, 0x9b, 0x2c, 0x27, 0x26, 0x0a, 0x53, 0x26, 0xdf, 0x91, 0x7b, 0x4a, 0x9b, + 0x88, 0x98, 0xc4, 0x43, 0xa1, 0x56, 0xd0, 0xfa, 0xa3, 0xf2, 0xec, 0xc4, 0x68, 0x83, 0x9e, 0xd2, + 0xcb, 0x0d, 0x36, 0x23, 0xca, 0x53, 0x94, 0x53, 0x31, 0xf4, 0x62, 0xd5, 0xd0, 0x12, 0x36, 0x92, + 0x29, 0xe2, 0xef, 0xb2, 0x72, 0xc4, 0x25, 0xf0, 0xff, 0x37, 0x39, 0xf3, 0x8d, 0x5d, 0x79, 0xe3, + 0xc6, 0xae, 0xbe, 0xa6, 0xb1, 0xf9, 0xd7, 0x37, 0xb6, 0xf0, 0xaf, 0x34, 0x16, 0xde, 0xb4, 0xb1, + 0xc5, 0x1b, 0x1a, 0x1b, 0xc1, 0xc6, 0xf4, 0x28, 0x34, 0x0e, 0x6f, 0x41, 0x81, 0x09, 0x9b, 0x38, + 0x31, 0xbb, 0xa4, 0xaa, 0xc1, 0x79, 0x9c, 0x67, 0xe2, 0x40, 0xc9, 0xe8, 0x09, 0x2c, 0x0b, 0x16, + 0x38, 0x7a, 0x6d, 0x17, 0x1f, 0x55, 0xea, 0xfa, 0xa2, 0x5c, 0x4f, 0x2e, 0xca, 0xf5, 0x93, 0xe4, + 0x26, 0xdd, 0xcc, 0xcb, 0x1d, 0xf3, 0xd1, 0x67, 0x35, 0x0b, 0x6b, 0x17, 0xf3, 0xc6, 0x03, 0xd8, + 0xd0, 0xcf, 0x9a, 0xbe, 0x17, 0x95, 0x61, 0x95, 0xb8, 0x2e, 0xa7, 0x42, 0x98, 0x33, 0x23, 0x11, + 0xe5, 0x1d, 0x32, 0x0a, 0xaf, 0x28, 0xd7, 0xb4, 0xc1, 0x5a, 0xd8, 0x7b, 0x91, 0x83, 0x95, 0x2e, + 0xe1, 0xc4, 0x17, 0x68, 0x1f, 0xee, 0xfa, 0x64, 0x64, 0xcf, 0x1c, 0x97, 0xa6, 0x1b, 0x6a, 0x53, + 0x60, 0xe4, 0x93, 0x51, 0x7a, 0x56, 0xea, 0xbe, 0xec, 0xc1, 0x9a, 0x74, 0x49, 0xd9, 0xa2, 0x9f, + 0x5d, 0xf4, 0xc9, 0xe8, 0x20, 0x21, 0xcc, 0x43, 0xd8, 0x92, 0x36, 0x09, 0xbb, 0x6c, 0xc1, 0x3e, + 0xa0, 0x66, 0x72, 0x37, 0x7c, 0x32, 0x6a, 0x19, 0xbc, 0xc7, 0x3e, 0xa0, 0xa8, 0x01, 0xdb, 0x2a, + 0x04, 0x75, 0xf6, 0xd8, 0xa9, 0xb9, 0x26, 0xa1, 0x7c, 0x8e, 0x3e, 0x96, 0x0e, 0x13, 0x87, 0xaf, + 0xc1, 0x0e, 0x1d, 0x45, 0x8c, 0x13, 0x79, 0xb5, 0xb5, 0xfb, 0x5e, 0xe8, 0x5c, 0xcc, 0x51, 0x73, + 0x3b, 0xd5, 0x36, 0xa5, 0x52, 0x87, 0xf4, 0x0e, 0xac, 0xcb, 0x3d, 0x6e, 0x87, 0x57, 0x44, 0xf8, + 0x6a, 0xb1, 0x2a, 0xaa, 0xe2, 0x92, 0x44, 0x9f, 0x49, 0x50, 0xee, 0xde, 0xc7, 0x70, 0x3f, 0xa2, + 0x3c, 0xbd, 0xf9, 0x4c, 0xab, 0x92, 0xae, 0xea, 0x9d, 0x88, 0xf2, 0x69, 0xed, 0x4d, 0x65, 0xa4, + 0xeb, 0xbb, 0x80, 0x04, 0xf1, 0x23, 0x8f, 0x05, 0x03, 0x3b, 0xe6, 0xd7, 0x26, 0x24, 0xbd, 0xbd, + 0x37, 0x13, 0xcd, 0x09, 0xbf, 0xd6, 0xe1, 0x7c, 0x03, 0xca, 0x66, 0xb6, 0x39, 0xbd, 0x22, 0xdc, + 0xb5, 0x23, 0xca, 0x1d, 0x1a, 0xc4, 0x64, 0xa0, 0x69, 0x9c, 0xc3, 0xe6, 0xeb, 0x0c, 0x2b, 0x75, + 0x77, 0xaa, 0x45, 0x4f, 0xe0, 0x3e, 0x0b, 0x34, 0xbd, 0xec, 0x88, 0x06, 0xc4, 0x8b, 0xaf, 0x6d, + 0x77, 0xa8, 0xf3, 0x35, 0x77, 0x8c, 0x7b, 0x89, 0x41, 0x57, 0xeb, 0x0f, 0x8d, 0x1a, 0xb5, 0xe1, + 0x8e, 0xbc, 0xd9, 0x24, 0x49, 0xd1, 0x80, 0xf4, 0x3d, 0xea, 0x2a, 0x66, 0xe7, 0x9b, 0x77, 0x27, + 0xe3, 0xda, 0x56, 0xa7, 0xd9, 0x32, 0x39, 0xb5, 0xb5, 0x12, 0x6f, 0xb1, 0xbe, 0x33, 0x0f, 0x3d, + 0xc9, 0xff, 0xec, 0x93, 0xda, 0x92, 0x62, 0xe3, 0x7b, 0x80, 0xba, 0x34, 0x70, 0x59, 0x30, 0x30, + 0x43, 0x74, 0xcc, 0x84, 0x3a, 0xe2, 0xd2, 0x95, 0x20, 0x49, 0x99, 0x95, 0x27, 0xd8, 0x74, 0xee, + 0x93, 0x13, 0xec, 0x7b, 0x30, 0x73, 0x73, 0x42, 0xf7, 0x60, 0x55, 0x31, 0x20, 0x59, 0x8b, 0x78, + 0x45, 0x8a, 0x1d, 0x17, 0x7d, 0x0e, 0xc0, 0x5c, 0xc5, 0x92, 0x05, 0x58, 0xc0, 0x05, 0x83, 0x4c, + 0x8f, 0xa9, 0x3f, 0x58, 0x70, 0xc7, 0x44, 0xf9, 0x9c, 0x72, 0x76, 0xc6, 0x1c, 0x9d, 0xf1, 0x17, + 0x21, 0xef, 0x9c, 0x13, 0x16, 0xa4, 0xdb, 0xb6, 0x38, 0x19, 0xd7, 0x56, 0x5b, 0x12, 0xeb, 0x1c, + 0xe2, 0x55, 0xa5, 0xec, 0xb8, 0xf3, 0x37, 0xaf, 0xcc, 0xe2, 0xcd, 0x6b, 0x7e, 0xc7, 0x65, 0x6f, + 0xb3, 0xe3, 0x16, 0xbe, 0x1f, 0x72, 0xb7, 0xfb, 0x7e, 0x30, 0xd9, 0xfd, 0xca, 0x82, 0x62, 0x97, + 0x33, 0x87, 0x9a, 0x43, 0x44, 0x7e, 0xb3, 0x5d, 0xfb, 0xfd, 0xd0, 0x4b, 0x4a, 0xa5, 0x25, 0x54, + 0x05, 0xf0, 0x87, 0x5e, 0xcc, 0x22, 0x8f, 0x4d, 0x87, 0x7e, 0x06, 0x41, 0xeb, 0x90, 0x89, 0x46, + 0x66, 0x10, 0x33, 0xd1, 0x68, 0x21, 0xaf, 0xdc, 0x6d, 0xf2, 0x7a, 0xfd, 0xa1, 0xfa, 0xf0, 0x6f, + 0x16, 0xac, 0xcd, 0xed, 0x56, 0xf4, 0x4d, 0xa8, 0xe1, 0x76, 0xef, 0xd9, 0xf1, 0xf3, 0xb6, 0xdd, + 0x3b, 0x39, 0x38, 0x39, 0xed, 0xd9, 0xcf, 0xba, 0xed, 0xa7, 0xf6, 0xe9, 0xd3, 0x5e, 0xb7, 0xdd, + 0xea, 0x1c, 0x75, 0xda, 0x87, 0x9b, 0x4b, 0x95, 0x7b, 0x1f, 0x7e, 0xbc, 0x7b, 0xe7, 0x06, 0x33, + 0xf4, 0x75, 0xd8, 0x59, 0x80, 0x7b, 0xa7, 0xad, 0x56, 0xbb, 0xd7, 0xdb, 0xb4, 0x2a, 0x95, 0x0f, + 0x3f, 0xde, 0x7d, 0x85, 0xf6, 0x06, 0xbf, 0xa3, 0x83, 0xce, 0xf1, 0x29, 0x6e, 0x6f, 0x66, 0x6e, + 0xf4, 0x33, 0xda, 0x1b, 0xfc, 0xda, 0xdf, 0xef, 0x76, 0x70, 0xfb, 0x70, 0x33, 0x7b, 0xa3, 0x9f, + 0xd1, 0x56, 0x72, 0x3f, 0xf9, 0x45, 0x75, 0xa9, 0x79, 0xf4, 0x62, 0x52, 0xb5, 0x3e, 0x9d, 0x54, + 0xad, 0x3f, 0x4e, 0xaa, 0xd6, 0x47, 0x2f, 0xab, 0x4b, 0x9f, 0xbe, 0xac, 0x2e, 0xfd, 0xfe, 0x65, + 0x75, 0xe9, 0x07, 0xef, 0xce, 0xdc, 0x1a, 0xfb, 0x24, 0x70, 0xd5, 0xf2, 0x77, 0x42, 0xaf, 0xa1, + 0xc8, 0xd8, 0x18, 0x99, 0xff, 0xc6, 0xe8, 0xfb, 0x63, 0x7f, 0x45, 0xa9, 0xbf, 0xfa, 0xf7, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x91, 0xec, 0x8d, 0x21, 0xae, 0x11, 0x00, 0x00, +} + +func (this *DataSource) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DataSource) + if !ok { + that2, ok := that.(DataSource) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Owner != that1.Owner { + return false + } + if this.Name != that1.Name { + return false + } + if this.Description != that1.Description { + return false + } + if this.Filename != that1.Filename { + return false + } + if this.Treasury != that1.Treasury { + return false + } + if len(this.Fee) != len(that1.Fee) { + return false + } + for i := range this.Fee { + if !this.Fee[i].Equal(&that1.Fee[i]) { + return false + } + } + return true +} +func (this *OracleScript) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleScript) + if !ok { + that2, ok := that.(OracleScript) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Owner != that1.Owner { + return false + } + if this.Name != that1.Name { + return false + } + if this.Description != that1.Description { + return false + } + if this.Filename != that1.Filename { + return false + } + if this.Schema != that1.Schema { + return false + } + if this.SourceCodeURL != that1.SourceCodeURL { + return false + } + return true +} +func (this *RawRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RawRequest) + if !ok { + that2, ok := that.(RawRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ExternalID != that1.ExternalID { + return false + } + if this.DataSourceID != that1.DataSourceID { + return false + } + if !bytes.Equal(this.Calldata, that1.Calldata) { + return false + } + return true +} +func (this *RawReport) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RawReport) + if !ok { + that2, ok := that.(RawReport) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ExternalID != that1.ExternalID { + return false + } + if this.ExitCode != that1.ExitCode { + return false + } + if !bytes.Equal(this.Data, that1.Data) { + return false + } + return true +} +func (this *Request) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Request) + if !ok { + that2, ok := that.(Request) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.OracleScriptID != that1.OracleScriptID { + return false + } + if !bytes.Equal(this.Calldata, that1.Calldata) { + return false + } + if len(this.RequestedValidators) != len(that1.RequestedValidators) { + return false + } + for i := range this.RequestedValidators { + if this.RequestedValidators[i] != that1.RequestedValidators[i] { + return false + } + } + if this.MinCount != that1.MinCount { + return false + } + if this.RequestHeight != that1.RequestHeight { + return false + } + if this.RequestTime != that1.RequestTime { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if len(this.RawRequests) != len(that1.RawRequests) { + return false + } + for i := range this.RawRequests { + if !this.RawRequests[i].Equal(&that1.RawRequests[i]) { + return false + } + } + if !this.IBCChannel.Equal(that1.IBCChannel) { + return false + } + if this.ExecuteGas != that1.ExecuteGas { + return false + } + return true +} +func (this *Report) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Report) + if !ok { + that2, ok := that.(Report) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Validator != that1.Validator { + return false + } + if this.InBeforeResolve != that1.InBeforeResolve { + return false + } + if len(this.RawReports) != len(that1.RawReports) { + return false + } + for i := range this.RawReports { + if !this.RawReports[i].Equal(&that1.RawReports[i]) { + return false + } + } + return true +} +func (this *OracleRequestPacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleRequestPacketData) + if !ok { + that2, ok := that.(OracleRequestPacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if this.OracleScriptID != that1.OracleScriptID { + return false + } + if !bytes.Equal(this.Calldata, that1.Calldata) { + return false + } + if this.AskCount != that1.AskCount { + return false + } + if this.MinCount != that1.MinCount { + return false + } + if len(this.FeeLimit) != len(that1.FeeLimit) { + return false + } + for i := range this.FeeLimit { + if !this.FeeLimit[i].Equal(&that1.FeeLimit[i]) { + return false + } + } + if this.PrepareGas != that1.PrepareGas { + return false + } + if this.ExecuteGas != that1.ExecuteGas { + return false + } + return true +} +func (this *OracleRequestPacketAcknowledgement) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleRequestPacketAcknowledgement) + if !ok { + that2, ok := that.(OracleRequestPacketAcknowledgement) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.RequestID != that1.RequestID { + return false + } + return true +} +func (this *OracleResponsePacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleResponsePacketData) + if !ok { + that2, ok := that.(OracleResponsePacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if this.RequestID != that1.RequestID { + return false + } + if this.AnsCount != that1.AnsCount { + return false + } + if this.RequestTime != that1.RequestTime { + return false + } + if this.ResolveTime != that1.ResolveTime { + return false + } + if this.ResolveStatus != that1.ResolveStatus { + return false + } + if !bytes.Equal(this.Result, that1.Result) { + return false + } + return true +} +func (this *Result) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Result) + if !ok { + that2, ok := that.(Result) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if this.OracleScriptID != that1.OracleScriptID { + return false + } + if !bytes.Equal(this.Calldata, that1.Calldata) { + return false + } + if this.AskCount != that1.AskCount { + return false + } + if this.MinCount != that1.MinCount { + return false + } + if this.RequestID != that1.RequestID { + return false + } + if this.AnsCount != that1.AnsCount { + return false + } + if this.RequestTime != that1.RequestTime { + return false + } + if this.ResolveTime != that1.ResolveTime { + return false + } + if this.ResolveStatus != that1.ResolveStatus { + return false + } + if !bytes.Equal(this.Result, that1.Result) { + return false + } + return true +} +func (this *ValidatorStatus) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorStatus) + if !ok { + that2, ok := that.(ValidatorStatus) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.IsActive != that1.IsActive { + return false + } + if !this.Since.Equal(that1.Since) { + return false + } + return true +} +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.MaxRawRequestCount != that1.MaxRawRequestCount { + return false + } + if this.MaxAskCount != that1.MaxAskCount { + return false + } + if this.MaxCalldataSize != that1.MaxCalldataSize { + return false + } + if this.MaxReportDataSize != that1.MaxReportDataSize { + return false + } + if this.ExpirationBlockCount != that1.ExpirationBlockCount { + return false + } + if this.BaseOwasmGas != that1.BaseOwasmGas { + return false + } + if this.PerValidatorRequestGas != that1.PerValidatorRequestGas { + return false + } + if this.SamplingTryCount != that1.SamplingTryCount { + return false + } + if this.OracleRewardPercentage != that1.OracleRewardPercentage { + return false + } + if this.InactivePenaltyDuration != that1.InactivePenaltyDuration { + return false + } + if this.IBCRequestEnabled != that1.IBCRequestEnabled { + return false + } + return true +} +func (this *PendingResolveList) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PendingResolveList) + if !ok { + that2, ok := that.(PendingResolveList) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.RequestIds) != len(that1.RequestIds) { + return false + } + for i := range this.RequestIds { + if this.RequestIds[i] != that1.RequestIds[i] { + return false + } + } + return true +} +func (this *IBCChannel) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCChannel) + if !ok { + that2, ok := that.(IBCChannel) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.PortId != that1.PortId { + return false + } + if this.ChannelId != that1.ChannelId { + return false + } + return true +} +func (this *RequestVerification) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RequestVerification) + if !ok { + that2, ok := that.(RequestVerification) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ChainID != that1.ChainID { + return false + } + if this.Validator != that1.Validator { + return false + } + if this.RequestID != that1.RequestID { + return false + } + if this.ExternalID != that1.ExternalID { + return false + } + return true +} +func (m *DataSource) 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 *DataSource) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DataSource) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Fee) > 0 { + for iNdEx := len(m.Fee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Treasury) > 0 { + i -= len(m.Treasury) + copy(dAtA[i:], m.Treasury) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Treasury))) + i-- + dAtA[i] = 0x2a + } + if len(m.Filename) > 0 { + i -= len(m.Filename) + copy(dAtA[i:], m.Filename) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Filename))) + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OracleScript) 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 *OracleScript) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleScript) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SourceCodeURL) > 0 { + i -= len(m.SourceCodeURL) + copy(dAtA[i:], m.SourceCodeURL) + i = encodeVarintOracle(dAtA, i, uint64(len(m.SourceCodeURL))) + i-- + dAtA[i] = 0x32 + } + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0x2a + } + if len(m.Filename) > 0 { + i -= len(m.Filename) + copy(dAtA[i:], m.Filename) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Filename))) + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RawRequest) 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 *RawRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Calldata) > 0 { + i -= len(m.Calldata) + copy(dAtA[i:], m.Calldata) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Calldata))) + i-- + dAtA[i] = 0x1a + } + if m.DataSourceID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.DataSourceID)) + i-- + dAtA[i] = 0x10 + } + if m.ExternalID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ExternalID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RawReport) 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 *RawReport) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawReport) 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 = encodeVarintOracle(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if m.ExitCode != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ExitCode)) + i-- + dAtA[i] = 0x10 + } + if m.ExternalID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ExternalID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Request) 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 *Request) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecuteGas != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ExecuteGas)) + i-- + dAtA[i] = 0x50 + } + if m.IBCChannel != nil { + { + size, err := m.IBCChannel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + if len(m.RawRequests) > 0 { + for iNdEx := len(m.RawRequests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RawRequests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0x3a + } + if m.RequestTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestTime)) + i-- + dAtA[i] = 0x30 + } + if m.RequestHeight != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestHeight)) + i-- + dAtA[i] = 0x28 + } + if m.MinCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MinCount)) + i-- + dAtA[i] = 0x20 + } + if len(m.RequestedValidators) > 0 { + for iNdEx := len(m.RequestedValidators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.RequestedValidators[iNdEx]) + copy(dAtA[i:], m.RequestedValidators[iNdEx]) + i = encodeVarintOracle(dAtA, i, uint64(len(m.RequestedValidators[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Calldata) > 0 { + i -= len(m.Calldata) + copy(dAtA[i:], m.Calldata) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Calldata))) + i-- + dAtA[i] = 0x12 + } + if m.OracleScriptID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.OracleScriptID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Report) 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 *Report) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Report) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RawReports) > 0 { + for iNdEx := len(m.RawReports) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RawReports[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.InBeforeResolve { + i-- + if m.InBeforeResolve { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OracleRequestPacketData) 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 *OracleRequestPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleRequestPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecuteGas != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ExecuteGas)) + i-- + dAtA[i] = 0x40 + } + if m.PrepareGas != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.PrepareGas)) + i-- + dAtA[i] = 0x38 + } + if len(m.FeeLimit) > 0 { + for iNdEx := len(m.FeeLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.MinCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MinCount)) + i-- + dAtA[i] = 0x28 + } + if m.AskCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.AskCount)) + i-- + dAtA[i] = 0x20 + } + if len(m.Calldata) > 0 { + i -= len(m.Calldata) + copy(dAtA[i:], m.Calldata) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Calldata))) + i-- + dAtA[i] = 0x1a + } + if m.OracleScriptID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.OracleScriptID)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OracleRequestPacketAcknowledgement) 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 *OracleRequestPacketAcknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleRequestPacketAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RequestID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *OracleResponsePacketData) 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 *OracleResponsePacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleResponsePacketData) 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 = encodeVarintOracle(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x3a + } + if m.ResolveStatus != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ResolveStatus)) + i-- + dAtA[i] = 0x30 + } + if m.ResolveTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ResolveTime)) + i-- + dAtA[i] = 0x28 + } + if m.RequestTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestTime)) + i-- + dAtA[i] = 0x20 + } + if m.AnsCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.AnsCount)) + i-- + dAtA[i] = 0x18 + } + if m.RequestID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Result) 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 *Result) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Result) 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 = encodeVarintOracle(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x5a + } + if m.ResolveStatus != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ResolveStatus)) + i-- + dAtA[i] = 0x50 + } + if m.ResolveTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ResolveTime)) + i-- + dAtA[i] = 0x48 + } + if m.RequestTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestTime)) + i-- + dAtA[i] = 0x40 + } + if m.AnsCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.AnsCount)) + i-- + dAtA[i] = 0x38 + } + if m.RequestID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x30 + } + if m.MinCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MinCount)) + i-- + dAtA[i] = 0x28 + } + if m.AskCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.AskCount)) + i-- + dAtA[i] = 0x20 + } + if len(m.Calldata) > 0 { + i -= len(m.Calldata) + copy(dAtA[i:], m.Calldata) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Calldata))) + i-- + dAtA[i] = 0x1a + } + if m.OracleScriptID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.OracleScriptID)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ValidatorStatus) 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 *ValidatorStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Since, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Since):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintOracle(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x12 + if m.IsActive { + i-- + if m.IsActive { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ActiveValidator) 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 *ActiveValidator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ActiveValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Power != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.Power)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +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 + if m.IBCRequestEnabled { + i-- + if m.IBCRequestEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x58 + } + if m.InactivePenaltyDuration != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.InactivePenaltyDuration)) + i-- + dAtA[i] = 0x50 + } + if m.OracleRewardPercentage != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.OracleRewardPercentage)) + i-- + dAtA[i] = 0x48 + } + if m.SamplingTryCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.SamplingTryCount)) + i-- + dAtA[i] = 0x40 + } + if m.PerValidatorRequestGas != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.PerValidatorRequestGas)) + i-- + dAtA[i] = 0x38 + } + if m.BaseOwasmGas != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.BaseOwasmGas)) + i-- + dAtA[i] = 0x30 + } + if m.ExpirationBlockCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ExpirationBlockCount)) + i-- + dAtA[i] = 0x28 + } + if m.MaxReportDataSize != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MaxReportDataSize)) + i-- + dAtA[i] = 0x20 + } + if m.MaxCalldataSize != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MaxCalldataSize)) + i-- + dAtA[i] = 0x18 + } + if m.MaxAskCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MaxAskCount)) + i-- + dAtA[i] = 0x10 + } + if m.MaxRawRequestCount != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MaxRawRequestCount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PendingResolveList) 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 *PendingResolveList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PendingResolveList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RequestIds) > 0 { + dAtA4 := make([]byte, len(m.RequestIds)*10) + var j3 int + for _, num := range m.RequestIds { + for num >= 1<<7 { + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA4[j3] = uint8(num) + j3++ + } + i -= j3 + copy(dAtA[i:], dAtA4[:j3]) + i = encodeVarintOracle(dAtA, i, uint64(j3)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *IBCChannel) 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 *IBCChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintOracle(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RequestVerification) 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 *RequestVerification) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RequestVerification) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExternalID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ExternalID)) + i-- + dAtA[i] = 0x20 + } + if m.RequestID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x18 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainID) > 0 { + i -= len(m.ChainID) + copy(dAtA[i:], m.ChainID) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ChainID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PriceResult) 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 *PriceResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PriceResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ResolveTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.ResolveTime)) + i-- + dAtA[i] = 0x28 + } + if m.RequestID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x20 + } + if m.Px != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.Px)) + i-- + dAtA[i] = 0x18 + } + if m.Multiplier != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.Multiplier)) + i-- + dAtA[i] = 0x10 + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOracle(dAtA []byte, offset int, v uint64) int { + offset -= sovOracle(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DataSource) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Filename) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Treasury) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if len(m.Fee) > 0 { + for _, e := range m.Fee { + l = e.Size() + n += 1 + l + sovOracle(uint64(l)) + } + } + return n +} + +func (m *OracleScript) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Filename) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Schema) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.SourceCodeURL) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *RawRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ExternalID != 0 { + n += 1 + sovOracle(uint64(m.ExternalID)) + } + if m.DataSourceID != 0 { + n += 1 + sovOracle(uint64(m.DataSourceID)) + } + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *RawReport) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ExternalID != 0 { + n += 1 + sovOracle(uint64(m.ExternalID)) + } + if m.ExitCode != 0 { + n += 1 + sovOracle(uint64(m.ExitCode)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *Request) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.OracleScriptID != 0 { + n += 1 + sovOracle(uint64(m.OracleScriptID)) + } + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if len(m.RequestedValidators) > 0 { + for _, s := range m.RequestedValidators { + l = len(s) + n += 1 + l + sovOracle(uint64(l)) + } + } + if m.MinCount != 0 { + n += 1 + sovOracle(uint64(m.MinCount)) + } + if m.RequestHeight != 0 { + n += 1 + sovOracle(uint64(m.RequestHeight)) + } + if m.RequestTime != 0 { + n += 1 + sovOracle(uint64(m.RequestTime)) + } + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if len(m.RawRequests) > 0 { + for _, e := range m.RawRequests { + l = e.Size() + n += 1 + l + sovOracle(uint64(l)) + } + } + if m.IBCChannel != nil { + l = m.IBCChannel.Size() + n += 1 + l + sovOracle(uint64(l)) + } + if m.ExecuteGas != 0 { + n += 1 + sovOracle(uint64(m.ExecuteGas)) + } + return n +} + +func (m *Report) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.InBeforeResolve { + n += 2 + } + if len(m.RawReports) > 0 { + for _, e := range m.RawReports { + l = e.Size() + n += 1 + l + sovOracle(uint64(l)) + } + } + return n +} + +func (m *OracleRequestPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.OracleScriptID != 0 { + n += 1 + sovOracle(uint64(m.OracleScriptID)) + } + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.AskCount != 0 { + n += 1 + sovOracle(uint64(m.AskCount)) + } + if m.MinCount != 0 { + n += 1 + sovOracle(uint64(m.MinCount)) + } + if len(m.FeeLimit) > 0 { + for _, e := range m.FeeLimit { + l = e.Size() + n += 1 + l + sovOracle(uint64(l)) + } + } + if m.PrepareGas != 0 { + n += 1 + sovOracle(uint64(m.PrepareGas)) + } + if m.ExecuteGas != 0 { + n += 1 + sovOracle(uint64(m.ExecuteGas)) + } + return n +} + +func (m *OracleRequestPacketAcknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestID != 0 { + n += 1 + sovOracle(uint64(m.RequestID)) + } + return n +} + +func (m *OracleResponsePacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.RequestID != 0 { + n += 1 + sovOracle(uint64(m.RequestID)) + } + if m.AnsCount != 0 { + n += 1 + sovOracle(uint64(m.AnsCount)) + } + if m.RequestTime != 0 { + n += 1 + sovOracle(uint64(m.RequestTime)) + } + if m.ResolveTime != 0 { + n += 1 + sovOracle(uint64(m.ResolveTime)) + } + if m.ResolveStatus != 0 { + n += 1 + sovOracle(uint64(m.ResolveStatus)) + } + l = len(m.Result) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *Result) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.OracleScriptID != 0 { + n += 1 + sovOracle(uint64(m.OracleScriptID)) + } + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.AskCount != 0 { + n += 1 + sovOracle(uint64(m.AskCount)) + } + if m.MinCount != 0 { + n += 1 + sovOracle(uint64(m.MinCount)) + } + if m.RequestID != 0 { + n += 1 + sovOracle(uint64(m.RequestID)) + } + if m.AnsCount != 0 { + n += 1 + sovOracle(uint64(m.AnsCount)) + } + if m.RequestTime != 0 { + n += 1 + sovOracle(uint64(m.RequestTime)) + } + if m.ResolveTime != 0 { + n += 1 + sovOracle(uint64(m.ResolveTime)) + } + if m.ResolveStatus != 0 { + n += 1 + sovOracle(uint64(m.ResolveStatus)) + } + l = len(m.Result) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *ValidatorStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IsActive { + n += 2 + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Since) + n += 1 + l + sovOracle(uint64(l)) + return n +} + +func (m *ActiveValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.Power != 0 { + n += 1 + sovOracle(uint64(m.Power)) + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MaxRawRequestCount != 0 { + n += 1 + sovOracle(uint64(m.MaxRawRequestCount)) + } + if m.MaxAskCount != 0 { + n += 1 + sovOracle(uint64(m.MaxAskCount)) + } + if m.MaxCalldataSize != 0 { + n += 1 + sovOracle(uint64(m.MaxCalldataSize)) + } + if m.MaxReportDataSize != 0 { + n += 1 + sovOracle(uint64(m.MaxReportDataSize)) + } + if m.ExpirationBlockCount != 0 { + n += 1 + sovOracle(uint64(m.ExpirationBlockCount)) + } + if m.BaseOwasmGas != 0 { + n += 1 + sovOracle(uint64(m.BaseOwasmGas)) + } + if m.PerValidatorRequestGas != 0 { + n += 1 + sovOracle(uint64(m.PerValidatorRequestGas)) + } + if m.SamplingTryCount != 0 { + n += 1 + sovOracle(uint64(m.SamplingTryCount)) + } + if m.OracleRewardPercentage != 0 { + n += 1 + sovOracle(uint64(m.OracleRewardPercentage)) + } + if m.InactivePenaltyDuration != 0 { + n += 1 + sovOracle(uint64(m.InactivePenaltyDuration)) + } + if m.IBCRequestEnabled { + n += 2 + } + return n +} + +func (m *PendingResolveList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RequestIds) > 0 { + l = 0 + for _, e := range m.RequestIds { + l += sovOracle(uint64(e)) + } + n += 1 + sovOracle(uint64(l)) + l + } + return n +} + +func (m *IBCChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *RequestVerification) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainID) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.RequestID != 0 { + n += 1 + sovOracle(uint64(m.RequestID)) + } + if m.ExternalID != 0 { + n += 1 + sovOracle(uint64(m.ExternalID)) + } + return n +} + +func (m *PriceResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.Multiplier != 0 { + n += 1 + sovOracle(uint64(m.Multiplier)) + } + if m.Px != 0 { + n += 1 + sovOracle(uint64(m.Px)) + } + if m.RequestID != 0 { + n += 1 + sovOracle(uint64(m.RequestID)) + } + if m.ResolveTime != 0 { + n += 1 + sovOracle(uint64(m.ResolveTime)) + } + return n +} + +func sovOracle(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOracle(x uint64) (n int) { + return sovOracle(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DataSource) 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 ErrIntOverflowOracle + } + 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: DataSource: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DataSource: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Filename", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Filename = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Treasury", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Treasury = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fee = append(m.Fee, types.Coin{}) + if err := m.Fee[len(m.Fee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleScript) 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 ErrIntOverflowOracle + } + 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: OracleScript: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleScript: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Filename", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Filename = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Schema = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceCodeURL", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceCodeURL = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawRequest) 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 ErrIntOverflowOracle + } + 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: RawRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalID", wireType) + } + m.ExternalID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExternalID |= ExternalID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DataSourceID", wireType) + } + m.DataSourceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DataSourceID |= DataSourceID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Calldata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Calldata = append(m.Calldata[:0], dAtA[iNdEx:postIndex]...) + if m.Calldata == nil { + m.Calldata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawReport) 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 ErrIntOverflowOracle + } + 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: RawReport: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawReport: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalID", wireType) + } + m.ExternalID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExternalID |= ExternalID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExitCode", wireType) + } + m.ExitCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExitCode |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + 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 ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + 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 := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Request) 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 ErrIntOverflowOracle + } + 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: Request: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScriptID", wireType) + } + m.OracleScriptID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleScriptID |= OracleScriptID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Calldata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Calldata = append(m.Calldata[:0], dAtA[iNdEx:postIndex]...) + if m.Calldata == nil { + m.Calldata = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestedValidators", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RequestedValidators = append(m.RequestedValidators, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCount", wireType) + } + m.MinCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestHeight", wireType) + } + m.RequestHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) + } + m.RequestTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawRequests", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawRequests = append(m.RawRequests, RawRequest{}) + if err := m.RawRequests[len(m.RawRequests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IBCChannel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.IBCChannel == nil { + m.IBCChannel = &IBCChannel{} + } + if err := m.IBCChannel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecuteGas", wireType) + } + m.ExecuteGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecuteGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Report) 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 ErrIntOverflowOracle + } + 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: Report: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Report: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InBeforeResolve", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.InBeforeResolve = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawReports", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawReports = append(m.RawReports, RawReport{}) + if err := m.RawReports[len(m.RawReports)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleRequestPacketData) 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 ErrIntOverflowOracle + } + 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: OracleRequestPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleRequestPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScriptID", wireType) + } + m.OracleScriptID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleScriptID |= OracleScriptID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Calldata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Calldata = append(m.Calldata[:0], dAtA[iNdEx:postIndex]...) + if m.Calldata == nil { + m.Calldata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AskCount", wireType) + } + m.AskCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AskCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCount", wireType) + } + m.MinCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeLimit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeLimit = append(m.FeeLimit, types.Coin{}) + if err := m.FeeLimit[len(m.FeeLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrepareGas", wireType) + } + m.PrepareGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrepareGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecuteGas", wireType) + } + m.ExecuteGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecuteGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleRequestPacketAcknowledgement) 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 ErrIntOverflowOracle + } + 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: OracleRequestPacketAcknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleRequestPacketAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= RequestID(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleResponsePacketData) 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 ErrIntOverflowOracle + } + 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: OracleResponsePacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleResponsePacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= RequestID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AnsCount", wireType) + } + m.AnsCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AnsCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) + } + m.RequestTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveTime", wireType) + } + m.ResolveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveStatus", wireType) + } + m.ResolveStatus = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveStatus |= ResolveStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = append(m.Result[:0], dAtA[iNdEx:postIndex]...) + if m.Result == nil { + m.Result = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Result) 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 ErrIntOverflowOracle + } + 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: Result: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Result: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScriptID", wireType) + } + m.OracleScriptID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleScriptID |= OracleScriptID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Calldata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Calldata = append(m.Calldata[:0], dAtA[iNdEx:postIndex]...) + if m.Calldata == nil { + m.Calldata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AskCount", wireType) + } + m.AskCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AskCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCount", wireType) + } + m.MinCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= RequestID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AnsCount", wireType) + } + m.AnsCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AnsCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) + } + m.RequestTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveTime", wireType) + } + m.ResolveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveStatus", wireType) + } + m.ResolveStatus = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveStatus |= ResolveStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = append(m.Result[:0], dAtA[iNdEx:postIndex]...) + if m.Result == nil { + m.Result = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorStatus) 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 ErrIntOverflowOracle + } + 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: ValidatorStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsActive", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsActive = bool(v != 0) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Since", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Since, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ActiveValidator) 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 ErrIntOverflowOracle + } + 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: ActiveValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ActiveValidator: 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 ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Power", wireType) + } + m.Power = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Power |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +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 ErrIntOverflowOracle + } + 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 { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxRawRequestCount", wireType) + } + m.MaxRawRequestCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxRawRequestCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAskCount", wireType) + } + m.MaxAskCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxAskCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxCalldataSize", wireType) + } + m.MaxCalldataSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxCalldataSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxReportDataSize", wireType) + } + m.MaxReportDataSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxReportDataSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpirationBlockCount", wireType) + } + m.ExpirationBlockCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExpirationBlockCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseOwasmGas", wireType) + } + m.BaseOwasmGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BaseOwasmGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PerValidatorRequestGas", wireType) + } + m.PerValidatorRequestGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PerValidatorRequestGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SamplingTryCount", wireType) + } + m.SamplingTryCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SamplingTryCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleRewardPercentage", wireType) + } + m.OracleRewardPercentage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleRewardPercentage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InactivePenaltyDuration", wireType) + } + m.InactivePenaltyDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.InactivePenaltyDuration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IBCRequestEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IBCRequestEnabled = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PendingResolveList) 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 ErrIntOverflowOracle + } + 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: PendingResolveList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PendingResolveList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.RequestIds = append(m.RequestIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.RequestIds) == 0 { + m.RequestIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.RequestIds = append(m.RequestIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field RequestIds", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IBCChannel) 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 ErrIntOverflowOracle + } + 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: IBCChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = 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 ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RequestVerification) 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 ErrIntOverflowOracle + } + 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: RequestVerification: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RequestVerification: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= RequestID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalID", wireType) + } + m.ExternalID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExternalID |= ExternalID(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PriceResult) 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 ErrIntOverflowOracle + } + 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: PriceResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PriceResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Multiplier", wireType) + } + m.Multiplier = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Multiplier |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Px", wireType) + } + m.Px = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Px |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= RequestID(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveTime", wireType) + } + m.ResolveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOracle(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, ErrIntOverflowOracle + } + 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, ErrIntOverflowOracle + } + 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, ErrIntOverflowOracle + } + 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, ErrInvalidLengthOracle + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOracle + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOracle + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOracle = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOracle = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOracle = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/bandtesting/x/oracle/types/packets.go b/x/oracle/bandtesting/x/oracle/types/packets.go new file mode 100644 index 00000000..407e4a74 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/packets.go @@ -0,0 +1,84 @@ +package types + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + bandoracletypes "github.com/onomyprotocol/reserve/x/oracle/bandchain/oracle/types" + +) + +// NewOracleRequestPacketData contructs a new OracleRequestPacketData instance +func NewOracleRequestPacketData( + clientID string, oracleScriptID OracleScriptID, calldata []byte, askCount uint64, minCount uint64, feeLimit sdk.Coins, prepareGas uint64, executeGas uint64, +) OracleRequestPacketData { + return OracleRequestPacketData{ + ClientID: clientID, + OracleScriptID: oracleScriptID, + Calldata: calldata, + AskCount: askCount, + MinCount: minCount, + FeeLimit: feeLimit, + PrepareGas: prepareGas, + ExecuteGas: executeGas, + } +} + +// ValidateBasic is used for validating the request. +func (p OracleRequestPacketData) ValidateBasic() error { + if p.MinCount <= 0 { + return errors.Wrapf(bandoracletypes.ErrInvalidMinCount, "got: %d", p.MinCount) + } + if p.AskCount < p.MinCount { + return errors.Wrapf(bandoracletypes.ErrInvalidAskCount, "got: %d, min count: %d", p.AskCount, p.MinCount) + } + if len(p.ClientID) > MaxClientIDLength { + return bandoracletypes.WrapMaxError(bandoracletypes.ErrTooLongClientID, len(p.ClientID), MaxClientIDLength) + } + if p.PrepareGas <= 0 { + return errors.Wrapf(bandoracletypes.ErrInvalidOwasmGas, "invalid prepare gas: %d", p.PrepareGas) + } + if p.ExecuteGas <= 0 { + return errors.Wrapf(bandoracletypes.ErrInvalidOwasmGas, "invalid execute gas: %d", p.ExecuteGas) + } + if p.PrepareGas+p.ExecuteGas > MaximumOwasmGas { + return errors.Wrapf(bandoracletypes.ErrInvalidOwasmGas, "sum of prepare gas and execute gas (%d) exceed %d", p.PrepareGas+p.ExecuteGas, MaximumOwasmGas) + } + if !p.FeeLimit.IsValid() { + return errors.Wrap(sdkerrors.ErrInvalidCoins, p.FeeLimit.String()) + } + return nil +} + +// GetBytes is a helper for serialising +func (p OracleRequestPacketData) GetBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&p)) +} + +func NewOracleRequestPacketAcknowledgement(requestID RequestID) *OracleRequestPacketAcknowledgement { + return &OracleRequestPacketAcknowledgement{ + RequestID: requestID, + } +} + +// NewOracleResponsePacketData contructs a new OracleResponsePacketData instance +func NewOracleResponsePacketData( + clientID string, requestID RequestID, ansCount uint64, requestTime int64, + resolveTime int64, resolveStatus ResolveStatus, result []byte, +) OracleResponsePacketData { + return OracleResponsePacketData{ + ClientID: clientID, + RequestID: requestID, + AnsCount: ansCount, + RequestTime: requestTime, + ResolveTime: resolveTime, + ResolveStatus: resolveStatus, + Result: result, + } +} + +// GetBytes returns the bytes representation of this oracle response packet data. +func (p OracleResponsePacketData) GetBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&p)) +} diff --git a/x/oracle/bandtesting/x/oracle/types/params.go b/x/oracle/bandtesting/x/oracle/types/params.go new file mode 100644 index 00000000..5780c520 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/params.go @@ -0,0 +1,134 @@ +package types + +import ( + "fmt" + "time" + + "gopkg.in/yaml.v2" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// nolint +const ( + // Each value below is the default value for each parameter when generating the default + // genesis file. See comments in types.proto for explanation for each parameter. + DefaultMaxRawRequestCount = uint64(12) + DefaultMaxAskCount = uint64(16) + DefaultMaxCalldataSize = uint64(256) // 256B + DefaultMaxReportDataSize = uint64(512) // 512B + DefaultExpirationBlockCount = uint64(100) + DefaultBaseRequestGas = uint64(20000) + DefaultPerValidatorRequestGas = uint64(30000) + DefaultSamplingTryCount = uint64(3) + DefaultOracleRewardPercentage = uint64(70) + DefaultInactivePenaltyDuration = uint64(10 * time.Minute) + DefaultIBCRequestEnabled = true +) + +// nolint +var ( + // Each value below is the key to store the respective oracle module parameter. See comments + // in types.proto for explanation for each parameter. + KeyMaxRawRequestCount = []byte("MaxRawRequestCount") + KeyMaxAskCount = []byte("MaxAskCount") + KeyMaxCalldataSize = []byte("MaxCalldataSize") + KeyMaxReportDataSize = []byte("MaxReportDataSize") + KeyExpirationBlockCount = []byte("ExpirationBlockCount") + KeyBaseOwasmGas = []byte("BaseOwasmGas") + KeyPerValidatorRequestGas = []byte("PerValidatorRequestGas") + KeySamplingTryCount = []byte("SamplingTryCount") + KeyOracleRewardPercentage = []byte("OracleRewardPercentage") + KeyInactivePenaltyDuration = []byte("InactivePenaltyDuration") + KeyIBCRequestEnabled = []byte("IBCRequestEnabled") +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable for oracle module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new parameter configuration for the oracle module +func NewParams( + maxRawRequestCount, maxAskCount, maxCalldataSize, maxReportDataSize, expirationBlockCount, baseRequestGas, perValidatorRequestGas, + samplingTryCount, oracleRewardPercentage, inactivePenaltyDuration uint64, ibcRequestEnabled bool, +) Params { + return Params{ + MaxRawRequestCount: maxRawRequestCount, + MaxAskCount: maxAskCount, + MaxCalldataSize: maxCalldataSize, + MaxReportDataSize: maxReportDataSize, + ExpirationBlockCount: expirationBlockCount, + BaseOwasmGas: baseRequestGas, + PerValidatorRequestGas: perValidatorRequestGas, + SamplingTryCount: samplingTryCount, + OracleRewardPercentage: oracleRewardPercentage, + InactivePenaltyDuration: inactivePenaltyDuration, + IBCRequestEnabled: ibcRequestEnabled, + } +} + +// ParamSetPairs implements the paramtypes.ParamSet interface for Params. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMaxRawRequestCount, &p.MaxRawRequestCount, validateUint64("max data source count", true)), + paramtypes.NewParamSetPair(KeyMaxAskCount, &p.MaxAskCount, validateUint64("max ask count", true)), + paramtypes.NewParamSetPair(KeyMaxCalldataSize, &p.MaxCalldataSize, validateUint64("max calldata size", true)), + paramtypes.NewParamSetPair(KeyMaxReportDataSize, &p.MaxReportDataSize, validateUint64("max report data size", true)), + paramtypes.NewParamSetPair(KeyExpirationBlockCount, &p.ExpirationBlockCount, validateUint64("expiration block count", true)), + paramtypes.NewParamSetPair(KeyBaseOwasmGas, &p.BaseOwasmGas, validateUint64("base request gas", false)), + paramtypes.NewParamSetPair(KeyPerValidatorRequestGas, &p.PerValidatorRequestGas, validateUint64("per validator request gas", false)), + paramtypes.NewParamSetPair(KeySamplingTryCount, &p.SamplingTryCount, validateUint64("sampling try count", true)), + paramtypes.NewParamSetPair(KeyOracleRewardPercentage, &p.OracleRewardPercentage, validateUint64("oracle reward percentage", false)), + paramtypes.NewParamSetPair(KeyInactivePenaltyDuration, &p.InactivePenaltyDuration, validateUint64("inactive penalty duration", false)), + paramtypes.NewParamSetPair(KeyIBCRequestEnabled, &p.IBCRequestEnabled, validateBool()), + } +} + +// DefaultParams defines the default parameters. +func DefaultParams() Params { + return NewParams( + DefaultMaxRawRequestCount, + DefaultMaxAskCount, + DefaultMaxCalldataSize, + DefaultMaxReportDataSize, + DefaultExpirationBlockCount, + DefaultBaseRequestGas, + DefaultPerValidatorRequestGas, + DefaultSamplingTryCount, + DefaultOracleRewardPercentage, + DefaultInactivePenaltyDuration, + DefaultIBCRequestEnabled, + ) +} + +// String returns a human readable string representation of the parameters. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +func validateUint64(name string, positiveOnly bool) func(interface{}) error { + return func(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + if v <= 0 && positiveOnly { + return fmt.Errorf("%s must be positive: %d", name, v) + } + return nil + } +} + +func validateBool() func(interface{}) error { + return func(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + return nil + } +} diff --git a/x/oracle/bandtesting/x/oracle/types/request.go b/x/oracle/bandtesting/x/oracle/types/request.go new file mode 100644 index 00000000..451052e4 --- /dev/null +++ b/x/oracle/bandtesting/x/oracle/types/request.go @@ -0,0 +1,57 @@ +package types + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ RequestSpec = &OracleRequestPacketData{} +) + +// RequestSpec captures the essence of what it means to be a request-making object. +type RequestSpec interface { + GetOracleScriptID() OracleScriptID + GetCalldata() []byte + GetAskCount() uint64 + GetMinCount() uint64 + GetClientID() string + GetPrepareGas() uint64 + GetExecuteGas() uint64 + GetFeeLimit() sdk.Coins +} + +func NewRequest( + oracleScriptID OracleScriptID, + calldata []byte, + requestedValidators []sdk.ValAddress, + minCount uint64, + requestHeight int64, + requestTime time.Time, + clientID string, + rawRequests []RawRequest, + ibcChannel *IBCChannel, + executeGas uint64, +) Request { + requestedVals := make([]string, len(requestedValidators)) + if requestedValidators != nil { + for idx, reqVal := range requestedValidators { + requestedVals[idx] = reqVal.String() + } + } else { + requestedVals = nil + } + return Request{ + OracleScriptID: oracleScriptID, + Calldata: calldata, + RequestedValidators: requestedVals, + MinCount: minCount, + RequestHeight: requestHeight, + RequestTime: requestTime.Unix(), + ClientID: clientID, + RawRequests: rawRequests, + IBCChannel: ibcChannel, + ExecuteGas: executeGas, + } +} diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go new file mode 100644 index 00000000..ef5679bf --- /dev/null +++ b/x/oracle/client/cli/query.go @@ -0,0 +1,56 @@ +package cli + +import ( + "context" + + "github.com/cosmos/gogoproto/proto" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/onomyprotocol/reserve/x/oracle/types" +) + +// GetQueryCmd returns the parent command for all modules/oracle CLi query commands. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the oracle module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetBandPriceStates(), + ) + return cmd +} + +// GetBandPriceStates queries the state for all band price states +func GetBandPriceStates() *cobra.Command { + cmd := &cobra.Command{ + Use: "band-price-states", + Short: "Gets Band price states", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + var res proto.Message + req := &types.QueryBandPriceStatesRequest{} + res, err = queryClient.BandPriceStates(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} \ No newline at end of file diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index f59772ed..eea8042a 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -2,16 +2,30 @@ package cli import ( "fmt" - "time" + "strconv" + errors "github.com/pkg/errors" "github.com/spf13/cobra" "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/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" + govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/onomyprotocol/reserve/x/oracle/types" ) -var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +const ( + flagSymbols = "symbols" + flagRequestedValidatorCount = "requested-validator-count" + flagSufficientValidatorCount = "sufficient-validator-count" + flagMinSourceCount = "min-source-count" + flagPrepareGas = "prepare-gas" + flagExecuteGas = "execute-gas" + flagFeeLimit = "fee-limit" +) // GetTxCmd returns the transaction commands for this module. func GetTxCmd() *cobra.Command { @@ -23,7 +37,276 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - // this line is used by starport scaffolding # 1 + cmd.AddCommand( + NewRequestBandRatesTxCmd(), + NewUpdateBandOracleRequestProposalTxCmd(), + NewDeleteBandOracleRequestProposalTxCmd(), + ) + + return cmd +} + +// NewRequestBandRatesTxCmd implements the request command handler. +func NewRequestBandRatesTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "request-band-rates [request-id]", + Short: "Make a new data request via an existing oracle script", + Args: cobra.ExactArgs(1), + Long: `Make a new request via an existing oracle script with the configuration flags. + Example: + $ %s tx oracle request-band-rates 2 --from mykey`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + requestID, err := strconv.Atoi(args[0]) + if err != nil { + return errors.New("requestID should be a positive number") + } else if requestID <= 0 { + return errors.New("requestID should be a positive number") + } + + msg := types.NewMsgRequestBandRates( + clientCtx.GetFromAddress(), + uint64(requestID), + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) return cmd } + +func NewUpdateBandOracleRequestProposalTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-band-oracle-request-proposal 1 37 [flags]", + Args: cobra.ExactArgs(2), + Short: "Submit a proposal to update a Band Oracle IBC Request.", + Long: `Submit a proposal to update a Band Oracle IBC Request. + Example: + $ %s tx oracle update-band-oracle-request-proposal 1 37 --port-id "oracle" --ibc-version "bandchain-1" --symbols "BTC,ETH,USDT,USDC" --requested-validator-count 4 --sufficient-validator-count 3 --min-source-count 3 --expiration 20 --prepare-gas 50 --execute-gas 5000 --from mykey + `, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + content, err := updateBandOracleRequestProposalArgsToContent(cmd, args) + if err != nil { + return err + } + + from := clientCtx.GetFromAddress() + + depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit) + if err != nil { + return err + } + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().StringSlice(flagSymbols, []string{}, "Symbols used in calling the oracle script") + cmd.Flags().Uint64(flagPrepareGas, 0, "Prepare gas used in fee counting for prepare request") + cmd.Flags().Uint64(flagExecuteGas, 0, "Execute gas used in fee counting for execute request") + cmd.Flags().String(flagFeeLimit, "", "the maximum tokens that will be paid to all data source providers") + cmd.Flags().Uint64(flagRequestedValidatorCount, 0, "Requested Validator Count") + cmd.Flags().Uint64(flagSufficientValidatorCount, 0, "Sufficient Validator Count") + cmd.Flags().Uint64(flagMinSourceCount, 3, "Min Source Count") + cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") + cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") + cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal") + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +func NewDeleteBandOracleRequestProposalTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete-band-oracle-request-proposal 1 [flags]", + Args: cobra.MinimumNArgs(1), + Short: "Submit a proposal to Delete a Band Oracle IBC Request.", + Long: `Submit a proposal to Delete a Band Oracle IBC Request. + Example: + $ %s tx oracle delete-band-oracle-request-proposal 1 --from mykey + `, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + content, err := deleteBandOracleRequestProposalArgsToContent(cmd, args) + if err != nil { + return err + } + + from := clientCtx.GetFromAddress() + + depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit) + if err != nil { + return err + } + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") + cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") + cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal") + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +func updateBandOracleRequestProposalArgsToContent( + cmd *cobra.Command, + args []string, +) (govtypes.Content, error) { + title, err := cmd.Flags().GetString(govcli.FlagTitle) + if err != nil { + return nil, err + } + + description, err := cmd.Flags().GetString(govcli.FlagDescription) + if err != nil { + return nil, err + } + + requestID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return nil, err + } + + int64OracleScriptID, err := strconv.ParseInt(args[1], 10, 64) + if err != nil { + return nil, err + } + + askCount, err := cmd.Flags().GetUint64(flagRequestedValidatorCount) + if err != nil { + return nil, err + } + + minCount, err := cmd.Flags().GetUint64(flagSufficientValidatorCount) + if err != nil { + return nil, err + } + minSourceCount, err := cmd.Flags().GetUint64(flagMinSourceCount) + if err != nil { + return nil, err + } + + symbols, err := cmd.Flags().GetStringSlice(flagSymbols) + if err != nil { + return nil, err + } + + prepareGas, err := cmd.Flags().GetUint64(flagPrepareGas) + if err != nil { + return nil, err + } + + executeGas, err := cmd.Flags().GetUint64(flagExecuteGas) + if err != nil { + return nil, err + } + + coinStr, err := cmd.Flags().GetString(flagFeeLimit) + if err != nil { + return nil, err + } + + feeLimit, err := sdk.ParseCoinsNormalized(coinStr) + if err != nil { + return nil, err + } + + content := &types.UpdateBandOracleRequestProposal{ + Title: title, + Description: description, + UpdateOracleRequest: &types.BandOracleRequest{ + RequestId: uint64(requestID), + OracleScriptId: int64OracleScriptID, + Symbols: symbols, + AskCount: askCount, + MinCount: minCount, + FeeLimit: feeLimit, + PrepareGas: prepareGas, + ExecuteGas: executeGas, + MinSourceCount: minSourceCount, + }, + } + if err := content.ValidateBasic(); err != nil { + return nil, err + } + + return content, nil +} + +func deleteBandOracleRequestProposalArgsToContent( + cmd *cobra.Command, + args []string, +) (govtypes.Content, error) { + title, err := cmd.Flags().GetString(govcli.FlagTitle) + if err != nil { + return nil, err + } + + description, err := cmd.Flags().GetString(govcli.FlagDescription) + if err != nil { + return nil, err + } + + requestIDs := make([]uint64, 0, len(args)) + for _, arg := range args { + id, err := strconv.ParseInt(arg, 10, 64) + if err != nil { + return nil, err + } + + requestIDs = append(requestIDs, uint64(id)) + } + + content := &types.DeleteBandOracleRequestProposal{ + Title: title, + Description: description, + DeleteRequestIds: requestIDs, + } + + if err := content.ValidateBasic(); err != nil { + return nil, err + } + + return content, nil +} diff --git a/x/oracle/keeper/abci.go b/x/oracle/keeper/abci.go new file mode 100644 index 00000000..04f54011 --- /dev/null +++ b/x/oracle/keeper/abci.go @@ -0,0 +1,50 @@ +package keeper + +import ( + "context" + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/onomyprotocol/reserve/x/oracle/types" +) + +func (k *Keeper) BeginBlocker(ctx context.Context) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + bandParams := k.GetBandParams(ctx) + sdkCtx := sdk.UnwrapSDKContext(ctx) + + // Request oracle prices using band IBC in frequent intervals + if sdkCtx.BlockHeight()%bandParams.IbcRequestInterval == 0 { + k.RequestAllBandRates(ctx) + } + + // todo: default cleanup interval (1 day) + if sdkCtx.BlockHeight()%86400 == 0 { + k.CleanUpStaleBandCalldataRecords(sdkCtx) + } +} + +func (k *Keeper) RequestAllBandRates(ctx context.Context) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + // TODO: check logic flow for this + bandOracleRequests := k.GetAllBandOracleRequests(ctx) + + if len(bandOracleRequests) == 0 { + return + } + + for _, req := range bandOracleRequests { + println("checking request .......") + for _, symbol := range req.Symbols { + println("With symbols: ", symbol) + } + err := k.RequestBandOraclePrices(ctx, req) + if err != nil { + sdkCtx.Logger().Error(err.Error()) + } + } +} + +func (k *Keeper) EndBlocker(ctx context.Context) { +} diff --git a/x/oracle/keeper/band_oracle.go b/x/oracle/keeper/band_oracle.go new file mode 100644 index 00000000..e57c6617 --- /dev/null +++ b/x/oracle/keeper/band_oracle.go @@ -0,0 +1,530 @@ +package keeper + +import ( + "fmt" + "time" + "strconv" + "context" + math "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + prefix "cosmossdk.io/store/prefix" + runtime "github.com/cosmos/cosmos-sdk/runtime" + "github.com/onomyprotocol/reserve/x/oracle/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + errorsmod "cosmossdk.io/errors" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" +) + +// SetBandParams sets the Band params in the state +func (k Keeper) SetBandParams(ctx context.Context, bandParams types.BandParams) error{ + bz := k.cdc.MustMarshal(&bandParams) + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.BandParamsKey, bz) +} + +// GetBandParams gets the Band params stored in the state +func (k Keeper) GetBandParams(ctx context.Context) types.BandParams { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.BandParamsKey) + + if err != nil { + return types.DefaultGenesis().BandParams + } + + if bz == nil { + return types.DefaultGenesis().BandParams + } + + var bandParams types.BandParams + k.cdc.MustUnmarshal(bz, &bandParams) + return bandParams +} + +// SetBandOracleRequestParams sets the Band Oracle request params in the state +func (k Keeper) SetBandOracleRequestParams(ctx context.Context, bandOracleRequestParams types.BandOracleRequestParams) error{ + bz := k.cdc.MustMarshal(&bandOracleRequestParams) + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.BandOracleRequestParamsKey, bz) +} + +// GetBandParams gets the Band params stored in the state +func (k Keeper) GetBandOracleRequestParams(ctx context.Context) types.BandOracleRequestParams { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.BandParamsKey) + + if err != nil { + return types.DefaultGenesis().BandOracleRequestParams + } + + if bz == nil { + return types.DefaultGenesis().BandOracleRequestParams + } + + var bandOracleRequestParams types.BandOracleRequestParams + k.cdc.MustUnmarshal(bz, &bandOracleRequestParams) + return bandOracleRequestParams +} + +// SetBandCallData sets the Band IBC oracle request call data +func (k Keeper) SetBandCallDataRecord(ctx context.Context, record *types.CalldataRecord) error { + bz := k.cdc.MustMarshal(record) + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.GetBandCallDataRecordKey(record.ClientId), bz) +} + +// DeleteBandCallDataRecord deletes the Band IBC oracle request call data +func (k Keeper) DeleteBandCallDataRecord(ctx context.Context, clientID uint64) error{ + store := k.storeService.OpenKVStore(ctx) + return store.Delete(types.GetBandCallDataRecordKey(clientID)) +} + +// GetAllBandCalldataRecords gets all Band oracle request CallData for each clientID +func (k Keeper) GetAllBandCalldataRecords(ctx context.Context) []*types.CalldataRecord { + calldataRecords := make([]*types.CalldataRecord, 0) + kvStore := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + bandCalldataStore := prefix.NewStore(kvStore, types.BandCallDataRecordKey) + + iterator := bandCalldataStore.Iterator(nil, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var calldataRecord types.CalldataRecord + k.cdc.MustUnmarshal(iterator.Value(), &calldataRecord) + calldataRecords = append(calldataRecords, &calldataRecord) + } + + return calldataRecords +} + +// GetBandCallDataRecord gets the Band oracle request CallDataRecord for a given clientID +func (k Keeper) GetBandCallDataRecord(ctx context.Context, clientID uint64) *types.CalldataRecord { + var callDataRecord types.CalldataRecord + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.GetBandCallDataRecordKey(clientID)) + if err != nil { + return nil + } + if bz == nil { + return nil + } + k.cdc.MustUnmarshal(bz, &callDataRecord) + return &callDataRecord +} + +// GetBandLatestClientID returns the latest clientID of Band oracle request packet data. +func (k Keeper) GetBandLatestClientID(ctx context.Context) uint64 { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.LatestClientIDKey) + if err != nil { + return 0 + } + if bz == nil { + return 0 + } + clientID := sdk.BigEndianToUint64(bz) + return clientID +} + +// SetBandLatestClientID sets the latest clientID of Band oracle request packet data. +func (k Keeper) SetBandLatestClientID(ctx context.Context, clientID uint64) error { + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.LatestClientIDKey, sdk.Uint64ToBigEndian(clientID)) +} + +// GetBandLatestRequestID returns the latest requestID of Band oracle request types. +func (k Keeper) GetBandLatestRequestID(ctx context.Context) uint64 { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.LatestRequestIDKey) + if err != nil { + // TODO: should we return 0 here? + return 0 + } + if bz == nil { + return 0 + } + requestID := sdk.BigEndianToUint64(bz) + return requestID +} + +// SetBandLatestRequestID sets the latest requestID of Band oracle request types. +func (k Keeper) SetBandLatestRequestID(ctx context.Context, requestID uint64) error { + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.LatestRequestIDKey, sdk.Uint64ToBigEndian(requestID)) +} + +// SetBandOracleRequest sets the Band oracle request data +func (k Keeper) SetBandOracleRequest(ctx context.Context, req types.BandOracleRequest) error { + bz := k.cdc.MustMarshal(&req) + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.GetBandOracleRequestIDKey(req.RequestId), bz) +} + +// GetBandOracleRequest gets the Band oracle request data +func (k Keeper) GetBandOracleRequest(ctx context.Context, requestID uint64) *types.BandOracleRequest { + var bandOracleRequest types.BandOracleRequest + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.GetBandOracleRequestIDKey(requestID)) + if err != nil { + return nil + } + if bz == nil { + return nil + } + + k.cdc.MustUnmarshal(bz, &bandOracleRequest) + return &bandOracleRequest +} + +// DeleteBandOracleRequest deletes the Band oracle request call data +func (k Keeper) DeleteBandOracleRequest(ctx context.Context, requestID uint64) error{ + store := k.storeService.OpenKVStore(ctx) + return store.Delete(types.GetBandOracleRequestIDKey(requestID)) +} + +// GetAllBandOracleRequests gets all Band oracle requests for each requestID +func (k Keeper) GetAllBandOracleRequests(ctx context.Context) []*types.BandOracleRequest { + bandOracleRequests := make([]*types.BandOracleRequest, 0) + kvStore := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + bandOracleRequestStore := prefix.NewStore(kvStore, types.BandOracleRequestIDKey) + + iterator := bandOracleRequestStore.Iterator(nil, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var bandOracleRequest types.BandOracleRequest + k.cdc.MustUnmarshal(iterator.Value(), &bandOracleRequest) + bandOracleRequests = append(bandOracleRequests, &bandOracleRequest) + } + + return bandOracleRequests +} + +// GetBandPriceState reads the stored band ibc price state. +func (k *Keeper) GetBandPriceState(ctx context.Context, symbol string) *types.BandPriceState { + var priceState types.BandPriceState + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.GetBandPriceStoreKey(symbol)) + if err != nil { + return nil + } + if bz == nil { + return nil + } + + k.cdc.MustUnmarshal(bz, &priceState) + return &priceState +} + +// SetBandPriceState sets the band ibc price state. +func (k *Keeper) SetBandPriceState(ctx context.Context, symbol string, priceState *types.BandPriceState) error{ + bz := k.cdc.MustMarshal(priceState) + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.GetBandPriceStoreKey(symbol), bz) +} + +// GetAllBandPriceStates reads all stored band price states. +func (k *Keeper) GetAllBandPriceStates(ctx context.Context) []*types.BandPriceState { + priceStates := make([]*types.BandPriceState, 0) + kvStore := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + bandPriceStore := prefix.NewStore(kvStore, types.BandPriceKey) + + iterator := bandPriceStore.Iterator(nil, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var bandPriceState types.BandPriceState + k.cdc.MustUnmarshal(iterator.Value(), &bandPriceState) + priceStates = append(priceStates, &bandPriceState) + } + + return priceStates +} + +// AddNewSymbolToBandOracleRequest adds a new symbol to the bandOracle request +func (k Keeper) AddNewSymbolToBandOracleRequest(ctx context.Context, symbol string, oracleScriptId int64) error{ + allBandOracleRequests := k.GetAllBandOracleRequests(ctx) + // check if new symbol's oracle script id is existing + for _, req := range allBandOracleRequests { + if req.OracleScriptId == oracleScriptId { + req.Symbols = append(req.Symbols, symbol) + k.SetBandOracleRequest(ctx, *req) + return nil + } + } + + bandOracleRequestParams := k.GetBandOracleRequestParams(ctx) + requestID := k.GetBandLatestRequestID(ctx) + 1 + newBandOracleRequest := types.BandOracleRequest{ + RequestId: requestID, + OracleScriptId: oracleScriptId, + Symbols: []string{symbol}, + AskCount: bandOracleRequestParams.AskCount, + MinCount: bandOracleRequestParams.MinCount, + FeeLimit: bandOracleRequestParams.FeeLimit, + PrepareGas: bandOracleRequestParams.PrepareGas, + ExecuteGas: bandOracleRequestParams.ExecuteGas, + MinSourceCount: bandOracleRequestParams.MinSourceCount, + } + + k.SetBandOracleRequest(ctx, newBandOracleRequest) + + k.SetBandLatestRequestID(ctx, requestID) + return nil +} + +// GetPrice fetches band ibc prices for a given pair in math.LegacyDec +func (k *Keeper) GetPrice(ctx context.Context, base, quote string) *math.LegacyDec { + // query ref by using GetBandPriceState + basePriceState := k.GetBandPriceState(ctx, base) + if basePriceState == nil || basePriceState.Rate.IsZero() { + return nil + } + + if quote == types.QuoteUSD { + return &basePriceState.PriceState.Price + } + + quotePriceState := k.GetBandPriceState(ctx, quote) + if quotePriceState == nil || quotePriceState.Rate.IsZero() { + return nil + } + + baseRate := basePriceState.Rate.ToLegacyDec() + quoteRate := quotePriceState.Rate.ToLegacyDec() + + if baseRate.IsNil() || quoteRate.IsNil() || !baseRate.IsPositive() || !quoteRate.IsPositive() { + return nil + } + + price := baseRate.Quo(quoteRate) + return &price +} + +// RequestBandOraclePrices creates and sends an IBC packet to fetch band oracle price feed data through IBC. +func (k *Keeper) RequestBandOraclePrices( + ctx context.Context, + req *types.BandOracleRequest, +) (err error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + bandParams := k.GetBandParams(ctx) + sourcePortID := bandParams.IbcPortId + sourceChannel := bandParams.IbcSourceChannel + + calldata := req.GetCalldata(types.IsLegacySchemeOracleScript(req.OracleScriptId, bandParams)) + + sourceChannelEnd, found := k.ibcKeeperFn().ChannelKeeper.GetChannel(sdkCtx, sourcePortID, sourceChannel) + if !found { + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unknown channel %s port %s", sourceChannel, sourcePortID) + } + + // retrieve the dynamic capability for this channel + channelCap, ok := k.ScopedKeeper().GetCapability(sdkCtx, host.ChannelCapabilityPath(sourcePortID, sourceChannel)) + if !ok { + return errorsmod.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + } + + destinationPort := sourceChannelEnd.Counterparty.PortId + destinationChannel := sourceChannelEnd.Counterparty.ChannelId + sequence, found := k.ibcKeeperFn().ChannelKeeper.GetNextSequenceSend(sdkCtx, sourcePortID, sourceChannel) + + if !found { + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unknown sequence number for channel %s port %s", sourceChannel, sourcePortID) + } + + clientID := k.GetBandLatestClientID(ctx) + 1 + packetData := types.NewOracleRequestPacketData(strconv.Itoa(int(clientID)), calldata, req) + + // Creating custom oracle packet data + packet := channeltypes.NewPacket( + packetData.GetBytes(), + sequence, + sourcePortID, + sourceChannel, + destinationPort, + destinationChannel, + clienttypes.NewHeight(0, 0), + uint64(sdkCtx.BlockTime().UnixNano()+int64(20*time.Minute)), // Arbitrarily high timeout for now + ) + + // Send packet to IBC, authenticating with channelCap + _, err = k.ibcKeeperFn().ChannelKeeper.SendPacket( + sdkCtx, + channelCap, + packet.SourcePort, + packet.SourceChannel, + packet.TimeoutHeight, + packet.TimeoutTimestamp, + packet.Data, + ) + if err != nil { + return err + } + + // Persist the sequence number and OracleRequest CallData. CallData contains list of symbols. + // This is used to map the prices/rates with the symbols upon receiving oracle response from Band IBC. + k.SetBandCallDataRecord(ctx, &types.CalldataRecord{ + ClientId: clientID, + Calldata: calldata, + }) + + k.SetBandLatestClientID(ctx, clientID) + + return +} + +func (k *Keeper) ProcessBandOraclePrices( + ctx context.Context, + relayer sdk.Address, + packet types.OracleResponsePacketData, +) error { + clientID, err := strconv.Atoi(packet.ClientID) + if err != nil { + return fmt.Errorf("failed to parse client ID: %w", err) + } + + callRecord := k.GetBandCallDataRecord(ctx, uint64(clientID)) + if callRecord == nil { + // TODO: should this be an error? + return nil + } + + input, err := types.DecodeOracleInput(callRecord.Calldata) + if err != nil { + return err + } + + output, err := types.DecodeOracleOutput(packet.Result) + if err != nil { + return err + } + + k.updateBandPriceStates(ctx, input, output, packet, relayer, clientID) + + // Delete the calldata corresponding to the sequence number + k.DeleteBandCallDataRecord(ctx, uint64(clientID)) + + return nil +} + +func (k *Keeper) updateBandPriceStates( + ctx context.Context, + input types.OracleInput, + output types.OracleOutput, + packet types.OracleResponsePacketData, + relayer sdk.Address, + clientID int, +) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + var ( + inputSymbols = input.PriceSymbols() + requestID = packet.RequestID + resolveTime = uint64(packet.ResolveTime) + symbols = make([]string, 0, len(inputSymbols)) + prices = make([]math.LegacyDec, 0, len(inputSymbols)) + ) + + // loop SetBandPriceState for all symbols + for idx, symbol := range inputSymbols { + if !output.Valid(idx) { + // failed response for given symbol, skip it + continue + } + + var ( + rate = output.Rate(idx) + multiplier = input.PriceMultiplier() + price = math.LegacyNewDec(int64(rate)).Quo(math.LegacyNewDec(int64(multiplier))) + ) + println("Checking symbol: %s and price: %s", symbol, price.String()) + if price.IsZero() { + continue + } + + bandPriceState := k.GetBandPriceState(ctx, symbol) + + // don't update band prices with an older price + if bandPriceState != nil && bandPriceState.ResolveTime > resolveTime { + continue + } + + // skip price update if the price changes beyond 100x or less than 1% of the last price + if bandPriceState != nil && types.CheckPriceFeedThreshold(bandPriceState.PriceState.Price, price) { + continue + } + + blockTime := sdkCtx.BlockTime().Unix() + if bandPriceState == nil { + bandPriceState = &types.BandPriceState{ + Symbol: symbol, + Rate: math.NewInt(int64(rate)), + ResolveTime: resolveTime, + Request_ID: requestID, + PriceState: *types.NewPriceState(price, blockTime), + } + } else { + bandPriceState.Rate = math.NewInt(int64(rate)) + bandPriceState.ResolveTime = resolveTime + bandPriceState.Request_ID = requestID + bandPriceState.PriceState.UpdatePrice(price, blockTime) + } + + err := k.SetBandPriceState(ctx, symbol, bandPriceState) + if err != nil { + k.Logger(sdkCtx).Info("Can not set band price state for symbol %v", symbol) + } + + symbols = append(symbols, symbol) + prices = append(prices, price) + } + + if len(symbols) == 0 { + return + } + + // emit SetBandPriceEvent event + // nolint:errcheck //ignored on purpose + sdkCtx.EventManager().EmitTypedEvent(&types.SetBandPriceEvent{ + Relayer: relayer.String(), + Symbols: symbols, + Prices: prices, + ResolveTime: uint64(packet.ResolveTime), + RequestId: packet.RequestID, + ClientId: int64(clientID), + }) +} + +func (k *Keeper) CleanUpStaleBandCalldataRecords(ctx context.Context) { + var ( + latestClientID = k.GetBandLatestClientID(ctx) + earliestToKeepClientID = latestClientID - 1000 // todo: default max records to keep (1000) + ) + + if earliestToKeepClientID > latestClientID { + // underflow + return + } + + for _, id := range k.getPreviousRecordIDs(ctx, earliestToKeepClientID) { + k.DeleteBandCallDataRecord(ctx, id) + } +} + +func (k *Keeper) getPreviousRecordIDs(ctx context.Context, clientID uint64) []uint64 { + kvStore := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + bandCalldataStore := prefix.NewStore(kvStore, types.BandCallDataRecordKey) + iter := bandCalldataStore.Iterator(nil, sdk.Uint64ToBigEndian(clientID)) + defer iter.Close() + + staleIDs := make([]uint64, 0) + for ; iter.Valid(); iter.Next() { + var record types.CalldataRecord + k.cdc.MustUnmarshal(iter.Value(), &record) + + staleIDs = append(staleIDs, record.ClientId) + } + + return staleIDs +} diff --git a/x/oracle/keeper/band_oracle_test.go b/x/oracle/keeper/band_oracle_test.go new file mode 100644 index 00000000..b6dcdcca --- /dev/null +++ b/x/oracle/keeper/band_oracle_test.go @@ -0,0 +1,423 @@ +package keeper_test + +import ( + "testing" + "time" + + "cosmossdk.io/math" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/onomyprotocol/reserve/app" + "github.com/onomyprotocol/reserve/x/oracle/types" + "github.com/onomyprotocol/reserve/x/oracle/utils" + "github.com/stretchr/testify/require" +) + +func TestBandPriceState(t *testing.T) { + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + // Band price state is nil now + data := app.OracleKeeper.GetBandPriceState(ctx, "ATOM") + require.Nil(t, data) + + states := app.OracleKeeper.GetAllBandPriceStates(ctx) + require.Equal(t, 0, len(states)) + + price := app.OracleKeeper.GetPrice(ctx, "ATOM", "USD") + require.Nil(t, price) + + bandPriceState := &types.BandPriceState{ + Symbol: "ATOM", + Rate: math.NewInt(10), + ResolveTime: 1, + Request_ID: 1, + PriceState: *types.NewPriceState(math.LegacyNewDec(10), 1), + } + // set band price state for ATOM + err := app.OracleKeeper.SetBandPriceState(ctx, "ATOM", bandPriceState) + require.NoError(t, err) + + data = app.OracleKeeper.GetBandPriceState(ctx, "ATOM") + require.Equal(t, bandPriceState, data) + + price = app.OracleKeeper.GetPrice(ctx, "ATOM", "USD") + expect := math.LegacyNewDec(10) + require.Equal(t, &expect, price) + + states = app.OracleKeeper.GetAllBandPriceStates(ctx) + require.Equal(t, 1, len(states)) +} + +func TestBandOracleRequest(t *testing.T) { + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + req := app.OracleKeeper.GetBandOracleRequest(ctx, 1) + require.Nil(t, req) + + reqs := app.OracleKeeper.GetAllBandOracleRequests(ctx) + require.Equal(t, 0, len(reqs)) + + bandOracleRequest := types.BandOracleRequest{ + RequestId: 1, + OracleScriptId: 1, + Symbols: []string{"INJ"}, + AskCount: 1, + MinCount: 1, + FeeLimit: sdk.Coins{sdk.NewInt64Coin("INJ", 1)}, + PrepareGas: 100, + ExecuteGas: 200, + } + err := app.OracleKeeper.SetBandOracleRequest(ctx, bandOracleRequest) + require.NoError(t, err) + + req = app.OracleKeeper.GetBandOracleRequest(ctx, 1) + require.Equal(t, &bandOracleRequest, req) + reqs = app.OracleKeeper.GetAllBandOracleRequests(ctx) + require.Equal(t, 1, len(reqs)) + + // delete request and try again + err = app.OracleKeeper.DeleteBandOracleRequest(ctx, 1) + require.NoError(t, err) + reqs = app.OracleKeeper.GetAllBandOracleRequests(ctx) + require.Equal(t, 0, len(reqs)) +} + +func TestBandLatestClientId(t *testing.T) { + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + id := app.OracleKeeper.GetBandLatestClientID(ctx) + require.Equal(t, uint64(0), id) + + err := app.OracleKeeper.SetBandLatestClientID(ctx, 10) + require.NoError(t, err) + + id = app.OracleKeeper.GetBandLatestClientID(ctx) + require.Equal(t, uint64(10), id) +} + +func TestBandLatestRequestId(t *testing.T) { + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + id := app.OracleKeeper.GetBandLatestRequestID(ctx) + require.Equal(t, uint64(0), id) + + err := app.OracleKeeper.SetBandLatestRequestID(ctx, 1) + require.NoError(t, err) + + id = app.OracleKeeper.GetBandLatestRequestID(ctx) + require.Equal(t, uint64(1), id) +} + +func TestBandCallDataRecord(t *testing.T) { + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + record := app.OracleKeeper.GetBandCallDataRecord(ctx, 1) + require.Nil(t, record) + + recordA := &types.CalldataRecord{ + ClientId: 1, + Calldata: []byte("123"), + } + err := app.OracleKeeper.SetBandCallDataRecord(ctx, recordA) + require.NoError(t, err) + record = app.OracleKeeper.GetBandCallDataRecord(ctx, 1) + require.Equal(t, recordA, record) + + err = app.OracleKeeper.DeleteBandCallDataRecord(ctx, 1) + require.NoError(t, err) + + record = app.OracleKeeper.GetBandCallDataRecord(ctx, 1) + require.Nil(t, record) +} + +func TestCleanStaleBandCallDataRecord(t *testing.T) { + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + for id := 0; id < 1010; id++ { + record := &types.CalldataRecord{ + ClientId: uint64(id), + Calldata: []byte("123"), + } + err := app.OracleKeeper.SetBandCallDataRecord(ctx, record) + require.NoError(t, err) + } + records := app.OracleKeeper.GetAllBandCalldataRecords(ctx) + require.Equal(t, 1010, len(records)) + + err := app.OracleKeeper.SetBandLatestClientID(ctx, uint64(1010)) + require.NoError(t, err) + app.OracleKeeper.CleanUpStaleBandCalldataRecords(ctx) + records = app.OracleKeeper.GetAllBandCalldataRecords(ctx) + require.Equal(t, 1000, len(records)) +} + +func TestGetPrice(t *testing.T) { + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + // Setup test data + bandPriceStateATOM := &types.BandPriceState{ + Symbol: "ATOM", + Rate: math.NewInt(10), + ResolveTime: 1, + Request_ID: 1, + PriceState: *types.NewPriceState(math.LegacyNewDec(10), 1), + } + bandPriceStateUSD := &types.BandPriceState{ + Symbol: "USD", + Rate: math.NewInt(1), + ResolveTime: 1, + Request_ID: 1, + PriceState: *types.NewPriceState(math.LegacyNewDec(1), 1), + } + bandPriceStateNOM := &types.BandPriceState{ + Symbol: "NOM", + Rate: math.NewInt(2), + ResolveTime: 1, + Request_ID: 1, + PriceState: *types.NewPriceState(math.LegacyNewDec(2), 1), + } + invalidPriceStateATOM := &types.BandPriceState{ + Symbol: "ATOM", + Rate: math.NewInt(0), // Invalid base rate + ResolveTime: 1, + Request_ID: 1, + PriceState: *types.NewPriceState(math.LegacyNewDec(0), 1), + } + + // Create variables for expected prices + expectedPrice10 := math.LegacyNewDec(10) + expectedPrice05 := math.LegacyNewDec(5) // For ATOM/NOM (10/2) + expectedPrice01 := math.LegacyNewDec(1).Quo(math.LegacyNewDec(10)) // 0.1 + + tests := []struct { + name string + baseSymbol string + quoteSymbol string + basePriceState *types.BandPriceState + quotePriceState *types.BandPriceState + expectedPrice *math.LegacyDec + expectNil bool + }{ + // Return nil cases first + { + name: "Base, quote price do not exist, expect nil", + baseSymbol: "ATOM", + quoteSymbol: "USD", + basePriceState: nil, + quotePriceState: nil, + expectedPrice: nil, + expectNil: true, + }, + { + name: "Base price is invalid (rate is zero), expect nil", + baseSymbol: "ATOM", + quoteSymbol: "USD", + basePriceState: invalidPriceStateATOM, + quotePriceState: bandPriceStateUSD, + expectedPrice: nil, + expectNil: true, + }, + { + name: "Valid base price (ATOM), quote NOM does not exist, expect nil", + baseSymbol: "ATOM", + quoteSymbol: "NOM", + basePriceState: bandPriceStateATOM, + quotePriceState: nil, + expectedPrice: nil, // Since NOM doesn't exist, expect nil + expectNil: true, + }, + // return a valid price + { + name: "Valid base price (ATOM), valid quote price (NOM), expect 5 for ATOM/NOM", + baseSymbol: "ATOM", + quoteSymbol: "NOM", + basePriceState: bandPriceStateATOM, + quotePriceState: bandPriceStateNOM, + expectedPrice: &expectedPrice05, // 10/2 = 5 + expectNil: false, + }, + { + name: "Valid base price (ATOM), quote does not exist, expect 10", + baseSymbol: "ATOM", + quoteSymbol: "USD", + basePriceState: bandPriceStateATOM, + quotePriceState: nil, + expectedPrice: &expectedPrice10, // Since quote = USD, we return base price directly + expectNil: false, + }, + { + name: "Valid base and quote price, expect 10 for ATOM/USD", + baseSymbol: "ATOM", + quoteSymbol: "USD", + basePriceState: bandPriceStateATOM, + quotePriceState: bandPriceStateUSD, + expectedPrice: &expectedPrice10, + expectNil: false, + }, + { + name: "Reverse price (USD to ATOM), expect 0.1", + baseSymbol: "USD", + quoteSymbol: "ATOM", + basePriceState: bandPriceStateUSD, + quotePriceState: bandPriceStateATOM, + expectedPrice: &expectedPrice01, + expectNil: false, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + // Set up base and quote prices + if tc.basePriceState != nil { + err := app.OracleKeeper.SetBandPriceState(ctx, tc.baseSymbol, tc.basePriceState) + require.NoError(t, err) + } + if tc.quotePriceState != nil { + err := app.OracleKeeper.SetBandPriceState(ctx, tc.quoteSymbol, tc.quotePriceState) + require.NoError(t, err) + } + + // Execute GetPrice + price := app.OracleKeeper.GetPrice(ctx, tc.baseSymbol, tc.quoteSymbol) + + // Check expectations + if tc.expectNil { + require.Nil(t, price) + } else { + require.NotNil(t, price) + require.Equal(t, tc.expectedPrice, price) + } + }) + } +} + +func TestProcessBandOraclePrices(t *testing.T) { + // Set up the application and context + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + // Define table-driven test cases + tests := []struct { + name string + clientID string + calldata *types.CalldataRecord + oracleOutput interface{} + expectedError bool + expectedRate int64 + }{ + { + name: "Fail when ClientID is not a valid integer", + clientID: "invalid-id", + calldata: nil, + oracleOutput: nil, + expectedError: true, + }, + { + name: "Return nil when no CallDataRecord found", + clientID: "1", + calldata: nil, + oracleOutput: nil, + expectedError: false, + }, + { + name: "Fail when decoding OracleInput", + clientID: "1", + calldata: &types.CalldataRecord{ + ClientId: 1, + Calldata: []byte{0xFF, 0xFF}, + }, + oracleOutput: nil, + expectedError: true, + }, + { + name: "Fail when decoding OracleOutput", + clientID: "1", + calldata: &types.CalldataRecord{ + ClientId: 1, + Calldata: utils.MustEncode(types.Input{ + Symbols: []string{"ATOM", "BTC"}, + Multiplier: types.BandPriceMultiplier, + }), + }, + oracleOutput: []byte{0xFF, 0xFF}, + expectedError: true, + }, + { + name: "Success with valid OracleResponsePacketData", + clientID: "1", + calldata: &types.CalldataRecord{ + ClientId: 1, + Calldata: utils.MustEncode(types.Input{ + Symbols: []string{"ATOM", "BTC"}, + Multiplier: types.BandPriceMultiplier, + }), + }, + oracleOutput: types.BandOutput{ + Responses: []types.Response{ + {Symbol: "ATOM", ResponseCode: 0, Rate: 100 * types.BandPriceMultiplier}, + {Symbol: "BTC", ResponseCode: 0, Rate: 50000 * types.BandPriceMultiplier}, + }, + }, + expectedError: false, + expectedRate: 100, + }, + } + + // Iterate over each test case + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.calldata != nil { + err := app.OracleKeeper.SetBandCallDataRecord(ctx, tt.calldata) + require.NoError(t, err) + } + + var result []byte + if tt.oracleOutput != nil { + switch v := tt.oracleOutput.(type) { + case types.BandOutput: + result = utils.MustEncode(v) + case []byte: + result = v + } + } + + oraclePacketData := types.OracleResponsePacketData{ + ClientID: tt.clientID, + RequestID: 1, + Result: result, + ResolveTime: time.Now().Unix(), + } + + relayer := sdk.AccAddress("mock-relayer-address") + + err := app.OracleKeeper.ProcessBandOraclePrices(ctx, relayer, oraclePacketData) + + if tt.expectedError { + require.Error(t, err) + } else { + require.NoError(t, err) + + record := app.OracleKeeper.GetBandCallDataRecord(ctx, 1) + require.Nil(t, record, "BandCallDataRecord was not deleted after processing") + + if tt.expectedRate != 0 { + priceState := app.OracleKeeper.GetBandPriceState(ctx, "ATOM") + require.NotNil(t, priceState) + + actualPrice := priceState.PriceState.Price + + expectedPrice := math.LegacyNewDec(tt.expectedRate) + require.True(t, actualPrice.Equal(expectedPrice), "Price for ATOM did not match. Expected: %s, Got: %s", expectedPrice, actualPrice) + } + } + }) + } +} diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index d12398f5..f3dc10bd 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -1,19 +1,17 @@ package keeper import ( - "context" "fmt" - + "context" "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" - "cosmossdk.io/math" "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v8/modules/core/24-host" "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -61,14 +59,16 @@ func NewKeeper( } } + // GetAuthority returns the module's authority. func (k Keeper) GetAuthority() string { return k.authority } // Logger returns a module-specific logger. -func (k Keeper) Logger() log.Logger { - return k.logger.With("module", fmt.Sprintf("x/%s", types.ModuleName)) +func (k Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", types.ModuleName) } // ---------------------------------------------------------------------------- @@ -76,55 +76,60 @@ func (k Keeper) Logger() log.Logger { // ---------------------------------------------------------------------------- // ChanCloseInit defines a wrapper function for the channel Keeper's function. -func (k *Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { +func (k *Keeper) ChanCloseInit(ctx context.Context, portID, channelID string) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) capName := host.ChannelCapabilityPath(portID, channelID) - chanCap, ok := k.ScopedKeeper().GetCapability(ctx, capName) + chanCap, ok := k.ScopedKeeper().GetCapability(sdkCtx, capName) if !ok { return errorsmod.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName) } - return k.ibcKeeperFn().ChannelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap) + return k.ibcKeeperFn().ChannelKeeper.ChanCloseInit(sdkCtx, portID, channelID, chanCap) } // ShouldBound checks if the IBC app module can be bound to the desired port -func (k *Keeper) ShouldBound(ctx sdk.Context, portID string) bool { +func (k *Keeper) ShouldBound(ctx context.Context, portID string) bool { + sdkCtx := sdk.UnwrapSDKContext(ctx) scopedKeeper := k.ScopedKeeper() if scopedKeeper == nil { return false } - _, ok := scopedKeeper.GetCapability(ctx, host.PortPath(portID)) + _, ok := scopedKeeper.GetCapability(sdkCtx, host.PortPath(portID)) return !ok } // BindPort defines a wrapper function for the port Keeper's function in // order to expose it to module's InitGenesis function -func (k *Keeper) BindPort(ctx sdk.Context, portID string) error { - cap := k.ibcKeeperFn().PortKeeper.BindPort(ctx, portID) +func (k *Keeper) BindPort(ctx context.Context, portID string) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + cap := k.ibcKeeperFn().PortKeeper.BindPort(sdkCtx, portID) return k.ClaimCapability(ctx, cap, host.PortPath(portID)) } // GetPort returns the portID for the IBC app module. Used in ExportGenesis -func (k *Keeper) GetPort(ctx sdk.Context) string { +func (k *Keeper) GetPort(ctx context.Context) string { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, []byte{}) return string(store.Get(types.PortKey)) } // SetPort sets the portID for the IBC app module. Used in InitGenesis -func (k *Keeper) SetPort(ctx sdk.Context, portID string) { +func (k *Keeper) SetPort(ctx context.Context, portID string) { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, []byte{}) 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) +func (k *Keeper) AuthenticateCapability(ctx context.Context, cap *capabilitytypes.Capability, name string) bool { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return k.ScopedKeeper().AuthenticateCapability(sdkCtx, cap, name) } // ClaimCapability allows the IBC app module to claim a capability that core IBC // passes to it -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 context.Context, cap *capabilitytypes.Capability, name string) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return k.ScopedKeeper().ClaimCapability(sdkCtx, cap, name) } // ScopedKeeper returns the ScopedKeeper @@ -134,13 +139,3 @@ func (k *Keeper) ScopedKeeper() exported.ScopedKeeper { } return k.scopedKeeper } - -// need to delete when merging with oracle -func (k *Keeper) GetPrice(ctx context.Context, denom string) math.LegacyDec { - return math.LegacyZeroDec() -} - -// need to delete when merging with oracle -func (k *Keeper) AddNewSymbolToBandOracleRequest(ctx context.Context, symbol string, oracleScriptId int64) error { - return nil -} diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go new file mode 100644 index 00000000..0148e6ea --- /dev/null +++ b/x/oracle/keeper/keeper_test.go @@ -0,0 +1,15 @@ +package keeper_test + +import ( + "testing" + testifysuite "github.com/stretchr/testify/suite" + apptesting "github.com/onomyprotocol/reserve/app/apptesting" +) + +type KeeperTestSuite struct { + apptesting.KeeperTestHelper +} + +func TestKeeperTestSuite(t *testing.T) { + testifysuite.Run(t, new(KeeperTestSuite)) +} \ No newline at end of file diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 2c4a4bcb..497478e1 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -1,6 +1,9 @@ package keeper import ( + "context" + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/oracle/types" ) @@ -15,3 +18,19 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } var _ types.MsgServer = msgServer{} + +func (k Keeper) RequestBandRates(goCtx context.Context, msg *types.MsgRequestBandRates) (*types.MsgRequestBandRatesResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + bandOracleRequest := k.GetBandOracleRequest(ctx, msg.RequestId) + if bandOracleRequest == nil { + return nil, errorsmod.Wrapf(types.ErrInvalidBandRequest, "Band oracle request not found!") + } + + if err := k.RequestBandOraclePrices(ctx, bandOracleRequest); err != nil { + k.Logger(ctx).Error(err.Error()) + return nil, err + } + + return &types.MsgRequestBandRatesResponse{}, nil +} diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go index fa8e62ee..997c24a4 100644 --- a/x/oracle/keeper/query.go +++ b/x/oracle/keeper/query.go @@ -1,7 +1,19 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/oracle/types" ) var _ types.QueryServer = Keeper{} + +func (k Keeper) BandPriceStates(c context.Context, _ *types.QueryBandPriceStatesRequest) (*types.QueryBandPriceStatesResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + res := &types.QueryBandPriceStatesResponse{ + PriceStates: k.GetAllBandPriceStates(ctx), + } + + return res, nil +} \ No newline at end of file diff --git a/x/oracle/module/genesis.go b/x/oracle/module/genesis.go index f94ce278..54210700 100644 --- a/x/oracle/module/genesis.go +++ b/x/oracle/module/genesis.go @@ -1,38 +1,67 @@ package oracle import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "context" "github.com/onomyprotocol/reserve/x/oracle/keeper" "github.com/onomyprotocol/reserve/x/oracle/types" ) // InitGenesis initializes the module's state from a provided genesis state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - // this line is used by starport scaffolding # genesis/module/init - k.SetPort(ctx, genState.PortId) - // Only try to bind to port if it is not already bound, since we may already own - // port capability from capability InitGenesis - if k.ShouldBound(ctx, genState.PortId) { - // module binds to the port on InitChain - // and claims the returned capability - err := k.BindPort(ctx, genState.PortId) - if err != nil { - panic("could not claim port capability: " + err.Error()) - } - } +func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { if err := k.SetParams(ctx, genState.Params); err != nil { + // TODO: should we panic here panic(err) } -} -// ExportGenesis returns the module's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) + for _, bandPriceState := range genState.BandPriceStates { + k.SetBandPriceState(ctx, bandPriceState.Symbol, bandPriceState) + } + + for _, bandOracleRequest := range genState.BandOracleRequests { + k.SetBandOracleRequest(ctx, *bandOracleRequest) + } + + k.SetBandParams(ctx, genState.BandParams) + + if genState.BandParams.IbcPortId != "" { + k.SetPort(ctx, genState.BandParams.IbcPortId) + // Only try to bind to port if it is not already bound, since we may already own port capability + if k.ShouldBound(ctx, genState.BandParams.IbcPortId) { + // module binds to the port on InitChain + // and claims the returned capability + err := k.BindPort(ctx, genState.BandParams.IbcPortId) + if err != nil { + panic(types.ErrBandPortBind.Error() + err.Error()) + } + } + } + + if genState.BandLatestClientId != 0 { + k.SetBandLatestClientID(ctx, genState.BandLatestClientId) + } + + for _, record := range genState.CalldataRecords { + k.SetBandCallDataRecord(ctx, record) + } - genesis.PortId = k.GetPort(ctx) - // this line is used by starport scaffolding # genesis/module/export + if genState.BandLatestRequestId != 0 { + k.SetBandLatestRequestID(ctx, genState.BandLatestRequestId) + } + + k.SetBandOracleRequestParams(ctx, genState.BandOracleRequestParams) +} - return genesis +// ExportGenesis returns the module's exported genesis. +func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { + return &types.GenesisState{ + Params: k.GetParams(ctx), + BandParams: k.GetBandParams(ctx), + BandPriceStates: k.GetAllBandPriceStates(ctx), + BandOracleRequests: k.GetAllBandOracleRequests(ctx), + BandLatestClientId: k.GetBandLatestClientID(ctx), + CalldataRecords: k.GetAllBandCalldataRecords(ctx), + BandLatestRequestId: k.GetBandLatestRequestID(ctx), + BandOracleRequestParams: k.GetBandOracleRequestParams(ctx), + } } diff --git a/x/oracle/module/genesis_test.go b/x/oracle/module/genesis_test.go index 6410bd4e..5919085b 100644 --- a/x/oracle/module/genesis_test.go +++ b/x/oracle/module/genesis_test.go @@ -14,7 +14,6 @@ import ( func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ Params: types.DefaultParams(), - PortId: types.PortID, // this line is used by starport scaffolding # genesis/test/state } @@ -26,7 +25,5 @@ func TestGenesis(t *testing.T) { nullify.Fill(&genesisState) nullify.Fill(got) - require.Equal(t, genesisState.PortId, got.PortId) - // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index a4350ccd..8f0d1def 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -18,7 +18,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" - ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -32,7 +32,6 @@ import ( var ( _ module.AppModuleBasic = (*AppModule)(nil) - _ module.AppModuleSimulation = (*AppModule)(nil) _ module.HasGenesis = (*AppModule)(nil) _ module.HasInvariants = (*AppModule)(nil) _ module.HasConsensusVersion = (*AppModule)(nil) @@ -64,7 +63,9 @@ func (AppModuleBasic) Name() string { // RegisterLegacyAminoCodec registers the amino codec for the module, which is used // to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} // RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message. func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { @@ -99,6 +100,10 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() } +// GetQueryCmd returns no root query command for the oracle module. +func (a AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} // ---------------------------------------------------------------------------- // AppModule // ---------------------------------------------------------------------------- @@ -157,13 +162,15 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block. // The begin block implementation is optional. -func (am AppModule) BeginBlock(_ context.Context) error { +func (am AppModule) BeginBlock(ctx context.Context) error { + am.keeper.BeginBlocker(sdk.UnwrapSDKContext(ctx)) return nil } // EndBlock contains the logic that is automatically triggered at the end of each block. // The end block implementation is optional. -func (am AppModule) EndBlock(_ context.Context) error { +func (am AppModule) EndBlock(ctx context.Context) error { + am.keeper.EndBlocker(sdk.UnwrapSDKContext(ctx)) return nil } diff --git a/x/oracle/module/module_ibc.go b/x/oracle/module/module_ibc.go index 3f0bafe6..7909d269 100644 --- a/x/oracle/module/module_ibc.go +++ b/x/oracle/module/module_ibc.go @@ -2,9 +2,10 @@ package oracle import ( "fmt" - "github.com/onomyprotocol/reserve/x/oracle/keeper" "github.com/onomyprotocol/reserve/x/oracle/types" + "strconv" + "strings" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -46,8 +47,14 @@ func (im IBCModule) OnChanOpenInit( return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } - if version != types.Version { - return "", errorsmod.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) + bandParams := im.keeper.GetBandParams(ctx) + + if strings.TrimSpace(version) == "" { + version = bandParams.IbcVersion + } + + if version != bandParams.IbcVersion { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, bandParams.IbcVersion) } // Claim channel capability passed back by IBC module @@ -76,8 +83,10 @@ func (im IBCModule) OnChanOpenTry( return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } - if counterpartyVersion != types.Version { - return "", errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", counterpartyVersion, types.Version) + bandParams := im.keeper.GetBandParams(ctx) + + if counterpartyVersion != bandParams.IbcVersion { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", counterpartyVersion, bandParams.IbcVersion) } // Module may have already claimed capability in OnChanOpenInit in the case of crossing hellos @@ -91,7 +100,7 @@ func (im IBCModule) OnChanOpenTry( } } - return types.Version, nil + return bandParams.IbcVersion, nil } // OnChanOpenAck implements the IBCModule interface @@ -102,8 +111,10 @@ func (im IBCModule) OnChanOpenAck( _, counterpartyVersion string, ) error { - if counterpartyVersion != types.Version { - return errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version) + bandParams := im.keeper.GetBandParams(ctx) + + if counterpartyVersion != bandParams.IbcVersion { + return errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, bandParams.IbcVersion) } return nil } @@ -142,25 +153,26 @@ func (im IBCModule) OnRecvPacket( modulePacket channeltypes.Packet, relayer sdk.AccAddress, ) ibcexported.Acknowledgement { - // var ack channeltypes.Acknowledgement - - // this line is used by starport scaffolding # oracle/packet/module/recv - - var modulePacketData types.OraclePacketData - if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { + var resp types.OracleResponsePacketData + if err := types.ModuleCdc.UnmarshalJSON(modulePacket.GetData(), &resp); err != nil { return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error())) } - // Dispatch packet - switch packet := modulePacketData.Packet.(type) { - // this line is used by starport scaffolding # ibc/packet/module/recv - default: - err := fmt.Errorf("unrecognized %s packet type: %T", types.ModuleName, packet) - return channeltypes.NewErrorAcknowledgement(err) + if resp.ResolveStatus != types.RESOLVE_STATUS_SUCCESS { + clientID, err := strconv.Atoi(resp.ClientID) + if err != nil { + return channeltypes.NewErrorAcknowledgement(fmt.Errorf("failed to parse client ID: %w", err)) + } + // Delete the calldata corresponding to the sequence number + im.keeper.DeleteBandCallDataRecord(ctx, uint64(clientID)) + return channeltypes.NewErrorAcknowledgement(types.ErrResolveStatusNotSuccess) + } + println("Process OnrecvPacket ..........") + if err := im.keeper.ProcessBandOraclePrices(ctx, relayer, resp); err != nil { + return channeltypes.NewErrorAcknowledgement(fmt.Errorf("cannot process Oracle response packet data: %w", err)) } - // NOTE: acknowledgement will be written synchronously during IBC handler execution. - // return ack + return channeltypes.NewResultAcknowledgement([]byte{byte(1)}) } // OnAcknowledgementPacket implements the IBCModule interface @@ -175,49 +187,35 @@ func (im IBCModule) OnAcknowledgementPacket( return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet acknowledgement: %v", err) } - // this line is used by starport scaffolding # oracle/packet/module/ack - - var modulePacketData types.OraclePacketData - if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { + var data types.OracleRequestPacketData + if err := types.ModuleCdc.UnmarshalJSON(modulePacket.GetData(), &data); err != nil { return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()) } - // var eventType string - - // Dispatch packet - switch packet := modulePacketData.Packet.(type) { - // this line is used by starport scaffolding # ibc/packet/module/ack - default: - errMsg := fmt.Sprintf("unrecognized %s packet type: %T", types.ModuleName, packet) - return errorsmod.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - - // ctx.EventManager().EmitEvent( - // sdk.NewEvent( - // eventType, - // sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - // sdk.NewAttribute(types.AttributeKeyAck, fmt.Sprintf("%v", ack)), - // ), - // ) - - // switch resp := ack.Response.(type) { - // case *channeltypes.Acknowledgement_Result: - // ctx.EventManager().EmitEvent( - // sdk.NewEvent( - // eventType, - // sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), - // ), - // ) - // case *channeltypes.Acknowledgement_Error: - // ctx.EventManager().EmitEvent( - // sdk.NewEvent( - // eventType, - // sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), - // ), - // ) - // } - - // return nil + clientID, err := strconv.Atoi(data.ClientID) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot parse client id: %s", err.Error()) + } + + switch resp := ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + // the acknowledgement succeeded on the receiving chain so nothing + // needs to be executed and no error needs to be returned + // nolint:errcheck //ignored on purpose + ctx.EventManager().EmitTypedEvent(&types.EventBandAckSuccess{ + AckResult: string(resp.Result), + ClientId: int64(clientID), + }) + case *channeltypes.Acknowledgement_Error: + im.keeper.DeleteBandCallDataRecord(ctx, uint64(clientID)) + // nolint:errcheck //ignored on purpose + ctx.EventManager().EmitTypedEvent(&types.EventBandAckError{ + AckError: resp.Error, + ClientId: int64(clientID), + }) + } + + return nil } // OnTimeoutPacket implements the IBCModule interface @@ -226,18 +224,22 @@ func (im IBCModule) OnTimeoutPacket( modulePacket channeltypes.Packet, relayer sdk.AccAddress, ) error { - var modulePacketData types.OraclePacketData - if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { + var data types.OracleRequestPacketData + if err := types.ModuleCdc.UnmarshalJSON(modulePacket.GetData(), &data); err != nil { return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()) } - // Dispatch packet - switch packet := modulePacketData.Packet.(type) { - // this line is used by starport scaffolding # ibc/packet/module/timeout - default: - errMsg := fmt.Sprintf("unrecognized %s packet type: %T", types.ModuleName, packet) - return errorsmod.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + clientID, err := strconv.Atoi(data.ClientID) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot parse client id: %s", err.Error()) } - // return nil + // Delete the calldata corresponding to the sequence number + im.keeper.DeleteBandCallDataRecord(ctx, uint64(clientID)) + // nolint:errcheck //ignored on purpose + ctx.EventManager().EmitTypedEvent(&types.EventBandResponseTimeout{ + ClientId: int64(clientID), + }) + + return nil } diff --git a/x/oracle/module/module_ibc_test.go b/x/oracle/module/module_ibc_test.go new file mode 100644 index 00000000..c8027f3b --- /dev/null +++ b/x/oracle/module/module_ibc_test.go @@ -0,0 +1,384 @@ +package oracle_test + +import ( + "encoding/hex" + + "cosmossdk.io/math" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + reserveapp "github.com/onomyprotocol/reserve/app" + oracletypes "github.com/onomyprotocol/reserve/x/oracle/types" + utils "github.com/onomyprotocol/reserve/x/oracle/utils" +) + +func (suite *PriceRelayTestSuite) TestOnChanOpenInit() { + var ( + channel *channeltypes.Channel + path *ibctesting.Path + chanCap *capabilitytypes.Capability + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + + { + "success", func() {}, true, + }, + { + "invalid port ID", func() { + path.EndpointA.ChannelConfig.PortID = ibctesting.MockPort + }, false, + }, + { + "invalid version", func() { + channel.Version = "version" + }, false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.TearDownTest() + suite.SetupTest() // reset + path = NewPriceRelayPath(suite.chainO, suite.chainB) + suite.coordinator.SetupConnections(path) + path.EndpointA.ChannelID = ibctesting.FirstChannelID + + counterparty := channeltypes.NewCounterparty(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + channel = &channeltypes.Channel{ + State: channeltypes.INIT, + Ordering: channeltypes.UNORDERED, + Counterparty: counterparty, + ConnectionHops: []string{path.EndpointA.ConnectionID}, + Version: oracletypes.DefaultTestBandIbcParams().IbcVersion, + } + + onomyapp := suite.chainO.App.(*reserveapp.App) + + portCap := onomyapp.IBCKeeper.PortKeeper.BindPort(suite.chainO.GetContext(), "oracle") + onomyapp.OracleKeeper.ClaimCapability(suite.chainO.GetContext(), portCap, host.PortPath("oracle")) //nolint:errcheck // checking this error isn't needed for the test + + module, _, err := suite.chainO.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainO.GetContext(), oracletypes.DefaultTestBandIbcParams().IbcPortId) + suite.Require().NoError(err) + + chanCap, err = suite.chainO.App.GetScopedIBCKeeper().NewCapability(suite.chainO.GetContext(), host.ChannelCapabilityPath(oracletypes.DefaultTestBandIbcParams().IbcPortId, path.EndpointA.ChannelID)) + suite.Require().NoError(err) + + cbs, ok := suite.chainO.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + tc.malleate() // explicitly change fields in channel and testChannel + + _, err = cbs.OnChanOpenInit(suite.chainO.GetContext(), channel.Ordering, channel.GetConnectionHops(), + path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, channel.GetVersion(), + ) + + if tc.expPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + + }) + } +} + +func (suite *PriceRelayTestSuite) TestOnChanOpenTry() { + var ( + channel *channeltypes.Channel + chanCap *capabilitytypes.Capability + path *ibctesting.Path + counterpartyVersion string + ) + + testCases := []struct { + name string + malleate func() + expPass bool + expAppVersion string + }{ + + { + "success", func() {}, true, oracletypes.DefaultTestBandIbcParams().IbcVersion, + }, + { + "invalid port ID", func() { + path.EndpointA.ChannelConfig.PortID = ibctesting.MockPort + }, false, "", + }, + { + "invalid channel version", func() { + channel.Version = "version" + }, true, oracletypes.DefaultTestBandIbcParams().IbcVersion, + }, + { + "invalid counterparty version", func() { + counterpartyVersion = "version" + }, false, "", + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.TearDownTest() + suite.SetupTest() // reset + + path = NewPriceRelayPath(suite.chainO, suite.chainB) + suite.coordinator.SetupConnections(path) + path.EndpointA.ChannelID = ibctesting.FirstChannelID + + counterparty := channeltypes.NewCounterparty(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + channel = &channeltypes.Channel{ + State: channeltypes.TRYOPEN, + Ordering: channeltypes.UNORDERED, + Counterparty: counterparty, + ConnectionHops: []string{path.EndpointA.ConnectionID}, + Version: oracletypes.DefaultTestBandIbcParams().IbcVersion, + } + counterpartyVersion = oracletypes.DefaultTestBandIbcParams().IbcVersion + + onomyapp := suite.chainO.App.(*reserveapp.App) + + portCap := onomyapp.IBCKeeper.PortKeeper.BindPort(suite.chainO.GetContext(), "oracle") + onomyapp.OracleKeeper.ClaimCapability(suite.chainO.GetContext(), portCap, host.PortPath("oracle")) //nolint:errcheck // checking this error isn't needed for the test + + module, _, err := suite.chainO.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainO.GetContext(), oracletypes.DefaultTestBandIbcParams().IbcPortId) + suite.Require().NoError(err) + + chanCap, err = suite.chainO.App.GetScopedIBCKeeper().NewCapability(suite.chainO.GetContext(), host.ChannelCapabilityPath(oracletypes.DefaultTestBandIbcParams().IbcPortId, path.EndpointA.ChannelID)) + suite.Require().NoError(err) + + cbs, ok := suite.chainO.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + tc.malleate() // explicitly change fields in channel and testChannel + + appVersion, err := cbs.OnChanOpenTry(suite.chainO.GetContext(), channel.Ordering, channel.GetConnectionHops(), + path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, counterpartyVersion, + ) + + suite.Assert().Equal(tc.expAppVersion, appVersion) + + if tc.expPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *PriceRelayTestSuite) TestOnChanOpenAck() { + var counterpartyVersion string + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + + { + "success", func() {}, true, + }, + { + "invalid counterparty version", func() { + counterpartyVersion = "version" + }, false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.TearDownTest() + suite.SetupTest() // reset + + path := NewPriceRelayPath(suite.chainO, suite.chainB) + suite.coordinator.SetupConnections(path) + path.EndpointA.ChannelID = ibctesting.FirstChannelID + counterpartyVersion = oracletypes.DefaultTestBandIbcParams().IbcVersion + + onomyapp := suite.chainO.App.(*reserveapp.App) + + portCap := onomyapp.IBCKeeper.PortKeeper.BindPort(suite.chainO.GetContext(), "oracle") + onomyapp.OracleKeeper.ClaimCapability(suite.chainO.GetContext(), portCap, host.PortPath("oracle")) //nolint:errcheck // checking this error isn't needed for the test + + module, _, err := suite.chainO.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainO.GetContext(), oracletypes.DefaultTestBandIbcParams().IbcPortId) + suite.Require().NoError(err) + + cbs, ok := suite.chainO.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + tc.malleate() // explicitly change fields in channel and testChannel + + err = cbs.OnChanOpenAck(suite.chainO.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointA.Counterparty.ChannelID, counterpartyVersion) + + if tc.expPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *PriceRelayTestSuite) TestOnRecvPacket() { + // TODO: Add more test case to cover all branch + var packetData []byte + var msg oracletypes.OracleResponsePacketData + var symbolsInput = oracletypes.SymbolInput{ + Symbols: []string{"ATOM","BNB","BTC","ETH","INJ","USDT","OSMO","STX","SOL"}, + MinimumSourceCount: 1, + } + data := utils.MustEncode(symbolsInput) + testCases := []struct { + name string + malleate func() + expAckSuccess bool + }{ + { + "success", func() {}, true, + }, + { + "fails - cannot unmarshal packet data", func() { + packetData = []byte("invalid data") + }, false, + }, + { + "fails - request is not resolved successfully", func() { + msg.ResolveStatus = oracletypes.RESOLVE_STATUS_FAILURE + packetData = msg.GetBytes() + }, false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.TearDownTest() + suite.SetupTest() // reset + path := NewPriceRelayPath(suite.chainO, suite.chainB) + suite.coordinator.SetupConnections(path) + + result, _ := hex.DecodeString( + "000000090000000441544f4d00000000028510582500000003424e42000000004b269758800000000342544300000019cde9ff0a340000000345544800000001b055202e8c00000003494e4a0000000001b991af3c000000045553445400000000003ba159af000000044f534d4f00000000002b0682d70000000353545800000000002f7a459e00000003534f4c0000000004fa3a37e8", + ) + // prepare packet + msg = oracletypes.OracleResponsePacketData{ + ClientID: "1", + RequestID: 1, + AnsCount: 1, + RequestTime: 1000000000, + ResolveTime: 1000000000, + ResolveStatus: oracletypes.RESOLVE_STATUS_SUCCESS, + Result: result, + } + packetData = msg.GetBytes() + + // modify test data + tc.malleate() + + packet := channeltypes.NewPacket( + packetData, + uint64(1), + path.EndpointA.ChannelConfig.PortID, + path.EndpointA.ChannelID, + path.EndpointB.ChannelConfig.PortID, + path.EndpointB.ChannelID, + clienttypes.NewHeight(0, 100), + 0, + ) + + // prepare expected ack + expectedAck := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + + onomyapp := suite.chainO.App.(*reserveapp.App) + + portCap := onomyapp.IBCKeeper.PortKeeper.BindPort(suite.chainO.GetContext(), "oracle") + onomyapp.OracleKeeper.ClaimCapability(suite.chainO.GetContext(), portCap, host.PortPath("oracle")) //nolint:errcheck // checking this error isn't needed for the test + + // get module + module, _, err := suite.chainO.App.GetIBCKeeper().PortKeeper.LookupModuleByPort( + suite.chainO.GetContext(), + path.EndpointA.ChannelConfig.PortID, + ) + suite.Require().NoError(err) + + // get route + cbs, ok := suite.chainO.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + injectiveApp := suite.chainO.App.(*reserveapp.App) + injectiveApp.OracleKeeper.SetBandCallDataRecord(suite.chainO.GetContext(), &oracletypes.CalldataRecord{ + ClientId: 1, + Calldata: data, + }) + + // call recv packet + ack := cbs.OnRecvPacket(suite.chainO.GetContext(), packet, nil) + + // check result + if tc.expAckSuccess { + suite.Require().True(ack.Success()) + suite.Require().Equal(expectedAck, ack) + } else { + suite.Require().False(ack.Success()) + } + }) + } +} + +func (suite *PriceRelayTestSuite) TestPriceFeedThreshold() { + + currentBTCPrice, _ := math.LegacyNewDecFromStr("48495.410") + withinThresholdBTCPrice, _ := math.LegacyNewDecFromStr("49523.620") + minThresholdBTCPrice, _ := math.LegacyNewDecFromStr("484.9540") + maxThresholdBTCPrice, _ := math.LegacyNewDecFromStr("4952362.012") + + testCases := []struct { + name string + lastPrice math.LegacyDec + newPrice math.LegacyDec + expThreshold bool + }{ + { + "Within Threshold", math.LegacyNewDec(100), math.LegacyNewDec(120), false, + }, + { + "Min Threshold", math.LegacyNewDec(101), math.LegacyNewDec(1), true, + }, + { + "Max Threshold", math.LegacyNewDec(2), math.LegacyNewDec(201), true, + }, + { + "Within Threshold BTC", currentBTCPrice, withinThresholdBTCPrice, false, + }, + { + "Min Threshold BTC", currentBTCPrice, minThresholdBTCPrice, true, + }, + { + "Max Threshold BTC", currentBTCPrice, maxThresholdBTCPrice, true, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + isThresholdExceeded := oracletypes.CheckPriceFeedThreshold(tc.lastPrice, tc.newPrice) + suite.Assert().Equal(tc.expThreshold, isThresholdExceeded) + }) + } +} diff --git a/x/oracle/module/price_relay_test.go b/x/oracle/module/price_relay_test.go new file mode 100644 index 00000000..1911958e --- /dev/null +++ b/x/oracle/module/price_relay_test.go @@ -0,0 +1,161 @@ +package oracle_test + +import ( + "encoding/json" + "testing" + + "cosmossdk.io/log" + dbm "github.com/cosmos/cosmos-db" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + testifysuite "github.com/stretchr/testify/suite" + + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + reserveapp "github.com/onomyprotocol/reserve/app" + simapp "github.com/onomyprotocol/reserve/app" + bandapp "github.com/onomyprotocol/reserve/x/oracle/bandtesting/app" + bandoracletypes "github.com/onomyprotocol/reserve/x/oracle/bandtesting/x/oracle/types" + oracletypes "github.com/onomyprotocol/reserve/x/oracle/types" + +) + +type PriceRelayTestSuite struct { + testifysuite.Suite + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainO *ibctesting.TestChain + chainB *ibctesting.TestChain +} + +func (suite *PriceRelayTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 0) + + // setup injective chain + chainID := ibctesting.GetChainID(0) + ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { + db := dbm.NewMemDB() + encCdc := bandapp.MakeEncodingConfig() + app, _ := reserveapp.New(log.NewNopLogger(), db, nil, true, simtestutil.EmptyAppOptions{}) + genesisState := app.DefaultGenesis() + oracleGenesis := oracletypes.DefaultGenesis() + oracleGenesis.BandParams = *oracletypes.DefaultTestBandIbcParams() + oracleGenesisRaw := encCdc.Marshaler.MustMarshalJSON(oracleGenesis) + genesisState[oracletypes.ModuleName] = oracleGenesisRaw + return app, genesisState + } + suite.coordinator.Chains[chainID] = ibctesting.NewTestChain(suite.T(), suite.coordinator, chainID) + + // setup band chain + chainID = ibctesting.GetChainID(1) + ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { + db := dbm.NewMemDB() + encCdc := bandapp.MakeEncodingConfig() + app := bandapp.NewBandApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, bandapp.DefaultNodeHome, 5, encCdc, simtestutil.EmptyAppOptions{}) + return app, bandapp.NewDefaultGenesisState() + } + suite.coordinator.Chains[chainID] = ibctesting.NewTestChain(suite.T(), suite.coordinator, chainID) + + suite.chainO = suite.coordinator.GetChain(ibctesting.GetChainID(0)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) +} + +func NewPriceRelayPath(chain0, chainB *ibctesting.TestChain) *ibctesting.Path { + path := ibctesting.NewPath(chain0, chainB) + path.EndpointA.ChannelConfig.Version = oracletypes.DefaultTestBandIbcParams().IbcVersion + path.EndpointA.ChannelConfig.PortID = oracletypes.DefaultTestBandIbcParams().IbcPortId + path.EndpointB.ChannelConfig.Version = oracletypes.DefaultTestBandIbcParams().IbcVersion + path.EndpointB.ChannelConfig.PortID = oracletypes.ModuleName + + return path +} + +// constructs a send from chainA to chainB on the established channel/connection +// and sends the same coin back from chainB to chainA. +func (suite *PriceRelayTestSuite) TestHandlePriceRelay() { + // setup between chainA and chainB + + onomyapp := suite.chainO.App.(*reserveapp.App) + + portCap := onomyapp.IBCKeeper.PortKeeper.BindPort(suite.chainO.GetContext(), "oracle") + onomyapp.OracleKeeper.ClaimCapability(suite.chainO.GetContext(), portCap, host.PortPath("oracle")) //nolint:errcheck // checking this error isn't needed for the test + + path := NewPriceRelayPath(suite.chainO, suite.chainB) + + suite.coordinator.Setup(path) + + timeoutHeight := clienttypes.NewHeight(1, 110) + + // relay send + bandOracleReq := oracletypes.BandOracleRequest{ + OracleScriptId: 1, + Symbols: []string{"nom", "btc"}, + AskCount: 1, + MinCount: 1, + FeeLimit: sdk.Coins{sdk.NewInt64Coin("nom", 1)}, + PrepareGas: 100, + ExecuteGas: 200, + } + + priceRelayPacket := oracletypes.NewOracleRequestPacketData("11", bandOracleReq.GetCalldata(true), &bandOracleReq) + packet := channeltypes.NewPacket(priceRelayPacket.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0) + _, err := path.EndpointA.SendPacket(packet.TimeoutHeight, packet.TimeoutTimestamp, packet.Data) + suite.Require().NoError(err) + + // nolint:all + // ack := channeltypes.NewResultAcknowledgement(types.ModuleCdc.MustMarshalJSON(bandoracletypes.NewOracleRequestPacketAcknowledgement(1))) + err = path.RelayPacket(packet) + suite.Require().NoError(err) // relay committed + + suite.chainB.NextBlock() + + oracleResponsePacket := bandoracletypes.NewOracleResponsePacketData("11", 1, 0, 1577923380, 1577923405, 1, []byte("beeb")) + responsePacket := channeltypes.NewPacket( + oracleResponsePacket.GetBytes(), + 1, + path.EndpointB.ChannelConfig.PortID, + path.EndpointB.ChannelID, + path.EndpointA.ChannelConfig.PortID, + path.EndpointA.ChannelID, + clienttypes.ZeroHeight(), + 1577924005000000000, + ) + + expectCommitment := channeltypes.CommitPacket(suite.chainB.Codec, responsePacket) + commitment := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, 1) + suite.Equal(expectCommitment, commitment) + + // injectiveApp := suite.chainO.App.(*reserveapp.App) + onomyapp.OracleKeeper.SetBandOracleRequest(suite.chainO.GetContext(), oracletypes.BandOracleRequest{ + RequestId: 1, + OracleScriptId: 1, + Symbols: []string{"A"}, + AskCount: 1, + MinCount: 1, + FeeLimit: sdk.Coins{}, + PrepareGas: 100, + ExecuteGas: 200, + }) + + // send from chainI to chainB + msg := oracletypes.NewMsgRequestBandRates(suite.chainO.SenderAccount.GetAddress(), 1) + + _, err = suite.chainO.SendMsgs(msg) + suite.Require().NoError(err) // message committed +} + +func (suite *PriceRelayTestSuite) TearDownTest() { + for _, chain := range suite.coordinator.Chains { + if app, ok := chain.App.(*reserveapp.App); ok { + simapp.Cleanup(app) // cleanup old instance first + } + } +} + +func TestPriceRelayTestSuite(t *testing.T) { + testifysuite.Run(t, new(PriceRelayTestSuite)) +} diff --git a/x/oracle/module/simulation.go b/x/oracle/module/simulation.go deleted file mode 100644 index b5c5a658..00000000 --- a/x/oracle/module/simulation.go +++ /dev/null @@ -1,60 +0,0 @@ -package oracle - -import ( - "math/rand" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" - - "github.com/onomyprotocol/reserve/testutil/sample" - oraclesimulation "github.com/onomyprotocol/reserve/x/oracle/simulation" - "github.com/onomyprotocol/reserve/x/oracle/types" -) - -// avoid unused import issue -var ( - _ = oraclesimulation.FindAccount - _ = rand.Rand{} - _ = sample.AccAddress - _ = sdk.AccAddress{} - _ = simulation.MsgEntryKind -) - -const ( -// this line is used by starport scaffolding # simapp/module/const -) - -// GenerateGenesisState creates a randomized GenState of the module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - accs := make([]string, len(simState.Accounts)) - for i, acc := range simState.Accounts { - accs[i] = acc.Address.String() - } - oracleGenesis := types.GenesisState{ - Params: types.DefaultParams(), - PortId: types.PortID, - // this line is used by starport scaffolding # simapp/module/genesisState - } - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&oracleGenesis) -} - -// RegisterStoreDecoder registers a decoder. -func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} - -// WeightedOperations returns the all the gov module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - operations := make([]simtypes.WeightedOperation, 0) - - // this line is used by starport scaffolding # simapp/module/operation - - return operations -} - -// ProposalMsgs returns msgs used for governance proposals for simulations. -func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { - return []simtypes.WeightedProposalMsg{ - // this line is used by starport scaffolding # simapp/module/OpMsg - } -} diff --git a/x/oracle/proposal_handler.go b/x/oracle/proposal_handler.go new file mode 100644 index 00000000..7f9b5822 --- /dev/null +++ b/x/oracle/proposal_handler.go @@ -0,0 +1,107 @@ +package oracle + +import ( + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/onomyprotocol/reserve/x/oracle/keeper" + "github.com/onomyprotocol/reserve/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsmod "cosmossdk.io/errors" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewOracleProposalHandler creates a governance handler to manage new oracles +func NewOracleProposalHandler(k keeper.Keeper) govtypes.Handler { + return func(ctx sdk.Context, content govtypes.Content) error { + switch c := content.(type) { + case *types.UpdateBandParamsProposal: + return handleUpdateBandParamsProposal(ctx, k, c) + case *types.UpdateBandOracleRequestProposal: + return handleUpdateBandOracleRequestProposal(ctx, k, c) + + case *types.DeleteBandOracleRequestProposal: + return handleDeleteBandOracleRequestProposal(ctx, k, c) + default: + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized param proposal content type: %T", c) + } + } +} + +func handleUpdateBandParamsProposal(ctx sdk.Context, k keeper.Keeper, p *types.UpdateBandParamsProposal) error { + if err := p.ValidateBasic(); err != nil { + return err + } + + k.SetPort(ctx, p.BandParams.IbcPortId) + // Only try to bind to port if it is not already bound, since we may already own port capability + if k.ShouldBound(ctx, p.BandParams.IbcPortId) { + // module binds to the port on InitChain + // and claims the returned capability + err := k.BindPort(ctx, p.BandParams.IbcPortId) + if err != nil { + return errorsmod.Wrap(types.ErrBandPortBind, err.Error()) + } + } + + k.SetBandParams(ctx, p.BandParams) + return nil +} + +func handleUpdateBandOracleRequestProposal(ctx sdk.Context, k keeper.Keeper, p *types.UpdateBandOracleRequestProposal) error { + if err := p.ValidateBasic(); err != nil { + return err + } + + request := k.GetBandOracleRequest(ctx, p.UpdateOracleRequest.RequestId) + if request == nil { + return errorsmod.Wrapf(types.ErrBandRequestNotFound, "cannot update requestID %T", p.UpdateOracleRequest.RequestId) + } + + if p.UpdateOracleRequest.OracleScriptId > 0 { + request.OracleScriptId = p.UpdateOracleRequest.OracleScriptId + } + + if len(p.UpdateOracleRequest.Symbols) > 0 { + request.Symbols = p.UpdateOracleRequest.Symbols + } + + if p.UpdateOracleRequest.MinCount > 0 { + request.MinCount = p.UpdateOracleRequest.MinCount + } + + if p.UpdateOracleRequest.AskCount > 0 { + request.AskCount = p.UpdateOracleRequest.AskCount + } + + if p.UpdateOracleRequest.FeeLimit != nil { + request.FeeLimit = p.UpdateOracleRequest.FeeLimit + } + + if p.UpdateOracleRequest.PrepareGas > 0 { + request.PrepareGas = p.UpdateOracleRequest.PrepareGas + } + + if p.UpdateOracleRequest.ExecuteGas > 0 { + request.ExecuteGas = p.UpdateOracleRequest.ExecuteGas + } + + if p.UpdateOracleRequest.MinSourceCount > 0 { + request.MinSourceCount = p.UpdateOracleRequest.MinSourceCount + } + + k.SetBandOracleRequest(ctx, *request) + + return nil +} + +func handleDeleteBandOracleRequestProposal(ctx sdk.Context, k keeper.Keeper, p *types.DeleteBandOracleRequestProposal) error { + if err := p.ValidateBasic(); err != nil { + return err + } + + for _, requestID := range p.DeleteRequestIds { + k.DeleteBandOracleRequest(ctx, requestID) + } + + return nil +} diff --git a/x/oracle/proposal_handler_test.go b/x/oracle/proposal_handler_test.go new file mode 100644 index 00000000..adddc82b --- /dev/null +++ b/x/oracle/proposal_handler_test.go @@ -0,0 +1,45 @@ +package oracle_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/onomyprotocol/reserve/app" + "github.com/onomyprotocol/reserve/x/oracle/types" + "github.com/onomyprotocol/reserve/x/oracle" +) + +func TestUpdateBandParamsProposal(t *testing.T) { + // check default band params + app := app.Setup(t, false) + ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "3", Time: time.Unix(1618997040, 0)}) + + bandParams := app.OracleKeeper.GetBandParams(ctx) + require.Equal(t ,types.DefaultBandParams(), bandParams) + + handler := oracle.NewOracleProposalHandler(app.OracleKeeper) + new_BandParams := types.BandParams{ + IbcRequestInterval: 2, + IbcSourceChannel: "channel-1", + IbcVersion: "bandchain-2", + IbcPortId: "oracle", + } + err := handler(ctx, &types.UpdateBandParamsProposal{ + Title: "Update Band param proposal", + Description: "Update band param proposal", + BandParams: new_BandParams, + }) + + require.NoError(t, err) + portID := app.OracleKeeper.GetPort(ctx) + require.Equal(t, new_BandParams.IbcPortId, portID) + + isBound := app.OracleKeeper.ShouldBound(ctx, portID) + require.False(t, isBound) + + bandParams = app.OracleKeeper.GetBandParams(ctx) + require.Equal(t ,new_BandParams, bandParams) + +} diff --git a/x/oracle/simulation/helpers.go b/x/oracle/simulation/helpers.go deleted file mode 100644 index 92c437c0..00000000 --- a/x/oracle/simulation/helpers.go +++ /dev/null @@ -1,15 +0,0 @@ -package simulation - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" -) - -// FindAccount find a specific address from an account list -func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { - creator, err := sdk.AccAddressFromBech32(address) - if err != nil { - panic(err) - } - return simtypes.FindAccount(accs, creator) -} diff --git a/x/oracle/types/band_oracle.go b/x/oracle/types/band_oracle.go new file mode 100644 index 00000000..cba44f3b --- /dev/null +++ b/x/oracle/types/band_oracle.go @@ -0,0 +1,219 @@ +package types + +import ( + "fmt" + + math "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + utils "github.com/onomyprotocol/reserve/x/oracle/utils" +) + +const ( + BandPriceMultiplier uint64 = 1000000000 // 1e9 + MaxDataSize = 256 // 256B + QuoteUSD = "USD" +) + +type RequestID int64 + +func NewOracleRequestPacketData(clientID string, calldata []byte, r *BandOracleRequest) OracleRequestPacketData { + return OracleRequestPacketData{ + ClientID: clientID, + OracleScriptID: uint64(r.OracleScriptId), + Calldata: calldata, + AskCount: r.AskCount, + MinCount: r.MinCount, + FeeLimit: r.FeeLimit, + PrepareGas: r.PrepareGas, + ExecuteGas: r.ExecuteGas, + } +} + +// GetBytes is a helper for serialising +func (p OracleRequestPacketData) GetBytes() []byte { + cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + return sdk.MustSortJSON(cdc.MustMarshalJSON(&p)) +} + +// GetBytes returns the bytes representation of this oracle response packet data. +func (p OracleResponsePacketData) GetBytes() []byte { + cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + return sdk.MustSortJSON(cdc.MustMarshalJSON(&p)) +} + +// GetCalldata gets the Band IBC request call data based on the symbols and multiplier. +func (r *BandOracleRequest) GetCalldata(legacyScheme bool) []byte { + if legacyScheme { + return utils.MustEncode(Input{ + Symbols: r.Symbols, + Multiplier: BandPriceMultiplier, + }) + } + + return utils.MustEncode(SymbolInput{ + Symbols: r.Symbols, + MinimumSourceCount: uint8(r.MinSourceCount), + }) +} + +func IsLegacySchemeOracleScript(scriptID int64, params BandParams) bool { + for _, id := range params.LegacyOracleIds { + if id == scriptID { + return true + } + } + + return false +} + +// CheckPriceFeedThreshold returns true if the newPrice has changed beyond 100x or less than 1% of the last price +func CheckPriceFeedThreshold(lastPrice, newPrice math.LegacyDec) bool { + return newPrice.GT(lastPrice.Mul(math.LegacyNewDec(100))) || newPrice.LT(lastPrice.Quo(math.LegacyNewDec(100))) +} + +func DecodeOracleInput(data []byte) (OracleInput, error) { + var ( + legacyInput LegacyBandInput + newInput BandInput + err error + ) + + if err = utils.Decode(data, &legacyInput); err == nil { + return legacyInput, nil + } + + if err = utils.Decode(data, &newInput); err == nil { + return newInput, nil + } + + return nil, fmt.Errorf("failed to decode oracle input: %w", err) +} + +func DecodeOracleOutput(data []byte) (OracleOutput, error) { + var ( + legacyOutput LegacyBandOutput + newOutput BandOutput + err error + ) + + if err = utils.Decode(data, &legacyOutput); err == nil { + return legacyOutput, nil + } + + if err = utils.Decode(data, &newOutput); err == nil { + return newOutput, nil + } + + return nil, fmt.Errorf("failed to decode oracle output: %w", err) +} + +// it is assumed that the id of a symbol +// within OracleInput exists within OracleOutput + +type OracleInput interface { + PriceSymbols() []string + PriceMultiplier() uint64 +} + +type ( + LegacyBandInput Input + BandInput SymbolInput +) + +func (in LegacyBandInput) PriceSymbols() []string { + return in.Symbols +} + +func (in LegacyBandInput) PriceMultiplier() uint64 { + return in.Multiplier +} + +func (in BandInput) PriceSymbols() []string { + return in.Symbols +} + +func (in BandInput) PriceMultiplier() uint64 { + return BandPriceMultiplier +} + +type OracleOutput interface { + Rate(id int) uint64 + Valid(id int) bool +} + +type ( + LegacyBandOutput Output + BandOutput SymbolOutput +) + +func (out LegacyBandOutput) Rate(id int) uint64 { + return out.Pxs[id] +} + +func (out LegacyBandOutput) Valid(id int) bool { + return true +} + +func (out BandOutput) Rate(id int) uint64 { + return out.Responses[id].Rate +} + +func (out BandOutput) Valid(id int) bool { + return out.Responses[id].ResponseCode == 0 +} + +type SymbolInput struct { + Symbols []string `json:"symbols"` + MinimumSourceCount uint8 `json:"minimum_source_count"` +} + +type SymbolOutput struct { + Responses []Response `json:"responses"` +} + +type Response struct { + Symbol string `json:"symbol"` + ResponseCode uint8 `json:"response_code"` + Rate uint64 `json:"rate"` +} + +type Input struct { + Symbols []string `json:"symbols"` + Multiplier uint64 `json:"multiplier"` +} + +type Output struct { + Pxs []uint64 `json:"pxs"` +} + +type Price struct { + Symbol string `json:"symbol"` + Multiplier uint64 `json:"multiplier"` + Px uint64 `json:"px"` + RequestID RequestID `json:"request_id"` + ResolveTime int64 `json:"resolve_time"` +} + +func NewPrice(symbol string, multiplier, px uint64, reqID RequestID, resolveTime int64) Price { + return Price{ + Symbol: symbol, + Multiplier: multiplier, + Px: px, + RequestID: reqID, + ResolveTime: resolveTime, + } +} + +func NewPriceState(price math.LegacyDec, timestamp int64) *PriceState { + return &PriceState{ + Price: price, + Timestamp: timestamp, + } +} + +func (p *PriceState) UpdatePrice(price math.LegacyDec, timestamp int64) { + p.Timestamp = timestamp + p.Price = price +} diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 26e58aba..137cfbe2 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -3,21 +3,40 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - // this line is used by starport scaffolding # 1 + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) -func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // this line is used by starport scaffolding # 3 +// RegisterLegacyAminoCodec registers the necessary x/oracle interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgUpdateParams{}, "oracle/MsgUpdateParams", nil) + cdc.RegisterConcrete(&MsgRequestBandRates{}, "oracle/MsgRequestBandRates", nil) + + cdc.RegisterConcrete(&UpdateBandParamsProposal{}, "oracle/UpdateBandParamsProposal", nil) + cdc.RegisterConcrete(&UpdateBandOracleRequestProposal{}, "oracle/UpdateBandOracleRequestProposal", nil) + cdc.RegisterConcrete(&DeleteBandOracleRequestProposal{}, "oracle/DeleteBandOracleRequestProposal", nil) +} +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateParams{}, + &MsgRequestBandRates{}, ) + + registry.RegisterImplementations((*govtypes.Content)(nil), + &UpdateBandParamsProposal{}, + &UpdateBandOracleRequestProposal{}, + &DeleteBandOracleRequestProposal{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } var ( + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/ibc-transfer module codec. Note, the codec // should ONLY be used in certain instances of tests and for JSON encoding. // @@ -25,3 +44,9 @@ var ( // defined at the application level. ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) ) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} \ No newline at end of file diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index cc88d7f5..a47fdbf7 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -1,15 +1,25 @@ package types -// DONTCOVER - import ( sdkerrors "cosmossdk.io/errors" ) // x/oracle module sentinel errors var ( - ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") - ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") - ErrInvalidPacketTimeout = sdkerrors.Register(ModuleName, 1500, "invalid packet timeout") - ErrInvalidVersion = sdkerrors.Register(ModuleName, 1501, "invalid version") + ErrInvalidSigner = sdkerrors.Register(ModuleName, 1, "expected gov account as only signer for proposal message") + ErrInvalidPacketTimeout = sdkerrors.Register(ModuleName, 2, "invalid packet timeout") + ErrInvalidVersion = sdkerrors.Register(ModuleName, 3, "invalid version") + ErrInvalidBandRequest = sdkerrors.Register(ModuleName, 4, "Invalid Band IBC Request") + ErrBandPortBind = sdkerrors.Register(ModuleName, 5, "could not claim port capability") + ErrBadRequestInterval = sdkerrors.Register(ModuleName, 6, "invalid Band IBC request interval") + ErrInvalidSourceChannel = sdkerrors.Register(ModuleName, 7, "invalid IBC source channel") + ErrBadSymbolsCount = sdkerrors.Register(ModuleName, 8, "invalid symbols count") + ErrTooLargeCalldata = sdkerrors.Register(ModuleName, 9, "too large calldata") + ErrInvalidMinCount = sdkerrors.Register(ModuleName, 10, "invalid min count") + ErrInvalidAskCount = sdkerrors.Register(ModuleName, 11, "invalid ask count") + ErrInvalidOwasmGas = sdkerrors.Register(ModuleName, 12, "invalid owasm gas") + ErrInvalidBandUpdateRequest = sdkerrors.Register(ModuleName, 13, "Invalid Band Update Request Proposal") + ErrBandRequestNotFound = sdkerrors.Register(ModuleName, 14, "Band Oracle Request not found") + ErrInvalidBandDeleteRequest = sdkerrors.Register(ModuleName, 15, "Invalid Band Delete Request Proposal") + ErrResolveStatusNotSuccess = sdkerrors.Register(ModuleName, 16, "Band Oracle request is not resolved successfully") ) diff --git a/x/oracle/types/events.pb.go b/x/oracle/types/events.pb.go new file mode 100644 index 00000000..86ee23d1 --- /dev/null +++ b/x/oracle/types/events.pb.go @@ -0,0 +1,1112 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: reserve/oracle/events.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +type EventBandAckSuccess struct { + AckResult string `protobuf:"bytes,1,opt,name=ack_result,json=ackResult,proto3" json:"ack_result,omitempty"` + ClientId int64 `protobuf:"varint,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *EventBandAckSuccess) Reset() { *m = EventBandAckSuccess{} } +func (m *EventBandAckSuccess) String() string { return proto.CompactTextString(m) } +func (*EventBandAckSuccess) ProtoMessage() {} +func (*EventBandAckSuccess) Descriptor() ([]byte, []int) { + return fileDescriptor_5441448c19065114, []int{0} +} +func (m *EventBandAckSuccess) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBandAckSuccess) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBandAckSuccess.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 *EventBandAckSuccess) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBandAckSuccess.Merge(m, src) +} +func (m *EventBandAckSuccess) XXX_Size() int { + return m.Size() +} +func (m *EventBandAckSuccess) XXX_DiscardUnknown() { + xxx_messageInfo_EventBandAckSuccess.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBandAckSuccess proto.InternalMessageInfo + +func (m *EventBandAckSuccess) GetAckResult() string { + if m != nil { + return m.AckResult + } + return "" +} + +func (m *EventBandAckSuccess) GetClientId() int64 { + if m != nil { + return m.ClientId + } + return 0 +} + +type EventBandAckError struct { + AckError string `protobuf:"bytes,1,opt,name=ack_error,json=ackError,proto3" json:"ack_error,omitempty"` + ClientId int64 `protobuf:"varint,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *EventBandAckError) Reset() { *m = EventBandAckError{} } +func (m *EventBandAckError) String() string { return proto.CompactTextString(m) } +func (*EventBandAckError) ProtoMessage() {} +func (*EventBandAckError) Descriptor() ([]byte, []int) { + return fileDescriptor_5441448c19065114, []int{1} +} +func (m *EventBandAckError) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBandAckError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBandAckError.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 *EventBandAckError) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBandAckError.Merge(m, src) +} +func (m *EventBandAckError) XXX_Size() int { + return m.Size() +} +func (m *EventBandAckError) XXX_DiscardUnknown() { + xxx_messageInfo_EventBandAckError.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBandAckError proto.InternalMessageInfo + +func (m *EventBandAckError) GetAckError() string { + if m != nil { + return m.AckError + } + return "" +} + +func (m *EventBandAckError) GetClientId() int64 { + if m != nil { + return m.ClientId + } + return 0 +} + +type EventBandResponseTimeout struct { + ClientId int64 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *EventBandResponseTimeout) Reset() { *m = EventBandResponseTimeout{} } +func (m *EventBandResponseTimeout) String() string { return proto.CompactTextString(m) } +func (*EventBandResponseTimeout) ProtoMessage() {} +func (*EventBandResponseTimeout) Descriptor() ([]byte, []int) { + return fileDescriptor_5441448c19065114, []int{2} +} +func (m *EventBandResponseTimeout) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBandResponseTimeout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBandResponseTimeout.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 *EventBandResponseTimeout) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBandResponseTimeout.Merge(m, src) +} +func (m *EventBandResponseTimeout) XXX_Size() int { + return m.Size() +} +func (m *EventBandResponseTimeout) XXX_DiscardUnknown() { + xxx_messageInfo_EventBandResponseTimeout.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBandResponseTimeout proto.InternalMessageInfo + +func (m *EventBandResponseTimeout) GetClientId() int64 { + if m != nil { + return m.ClientId + } + return 0 +} + +type SetBandPriceEvent struct { + Relayer string `protobuf:"bytes,1,opt,name=relayer,proto3" json:"relayer,omitempty"` + Symbols []string `protobuf:"bytes,2,rep,name=symbols,proto3" json:"symbols,omitempty"` + Prices []cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,rep,name=prices,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"prices"` + ResolveTime uint64 `protobuf:"varint,4,opt,name=resolve_time,json=resolveTime,proto3" json:"resolve_time,omitempty"` + RequestId uint64 `protobuf:"varint,5,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + ClientId int64 `protobuf:"varint,6,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *SetBandPriceEvent) Reset() { *m = SetBandPriceEvent{} } +func (m *SetBandPriceEvent) String() string { return proto.CompactTextString(m) } +func (*SetBandPriceEvent) ProtoMessage() {} +func (*SetBandPriceEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_5441448c19065114, []int{3} +} +func (m *SetBandPriceEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SetBandPriceEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SetBandPriceEvent.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 *SetBandPriceEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetBandPriceEvent.Merge(m, src) +} +func (m *SetBandPriceEvent) XXX_Size() int { + return m.Size() +} +func (m *SetBandPriceEvent) XXX_DiscardUnknown() { + xxx_messageInfo_SetBandPriceEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_SetBandPriceEvent proto.InternalMessageInfo + +func (m *SetBandPriceEvent) GetRelayer() string { + if m != nil { + return m.Relayer + } + return "" +} + +func (m *SetBandPriceEvent) GetSymbols() []string { + if m != nil { + return m.Symbols + } + return nil +} + +func (m *SetBandPriceEvent) GetResolveTime() uint64 { + if m != nil { + return m.ResolveTime + } + return 0 +} + +func (m *SetBandPriceEvent) GetRequestId() uint64 { + if m != nil { + return m.RequestId + } + return 0 +} + +func (m *SetBandPriceEvent) GetClientId() int64 { + if m != nil { + return m.ClientId + } + return 0 +} + +func init() { + proto.RegisterType((*EventBandAckSuccess)(nil), "reserve.oracle.EventBandAckSuccess") + proto.RegisterType((*EventBandAckError)(nil), "reserve.oracle.EventBandAckError") + proto.RegisterType((*EventBandResponseTimeout)(nil), "reserve.oracle.EventBandResponseTimeout") + proto.RegisterType((*SetBandPriceEvent)(nil), "reserve.oracle.SetBandPriceEvent") +} + +func init() { proto.RegisterFile("reserve/oracle/events.proto", fileDescriptor_5441448c19065114) } + +var fileDescriptor_5441448c19065114 = []byte{ + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x3f, 0x8f, 0xd3, 0x40, + 0x10, 0xc5, 0xbd, 0x97, 0x23, 0x9c, 0x17, 0x84, 0x74, 0x86, 0xc2, 0x22, 0xc2, 0x67, 0x8e, 0x26, + 0x95, 0x5d, 0x50, 0x50, 0x50, 0x11, 0x71, 0x45, 0x24, 0x90, 0xc0, 0x47, 0x45, 0x13, 0x6d, 0xd6, + 0x23, 0x9f, 0xe5, 0x3f, 0x63, 0x76, 0xd6, 0x11, 0xfe, 0x16, 0x7c, 0xac, 0x2b, 0xaf, 0x44, 0x14, + 0x27, 0x14, 0x7f, 0x11, 0xb4, 0x1b, 0x1b, 0x25, 0x91, 0xae, 0xf3, 0xbc, 0x37, 0xef, 0xa7, 0x7d, + 0xde, 0xe5, 0x33, 0x05, 0x04, 0x6a, 0x03, 0x31, 0x2a, 0x21, 0x4b, 0x88, 0x61, 0x03, 0xb5, 0xa6, + 0xa8, 0x51, 0xa8, 0xd1, 0x7b, 0x36, 0x98, 0xd1, 0xce, 0x7c, 0xf9, 0x22, 0xc3, 0x0c, 0xad, 0x15, + 0x9b, 0xaf, 0xdd, 0xd6, 0xe5, 0x57, 0xfe, 0xfc, 0xca, 0xa4, 0x16, 0xa2, 0x4e, 0x3f, 0xc8, 0xe2, + 0xba, 0x95, 0x12, 0x88, 0xbc, 0x57, 0x9c, 0x0b, 0x59, 0xac, 0x14, 0x50, 0x5b, 0x6a, 0x9f, 0x85, + 0x6c, 0xee, 0x26, 0xae, 0x90, 0x45, 0x62, 0x05, 0x6f, 0xc6, 0x5d, 0x59, 0xe6, 0x50, 0xeb, 0x55, + 0x9e, 0xfa, 0x27, 0x21, 0x9b, 0x4f, 0x92, 0xb3, 0x9d, 0xb0, 0x4c, 0x2f, 0x3f, 0xf3, 0xf3, 0x7d, + 0xe4, 0x95, 0x52, 0xa8, 0x4c, 0xc2, 0x00, 0xc1, 0x0c, 0x03, 0xef, 0x4c, 0xec, 0x99, 0x0f, 0xe3, + 0xde, 0x71, 0xff, 0x3f, 0x2e, 0x01, 0x6a, 0xb0, 0x26, 0xf8, 0x96, 0x57, 0x80, 0xed, 0xd1, 0x39, + 0xd8, 0x51, 0xb0, 0x67, 0xfc, 0xfc, 0x1a, 0x6c, 0xee, 0x8b, 0xca, 0x25, 0x58, 0x8a, 0xe7, 0xf3, + 0xc7, 0x0a, 0x4a, 0xd1, 0xc1, 0x78, 0x8c, 0x71, 0x34, 0x0e, 0x75, 0xd5, 0x1a, 0x4b, 0xf2, 0x4f, + 0xc2, 0x89, 0x71, 0x86, 0xd1, 0x7b, 0xcf, 0xa7, 0x8d, 0x21, 0x90, 0x3f, 0x31, 0xc6, 0xe2, 0xcd, + 0xed, 0xfd, 0x85, 0xf3, 0xe7, 0xfe, 0x62, 0x26, 0x91, 0x2a, 0x24, 0x4a, 0x8b, 0x28, 0xc7, 0xb8, + 0x12, 0xfa, 0x26, 0xfa, 0x04, 0x99, 0x90, 0xdd, 0x47, 0x90, 0xc9, 0x10, 0xf1, 0x5e, 0xf3, 0xa7, + 0x0a, 0x08, 0xcb, 0x0d, 0xac, 0x74, 0x5e, 0x81, 0x7f, 0x1a, 0xb2, 0xf9, 0x69, 0xf2, 0x64, 0xd0, + 0x4c, 0x13, 0xf3, 0xb7, 0x15, 0xfc, 0x68, 0x81, 0x6c, 0x8f, 0x47, 0x76, 0xc1, 0x1d, 0x94, 0x65, + 0x7a, 0xd8, 0x72, 0x7a, 0xd8, 0x72, 0xb1, 0xbc, 0xdd, 0x06, 0xec, 0x6e, 0x1b, 0xb0, 0xbf, 0xdb, + 0x80, 0xfd, 0xea, 0x03, 0xe7, 0xae, 0x0f, 0x9c, 0xdf, 0x7d, 0xe0, 0x7c, 0x8f, 0xb3, 0x5c, 0xdf, + 0xb4, 0xeb, 0x48, 0x62, 0x15, 0x63, 0x8d, 0x55, 0x67, 0x6f, 0x5c, 0x62, 0x19, 0x8f, 0xcf, 0xe6, + 0xe7, 0xf8, 0x70, 0x74, 0xd7, 0x00, 0xad, 0xa7, 0x76, 0xe1, 0xed, 0xbf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xa5, 0x56, 0xe4, 0xad, 0x57, 0x02, 0x00, 0x00, +} + +func (m *EventBandAckSuccess) 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 *EventBandAckSuccess) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBandAckSuccess) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClientId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ClientId)) + i-- + dAtA[i] = 0x10 + } + if len(m.AckResult) > 0 { + i -= len(m.AckResult) + copy(dAtA[i:], m.AckResult) + i = encodeVarintEvents(dAtA, i, uint64(len(m.AckResult))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBandAckError) 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 *EventBandAckError) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBandAckError) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClientId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ClientId)) + i-- + dAtA[i] = 0x10 + } + if len(m.AckError) > 0 { + i -= len(m.AckError) + copy(dAtA[i:], m.AckError) + i = encodeVarintEvents(dAtA, i, uint64(len(m.AckError))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBandResponseTimeout) 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 *EventBandResponseTimeout) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBandResponseTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClientId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ClientId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SetBandPriceEvent) 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 *SetBandPriceEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SetBandPriceEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClientId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ClientId)) + i-- + dAtA[i] = 0x30 + } + if m.RequestId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.RequestId)) + i-- + dAtA[i] = 0x28 + } + if m.ResolveTime != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ResolveTime)) + i-- + dAtA[i] = 0x20 + } + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.Prices[iNdEx].Size() + i -= size + if _, err := m.Prices[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Symbols) > 0 { + for iNdEx := len(m.Symbols) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Symbols[iNdEx]) + copy(dAtA[i:], m.Symbols[iNdEx]) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Symbols[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Relayer) > 0 { + i -= len(m.Relayer) + copy(dAtA[i:], m.Relayer) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Relayer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventBandAckSuccess) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AckResult) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ClientId != 0 { + n += 1 + sovEvents(uint64(m.ClientId)) + } + return n +} + +func (m *EventBandAckError) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AckError) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ClientId != 0 { + n += 1 + sovEvents(uint64(m.ClientId)) + } + return n +} + +func (m *EventBandResponseTimeout) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ClientId != 0 { + n += 1 + sovEvents(uint64(m.ClientId)) + } + return n +} + +func (m *SetBandPriceEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Relayer) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if len(m.Symbols) > 0 { + for _, s := range m.Symbols { + l = len(s) + n += 1 + l + sovEvents(uint64(l)) + } + } + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovEvents(uint64(l)) + } + } + if m.ResolveTime != 0 { + n += 1 + sovEvents(uint64(m.ResolveTime)) + } + if m.RequestId != 0 { + n += 1 + sovEvents(uint64(m.RequestId)) + } + if m.ClientId != 0 { + n += 1 + sovEvents(uint64(m.ClientId)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventBandAckSuccess) 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 ErrIntOverflowEvents + } + 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: EventBandAckSuccess: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBandAckSuccess: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AckResult", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AckResult = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + m.ClientId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClientId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBandAckError) 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 ErrIntOverflowEvents + } + 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: EventBandAckError: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBandAckError: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AckError", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AckError = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + m.ClientId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClientId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBandResponseTimeout) 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 ErrIntOverflowEvents + } + 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: EventBandResponseTimeout: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBandResponseTimeout: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + m.ClientId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClientId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetBandPriceEvent) 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 ErrIntOverflowEvents + } + 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: SetBandPriceEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetBandPriceEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relayer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relayer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbols", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Symbols = append(m.Symbols, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.LegacyDec + m.Prices = append(m.Prices, v) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveTime", wireType) + } + m.ResolveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) + } + m.RequestId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + m.ClientId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClientId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvents(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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 77391d3a..075389a8 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -1,29 +1,25 @@ package types -import ( - host "github.com/cosmos/ibc-go/v8/modules/core/24-host" - // this line is used by starport scaffolding # genesis/types/import -) - -// DefaultIndex is the default global index -const DefaultIndex uint64 = 1 +func NewGenesisState() GenesisState { + return GenesisState{} +} // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - PortId: PortID, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), + BandParams: DefaultBandParams(), + BandOracleRequestParams: DefaultBandOracelRequestParams(), } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - if err := host.PortIdentifierValidator(gs.PortId); err != nil { + // TODO: validate stuff in genesis + if err := gs.Params.Validate(); err != nil { return err } - // this line is used by starport scaffolding # genesis/types/validate - - return gs.Params.Validate() + return nil } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index b9af0422..17895429 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -4,7 +4,10 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -27,8 +30,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the oracle module's genesis state. type GenesisState struct { // params defines all the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + BandParams BandParams `protobuf:"bytes,2,opt,name=band_params,json=bandParams,proto3" json:"band_params"` + BandPriceStates []*BandPriceState `protobuf:"bytes,3,rep,name=band_price_states,json=bandPriceStates,proto3" json:"band_price_states,omitempty"` + BandOracleRequests []*BandOracleRequest `protobuf:"bytes,4,rep,name=band_oracle_requests,json=bandOracleRequests,proto3" json:"band_oracle_requests,omitempty"` + BandLatestClientId uint64 `protobuf:"varint,5,opt,name=band_latest_client_id,json=bandLatestClientId,proto3" json:"band_latest_client_id,omitempty"` + CalldataRecords []*CalldataRecord `protobuf:"bytes,6,rep,name=calldata_records,json=calldataRecords,proto3" json:"calldata_records,omitempty"` + BandLatestRequestId uint64 `protobuf:"varint,7,opt,name=band_latest_request_id,json=bandLatestRequestId,proto3" json:"band_latest_request_id,omitempty"` + BandOracleRequestParams BandOracleRequestParams `protobuf:"bytes,8,opt,name=band_oracle_request_params,json=bandOracleRequestParams,proto3" json:"band_oracle_request_params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -71,111 +80,2215 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetPortId() string { +func (m *GenesisState) GetBandParams() BandParams { if m != nil { - return m.PortId + return m.BandParams } - return "" + return BandParams{} } -func init() { - proto.RegisterType((*GenesisState)(nil), "reserve.oracle.GenesisState") +func (m *GenesisState) GetBandPriceStates() []*BandPriceState { + if m != nil { + return m.BandPriceStates + } + return nil } -func init() { proto.RegisterFile("reserve/oracle/genesis.proto", fileDescriptor_78a657bc7a2646c9) } +func (m *GenesisState) GetBandOracleRequests() []*BandOracleRequest { + if m != nil { + return m.BandOracleRequests + } + return nil +} -var fileDescriptor_78a657bc7a2646c9 = []byte{ - // 233 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x4a, 0x2d, 0x4e, - 0x2d, 0x2a, 0x4b, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, - 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xca, 0xea, 0x41, 0x64, 0xa5, - 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x89, 0x94, 0x48, 0x7a, 0x7e, 0x7a, - 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0xa5, 0xd1, 0x8c, 0x2d, 0x48, 0x2c, 0x4a, 0xcc, 0x85, - 0x9a, 0xaa, 0x94, 0xc4, 0xc5, 0xe3, 0x0e, 0xb1, 0x26, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x92, - 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, 0x87, 0x6a, 0xad, 0x5e, - 0x00, 0x58, 0xd6, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, 0x41, - 0x35, 0x08, 0x89, 0x73, 0xb1, 0x17, 0xe4, 0x17, 0x95, 0xc4, 0x67, 0xa6, 0x48, 0x30, 0x29, 0x30, - 0x6a, 0x70, 0x06, 0xb1, 0x81, 0xb8, 0x9e, 0x29, 0x4e, 0x9e, 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, 0x10, 0xa5, 0x9f, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, - 0x9f, 0x9f, 0x97, 0x9f, 0x5b, 0x09, 0x76, 0x54, 0x72, 0x7e, 0x8e, 0x3e, 0xcc, 0xcd, 0x15, 0x30, - 0x57, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x15, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, - 0xff, 0x2d, 0xfc, 0x04, 0xb6, 0x2b, 0x01, 0x00, 0x00, +func (m *GenesisState) GetBandLatestClientId() uint64 { + if m != nil { + return m.BandLatestClientId + } + return 0 } -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 +func (m *GenesisState) GetCalldataRecords() []*CalldataRecord { + if m != nil { + return m.CalldataRecords } - return dAtA[:n], nil + return nil } -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *GenesisState) GetBandLatestRequestId() uint64 { + if m != nil { + return m.BandLatestRequestId + } + return 0 } -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = 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] = 0x12 +func (m *GenesisState) GetBandOracleRequestParams() BandOracleRequestParams { + if m != nil { + return m.BandOracleRequestParams } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + return BandOracleRequestParams{} +} + +type BandOracleRequest struct { + // Unique Identifier for band ibc oracle request + RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + // OracleScriptID is the unique identifier of the oracle script to be + // executed. + OracleScriptId int64 `protobuf:"varint,2,opt,name=oracle_script_id,json=oracleScriptId,proto3" json:"oracle_script_id,omitempty"` + // Symbols is the list of symbols to prepare in the calldata + Symbols []string `protobuf:"bytes,3,rep,name=symbols,proto3" json:"symbols,omitempty"` + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + AskCount uint64 `protobuf:"varint,4,opt,name=ask_count,json=askCount,proto3" json:"ask_count,omitempty"` + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + MinCount uint64 `protobuf:"varint,5,opt,name=min_count,json=minCount,proto3" json:"min_count,omitempty"` + // FeeLimit is the maximum tokens that will be paid to all data source + // providers. + FeeLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=fee_limit,json=feeLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee_limit"` + // PrepareGas is amount of gas to pay to prepare raw requests + PrepareGas uint64 `protobuf:"varint,7,opt,name=prepare_gas,json=prepareGas,proto3" json:"prepare_gas,omitempty"` + // ExecuteGas is amount of gas to reserve for executing + ExecuteGas uint64 `protobuf:"varint,8,opt,name=execute_gas,json=executeGas,proto3" json:"execute_gas,omitempty"` + // MinSourceCount is the minimum number of data sources that must be used by + // each validator + MinSourceCount uint64 `protobuf:"varint,9,opt,name=min_source_count,json=minSourceCount,proto3" json:"min_source_count,omitempty"` +} + +func (m *BandOracleRequest) Reset() { *m = BandOracleRequest{} } +func (m *BandOracleRequest) String() string { return proto.CompactTextString(m) } +func (*BandOracleRequest) ProtoMessage() {} +func (*BandOracleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_78a657bc7a2646c9, []int{1} +} +func (m *BandOracleRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BandOracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BandOracleRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) if err != nil { - return 0, err + return nil, err } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + return b[:n], nil } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil +} +func (m *BandOracleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_BandOracleRequest.Merge(m, src) +} +func (m *BandOracleRequest) XXX_Size() int { + return m.Size() +} +func (m *BandOracleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_BandOracleRequest.DiscardUnknown(m) } -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++ +var xxx_messageInfo_BandOracleRequest proto.InternalMessageInfo + +func (m *BandOracleRequest) GetRequestId() uint64 { + if m != nil { + return m.RequestId } - dAtA[offset] = uint8(v) - return base + return 0 } -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 + +func (m *BandOracleRequest) GetOracleScriptId() int64 { + if m != nil { + return m.OracleScriptId } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) + return 0 +} + +func (m *BandOracleRequest) GetSymbols() []string { + if m != nil { + return m.Symbols } - return n + return nil } -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *BandOracleRequest) GetAskCount() uint64 { + if m != nil { + return m.AskCount + } + return 0 } -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + +func (m *BandOracleRequest) GetMinCount() uint64 { + if m != nil { + return m.MinCount + } + return 0 +} + +func (m *BandOracleRequest) GetFeeLimit() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.FeeLimit + } + return nil +} + +func (m *BandOracleRequest) GetPrepareGas() uint64 { + if m != nil { + return m.PrepareGas + } + return 0 +} + +func (m *BandOracleRequest) GetExecuteGas() uint64 { + if m != nil { + return m.ExecuteGas + } + return 0 +} + +func (m *BandOracleRequest) GetMinSourceCount() uint64 { + if m != nil { + return m.MinSourceCount + } + return 0 +} + +type BandOracleRequestParams struct { + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + AskCount uint64 `protobuf:"varint,1,opt,name=ask_count,json=askCount,proto3" json:"ask_count,omitempty"` + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + MinCount uint64 `protobuf:"varint,2,opt,name=min_count,json=minCount,proto3" json:"min_count,omitempty"` + // FeeLimit is the maximum tokens that will be paid to all data source + // providers. + FeeLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=fee_limit,json=feeLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee_limit"` + // PrepareGas is amount of gas to pay to prepare raw requests + PrepareGas uint64 `protobuf:"varint,4,opt,name=prepare_gas,json=prepareGas,proto3" json:"prepare_gas,omitempty"` + // ExecuteGas is amount of gas to reserve for executing + ExecuteGas uint64 `protobuf:"varint,5,opt,name=execute_gas,json=executeGas,proto3" json:"execute_gas,omitempty"` + // MinSourceCount is the minimum number of data sources that must be used by + // each validator + MinSourceCount uint64 `protobuf:"varint,6,opt,name=min_source_count,json=minSourceCount,proto3" json:"min_source_count,omitempty"` +} + +func (m *BandOracleRequestParams) Reset() { *m = BandOracleRequestParams{} } +func (m *BandOracleRequestParams) String() string { return proto.CompactTextString(m) } +func (*BandOracleRequestParams) ProtoMessage() {} +func (*BandOracleRequestParams) Descriptor() ([]byte, []int) { + return fileDescriptor_78a657bc7a2646c9, []int{2} +} +func (m *BandOracleRequestParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BandOracleRequestParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BandOracleRequestParams.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 *BandOracleRequestParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_BandOracleRequestParams.Merge(m, src) +} +func (m *BandOracleRequestParams) XXX_Size() int { + return m.Size() +} +func (m *BandOracleRequestParams) XXX_DiscardUnknown() { + xxx_messageInfo_BandOracleRequestParams.DiscardUnknown(m) +} + +var xxx_messageInfo_BandOracleRequestParams proto.InternalMessageInfo + +func (m *BandOracleRequestParams) GetAskCount() uint64 { + if m != nil { + return m.AskCount + } + return 0 +} + +func (m *BandOracleRequestParams) GetMinCount() uint64 { + if m != nil { + return m.MinCount + } + return 0 +} + +func (m *BandOracleRequestParams) GetFeeLimit() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.FeeLimit + } + return nil +} + +func (m *BandOracleRequestParams) GetPrepareGas() uint64 { + if m != nil { + return m.PrepareGas + } + return 0 +} + +func (m *BandOracleRequestParams) GetExecuteGas() uint64 { + if m != nil { + return m.ExecuteGas + } + return 0 +} + +func (m *BandOracleRequestParams) GetMinSourceCount() uint64 { + if m != nil { + return m.MinSourceCount + } + return 0 +} + +type BandParams struct { + // block request interval to send Band IBC prices + IbcRequestInterval int64 `protobuf:"varint,2,opt,name=ibc_request_interval,json=ibcRequestInterval,proto3" json:"ibc_request_interval,omitempty"` + // band IBC source channel + IbcSourceChannel string `protobuf:"bytes,3,opt,name=ibc_source_channel,json=ibcSourceChannel,proto3" json:"ibc_source_channel,omitempty"` + // band IBC version + IbcVersion string `protobuf:"bytes,4,opt,name=ibc_version,json=ibcVersion,proto3" json:"ibc_version,omitempty"` + // band IBC portID + IbcPortId string `protobuf:"bytes,5,opt,name=ibc_port_id,json=ibcPortId,proto3" json:"ibc_port_id,omitempty"` + // legacy oracle scheme ids + LegacyOracleIds []int64 `protobuf:"varint,6,rep,packed,name=legacy_oracle_ids,json=legacyOracleIds,proto3" json:"legacy_oracle_ids,omitempty"` +} + +func (m *BandParams) Reset() { *m = BandParams{} } +func (m *BandParams) String() string { return proto.CompactTextString(m) } +func (*BandParams) ProtoMessage() {} +func (*BandParams) Descriptor() ([]byte, []int) { + return fileDescriptor_78a657bc7a2646c9, []int{3} +} +func (m *BandParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BandParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BandParams.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 *BandParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_BandParams.Merge(m, src) +} +func (m *BandParams) XXX_Size() int { + return m.Size() +} +func (m *BandParams) XXX_DiscardUnknown() { + xxx_messageInfo_BandParams.DiscardUnknown(m) +} + +var xxx_messageInfo_BandParams proto.InternalMessageInfo + +func (m *BandParams) GetIbcRequestInterval() int64 { + if m != nil { + return m.IbcRequestInterval + } + return 0 +} + +func (m *BandParams) GetIbcSourceChannel() string { + if m != nil { + return m.IbcSourceChannel + } + return "" +} + +func (m *BandParams) GetIbcVersion() string { + if m != nil { + return m.IbcVersion + } + return "" +} + +func (m *BandParams) GetIbcPortId() string { + if m != nil { + return m.IbcPortId + } + return "" +} + +func (m *BandParams) GetLegacyOracleIds() []int64 { + if m != nil { + return m.LegacyOracleIds + } + return nil +} + +type BandPriceState struct { + Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` + Rate cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=rate,proto3,customtype=cosmossdk.io/math.Int" json:"rate"` + ResolveTime uint64 `protobuf:"varint,3,opt,name=resolve_time,json=resolveTime,proto3" json:"resolve_time,omitempty"` + Request_ID uint64 `protobuf:"varint,4,opt,name=request_ID,json=requestID,proto3" json:"request_ID,omitempty"` + PriceState PriceState `protobuf:"bytes,5,opt,name=price_state,json=priceState,proto3" json:"price_state"` +} + +func (m *BandPriceState) Reset() { *m = BandPriceState{} } +func (m *BandPriceState) String() string { return proto.CompactTextString(m) } +func (*BandPriceState) ProtoMessage() {} +func (*BandPriceState) Descriptor() ([]byte, []int) { + return fileDescriptor_78a657bc7a2646c9, []int{4} +} +func (m *BandPriceState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BandPriceState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BandPriceState.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 *BandPriceState) XXX_Merge(src proto.Message) { + xxx_messageInfo_BandPriceState.Merge(m, src) +} +func (m *BandPriceState) XXX_Size() int { + return m.Size() +} +func (m *BandPriceState) XXX_DiscardUnknown() { + xxx_messageInfo_BandPriceState.DiscardUnknown(m) +} + +var xxx_messageInfo_BandPriceState proto.InternalMessageInfo + +func (m *BandPriceState) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *BandPriceState) GetResolveTime() uint64 { + if m != nil { + return m.ResolveTime + } + return 0 +} + +func (m *BandPriceState) GetRequest_ID() uint64 { + if m != nil { + return m.Request_ID + } + return 0 +} + +func (m *BandPriceState) GetPriceState() PriceState { + if m != nil { + return m.PriceState + } + return PriceState{} +} + +type PriceState struct { + Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` + Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *PriceState) Reset() { *m = PriceState{} } +func (m *PriceState) String() string { return proto.CompactTextString(m) } +func (*PriceState) ProtoMessage() {} +func (*PriceState) Descriptor() ([]byte, []int) { + return fileDescriptor_78a657bc7a2646c9, []int{5} +} +func (m *PriceState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PriceState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PriceState.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 *PriceState) XXX_Merge(src proto.Message) { + xxx_messageInfo_PriceState.Merge(m, src) +} +func (m *PriceState) XXX_Size() int { + return m.Size() +} +func (m *PriceState) XXX_DiscardUnknown() { + xxx_messageInfo_PriceState.DiscardUnknown(m) +} + +var xxx_messageInfo_PriceState proto.InternalMessageInfo + +func (m *PriceState) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type CalldataRecord struct { + ClientId uint64 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + Calldata []byte `protobuf:"bytes,2,opt,name=calldata,proto3" json:"calldata,omitempty"` +} + +func (m *CalldataRecord) Reset() { *m = CalldataRecord{} } +func (m *CalldataRecord) String() string { return proto.CompactTextString(m) } +func (*CalldataRecord) ProtoMessage() {} +func (*CalldataRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_78a657bc7a2646c9, []int{6} +} +func (m *CalldataRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CalldataRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CalldataRecord.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 *CalldataRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_CalldataRecord.Merge(m, src) +} +func (m *CalldataRecord) XXX_Size() int { + return m.Size() +} +func (m *CalldataRecord) XXX_DiscardUnknown() { + xxx_messageInfo_CalldataRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_CalldataRecord proto.InternalMessageInfo + +func (m *CalldataRecord) GetClientId() uint64 { + if m != nil { + return m.ClientId + } + return 0 +} + +func (m *CalldataRecord) GetCalldata() []byte { + if m != nil { + return m.Calldata + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "reserve.oracle.GenesisState") + proto.RegisterType((*BandOracleRequest)(nil), "reserve.oracle.BandOracleRequest") + proto.RegisterType((*BandOracleRequestParams)(nil), "reserve.oracle.BandOracleRequestParams") + proto.RegisterType((*BandParams)(nil), "reserve.oracle.BandParams") + proto.RegisterType((*BandPriceState)(nil), "reserve.oracle.BandPriceState") + proto.RegisterType((*PriceState)(nil), "reserve.oracle.PriceState") + proto.RegisterType((*CalldataRecord)(nil), "reserve.oracle.CalldataRecord") +} + +func init() { proto.RegisterFile("reserve/oracle/genesis.proto", fileDescriptor_78a657bc7a2646c9) } + +var fileDescriptor_78a657bc7a2646c9 = []byte{ + // 941 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xc6, 0x8e, 0xeb, 0x7d, 0x8e, 0x9c, 0x64, 0x48, 0x53, 0xe3, 0xb4, 0x4e, 0x6a, 0x0e, + 0x58, 0x15, 0xec, 0x36, 0xed, 0xa9, 0x47, 0x9c, 0x48, 0x95, 0x51, 0x24, 0xaa, 0x09, 0xe2, 0xc0, + 0x65, 0x35, 0x3b, 0x3b, 0x75, 0x86, 0xec, 0xee, 0x98, 0x99, 0xb1, 0xd5, 0x7c, 0x01, 0xce, 0x7c, + 0x0c, 0xe0, 0xc4, 0xc7, 0xe8, 0x81, 0x43, 0x8f, 0xc0, 0xa1, 0x54, 0xc9, 0x81, 0xaf, 0x81, 0xe6, + 0x8f, 0xff, 0xa5, 0xa6, 0xe1, 0xc4, 0xc5, 0xde, 0x79, 0xef, 0xf7, 0xfe, 0xcf, 0xef, 0x0d, 0xdc, + 0x97, 0x4c, 0x31, 0x39, 0x61, 0xb1, 0x90, 0x84, 0xe6, 0x2c, 0x1e, 0xb2, 0x92, 0x29, 0xae, 0xa2, + 0x91, 0x14, 0x5a, 0xa0, 0xa6, 0xd7, 0x46, 0x4e, 0xdb, 0xde, 0x21, 0x05, 0x2f, 0x45, 0x6c, 0x7f, + 0x1d, 0xa4, 0xbd, 0x3b, 0x14, 0x43, 0x61, 0x3f, 0x63, 0xf3, 0xe5, 0xa5, 0xfb, 0x37, 0xdc, 0x8e, + 0x88, 0x24, 0x85, 0xf7, 0xda, 0xee, 0x50, 0xa1, 0x0a, 0xa1, 0xe2, 0x94, 0x28, 0x16, 0x4f, 0x8e, + 0x52, 0xa6, 0xc9, 0x51, 0x4c, 0x05, 0x2f, 0x9d, 0xbe, 0xfb, 0x5b, 0x15, 0x36, 0x9f, 0xbb, 0x3c, + 0xce, 0x34, 0xd1, 0x0c, 0x3d, 0x83, 0x9a, 0x73, 0xd0, 0x0a, 0x0e, 0x83, 0x5e, 0xe3, 0xc9, 0x5e, + 0xb4, 0x9c, 0x57, 0xf4, 0xc2, 0x6a, 0xfb, 0xe1, 0xeb, 0xb7, 0x07, 0x6b, 0x3f, 0xfd, 0xfd, 0xeb, + 0xa3, 0x00, 0x7b, 0x03, 0xf4, 0x05, 0x34, 0x52, 0x52, 0x66, 0x89, 0xb7, 0x5f, 0xb7, 0xf6, 0xed, + 0x9b, 0xf6, 0x7d, 0x52, 0x66, 0xde, 0x47, 0xd5, 0xf8, 0xc0, 0x90, 0xce, 0x24, 0xe8, 0x4b, 0xd8, + 0x71, 0x2e, 0x24, 0xa7, 0x2c, 0x51, 0x26, 0x23, 0xd5, 0xaa, 0x1c, 0x56, 0x7a, 0x8d, 0x27, 0x9d, + 0x95, 0x8e, 0x0c, 0xce, 0x26, 0x8e, 0xb7, 0xd2, 0xa5, 0xb3, 0x42, 0x67, 0xb0, 0x6b, 0x7d, 0x39, + 0x78, 0x22, 0xd9, 0xf7, 0x63, 0xa6, 0xb4, 0x6a, 0x55, 0xad, 0xbb, 0x87, 0xab, 0xdc, 0x7d, 0x65, + 0x3f, 0xb1, 0x43, 0x62, 0x94, 0xde, 0x14, 0x29, 0x74, 0x04, 0x77, 0xad, 0xd3, 0xdc, 0x84, 0xd0, + 0x09, 0xcd, 0x39, 0x2b, 0x75, 0xc2, 0xb3, 0xd6, 0xc6, 0x61, 0xd0, 0xab, 0x3a, 0x93, 0x53, 0xab, + 0x3b, 0xb6, 0xaa, 0x41, 0x86, 0x06, 0xb0, 0x4d, 0x49, 0x9e, 0x67, 0x44, 0x93, 0x44, 0x32, 0x2a, + 0x64, 0xa6, 0x5a, 0xb5, 0xd5, 0x25, 0x1d, 0x7b, 0x1c, 0xb6, 0x30, 0xbc, 0x45, 0x97, 0xce, 0x0a, + 0x3d, 0x85, 0xbd, 0xc5, 0xe8, 0xbe, 0x24, 0x13, 0xfe, 0x8e, 0x0d, 0xff, 0xd1, 0x3c, 0xbc, 0xcf, + 0x78, 0x90, 0xa1, 0xef, 0xa0, 0xbd, 0xa2, 0x0f, 0xd3, 0x29, 0xd5, 0xed, 0x94, 0x3e, 0xbd, 0xb5, + 0x1b, 0x4b, 0x23, 0xbb, 0x97, 0xae, 0x56, 0x77, 0x7f, 0xa8, 0xc0, 0xce, 0x7b, 0xa6, 0xe8, 0x01, + 0xc0, 0x42, 0xaa, 0x81, 0x4d, 0x35, 0x94, 0xb3, 0x04, 0x7b, 0xb0, 0xed, 0x73, 0x53, 0x54, 0xf2, + 0x91, 0x05, 0x99, 0xcb, 0x53, 0xc1, 0x4d, 0x27, 0x3f, 0xb3, 0xe2, 0x41, 0x86, 0x5a, 0x70, 0x47, + 0x5d, 0x16, 0xa9, 0xc8, 0xdd, 0xa5, 0x08, 0xf1, 0xf4, 0x88, 0xf6, 0x21, 0x24, 0xea, 0x22, 0xa1, + 0x62, 0x5c, 0xea, 0x56, 0xd5, 0x46, 0xa8, 0x13, 0x75, 0x71, 0x6c, 0xce, 0x46, 0x59, 0xf0, 0xd2, + 0x2b, 0xdd, 0xa0, 0xea, 0x05, 0x2f, 0x9d, 0xf2, 0x1c, 0xc2, 0x97, 0x8c, 0x25, 0x39, 0x2f, 0xb8, + 0xf6, 0x73, 0xf9, 0x38, 0x72, 0xac, 0x89, 0x0c, 0x6b, 0x22, 0xcf, 0x9a, 0xe8, 0x58, 0xf0, 0xb2, + 0xff, 0xd8, 0xd4, 0xff, 0xcb, 0x5f, 0x07, 0xbd, 0x21, 0xd7, 0xe7, 0xe3, 0x34, 0xa2, 0xa2, 0x88, + 0x3d, 0xc5, 0xdc, 0xdf, 0xe7, 0x2a, 0xbb, 0x88, 0xf5, 0xe5, 0x88, 0x29, 0x6b, 0xa0, 0x70, 0xfd, + 0x25, 0x63, 0xa7, 0xc6, 0x39, 0x3a, 0x80, 0xc6, 0x48, 0xb2, 0x11, 0x91, 0x2c, 0x19, 0x12, 0xe5, + 0x47, 0x06, 0x5e, 0xf4, 0x9c, 0x28, 0x03, 0x60, 0xaf, 0x18, 0x1d, 0x6b, 0x07, 0xa8, 0x3b, 0x80, + 0x17, 0x19, 0x40, 0x0f, 0xb6, 0x4d, 0x21, 0x4a, 0x8c, 0x25, 0x65, 0xbe, 0x9e, 0xd0, 0xa2, 0x9a, + 0x05, 0x2f, 0xcf, 0xac, 0xd8, 0x56, 0xd5, 0xfd, 0x79, 0x1d, 0xee, 0xfd, 0xcb, 0x0c, 0x97, 0x7b, + 0x15, 0x7c, 0xa8, 0x57, 0xeb, 0x1f, 0xea, 0x55, 0xe5, 0x7f, 0xec, 0x55, 0xf5, 0xb6, 0x5e, 0x6d, + 0xfc, 0xa7, 0x5e, 0xd5, 0x56, 0xf6, 0xea, 0x8f, 0x00, 0x60, 0xbe, 0x95, 0xd0, 0x63, 0xd8, 0xe5, + 0x29, 0x9d, 0x93, 0xab, 0xd4, 0x4c, 0x4e, 0x48, 0xee, 0xaf, 0x24, 0xe2, 0x29, 0x9d, 0x72, 0xcb, + 0x6b, 0xd0, 0x67, 0x60, 0xa4, 0xb3, 0x50, 0xe7, 0xa4, 0x2c, 0x59, 0xde, 0xaa, 0x1c, 0x06, 0xbd, + 0x10, 0x6f, 0xf3, 0x94, 0xfa, 0x60, 0x4e, 0x6e, 0x32, 0x37, 0xe8, 0x09, 0x93, 0x8a, 0x8b, 0xd2, + 0x96, 0x16, 0x62, 0xe0, 0x29, 0xfd, 0xc6, 0x49, 0x50, 0xc7, 0x01, 0x46, 0x42, 0xce, 0x36, 0x4b, + 0x88, 0x43, 0x9e, 0xd2, 0x17, 0x42, 0x1a, 0x16, 0x3c, 0x82, 0x9d, 0x9c, 0x0d, 0x09, 0xbd, 0x9c, + 0x52, 0x9a, 0xfb, 0x8d, 0x52, 0xc1, 0x5b, 0x4e, 0xe1, 0xa6, 0x3e, 0xc8, 0x54, 0xf7, 0x5d, 0x00, + 0xcd, 0xe5, 0x45, 0x89, 0xf6, 0xa0, 0xe6, 0x58, 0x63, 0x67, 0x1f, 0x62, 0x7f, 0x42, 0x47, 0x50, + 0x95, 0x44, 0x33, 0x5b, 0x67, 0xd8, 0x7f, 0x60, 0x86, 0xf7, 0xe7, 0xdb, 0x83, 0xbb, 0x6e, 0x54, + 0x2a, 0xbb, 0x88, 0xb8, 0x88, 0x0b, 0xa2, 0xcf, 0xa3, 0x41, 0xa9, 0xb1, 0x85, 0xa2, 0x87, 0xb0, + 0x29, 0x99, 0x12, 0xf9, 0x84, 0x25, 0x9a, 0x17, 0xcc, 0x96, 0x5c, 0xc5, 0x0d, 0x2f, 0xfb, 0x9a, + 0x17, 0x6c, 0x91, 0xfb, 0x83, 0x13, 0x3f, 0xc7, 0x19, 0xf7, 0x4f, 0xcc, 0x9b, 0xb1, 0xb0, 0xeb, + 0x6d, 0xad, 0x2b, 0xde, 0x8c, 0x79, 0xf6, 0xd3, 0x37, 0x63, 0x34, 0x93, 0x74, 0x19, 0xc0, 0x42, + 0x75, 0xcf, 0x60, 0xc3, 0xea, 0x5c, 0x71, 0xfd, 0x4f, 0x7c, 0x19, 0xfb, 0xef, 0x97, 0x71, 0x6a, + 0x5b, 0x75, 0xc2, 0x28, 0x76, 0x16, 0xe8, 0x3e, 0x84, 0xa6, 0x0a, 0xa5, 0x49, 0x31, 0xf2, 0xd3, + 0x9e, 0x0b, 0xba, 0x03, 0x68, 0x2e, 0xaf, 0x67, 0x43, 0x95, 0xf9, 0xfe, 0xf7, 0x3c, 0xa2, 0xd3, + 0xad, 0xdf, 0x86, 0xfa, 0x74, 0x7b, 0x5b, 0x5f, 0x9b, 0x78, 0x76, 0xee, 0x0f, 0x5e, 0x5f, 0x75, + 0x82, 0x37, 0x57, 0x9d, 0xe0, 0xdd, 0x55, 0x27, 0xf8, 0xf1, 0xba, 0xb3, 0xf6, 0xe6, 0xba, 0xb3, + 0xf6, 0xfb, 0x75, 0x67, 0xed, 0xdb, 0x78, 0x81, 0x2a, 0xa2, 0x14, 0xc5, 0xa5, 0x7d, 0xa5, 0xa9, + 0xc8, 0xe3, 0xe9, 0x23, 0xff, 0x6a, 0xfa, 0xcc, 0x5b, 0xde, 0xa4, 0x35, 0x0b, 0x78, 0xfa, 0x4f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x79, 0xd4, 0x41, 0xd7, 0x5c, 0x08, 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 + { + size, err := m.BandOracleRequestParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + if m.BandLatestRequestId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BandLatestRequestId)) + i-- + dAtA[i] = 0x38 + } + if len(m.CalldataRecords) > 0 { + for iNdEx := len(m.CalldataRecords) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CalldataRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.BandLatestClientId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BandLatestClientId)) + i-- + dAtA[i] = 0x28 + } + if len(m.BandOracleRequests) > 0 { + for iNdEx := len(m.BandOracleRequests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BandOracleRequests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.BandPriceStates) > 0 { + for iNdEx := len(m.BandPriceStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BandPriceStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + { + size, err := m.BandParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *BandOracleRequest) 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 *BandOracleRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BandOracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MinSourceCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.MinSourceCount)) + i-- + dAtA[i] = 0x48 + } + if m.ExecuteGas != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ExecuteGas)) + i-- + dAtA[i] = 0x40 + } + if m.PrepareGas != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.PrepareGas)) + i-- + dAtA[i] = 0x38 + } + if len(m.FeeLimit) > 0 { + for iNdEx := len(m.FeeLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.MinCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.MinCount)) + i-- + dAtA[i] = 0x28 + } + if m.AskCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.AskCount)) + i-- + dAtA[i] = 0x20 + } + if len(m.Symbols) > 0 { + for iNdEx := len(m.Symbols) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Symbols[iNdEx]) + copy(dAtA[i:], m.Symbols[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Symbols[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if m.OracleScriptId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.OracleScriptId)) + i-- + dAtA[i] = 0x10 + } + if m.RequestId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.RequestId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BandOracleRequestParams) 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 *BandOracleRequestParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BandOracleRequestParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MinSourceCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.MinSourceCount)) + i-- + dAtA[i] = 0x30 + } + if m.ExecuteGas != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ExecuteGas)) + i-- + dAtA[i] = 0x28 + } + if m.PrepareGas != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.PrepareGas)) + i-- + dAtA[i] = 0x20 + } + if len(m.FeeLimit) > 0 { + for iNdEx := len(m.FeeLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.MinCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.MinCount)) + i-- + dAtA[i] = 0x10 + } + if m.AskCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.AskCount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BandParams) 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 *BandParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BandParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.LegacyOracleIds) > 0 { + dAtA5 := make([]byte, len(m.LegacyOracleIds)*10) + var j4 int + for _, num1 := range m.LegacyOracleIds { + num := uint64(num1) + for num >= 1<<7 { + dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j4++ + } + dAtA5[j4] = uint8(num) + j4++ + } + i -= j4 + copy(dAtA[i:], dAtA5[:j4]) + i = encodeVarintGenesis(dAtA, i, uint64(j4)) + i-- + dAtA[i] = 0x32 + } + if len(m.IbcPortId) > 0 { + i -= len(m.IbcPortId) + copy(dAtA[i:], m.IbcPortId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.IbcPortId))) + i-- + dAtA[i] = 0x2a + } + if len(m.IbcVersion) > 0 { + i -= len(m.IbcVersion) + copy(dAtA[i:], m.IbcVersion) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.IbcVersion))) + i-- + dAtA[i] = 0x22 + } + if len(m.IbcSourceChannel) > 0 { + i -= len(m.IbcSourceChannel) + copy(dAtA[i:], m.IbcSourceChannel) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.IbcSourceChannel))) + i-- + dAtA[i] = 0x1a + } + if m.IbcRequestInterval != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.IbcRequestInterval)) + i-- + dAtA[i] = 0x10 + } + return len(dAtA) - i, nil +} + +func (m *BandPriceState) 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 *BandPriceState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BandPriceState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PriceState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if m.Request_ID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Request_ID)) + i-- + dAtA[i] = 0x20 + } + if m.ResolveTime != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ResolveTime)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PriceState) 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 *PriceState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PriceState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x10 + } + { + size := m.Price.Size() + i -= size + if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *CalldataRecord) 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 *CalldataRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CalldataRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Calldata) > 0 { + i -= len(m.Calldata) + copy(dAtA[i:], m.Calldata) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Calldata))) + i-- + dAtA[i] = 0x12 + } + if m.ClientId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ClientId)) + 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 + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.BandParams.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.BandPriceStates) > 0 { + for _, e := range m.BandPriceStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.BandOracleRequests) > 0 { + for _, e := range m.BandOracleRequests { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.BandLatestClientId != 0 { + n += 1 + sovGenesis(uint64(m.BandLatestClientId)) + } + if len(m.CalldataRecords) > 0 { + for _, e := range m.CalldataRecords { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.BandLatestRequestId != 0 { + n += 1 + sovGenesis(uint64(m.BandLatestRequestId)) + } + l = m.BandOracleRequestParams.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *BandOracleRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestId != 0 { + n += 1 + sovGenesis(uint64(m.RequestId)) + } + if m.OracleScriptId != 0 { + n += 1 + sovGenesis(uint64(m.OracleScriptId)) + } + if len(m.Symbols) > 0 { + for _, s := range m.Symbols { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.AskCount != 0 { + n += 1 + sovGenesis(uint64(m.AskCount)) + } + if m.MinCount != 0 { + n += 1 + sovGenesis(uint64(m.MinCount)) + } + if len(m.FeeLimit) > 0 { + for _, e := range m.FeeLimit { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.PrepareGas != 0 { + n += 1 + sovGenesis(uint64(m.PrepareGas)) + } + if m.ExecuteGas != 0 { + n += 1 + sovGenesis(uint64(m.ExecuteGas)) + } + if m.MinSourceCount != 0 { + n += 1 + sovGenesis(uint64(m.MinSourceCount)) + } + return n +} + +func (m *BandOracleRequestParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AskCount != 0 { + n += 1 + sovGenesis(uint64(m.AskCount)) + } + if m.MinCount != 0 { + n += 1 + sovGenesis(uint64(m.MinCount)) + } + if len(m.FeeLimit) > 0 { + for _, e := range m.FeeLimit { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.PrepareGas != 0 { + n += 1 + sovGenesis(uint64(m.PrepareGas)) + } + if m.ExecuteGas != 0 { + n += 1 + sovGenesis(uint64(m.ExecuteGas)) + } + if m.MinSourceCount != 0 { + n += 1 + sovGenesis(uint64(m.MinSourceCount)) + } + return n +} + +func (m *BandParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IbcRequestInterval != 0 { + n += 1 + sovGenesis(uint64(m.IbcRequestInterval)) + } + l = len(m.IbcSourceChannel) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.IbcVersion) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.IbcPortId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.LegacyOracleIds) > 0 { + l = 0 + for _, e := range m.LegacyOracleIds { + l += sovGenesis(uint64(e)) + } + n += 1 + sovGenesis(uint64(l)) + l + } + return n +} + +func (m *BandPriceState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Rate.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.ResolveTime != 0 { + n += 1 + sovGenesis(uint64(m.ResolveTime)) + } + if m.Request_ID != 0 { + n += 1 + sovGenesis(uint64(m.Request_ID)) + } + l = m.PriceState.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *PriceState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Price.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.Timestamp != 0 { + n += 1 + sovGenesis(uint64(m.Timestamp)) + } + return n +} + +func (m *CalldataRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ClientId != 0 { + n += 1 + sovGenesis(uint64(m.ClientId)) + } + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + 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 != 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BandParams", 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.BandParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BandPriceStates", 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 + } + m.BandPriceStates = append(m.BandPriceStates, &BandPriceState{}) + if err := m.BandPriceStates[len(m.BandPriceStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BandOracleRequests", 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 + } + m.BandOracleRequests = append(m.BandOracleRequests, &BandOracleRequest{}) + if err := m.BandOracleRequests[len(m.BandOracleRequests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BandLatestClientId", wireType) + } + m.BandLatestClientId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BandLatestClientId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CalldataRecords", 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 + } + m.CalldataRecords = append(m.CalldataRecords, &CalldataRecord{}) + if err := m.CalldataRecords[len(m.CalldataRecords)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BandLatestRequestId", wireType) + } + m.BandLatestRequestId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BandLatestRequestId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BandOracleRequestParams", 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.BandOracleRequestParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 (m *BandOracleRequest) 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: BandOracleRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BandOracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) + } + m.RequestId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScriptId", wireType) + } + m.OracleScriptId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleScriptId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbols", 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.Symbols = append(m.Symbols, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AskCount", wireType) + } + m.AskCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AskCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCount", wireType) + } + m.MinCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeLimit", 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 + } + m.FeeLimit = append(m.FeeLimit, types.Coin{}) + if err := m.FeeLimit[len(m.FeeLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrepareGas", wireType) + } + m.PrepareGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrepareGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecuteGas", wireType) + } + m.ExecuteGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecuteGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSourceCount", wireType) + } + m.MinSourceCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinSourceCount |= 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 (m *BandOracleRequestParams) 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: BandOracleRequestParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BandOracleRequestParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AskCount", wireType) + } + m.AskCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AskCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCount", wireType) + } + m.MinCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeLimit", 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 + } + m.FeeLimit = append(m.FeeLimit, types.Coin{}) + if err := m.FeeLimit[len(m.FeeLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrepareGas", wireType) + } + m.PrepareGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrepareGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecuteGas", wireType) + } + m.ExecuteGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecuteGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSourceCount", wireType) + } + m.MinSourceCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinSourceCount |= 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 (m *BandParams) 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: BandParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BandParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IbcRequestInterval", wireType) + } + m.IbcRequestInterval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.IbcRequestInterval |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IbcSourceChannel", 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.IbcSourceChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IbcVersion", 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.IbcVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IbcPortId", 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.IbcPortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LegacyOracleIds = append(m.LegacyOracleIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.LegacyOracleIds) == 0 { + m.LegacyOracleIds = make([]int64, 0, elementCount) + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LegacyOracleIds = append(m.LegacyOracleIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field LegacyOracleIds", wireType) + } + 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 (m *GenesisState) Unmarshal(dAtA []byte) error { +func (m *BandPriceState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -198,15 +2311,119 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + return fmt.Errorf("proto: BandPriceState: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: BandPriceState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", 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.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rate", 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 + } + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveTime", wireType) + } + m.ResolveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Request_ID", wireType) + } + m.Request_ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Request_ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceState", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -233,13 +2450,63 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PriceState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 2: + 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 (m *PriceState) 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: PriceState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PriceState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -267,7 +2534,131 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PortId = string(dAtA[iNdEx:postIndex]) + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(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 (m *CalldataRecord) 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: CalldataRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CalldataRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + m.ClientId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClientId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Calldata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Calldata = append(m.Calldata[:0], dAtA[iNdEx:postIndex]...) + if m.Calldata == nil { + m.Calldata = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go index 525bfefb..88998ff1 100644 --- a/x/oracle/types/genesis_test.go +++ b/x/oracle/types/genesis_test.go @@ -3,40 +3,40 @@ package types_test import ( "testing" - "github.com/onomyprotocol/reserve/x/oracle/types" + // "github.com/onomyprotocol/reserve/x/oracle/types" - "github.com/stretchr/testify/require" + // "github.com/stretchr/testify/require" ) func TestGenesisState_Validate(t *testing.T) { - tests := []struct { - desc string - genState *types.GenesisState - valid bool - }{ - { - desc: "default is valid", - genState: types.DefaultGenesis(), - valid: true, - }, - { - desc: "valid genesis state", - genState: &types.GenesisState{ - PortId: types.PortID, - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, - }, - // this line is used by starport scaffolding # types/genesis/testcase - } - for _, tc := range tests { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } + // tests := []struct { + // desc string + // genState *types.GenesisState + // valid bool + // }{ + // { + // desc: "default is valid", + // genState: types.DefaultGenesis(), + // valid: true, + // }, + // { + // desc: "valid genesis state", + // genState: &types.GenesisState{ + // PortId: types.PortID, + // // this line is used by starport scaffolding # types/genesis/validField + // }, + // valid: true, + // }, + // // this line is used by starport scaffolding # types/genesis/testcase + // } + // for _, tc := range tests { + // t.Run(tc.desc, func(t *testing.T) { + // err := tc.genState.Validate() + // if tc.valid { + // require.NoError(t, err) + // } else { + // require.Error(t, err) + // } + // }) + // } } diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 45304fdb..8401bfb8 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -1,5 +1,9 @@ package types +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + const ( // ModuleName defines the module name ModuleName = "oracle" @@ -11,14 +15,21 @@ const ( MemStoreKey = "mem_oracle" // Version defines the current version the IBC module supports - Version = "oracle-1" + // Version = "oracle-1" // PortID is the default port id that module binds to PortID = "oracle" ) var ( - ParamsKey = []byte("p_oracle") + ParamsKey = []byte("p_oracle") + BandParamsKey = []byte{0x01} + BandCallDataRecordKey = []byte{0x02} + LatestClientIDKey = []byte{0x03} + BandOracleRequestIDKey = []byte{0x04} + BandPriceKey = []byte{0x05} + LatestRequestIDKey = []byte{0x06} + BandOracleRequestParamsKey = []byte{0x07} ) var ( @@ -26,6 +37,18 @@ var ( PortKey = KeyPrefix("oracle-port-") ) +func GetBandCallDataRecordKey(clientID uint64) []byte { + return append(BandCallDataRecordKey, sdk.Uint64ToBigEndian(clientID)...) +} + +func GetBandOracleRequestIDKey(requestID uint64) []byte { + return append(BandOracleRequestIDKey, sdk.Uint64ToBigEndian(requestID)...) +} + +func GetBandPriceStoreKey(symbol string) []byte { + return append(BandPriceKey, []byte(symbol)...) +} + func KeyPrefix(p string) []byte { return []byte(p) } diff --git a/x/oracle/types/msg_update_params.go b/x/oracle/types/msg_update_params.go deleted file mode 100644 index e36d023d..00000000 --- a/x/oracle/types/msg_update_params.go +++ /dev/null @@ -1,21 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ sdk.Msg = &MsgUpdateParams{} - -// ValidateBasic does a sanity check on the provided data. -func (m *MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { - return errorsmod.Wrap(err, "invalid authority address") - } - - if err := m.Params.Validate(); err != nil { - return err - } - - return nil -} diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go new file mode 100644 index 00000000..d0ebeb8a --- /dev/null +++ b/x/oracle/types/msgs.go @@ -0,0 +1,92 @@ +package types + +import ( + "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// oracle message types +const ( + RouterKey = ModuleName + TypeMsgRequestBandRates = "requestBandRates" + TypeMsgUpdateParams = "updateParams" +) + +var ( + _ sdk.Msg = &MsgRequestBandRates{} + _ sdk.Msg = &MsgUpdateParams{} +) + +func (msg MsgUpdateParams) Route() string { return RouterKey } + +func (msg MsgUpdateParams) Type() string { return TypeMsgUpdateParams } + +func (m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errorsmod.Wrap(err, "invalid authority address") + } + + if err := m.Params.Validate(); err != nil { + return err + } + + return nil +} + +func (msg *MsgUpdateParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshal(msg)) +} + +func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} + +// NewMsgRequestBandRates creates a new MsgRequestBandRates instance. +func NewMsgRequestBandRates( + sender sdk.AccAddress, + requestID uint64, +) *MsgRequestBandRates { + return &MsgRequestBandRates{ + Sender: sender.String(), + RequestId: requestID, + } +} + +// Route implements the sdk.Msg interface for MsgRequestBandRates. +func (msg MsgRequestBandRates) Route() string { return RouterKey } + +// Type implements the sdk.Msg interface for MsgRequestBandRates. +func (msg MsgRequestBandRates) Type() string { return TypeMsgRequestBandRates } + +// ValidateBasic implements the sdk.Msg interface for MsgRequestBandRates. +func (msg MsgRequestBandRates) ValidateBasic() error { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return err + } + if sender.Empty() { + return errors.Wrapf(ErrInvalidBandRequest, "MsgRequestBandRates: Sender address must not be empty.") + } + + if msg.RequestId == 0 { + return errors.Wrapf(ErrInvalidBandRequest, "MsgRequestBandRates: requestID should be greater than zero") + } + return nil +} + +// GetSigners implements the sdk.Msg interface for MsgRequestBandRates. +func (msg MsgRequestBandRates) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +// GetSignBytes implements the sdk.Msg interface for MsgRequestBandRates. +func (msg MsgRequestBandRates) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} diff --git a/x/oracle/types/packet.pb.go b/x/oracle/types/packet.pb.go index e33191e2..2b65e6b0 100644 --- a/x/oracle/types/packet.pb.go +++ b/x/oracle/types/packet.pb.go @@ -4,7 +4,11 @@ package types import ( + bytes "bytes" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -22,25 +26,82 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type OraclePacketData struct { - // Types that are valid to be assigned to Packet: - // - // *OraclePacketData_NoData - Packet isOraclePacketData_Packet `protobuf_oneof:"packet"` +// ResolveStatus encodes the status of an oracle request. +type ResolveStatus int32 + +const ( + // Open - the request is not yet resolved. + RESOLVE_STATUS_OPEN ResolveStatus = 0 + // Success - the request has been resolved successfully with no errors. + RESOLVE_STATUS_SUCCESS ResolveStatus = 1 + // Failure - an error occured during the request's resolve call. + RESOLVE_STATUS_FAILURE ResolveStatus = 2 + // Expired - the request does not get enough reports from validator within the + // timeframe. + RESOLVE_STATUS_EXPIRED ResolveStatus = 3 +) + +var ResolveStatus_name = map[int32]string{ + 0: "RESOLVE_STATUS_OPEN_UNSPECIFIED", + 1: "RESOLVE_STATUS_SUCCESS", + 2: "RESOLVE_STATUS_FAILURE", + 3: "RESOLVE_STATUS_EXPIRED", +} + +var ResolveStatus_value = map[string]int32{ + "RESOLVE_STATUS_OPEN_UNSPECIFIED": 0, + "RESOLVE_STATUS_SUCCESS": 1, + "RESOLVE_STATUS_FAILURE": 2, + "RESOLVE_STATUS_EXPIRED": 3, +} + +func (x ResolveStatus) String() string { + return proto.EnumName(ResolveStatus_name, int32(x)) } -func (m *OraclePacketData) Reset() { *m = OraclePacketData{} } -func (m *OraclePacketData) String() string { return proto.CompactTextString(m) } -func (*OraclePacketData) ProtoMessage() {} -func (*OraclePacketData) Descriptor() ([]byte, []int) { +func (ResolveStatus) EnumDescriptor() ([]byte, []int) { return fileDescriptor_dacd96e030a6c748, []int{0} } -func (m *OraclePacketData) XXX_Unmarshal(b []byte) error { + +type OracleRequestPacketData struct { + // ClientID is the unique identifier of this oracle request, as specified by + // the client. This same unique ID will be sent back to the requester with the + // oracle response. + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // OracleScriptID is the unique identifier of the oracle script to be + // executed. + OracleScriptID uint64 `protobuf:"varint,2,opt,name=oracle_script_id,json=oracleScriptId,proto3" json:"oracle_script_id,omitempty"` + // Calldata is the OBI-encoded calldata bytes available for oracle executor to + // read. + Calldata []byte `protobuf:"bytes,3,opt,name=calldata,proto3" json:"calldata,omitempty"` + // AskCount is the number of validators that are requested to respond to this + // oracle request. Higher value means more security, at a higher gas cost. + AskCount uint64 `protobuf:"varint,4,opt,name=ask_count,json=askCount,proto3" json:"ask_count,omitempty"` + // MinCount is the minimum number of validators necessary for the request to + // proceed to the execution phase. Higher value means more security, at the + // cost of liveness. + MinCount uint64 `protobuf:"varint,5,opt,name=min_count,json=minCount,proto3" json:"min_count,omitempty"` + // FeeLimit is the maximum tokens that will be paid to all data source + // providers. + FeeLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=fee_limit,json=feeLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee_limit"` + // PrepareGas is amount of gas to pay to prepare raw requests + PrepareGas uint64 `protobuf:"varint,7,opt,name=prepare_gas,json=prepareGas,proto3" json:"prepare_gas,omitempty"` + // ExecuteGas is amount of gas to reserve for executing + ExecuteGas uint64 `protobuf:"varint,8,opt,name=execute_gas,json=executeGas,proto3" json:"execute_gas,omitempty"` +} + +func (m *OracleRequestPacketData) Reset() { *m = OracleRequestPacketData{} } +func (m *OracleRequestPacketData) String() string { return proto.CompactTextString(m) } +func (*OracleRequestPacketData) ProtoMessage() {} +func (*OracleRequestPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_dacd96e030a6c748, []int{0} +} +func (m *OracleRequestPacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OraclePacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OracleRequestPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OraclePacketData.Marshal(b, m, deterministic) + return xxx_messageInfo_OracleRequestPacketData.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -50,66 +111,112 @@ func (m *OraclePacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *OraclePacketData) XXX_Merge(src proto.Message) { - xxx_messageInfo_OraclePacketData.Merge(m, src) +func (m *OracleRequestPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleRequestPacketData.Merge(m, src) } -func (m *OraclePacketData) XXX_Size() int { +func (m *OracleRequestPacketData) XXX_Size() int { return m.Size() } -func (m *OraclePacketData) XXX_DiscardUnknown() { - xxx_messageInfo_OraclePacketData.DiscardUnknown(m) +func (m *OracleRequestPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_OracleRequestPacketData.DiscardUnknown(m) } -var xxx_messageInfo_OraclePacketData proto.InternalMessageInfo +var xxx_messageInfo_OracleRequestPacketData proto.InternalMessageInfo -type isOraclePacketData_Packet interface { - isOraclePacketData_Packet() - MarshalTo([]byte) (int, error) - Size() int +func (m *OracleRequestPacketData) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" } -type OraclePacketData_NoData struct { - NoData *NoData `protobuf:"bytes,1,opt,name=noData,proto3,oneof" json:"noData,omitempty"` +func (m *OracleRequestPacketData) GetOracleScriptID() uint64 { + if m != nil { + return m.OracleScriptID + } + return 0 } -func (*OraclePacketData_NoData) isOraclePacketData_Packet() {} - -func (m *OraclePacketData) GetPacket() isOraclePacketData_Packet { +func (m *OracleRequestPacketData) GetCalldata() []byte { if m != nil { - return m.Packet + return m.Calldata } return nil } -func (m *OraclePacketData) GetNoData() *NoData { - if x, ok := m.GetPacket().(*OraclePacketData_NoData); ok { - return x.NoData +func (m *OracleRequestPacketData) GetAskCount() uint64 { + if m != nil { + return m.AskCount + } + return 0 +} + +func (m *OracleRequestPacketData) GetMinCount() uint64 { + if m != nil { + return m.MinCount + } + return 0 +} + +func (m *OracleRequestPacketData) GetFeeLimit() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.FeeLimit } return nil } -// XXX_OneofWrappers is for the internal use of the proto package. -func (*OraclePacketData) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*OraclePacketData_NoData)(nil), +func (m *OracleRequestPacketData) GetPrepareGas() uint64 { + if m != nil { + return m.PrepareGas } + return 0 } -type NoData struct { +func (m *OracleRequestPacketData) GetExecuteGas() uint64 { + if m != nil { + return m.ExecuteGas + } + return 0 } -func (m *NoData) Reset() { *m = NoData{} } -func (m *NoData) String() string { return proto.CompactTextString(m) } -func (*NoData) ProtoMessage() {} -func (*NoData) Descriptor() ([]byte, []int) { +// OracleResponsePacketData encodes an oracle response from BandChain to the +// requester. +type OracleResponsePacketData struct { + // ClientID is the unique identifier matched with that of the oracle request + // packet. + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // RequestID is BandChain's unique identifier for this oracle request. + RequestID uint64 `protobuf:"varint,2,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + // AnsCount is the number of validators among to the asked validators that + // actually responded to this oracle request prior to this oracle request + // being resolved. + AnsCount uint64 `protobuf:"varint,3,opt,name=ans_count,json=ansCount,proto3" json:"ans_count,omitempty"` + // RequestTime is the UNIX epoch time at which the request was sent to + // BandChain. + RequestTime int64 `protobuf:"varint,4,opt,name=request_time,json=requestTime,proto3" json:"request_time,omitempty"` + // ResolveTime is the UNIX epoch time at which the request was resolved to the + // final result. + ResolveTime int64 `protobuf:"varint,5,opt,name=resolve_time,json=resolveTime,proto3" json:"resolve_time,omitempty"` + // ResolveStatus is the status of this oracle request, which can be OK, + // FAILURE, or EXPIRED. + ResolveStatus ResolveStatus `protobuf:"varint,6,opt,name=resolve_status,json=resolveStatus,proto3,enum=reserve.oracle.ResolveStatus" json:"resolve_status,omitempty"` + // Result is the final aggregated value encoded in OBI format. Only available + // if status if OK. + Result []byte `protobuf:"bytes,7,opt,name=result,proto3" json:"result,omitempty"` +} + +func (m *OracleResponsePacketData) Reset() { *m = OracleResponsePacketData{} } +func (m *OracleResponsePacketData) String() string { return proto.CompactTextString(m) } +func (*OracleResponsePacketData) ProtoMessage() {} +func (*OracleResponsePacketData) Descriptor() ([]byte, []int) { return fileDescriptor_dacd96e030a6c748, []int{1} } -func (m *NoData) XXX_Unmarshal(b []byte) error { +func (m *OracleResponsePacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *NoData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OracleResponsePacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_NoData.Marshal(b, m, deterministic) + return xxx_messageInfo_OracleResponsePacketData.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -119,42 +226,214 @@ func (m *NoData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *NoData) XXX_Merge(src proto.Message) { - xxx_messageInfo_NoData.Merge(m, src) +func (m *OracleResponsePacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleResponsePacketData.Merge(m, src) } -func (m *NoData) XXX_Size() int { +func (m *OracleResponsePacketData) XXX_Size() int { return m.Size() } -func (m *NoData) XXX_DiscardUnknown() { - xxx_messageInfo_NoData.DiscardUnknown(m) +func (m *OracleResponsePacketData) XXX_DiscardUnknown() { + xxx_messageInfo_OracleResponsePacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleResponsePacketData proto.InternalMessageInfo + +func (m *OracleResponsePacketData) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *OracleResponsePacketData) GetRequestID() uint64 { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *OracleResponsePacketData) GetAnsCount() uint64 { + if m != nil { + return m.AnsCount + } + return 0 +} + +func (m *OracleResponsePacketData) GetRequestTime() int64 { + if m != nil { + return m.RequestTime + } + return 0 +} + +func (m *OracleResponsePacketData) GetResolveTime() int64 { + if m != nil { + return m.ResolveTime + } + return 0 +} + +func (m *OracleResponsePacketData) GetResolveStatus() ResolveStatus { + if m != nil { + return m.ResolveStatus + } + return RESOLVE_STATUS_OPEN } -var xxx_messageInfo_NoData proto.InternalMessageInfo +func (m *OracleResponsePacketData) GetResult() []byte { + if m != nil { + return m.Result + } + return nil +} func init() { - proto.RegisterType((*OraclePacketData)(nil), "reserve.oracle.OraclePacketData") - proto.RegisterType((*NoData)(nil), "reserve.oracle.NoData") + proto.RegisterEnum("reserve.oracle.ResolveStatus", ResolveStatus_name, ResolveStatus_value) + proto.RegisterType((*OracleRequestPacketData)(nil), "reserve.oracle.OracleRequestPacketData") + proto.RegisterType((*OracleResponsePacketData)(nil), "reserve.oracle.OracleResponsePacketData") } func init() { proto.RegisterFile("reserve/oracle/packet.proto", fileDescriptor_dacd96e030a6c748) } var fileDescriptor_dacd96e030a6c748 = []byte{ - // 181 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0x4a, 0x2d, 0x4e, - 0x2d, 0x2a, 0x4b, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x48, 0x4c, 0xce, 0x4e, - 0x2d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x4a, 0xea, 0x41, 0x24, 0x95, 0xfc, - 0xb8, 0x04, 0xfc, 0xc1, 0xac, 0x00, 0xb0, 0x2a, 0x97, 0xc4, 0x92, 0x44, 0x21, 0x03, 0x2e, 0xb6, - 0xbc, 0x7c, 0x10, 0x4b, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4c, 0x0f, 0x55, 0x93, 0x9e, - 0x1f, 0x58, 0xd6, 0x83, 0x21, 0x08, 0xaa, 0xce, 0x89, 0x83, 0x8b, 0x0d, 0x62, 0x8b, 0x12, 0x07, - 0x17, 0x1b, 0x44, 0xd6, 0xc9, 0xf3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, - 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, - 0xf4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xf3, 0xf3, 0xf2, 0x73, - 0x2b, 0xc1, 0x4e, 0x4b, 0xce, 0xcf, 0xd1, 0x87, 0xb9, 0xbc, 0x02, 0xe6, 0xf6, 0x92, 0xca, 0x82, - 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x02, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x95, 0x28, 0x41, - 0xe2, 0xda, 0x00, 0x00, 0x00, -} - -func (m *OraclePacketData) Marshal() (dAtA []byte, err error) { + // 661 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x4e, 0xdb, 0x4a, + 0x14, 0x86, 0x63, 0x12, 0x72, 0x93, 0x21, 0x44, 0x91, 0xef, 0x15, 0xe4, 0x06, 0x5d, 0xdb, 0x97, + 0x55, 0x5a, 0xb5, 0x76, 0xa1, 0x52, 0x17, 0x15, 0x1b, 0x12, 0x1b, 0x64, 0x09, 0x41, 0x34, 0x26, + 0x55, 0xd5, 0x8d, 0x35, 0x71, 0x86, 0x60, 0xc5, 0xf6, 0xb8, 0x9e, 0x09, 0x82, 0x37, 0xa8, 0x58, + 0xf5, 0x05, 0x90, 0x2a, 0x75, 0xd7, 0x47, 0xe8, 0x13, 0xb0, 0x64, 0xd9, 0x55, 0x5a, 0x85, 0x4d, + 0xdf, 0xa1, 0x9b, 0xca, 0x33, 0x93, 0x16, 0xaa, 0x74, 0xd3, 0x55, 0x72, 0xce, 0xff, 0xfd, 0xc7, + 0xd6, 0x7f, 0xc6, 0x03, 0x36, 0x32, 0x4c, 0x71, 0x76, 0x86, 0x2d, 0x92, 0xa1, 0x20, 0xc2, 0x56, + 0x8a, 0x82, 0x31, 0x66, 0x66, 0x9a, 0x11, 0x46, 0xd4, 0xba, 0x14, 0x4d, 0x21, 0xb6, 0xfe, 0x19, + 0x91, 0x11, 0xe1, 0x92, 0x95, 0xff, 0x13, 0x54, 0x4b, 0x0b, 0x08, 0x8d, 0x09, 0xb5, 0x06, 0x88, + 0x62, 0xeb, 0x6c, 0x6b, 0x80, 0x19, 0xda, 0xb2, 0x02, 0x12, 0x26, 0x42, 0xdf, 0xbc, 0x2c, 0x82, + 0xf5, 0x23, 0x3e, 0x00, 0xe2, 0xd7, 0x13, 0x4c, 0x59, 0x8f, 0x3f, 0xc3, 0x46, 0x0c, 0xa9, 0x0f, + 0x40, 0x35, 0x88, 0x42, 0x9c, 0x30, 0x3f, 0x1c, 0x36, 0x15, 0x43, 0x69, 0x57, 0x3b, 0xb5, 0xd9, + 0x54, 0xaf, 0x74, 0x79, 0xd3, 0xb5, 0x61, 0x45, 0xc8, 0xee, 0x50, 0xdd, 0x01, 0x0d, 0xf1, 0x1a, + 0x3e, 0x0d, 0xb2, 0x30, 0xe5, 0x8e, 0x25, 0x43, 0x69, 0x97, 0x3a, 0xea, 0x6c, 0xaa, 0xd7, 0xc5, + 0x13, 0x3c, 0x2e, 0xb9, 0x36, 0xac, 0x93, 0xbb, 0xf5, 0x50, 0x6d, 0x81, 0x4a, 0x80, 0xa2, 0x68, + 0x88, 0x18, 0x6a, 0x16, 0x0d, 0xa5, 0x5d, 0x83, 0x3f, 0x6a, 0x75, 0x03, 0x54, 0x11, 0x1d, 0xfb, + 0x01, 0x99, 0x24, 0xac, 0x59, 0xca, 0x47, 0xc2, 0x0a, 0xa2, 0xe3, 0x6e, 0x5e, 0xe7, 0x62, 0x1c, + 0x26, 0x52, 0x5c, 0x16, 0x62, 0x1c, 0x26, 0x42, 0x3c, 0x05, 0xd5, 0x13, 0x8c, 0xfd, 0x28, 0x8c, + 0x43, 0xd6, 0x2c, 0x1b, 0xc5, 0xf6, 0xca, 0xf6, 0xbf, 0xa6, 0x88, 0xc3, 0xcc, 0xe3, 0x30, 0x65, + 0x1c, 0x66, 0x97, 0x84, 0x49, 0xe7, 0xc9, 0xf5, 0x54, 0x2f, 0x7c, 0xf8, 0xac, 0xb7, 0x47, 0x21, + 0x3b, 0x9d, 0x0c, 0xcc, 0x80, 0xc4, 0x96, 0xcc, 0x4e, 0xfc, 0x3c, 0xa6, 0xc3, 0xb1, 0xc5, 0x2e, + 0x52, 0x4c, 0xb9, 0x81, 0xc2, 0xca, 0x09, 0xc6, 0x07, 0xf9, 0x70, 0x55, 0x07, 0x2b, 0x69, 0x86, + 0x53, 0x94, 0x61, 0x7f, 0x84, 0x68, 0xf3, 0x2f, 0xfe, 0x22, 0x40, 0xb6, 0xf6, 0x11, 0xcd, 0x01, + 0x7c, 0x8e, 0x83, 0x09, 0x13, 0x40, 0x45, 0x00, 0xb2, 0xb5, 0x8f, 0xe8, 0xf3, 0xd2, 0xd7, 0x77, + 0xba, 0xb2, 0xf9, 0x71, 0x09, 0x34, 0xe7, 0xcb, 0xa0, 0x29, 0x49, 0x28, 0xfe, 0xb3, 0x6d, 0x3c, + 0x02, 0x20, 0x13, 0xdb, 0xfc, 0xb9, 0x87, 0xd5, 0xd9, 0x54, 0xaf, 0xca, 0x1d, 0xbb, 0x36, 0xac, + 0x4a, 0xc0, 0x1d, 0xf2, 0x84, 0x13, 0x2a, 0x43, 0x2c, 0xca, 0x84, 0x13, 0x2a, 0x42, 0xfc, 0x1f, + 0xd4, 0xe6, 0xa3, 0x58, 0x18, 0x63, 0xbe, 0x81, 0x22, 0x5c, 0x91, 0xbd, 0xe3, 0x30, 0xc6, 0x02, + 0xa1, 0x24, 0x3a, 0xc3, 0x02, 0x59, 0x9e, 0x23, 0xbc, 0xc7, 0x11, 0x1b, 0xd4, 0xe7, 0x08, 0x65, + 0x88, 0x4d, 0x68, 0xb3, 0x6c, 0x28, 0xed, 0xfa, 0xf6, 0x7f, 0xe6, 0xfd, 0x43, 0x6c, 0x42, 0x41, + 0x79, 0x1c, 0x82, 0xab, 0xd9, 0xdd, 0x52, 0x5d, 0x03, 0xe5, 0x0c, 0xd3, 0x49, 0xc4, 0x78, 0xc2, + 0x35, 0x28, 0x2b, 0x11, 0xde, 0xc3, 0x6f, 0x0a, 0x58, 0xbd, 0x67, 0x57, 0x77, 0x80, 0x0e, 0x1d, + 0xef, 0xe8, 0xe0, 0x85, 0xe3, 0x7b, 0xc7, 0xbb, 0xc7, 0x7d, 0xcf, 0x3f, 0xea, 0x39, 0x87, 0x7e, + 0xff, 0xd0, 0xeb, 0x39, 0x5d, 0x77, 0xcf, 0x75, 0xec, 0x46, 0xa1, 0xb5, 0x7e, 0x79, 0x65, 0xfc, + 0xbd, 0x00, 0x53, 0x9f, 0x81, 0xb5, 0x5f, 0xda, 0x5e, 0xbf, 0xdb, 0x75, 0x3c, 0xaf, 0xa1, 0xb4, + 0x5a, 0x97, 0x57, 0xc6, 0x6f, 0xd4, 0x05, 0xbe, 0xbd, 0x5d, 0xf7, 0xa0, 0x0f, 0x9d, 0xc6, 0xd2, + 0x42, 0x9f, 0x54, 0x17, 0xf8, 0x9c, 0x97, 0x3d, 0x17, 0x3a, 0x76, 0xa3, 0xb8, 0xd0, 0x27, 0xd5, + 0x56, 0xe9, 0xcd, 0x7b, 0xad, 0xd0, 0x71, 0xaf, 0x67, 0x9a, 0x72, 0x33, 0xd3, 0x94, 0x2f, 0x33, + 0x4d, 0x79, 0x7b, 0xab, 0x15, 0x6e, 0x6e, 0xb5, 0xc2, 0xa7, 0x5b, 0xad, 0xf0, 0xca, 0xba, 0x73, + 0xa0, 0x49, 0x42, 0xe2, 0x0b, 0xfe, 0xe1, 0x07, 0x24, 0xb2, 0xe6, 0xb7, 0xcb, 0xf9, 0xfc, 0x7e, + 0xe1, 0xa7, 0x7b, 0x50, 0xe6, 0xc0, 0xd3, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x14, 0xcb, + 0xbf, 0x7e, 0x04, 0x00, 0x00, +} + +func (this *OracleRequestPacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleRequestPacketData) + if !ok { + that2, ok := that.(OracleRequestPacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if this.OracleScriptID != that1.OracleScriptID { + return false + } + if !bytes.Equal(this.Calldata, that1.Calldata) { + return false + } + if this.AskCount != that1.AskCount { + return false + } + if this.MinCount != that1.MinCount { + return false + } + if len(this.FeeLimit) != len(that1.FeeLimit) { + return false + } + for i := range this.FeeLimit { + if !this.FeeLimit[i].Equal(&that1.FeeLimit[i]) { + return false + } + } + if this.PrepareGas != that1.PrepareGas { + return false + } + if this.ExecuteGas != that1.ExecuteGas { + return false + } + return true +} +func (this *OracleResponsePacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleResponsePacketData) + if !ok { + that2, ok := that.(OracleResponsePacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if this.RequestID != that1.RequestID { + return false + } + if this.AnsCount != that1.AnsCount { + return false + } + if this.RequestTime != that1.RequestTime { + return false + } + if this.ResolveTime != that1.ResolveTime { + return false + } + if this.ResolveStatus != that1.ResolveStatus { + return false + } + if !bytes.Equal(this.Result, that1.Result) { + return false + } + return true +} +func (m *OracleRequestPacketData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -164,50 +443,73 @@ func (m *OraclePacketData) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OraclePacketData) MarshalTo(dAtA []byte) (int, error) { +func (m *OracleRequestPacketData) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OraclePacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OracleRequestPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Packet != nil { - { - size := m.Packet.Size() - i -= size - if _, err := m.Packet.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } + if m.ExecuteGas != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.ExecuteGas)) + i-- + dAtA[i] = 0x40 } - return len(dAtA) - i, nil -} - -func (m *OraclePacketData_NoData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *OraclePacketData_NoData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.NoData != nil { - { - size, err := m.NoData.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.PrepareGas != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.PrepareGas)) + i-- + dAtA[i] = 0x38 + } + if len(m.FeeLimit) > 0 { + for iNdEx := len(m.FeeLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeLimit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintPacket(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 } + } + if m.MinCount != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.MinCount)) + i-- + dAtA[i] = 0x28 + } + if m.AskCount != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.AskCount)) + i-- + dAtA[i] = 0x20 + } + if len(m.Calldata) > 0 { + i -= len(m.Calldata) + copy(dAtA[i:], m.Calldata) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Calldata))) + i-- + dAtA[i] = 0x1a + } + if m.OracleScriptID != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.OracleScriptID)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintPacket(dAtA, i, uint64(len(m.ClientID))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *NoData) Marshal() (dAtA []byte, err error) { + +func (m *OracleResponsePacketData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -217,16 +519,55 @@ func (m *NoData) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *NoData) MarshalTo(dAtA []byte) (int, error) { +func (m *OracleResponsePacketData) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *NoData) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OracleResponsePacketData) 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 = encodeVarintPacket(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x3a + } + if m.ResolveStatus != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.ResolveStatus)) + i-- + dAtA[i] = 0x30 + } + if m.ResolveTime != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.ResolveTime)) + i-- + dAtA[i] = 0x28 + } + if m.RequestTime != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.RequestTime)) + i-- + dAtA[i] = 0x20 + } + if m.AnsCount != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.AnsCount)) + i-- + dAtA[i] = 0x18 + } + if m.RequestID != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintPacket(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -241,36 +582,73 @@ func encodeVarintPacket(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *OraclePacketData) Size() (n int) { +func (m *OracleRequestPacketData) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Packet != nil { - n += m.Packet.Size() + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + if m.OracleScriptID != 0 { + n += 1 + sovPacket(uint64(m.OracleScriptID)) + } + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + if m.AskCount != 0 { + n += 1 + sovPacket(uint64(m.AskCount)) + } + if m.MinCount != 0 { + n += 1 + sovPacket(uint64(m.MinCount)) + } + if len(m.FeeLimit) > 0 { + for _, e := range m.FeeLimit { + l = e.Size() + n += 1 + l + sovPacket(uint64(l)) + } + } + if m.PrepareGas != 0 { + n += 1 + sovPacket(uint64(m.PrepareGas)) + } + if m.ExecuteGas != 0 { + n += 1 + sovPacket(uint64(m.ExecuteGas)) } return n } -func (m *OraclePacketData_NoData) Size() (n int) { +func (m *OracleResponsePacketData) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.NoData != nil { - l = m.NoData.Size() + l = len(m.ClientID) + if l > 0 { n += 1 + l + sovPacket(uint64(l)) } - return n -} -func (m *NoData) Size() (n int) { - if m == nil { - return 0 + if m.RequestID != 0 { + n += 1 + sovPacket(uint64(m.RequestID)) + } + if m.AnsCount != 0 { + n += 1 + sovPacket(uint64(m.AnsCount)) + } + if m.RequestTime != 0 { + n += 1 + sovPacket(uint64(m.RequestTime)) + } + if m.ResolveTime != 0 { + n += 1 + sovPacket(uint64(m.ResolveTime)) + } + if m.ResolveStatus != 0 { + n += 1 + sovPacket(uint64(m.ResolveStatus)) + } + l = len(m.Result) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) } - var l int - _ = l return n } @@ -280,7 +658,7 @@ func sovPacket(x uint64) (n int) { func sozPacket(x uint64) (n int) { return sovPacket(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *OraclePacketData) Unmarshal(dAtA []byte) error { +func (m *OracleRequestPacketData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -303,15 +681,138 @@ func (m *OraclePacketData) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OraclePacketData: wiretype end group for non-group") + return fmt.Errorf("proto: OracleRequestPacketData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OraclePacketData: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OracleRequestPacketData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NoData", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScriptID", wireType) + } + m.OracleScriptID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleScriptID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Calldata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Calldata = append(m.Calldata[:0], dAtA[iNdEx:postIndex]...) + if m.Calldata == nil { + m.Calldata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AskCount", wireType) + } + m.AskCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AskCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCount", wireType) + } + m.MinCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeLimit", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -338,12 +839,49 @@ func (m *OraclePacketData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &NoData{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.FeeLimit = append(m.FeeLimit, types.Coin{}) + if err := m.FeeLimit[len(m.FeeLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Packet = &OraclePacketData_NoData{v} iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrepareGas", wireType) + } + m.PrepareGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrepareGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecuteGas", wireType) + } + m.ExecuteGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecuteGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipPacket(dAtA[iNdEx:]) @@ -365,7 +903,7 @@ func (m *OraclePacketData) Unmarshal(dAtA []byte) error { } return nil } -func (m *NoData) Unmarshal(dAtA []byte) error { +func (m *OracleResponsePacketData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -388,12 +926,173 @@ func (m *NoData) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: NoData: wiretype end group for non-group") + return fmt.Errorf("proto: OracleResponsePacketData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: NoData: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OracleResponsePacketData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AnsCount", wireType) + } + m.AnsCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AnsCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) + } + m.RequestTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveTime", wireType) + } + m.ResolveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveStatus", wireType) + } + m.ResolveStatus = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveStatus |= ResolveStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = append(m.Result[:0], dAtA[iNdEx:postIndex]...) + if m.Result == nil { + m.Result = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPacket(dAtA[iNdEx:]) diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index 4f3215e3..c361c559 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -1,11 +1,31 @@ package types import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ paramtypes.ParamSet = (*Params)(nil) +var ( + // Each value below is the default value for each parameter when generating the default + // genesis file. + DefaultBandRequestInterval = int64(1) // every 1 block + DefaultBandSourceChannel = "channel-0" + DefaultBandVersion = "bandchain-1" + DefaultBandPortID = "oracle" + + // DefaultBandOracleRequestParams + // TODO: Check these params + DefaultAskCount = uint64(16) + DefaultMinCount = uint64(10) + DefaultFeeLimit = sdk.Coins{sdk.NewCoin("uband", sdkmath.NewInt(100))} + DefaultPrepareGas = uint64(20000) + DefaultExecuteGas = uint64(100000) + DefaultMinSourceCount = uint64(3) +) + // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -26,7 +46,42 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{} } +// DefaultBandParams returns the default BandParams +func DefaultBandParams() BandParams { + return BandParams{ + IbcRequestInterval: DefaultBandRequestInterval, + IbcSourceChannel: DefaultBandSourceChannel, + IbcVersion: DefaultBandVersion, + IbcPortId: DefaultBandPortID, + } +} + +// DefaultBandOracelRequestParams return the default BandOracelRequestParams +func DefaultBandOracelRequestParams() BandOracleRequestParams { + return BandOracleRequestParams{ + AskCount: DefaultAskCount, + MinCount: DefaultMinCount, + FeeLimit: DefaultFeeLimit, + PrepareGas: DefaultPrepareGas, + ExecuteGas: DefaultExecuteGas, + MinSourceCount: DefaultMinSourceCount, + } +} + // Validate validates the set of params func (p Params) Validate() error { return nil } + +func DefaultTestBandIbcParams() *BandParams { + return &BandParams{ + // block request interval to send Band IBC prices + IbcRequestInterval: 10, + // band IBC source channel + IbcSourceChannel: "channel-0", + // band IBC version + IbcVersion: "bandchain-1", + // band IBC portID + IbcPortId: "oracle", + } +} diff --git a/x/oracle/types/proposal.go b/x/oracle/types/proposal.go new file mode 100644 index 00000000..a78f0cc0 --- /dev/null +++ b/x/oracle/types/proposal.go @@ -0,0 +1,146 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/onomyprotocol/reserve/x/oracle/utils" +) + +// constants +const ( + ProposalUpdateBandParams string = "ProposalUpdateBandParams" + ProposalUpdateBandOracleRequest string = "ProposalUpdateBandOracleRequest" + ProposalDeleteBandOracleRequest string = "ProposalDeleteBandOracleRequest" +) + +func init() { + govtypes.RegisterProposalType(ProposalUpdateBandParams) + govtypes.RegisterProposalType(ProposalUpdateBandOracleRequest) + govtypes.RegisterProposalType(ProposalDeleteBandOracleRequest) +} + +// Implements Proposal Interface +var _ govtypes.Content = &UpdateBandParamsProposal{} +var _ govtypes.Content = &UpdateBandOracleRequestProposal{} +var _ govtypes.Content = &DeleteBandOracleRequestProposal{} + +// GetTitle returns the title of this proposal. +func (p *UpdateBandParamsProposal) GetTitle() string { + return p.Title +} + +// GetDescription returns the description of this proposal. +func (p *UpdateBandParamsProposal) GetDescription() string { + return p.Description +} + +// ProposalRoute returns router key of this proposal. +func (p *UpdateBandParamsProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns proposal type of this proposal. +func (p *UpdateBandParamsProposal) ProposalType() string { + return ProposalUpdateBandParams +} + +// ValidateBasic returns ValidateBasic result of this proposal. +func (p *UpdateBandParamsProposal) ValidateBasic() error { + + if p.BandParams.IbcRequestInterval == 0 { + return ErrBadRequestInterval + } + + if p.BandParams.IbcSourceChannel == "" { + return errorsmod.Wrap(ErrInvalidSourceChannel, "UpdateBandParamsProposal: IBC Source Channel must not be empty.") + } + if p.BandParams.IbcVersion == "" { + return errorsmod.Wrap(ErrInvalidVersion, "UpdateBandParamsProposal: IBC Version must not be empty.") + } + + return govtypes.ValidateAbstract(p) +} + +// GetTitle returns the title of this proposal. +func (p *UpdateBandOracleRequestProposal) GetTitle() string { + return p.Title +} + +// GetDescription returns the description of this proposal. +func (p *UpdateBandOracleRequestProposal) GetDescription() string { + return p.Description +} + +// ProposalRoute returns router key of this proposal. +func (p *UpdateBandOracleRequestProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns proposal type of this proposal. +func (p *UpdateBandOracleRequestProposal) ProposalType() string { + return ProposalUpdateBandOracleRequest +} + +// ValidateBasic returns ValidateBasic result of this proposal. +func (p *UpdateBandOracleRequestProposal) ValidateBasic() error { + if p.UpdateOracleRequest == nil { + return ErrInvalidBandUpdateRequest + } + + if p.UpdateOracleRequest != nil && len(p.UpdateOracleRequest.Symbols) > 0 { + callData, err := utils.Encode(SymbolInput{ + Symbols: p.UpdateOracleRequest.Symbols, + MinimumSourceCount: uint8(p.UpdateOracleRequest.MinCount), + }) + + if err != nil { + return err + } + + if len(callData) > MaxDataSize { + return errorsmod.Wrapf(ErrTooLargeCalldata, "got: %d, maximum: %d", len(callData), MaxDataSize) + } + } + + if p.UpdateOracleRequest != nil && p.UpdateOracleRequest.AskCount > 0 && p.UpdateOracleRequest.MinCount > 0 && p.UpdateOracleRequest.AskCount < p.UpdateOracleRequest.MinCount { + return errorsmod.Wrapf(ErrInvalidAskCount, "UpdateBandOracleRequestProposal: Request validator count (%d) must not be less than sufficient validator count (%d).", p.UpdateOracleRequest.AskCount, p.UpdateOracleRequest.MinCount) + } + + if p.UpdateOracleRequest != nil && p.UpdateOracleRequest.FeeLimit != nil && !p.UpdateOracleRequest.FeeLimit.IsValid() { + return errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "UpdateBandOracleRequestProposal: Invalid Fee Limit (%s)", p.UpdateOracleRequest.GetFeeLimit().String()) + } + + if p.UpdateOracleRequest != nil && p.UpdateOracleRequest.PrepareGas <= 0 && p.UpdateOracleRequest.ExecuteGas > 0 { + return errorsmod.Wrapf(ErrInvalidOwasmGas, "UpdateBandOracleRequestProposal: Invalid Prepare Gas (%d)", p.UpdateOracleRequest.PrepareGas) + } + + if p.UpdateOracleRequest != nil && p.UpdateOracleRequest.ExecuteGas <= 0 { + return errorsmod.Wrapf(ErrInvalidOwasmGas, "UpdateBandOracleRequestProposal: Invalid Execute Gas (%d)", p.UpdateOracleRequest.ExecuteGas) + } + + return govtypes.ValidateAbstract(p) +} + +// GetTitle returns the title of this proposal. +func (p *DeleteBandOracleRequestProposal) GetTitle() string { + return p.Title +} + +// GetDescription returns the description of this proposal. +func (p *DeleteBandOracleRequestProposal) GetDescription() string { + return p.Description +} + +// ProposalRoute returns router key of this proposal. +func (p *DeleteBandOracleRequestProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns proposal type of this proposal. +func (p *DeleteBandOracleRequestProposal) ProposalType() string { + return ProposalDeleteBandOracleRequest +} + +// ValidateBasic returns ValidateBasic result of this proposal. +func (p *DeleteBandOracleRequestProposal) ValidateBasic() error { + if len(p.DeleteRequestIds) == 0 { + return ErrInvalidBandDeleteRequest + } + + return govtypes.ValidateAbstract(p) +} diff --git a/x/oracle/types/proposal.pb.go b/x/oracle/types/proposal.pb.go new file mode 100644 index 00000000..54128fb4 --- /dev/null +++ b/x/oracle/types/proposal.pb.go @@ -0,0 +1,986 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: reserve/oracle/proposal.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +type UpdateBandParamsProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + BandParams BandParams `protobuf:"bytes,3,opt,name=band_params,json=bandParams,proto3" json:"band_params"` +} + +func (m *UpdateBandParamsProposal) Reset() { *m = UpdateBandParamsProposal{} } +func (m *UpdateBandParamsProposal) String() string { return proto.CompactTextString(m) } +func (*UpdateBandParamsProposal) ProtoMessage() {} +func (*UpdateBandParamsProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_b7efcb1ff26f229a, []int{0} +} +func (m *UpdateBandParamsProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateBandParamsProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateBandParamsProposal.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 *UpdateBandParamsProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateBandParamsProposal.Merge(m, src) +} +func (m *UpdateBandParamsProposal) XXX_Size() int { + return m.Size() +} +func (m *UpdateBandParamsProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateBandParamsProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateBandParamsProposal proto.InternalMessageInfo + +type UpdateBandOracleRequestProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + UpdateOracleRequest *BandOracleRequest `protobuf:"bytes,4,opt,name=update_oracle_request,json=updateOracleRequest,proto3" json:"update_oracle_request,omitempty"` +} + +func (m *UpdateBandOracleRequestProposal) Reset() { *m = UpdateBandOracleRequestProposal{} } +func (m *UpdateBandOracleRequestProposal) String() string { return proto.CompactTextString(m) } +func (*UpdateBandOracleRequestProposal) ProtoMessage() {} +func (*UpdateBandOracleRequestProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_b7efcb1ff26f229a, []int{1} +} +func (m *UpdateBandOracleRequestProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateBandOracleRequestProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateBandOracleRequestProposal.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 *UpdateBandOracleRequestProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateBandOracleRequestProposal.Merge(m, src) +} +func (m *UpdateBandOracleRequestProposal) XXX_Size() int { + return m.Size() +} +func (m *UpdateBandOracleRequestProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateBandOracleRequestProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateBandOracleRequestProposal proto.InternalMessageInfo + +type DeleteBandOracleRequestProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + DeleteRequestIds []uint64 `protobuf:"varint,3,rep,packed,name=delete_request_ids,json=deleteRequestIds,proto3" json:"delete_request_ids,omitempty"` +} + +func (m *DeleteBandOracleRequestProposal) Reset() { *m = DeleteBandOracleRequestProposal{} } +func (m *DeleteBandOracleRequestProposal) String() string { return proto.CompactTextString(m) } +func (*DeleteBandOracleRequestProposal) ProtoMessage() {} +func (*DeleteBandOracleRequestProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_b7efcb1ff26f229a, []int{2} +} +func (m *DeleteBandOracleRequestProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteBandOracleRequestProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteBandOracleRequestProposal.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 *DeleteBandOracleRequestProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteBandOracleRequestProposal.Merge(m, src) +} +func (m *DeleteBandOracleRequestProposal) XXX_Size() int { + return m.Size() +} +func (m *DeleteBandOracleRequestProposal) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteBandOracleRequestProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteBandOracleRequestProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*UpdateBandParamsProposal)(nil), "reserve.oracle.UpdateBandParamsProposal") + proto.RegisterType((*UpdateBandOracleRequestProposal)(nil), "reserve.oracle.UpdateBandOracleRequestProposal") + proto.RegisterType((*DeleteBandOracleRequestProposal)(nil), "reserve.oracle.DeleteBandOracleRequestProposal") +} + +func init() { proto.RegisterFile("reserve/oracle/proposal.proto", fileDescriptor_b7efcb1ff26f229a) } + +var fileDescriptor_b7efcb1ff26f229a = []byte{ + // 425 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0xc1, 0xaa, 0xd3, 0x40, + 0x14, 0x86, 0x33, 0xf7, 0x56, 0xc1, 0x29, 0x88, 0xc6, 0x2b, 0xc4, 0xa0, 0x49, 0xed, 0x42, 0x8a, + 0x68, 0xc2, 0xd5, 0xdd, 0xdd, 0x59, 0xdd, 0xd4, 0x8d, 0x35, 0xd0, 0x8d, 0x9b, 0x30, 0x49, 0x0e, + 0x31, 0x90, 0xcc, 0x89, 0x33, 0xd3, 0x62, 0xd7, 0x6e, 0xc4, 0x95, 0x8f, 0xd0, 0x47, 0x70, 0xe1, + 0x43, 0x14, 0x57, 0x5d, 0x8a, 0x0b, 0xd1, 0x76, 0xa1, 0x8f, 0x21, 0x9d, 0x49, 0xad, 0xd5, 0x0a, + 0x82, 0x74, 0x13, 0x66, 0xfe, 0xff, 0xe4, 0xcc, 0xff, 0x4d, 0x72, 0xe8, 0x0d, 0x01, 0x12, 0xc4, + 0x04, 0x42, 0x14, 0x2c, 0x2d, 0x21, 0xac, 0x05, 0xd6, 0x28, 0x59, 0x19, 0xd4, 0x02, 0x15, 0xda, + 0x17, 0x1b, 0x3b, 0x30, 0xb6, 0x7b, 0xfd, 0xb7, 0xf2, 0x1c, 0x38, 0xc8, 0x42, 0x9a, 0x6a, 0xf7, + 0x32, 0xab, 0x0a, 0x8e, 0xa1, 0x7e, 0x36, 0xd2, 0x49, 0x8e, 0x39, 0xea, 0x65, 0xb8, 0x5e, 0x35, + 0xea, 0xb5, 0x14, 0x65, 0x85, 0x32, 0x36, 0x86, 0xd9, 0x18, 0xab, 0xfb, 0x95, 0x50, 0x67, 0x54, + 0x67, 0x4c, 0x41, 0x9f, 0xf1, 0x6c, 0xc8, 0x04, 0xab, 0xe4, 0xb0, 0x09, 0x65, 0x9f, 0xd0, 0x73, + 0xaa, 0x50, 0x25, 0x38, 0xa4, 0x43, 0x7a, 0x17, 0x22, 0xb3, 0xb1, 0x3b, 0xb4, 0x9d, 0x81, 0x4c, + 0x45, 0x51, 0xab, 0x02, 0xb9, 0x73, 0xa4, 0xbd, 0x5f, 0x25, 0xfb, 0x01, 0x6d, 0x27, 0x8c, 0x67, + 0x71, 0xad, 0xdb, 0x39, 0xc7, 0x1d, 0xd2, 0x6b, 0xdf, 0x73, 0x83, 0x5d, 0xb8, 0x60, 0x7b, 0x60, + 0xbf, 0x35, 0xff, 0xec, 0x5b, 0x11, 0x4d, 0x7e, 0x2a, 0x67, 0x8f, 0x5f, 0xcf, 0x7c, 0xeb, 0xfb, + 0xcc, 0xb7, 0x3e, 0xbc, 0xbf, 0xeb, 0x36, 0x89, 0x73, 0x9c, 0x04, 0x93, 0xd3, 0x04, 0x14, 0x3b, + 0x0d, 0x1e, 0x22, 0x57, 0xc0, 0xd5, 0x9b, 0x6f, 0xef, 0x6e, 0xfb, 0xcd, 0xe5, 0xfc, 0x0d, 0xa3, + 0xfb, 0xea, 0x88, 0xfa, 0x5b, 0xf3, 0x89, 0xae, 0x8e, 0xe0, 0xc5, 0x18, 0xa4, 0xfa, 0x6f, 0xd4, + 0x11, 0xbd, 0x3a, 0xd6, 0xad, 0x63, 0x93, 0x22, 0x16, 0xa6, 0xb1, 0xd3, 0xd2, 0xd0, 0x37, 0xf7, + 0x41, 0xef, 0x24, 0x88, 0xae, 0x98, 0xf7, 0x77, 0xc4, 0xb3, 0xa7, 0xff, 0x8e, 0x7f, 0xeb, 0x0f, + 0xfc, 0xbd, 0x84, 0xdd, 0x4f, 0x84, 0xfa, 0x8f, 0xa0, 0x84, 0x43, 0xdc, 0xc2, 0x1d, 0x6a, 0x67, + 0xba, 0xf5, 0x06, 0x3f, 0x2e, 0xb2, 0xf5, 0x77, 0x3f, 0xee, 0xb5, 0xa2, 0x4b, 0xc6, 0x69, 0x8e, + 0x1a, 0x64, 0xf2, 0x00, 0x70, 0xfd, 0xc1, 0x7c, 0xe9, 0x91, 0xc5, 0xd2, 0x23, 0x5f, 0x96, 0x1e, + 0x79, 0xbb, 0xf2, 0xac, 0xc5, 0xca, 0xb3, 0x3e, 0xae, 0x3c, 0xeb, 0x59, 0x98, 0x17, 0xea, 0xf9, + 0x38, 0x09, 0x52, 0xac, 0x42, 0xe4, 0x58, 0x4d, 0xf5, 0x7f, 0x9f, 0x62, 0x19, 0x6e, 0x66, 0xeb, + 0xe5, 0x66, 0xba, 0xd4, 0xb4, 0x06, 0x99, 0x9c, 0xd7, 0x05, 0xf7, 0x7f, 0x04, 0x00, 0x00, 0xff, + 0xff, 0xaa, 0x3e, 0xe9, 0x4e, 0xab, 0x03, 0x00, 0x00, +} + +func (m *UpdateBandParamsProposal) 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 *UpdateBandParamsProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateBandParamsProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.BandParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UpdateBandOracleRequestProposal) 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 *UpdateBandOracleRequestProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateBandOracleRequestProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.UpdateOracleRequest != nil { + { + size, err := m.UpdateOracleRequest.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeleteBandOracleRequestProposal) 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 *DeleteBandOracleRequestProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteBandOracleRequestProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DeleteRequestIds) > 0 { + dAtA4 := make([]byte, len(m.DeleteRequestIds)*10) + var j3 int + for _, num := range m.DeleteRequestIds { + for num >= 1<<7 { + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA4[j3] = uint8(num) + j3++ + } + i -= j3 + copy(dAtA[i:], dAtA4[:j3]) + i = encodeVarintProposal(dAtA, i, uint64(j3)) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintProposal(dAtA []byte, offset int, v uint64) int { + offset -= sovProposal(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *UpdateBandParamsProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = m.BandParams.Size() + n += 1 + l + sovProposal(uint64(l)) + return n +} + +func (m *UpdateBandOracleRequestProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if m.UpdateOracleRequest != nil { + l = m.UpdateOracleRequest.Size() + n += 1 + l + sovProposal(uint64(l)) + } + return n +} + +func (m *DeleteBandOracleRequestProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if len(m.DeleteRequestIds) > 0 { + l = 0 + for _, e := range m.DeleteRequestIds { + l += sovProposal(uint64(e)) + } + n += 1 + sovProposal(uint64(l)) + l + } + return n +} + +func sovProposal(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProposal(x uint64) (n int) { + return sovProposal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *UpdateBandParamsProposal) 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 ErrIntOverflowProposal + } + 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: UpdateBandParamsProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateBandParamsProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BandParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BandParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UpdateBandOracleRequestProposal) 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 ErrIntOverflowProposal + } + 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: UpdateBandOracleRequestProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateBandOracleRequestProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateOracleRequest", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateOracleRequest == nil { + m.UpdateOracleRequest = &BandOracleRequest{} + } + if err := m.UpdateOracleRequest.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteBandOracleRequestProposal) 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 ErrIntOverflowProposal + } + 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: DeleteBandOracleRequestProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteBandOracleRequestProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.DeleteRequestIds = append(m.DeleteRequestIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.DeleteRequestIds) == 0 { + m.DeleteRequestIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.DeleteRequestIds = append(m.DeleteRequestIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field DeleteRequestIds", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipProposal(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, ErrIntOverflowProposal + } + 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, ErrIntOverflowProposal + } + 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, ErrIntOverflowProposal + } + 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, ErrInvalidLengthProposal + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupProposal + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthProposal + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthProposal = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowProposal = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupProposal = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 84d82a44..66944a81 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -113,33 +113,126 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryBandPriceStatesRequest is the request type for the +// Query/BandPriceStates RPC method. +type QueryBandPriceStatesRequest struct { +} + +func (m *QueryBandPriceStatesRequest) Reset() { *m = QueryBandPriceStatesRequest{} } +func (m *QueryBandPriceStatesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBandPriceStatesRequest) ProtoMessage() {} +func (*QueryBandPriceStatesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5be66edb02a359da, []int{2} +} +func (m *QueryBandPriceStatesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBandPriceStatesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBandPriceStatesRequest.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 *QueryBandPriceStatesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBandPriceStatesRequest.Merge(m, src) +} +func (m *QueryBandPriceStatesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBandPriceStatesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBandPriceStatesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBandPriceStatesRequest proto.InternalMessageInfo + +// QueryBandPriceStatesResponse is the response type for the +// Query/BandPriceStates RPC method. +type QueryBandPriceStatesResponse struct { + PriceStates []*BandPriceState `protobuf:"bytes,1,rep,name=price_states,json=priceStates,proto3" json:"price_states,omitempty"` +} + +func (m *QueryBandPriceStatesResponse) Reset() { *m = QueryBandPriceStatesResponse{} } +func (m *QueryBandPriceStatesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBandPriceStatesResponse) ProtoMessage() {} +func (*QueryBandPriceStatesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5be66edb02a359da, []int{3} +} +func (m *QueryBandPriceStatesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBandPriceStatesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBandPriceStatesResponse.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 *QueryBandPriceStatesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBandPriceStatesResponse.Merge(m, src) +} +func (m *QueryBandPriceStatesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBandPriceStatesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBandPriceStatesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBandPriceStatesResponse proto.InternalMessageInfo + +func (m *QueryBandPriceStatesResponse) GetPriceStates() []*BandPriceState { + if m != nil { + return m.PriceStates + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "reserve.oracle.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "reserve.oracle.QueryParamsResponse") + proto.RegisterType((*QueryBandPriceStatesRequest)(nil), "reserve.oracle.QueryBandPriceStatesRequest") + proto.RegisterType((*QueryBandPriceStatesResponse)(nil), "reserve.oracle.QueryBandPriceStatesResponse") } func init() { proto.RegisterFile("reserve/oracle/query.proto", fileDescriptor_5be66edb02a359da) } var fileDescriptor_5be66edb02a359da = []byte{ - // 287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x4a, 0x2d, 0x4e, - 0x2d, 0x2a, 0x4b, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, - 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xca, 0xe9, 0x41, 0xe4, 0xa4, 0x04, 0x13, - 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x89, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, - 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x65, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, - 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0xa1, 0xb2, 0xd2, 0x68, - 0x56, 0x16, 0x24, 0x16, 0x25, 0xe6, 0x42, 0x25, 0x95, 0x44, 0xb8, 0x84, 0x02, 0x41, 0x4e, 0x08, - 0x00, 0x0b, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0x05, 0x70, 0x09, 0xa3, 0x88, 0x16, - 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x59, 0x72, 0xb1, 0x41, 0x34, 0x4b, 0x30, 0x2a, 0x30, 0x6a, - 0x70, 0x1b, 0x89, 0xe9, 0xa1, 0xba, 0x58, 0x0f, 0xa2, 0xde, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, - 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, 0x41, 0x35, 0x18, 0x55, 0x71, 0xb1, 0x82, 0x4d, 0x14, 0x2a, - 0xe4, 0x62, 0x83, 0xa8, 0x12, 0x52, 0x42, 0xd7, 0x8d, 0xe9, 0x10, 0x29, 0x65, 0xbc, 0x6a, 0x20, - 0xce, 0x52, 0x92, 0x6b, 0xba, 0xfc, 0x64, 0x32, 0x93, 0x84, 0x90, 0x98, 0x3e, 0x56, 0x9f, 0x3a, - 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, - 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, - 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7e, 0x5e, 0x7e, 0x6e, 0x25, 0x38, 0x50, 0x92, - 0xf3, 0x73, 0xe0, 0x26, 0x55, 0xc0, 0xcc, 0x2a, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x2b, - 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xd8, 0xeb, 0xe9, 0x0e, 0xc7, 0x01, 0x00, 0x00, + // 388 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4f, 0x4b, 0xc3, 0x30, + 0x1c, 0x6d, 0x26, 0x0e, 0xcc, 0x44, 0x31, 0x8e, 0x31, 0xba, 0x19, 0x67, 0x77, 0x99, 0x7f, 0x68, + 0x60, 0x9e, 0x3c, 0xba, 0x9b, 0xb7, 0x39, 0x6f, 0x5e, 0x46, 0xd6, 0x85, 0x5a, 0x58, 0x93, 0xae, + 0xc9, 0xc4, 0x5d, 0xfd, 0x04, 0x82, 0x82, 0x5f, 0xc1, 0xa3, 0x1f, 0x63, 0xc7, 0x81, 0x17, 0x4f, + 0x22, 0x9b, 0xe0, 0xd7, 0x90, 0xa5, 0xdd, 0x74, 0xb5, 0x88, 0x97, 0x12, 0xde, 0x7b, 0xbf, 0xf7, + 0x5e, 0x7e, 0x0d, 0x34, 0x43, 0x26, 0x59, 0x78, 0xcd, 0x88, 0x08, 0xa9, 0xd3, 0x63, 0xa4, 0x3f, + 0x60, 0xe1, 0xd0, 0x0e, 0x42, 0xa1, 0x04, 0xda, 0x88, 0x39, 0x3b, 0xe2, 0xcc, 0x2d, 0xea, 0x7b, + 0x5c, 0x10, 0xfd, 0x8d, 0x24, 0x66, 0xde, 0x15, 0xae, 0xd0, 0x47, 0x32, 0x3b, 0xc5, 0x68, 0xd9, + 0x15, 0xc2, 0xed, 0x31, 0x42, 0x03, 0x8f, 0x50, 0xce, 0x85, 0xa2, 0xca, 0x13, 0x5c, 0xc6, 0x6c, + 0x29, 0x11, 0x19, 0xd0, 0x90, 0xfa, 0x73, 0xb2, 0x9c, 0x20, 0x5d, 0xc6, 0x99, 0xf4, 0x62, 0xd6, + 0xca, 0x43, 0x74, 0x3e, 0x2b, 0xd8, 0xd4, 0x23, 0x2d, 0xd6, 0x1f, 0x30, 0xa9, 0xac, 0x26, 0xdc, + 0x5e, 0x42, 0x65, 0x20, 0xb8, 0x64, 0xe8, 0x04, 0x66, 0x23, 0xeb, 0x22, 0xa8, 0x80, 0x5a, 0xae, + 0x5e, 0xb0, 0x97, 0xef, 0x63, 0x47, 0xfa, 0xc6, 0xda, 0xe8, 0x6d, 0xd7, 0x78, 0xfa, 0x7c, 0x3e, + 0x00, 0xad, 0x78, 0xc0, 0xda, 0x81, 0x25, 0xed, 0xd8, 0xa0, 0xbc, 0xdb, 0x0c, 0x3d, 0x87, 0x5d, + 0x28, 0xaa, 0xd8, 0x22, 0x90, 0xc2, 0x72, 0x3a, 0x1d, 0x27, 0x9f, 0xc2, 0xf5, 0x60, 0x06, 0xb7, + 0xa5, 0xc6, 0x8b, 0xa0, 0xb2, 0x52, 0xcb, 0xd5, 0x71, 0x32, 0x7f, 0x79, 0xbc, 0x95, 0x0b, 0xbe, + 0xad, 0xea, 0x0f, 0x19, 0xb8, 0xaa, 0x33, 0x50, 0x1f, 0x66, 0xa3, 0xa2, 0xc8, 0x4a, 0x1a, 0xfc, + 0xde, 0x85, 0x59, 0xfd, 0x53, 0x13, 0xf5, 0xb3, 0xf0, 0xed, 0xcb, 0xc7, 0x7d, 0xa6, 0x88, 0x0a, + 0x24, 0xf5, 0x57, 0xa0, 0x47, 0x00, 0x37, 0x13, 0x77, 0x43, 0x87, 0xa9, 0xc6, 0xe9, 0x0b, 0x32, + 0x8f, 0xfe, 0x27, 0x8e, 0xeb, 0xec, 0xeb, 0x3a, 0x55, 0xb4, 0x97, 0xac, 0xd3, 0xa1, 0xbc, 0xdb, + 0xfe, 0xb9, 0xc9, 0xc6, 0xd9, 0x68, 0x82, 0xc1, 0x78, 0x82, 0xc1, 0xfb, 0x04, 0x83, 0xbb, 0x29, + 0x36, 0xc6, 0x53, 0x6c, 0xbc, 0x4e, 0xb1, 0x71, 0x49, 0x5c, 0x4f, 0x5d, 0x0d, 0x3a, 0xb6, 0x23, + 0x7c, 0x22, 0xb8, 0xf0, 0x87, 0xfa, 0xc5, 0x38, 0xa2, 0xb7, 0x30, 0xbd, 0x99, 0xdb, 0xaa, 0x61, + 0xc0, 0x64, 0x27, 0xab, 0x05, 0xc7, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x59, 0xb3, 0x47, 0x63, + 0x02, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -156,6 +249,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Retrieves the state for all band price feeds + BandPriceStates(ctx context.Context, in *QueryBandPriceStatesRequest, opts ...grpc.CallOption) (*QueryBandPriceStatesResponse, error) } type queryClient struct { @@ -175,10 +270,21 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) BandPriceStates(ctx context.Context, in *QueryBandPriceStatesRequest, opts ...grpc.CallOption) (*QueryBandPriceStatesResponse, error) { + out := new(QueryBandPriceStatesResponse) + err := c.cc.Invoke(ctx, "/reserve.oracle.Query/BandPriceStates", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Retrieves the state for all band price feeds + BandPriceStates(context.Context, *QueryBandPriceStatesRequest) (*QueryBandPriceStatesResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -188,6 +294,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) BandPriceStates(ctx context.Context, req *QueryBandPriceStatesRequest) (*QueryBandPriceStatesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BandPriceStates not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -211,6 +320,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_BandPriceStates_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBandPriceStatesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).BandPriceStates(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/reserve.oracle.Query/BandPriceStates", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BandPriceStates(ctx, req.(*QueryBandPriceStatesRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "reserve.oracle.Query", HandlerType: (*QueryServer)(nil), @@ -219,6 +346,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "BandPriceStates", + Handler: _Query_BandPriceStates_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "reserve/oracle/query.proto", @@ -280,6 +411,66 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryBandPriceStatesRequest) 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 *QueryBandPriceStatesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBandPriceStatesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryBandPriceStatesResponse) 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 *QueryBandPriceStatesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBandPriceStatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PriceStates) > 0 { + for iNdEx := len(m.PriceStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PriceStates[iNdEx].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 encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -311,6 +502,30 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryBandPriceStatesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryBandPriceStatesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PriceStates) > 0 { + for _, e := range m.PriceStates { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -450,6 +665,140 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryBandPriceStatesRequest) 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: QueryBandPriceStatesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBandPriceStatesRequest: 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 *QueryBandPriceStatesResponse) 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: QueryBandPriceStatesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBandPriceStatesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceStates", 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 + } + m.PriceStates = append(m.PriceStates, &BandPriceState{}) + if err := m.PriceStates[len(m.PriceStates)-1].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 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 94c4c60d..37ff374f 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -51,6 +51,24 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_BandPriceStates_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBandPriceStatesRequest + var metadata runtime.ServerMetadata + + msg, err := client.BandPriceStates(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_BandPriceStates_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBandPriceStatesRequest + var metadata runtime.ServerMetadata + + msg, err := server.BandPriceStates(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. @@ -80,6 +98,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_BandPriceStates_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + 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_BandPriceStates_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BandPriceStates_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +182,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_BandPriceStates_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_BandPriceStates_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_BandPriceStates_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"reserve", "oracle", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_BandPriceStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"reserve", "oracle", "band_price_states"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_BandPriceStates_0 = runtime.ForwardResponseMessage ) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 7032854b..4a37be1c 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -127,15 +127,94 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgRequestBandRates defines a SDK message for requesting data from +// BandChain using IBC. +type MsgRequestBandRates struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + RequestId uint64 `protobuf:"varint,2,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (m *MsgRequestBandRates) Reset() { *m = MsgRequestBandRates{} } +func (m *MsgRequestBandRates) String() string { return proto.CompactTextString(m) } +func (*MsgRequestBandRates) ProtoMessage() {} +func (*MsgRequestBandRates) Descriptor() ([]byte, []int) { + return fileDescriptor_2ca24ac8eaee815d, []int{2} +} +func (m *MsgRequestBandRates) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestBandRates) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestBandRates.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 *MsgRequestBandRates) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestBandRates.Merge(m, src) +} +func (m *MsgRequestBandRates) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestBandRates) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestBandRates.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestBandRates proto.InternalMessageInfo + +// MsgRequestBandRatesResponse defines the Msg/RequestBandRates response type. +type MsgRequestBandRatesResponse struct { +} + +func (m *MsgRequestBandRatesResponse) Reset() { *m = MsgRequestBandRatesResponse{} } +func (m *MsgRequestBandRatesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRequestBandRatesResponse) ProtoMessage() {} +func (*MsgRequestBandRatesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2ca24ac8eaee815d, []int{3} +} +func (m *MsgRequestBandRatesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestBandRatesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestBandRatesResponse.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 *MsgRequestBandRatesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestBandRatesResponse.Merge(m, src) +} +func (m *MsgRequestBandRatesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestBandRatesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestBandRatesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestBandRatesResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "reserve.oracle.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "reserve.oracle.MsgUpdateParamsResponse") + proto.RegisterType((*MsgRequestBandRates)(nil), "reserve.oracle.MsgRequestBandRates") + proto.RegisterType((*MsgRequestBandRatesResponse)(nil), "reserve.oracle.MsgRequestBandRatesResponse") } func init() { proto.RegisterFile("reserve/oracle/tx.proto", fileDescriptor_2ca24ac8eaee815d) } var fileDescriptor_2ca24ac8eaee815d = []byte{ - // 343 bytes of a gzipped FileDescriptorProto + // 452 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2f, 0x4a, 0x2d, 0x4e, 0x2d, 0x2a, 0x4b, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x4a, 0xe8, 0x41, 0x24, 0xa4, 0x04, 0x13, 0x73, 0x33, 0xf3, @@ -150,14 +229,21 @@ var fileDescriptor_2ca24ac8eaee815d = []byte{ 0x23, 0x31, 0x3d, 0x54, 0x6f, 0xea, 0x41, 0xcc, 0x77, 0xe2, 0x3c, 0x71, 0x4f, 0x9e, 0x61, 0xc5, 0xf3, 0x0d, 0x5a, 0x8c, 0x41, 0x50, 0x0d, 0x56, 0xc6, 0x4d, 0xcf, 0x37, 0x68, 0x21, 0x8c, 0xea, 0x7a, 0xbe, 0x41, 0x4b, 0x01, 0xe6, 0xec, 0x0a, 0x98, 0xc3, 0xd1, 0xdc, 0xa9, 0x24, 0xc9, 0x25, - 0x8e, 0x26, 0x14, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x6a, 0x94, 0xc6, 0xc5, 0xec, 0x5b, - 0x9c, 0x2e, 0x14, 0xc1, 0xc5, 0x83, 0xe2, 0x33, 0x79, 0x74, 0x17, 0xa1, 0xe9, 0x97, 0x52, 0x27, - 0xa0, 0x00, 0x66, 0x81, 0x14, 0x6b, 0x03, 0xc8, 0xfd, 0x4e, 0x9e, 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, 0x10, 0xa5, 0x9f, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, - 0xab, 0x9f, 0x9f, 0x97, 0x9f, 0x5b, 0x09, 0x0e, 0xef, 0xe4, 0xfc, 0x1c, 0x7d, 0x0c, 0x7f, 0x95, - 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x15, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xdb, - 0xe4, 0x20, 0x8c, 0x35, 0x02, 0x00, 0x00, + 0x8e, 0x26, 0x14, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0xaa, 0xd4, 0xc0, 0xc8, 0x25, 0xec, + 0x5b, 0x9c, 0x1e, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0xe2, 0x94, 0x98, 0x97, 0x12, 0x94, 0x58, + 0x92, 0x5a, 0x2c, 0x24, 0xc6, 0xc5, 0x56, 0x9c, 0x9a, 0x97, 0x92, 0x5a, 0x04, 0xf1, 0x57, 0x10, + 0x94, 0x27, 0x24, 0xcb, 0xc5, 0x55, 0x04, 0x51, 0x1b, 0x9f, 0x99, 0x02, 0x76, 0x3e, 0x4b, 0x10, + 0x27, 0x54, 0xc4, 0x33, 0xc5, 0xca, 0xa8, 0x63, 0x81, 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x0c, 0x20, + 0x67, 0x42, 0xf5, 0x80, 0xdc, 0x28, 0x85, 0x70, 0x19, 0xba, 0x55, 0x4a, 0xb2, 0x5c, 0xd2, 0x58, + 0x84, 0x61, 0x2e, 0x34, 0x3a, 0xc3, 0xc8, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0x14, 0xc1, 0xc5, 0x83, + 0x12, 0xf8, 0xf2, 0xe8, 0x81, 0x86, 0xe6, 0x45, 0x29, 0x75, 0x02, 0x0a, 0x60, 0x36, 0x08, 0xa5, + 0x70, 0x09, 0x60, 0xf8, 0x5f, 0x19, 0x8b, 0x66, 0x74, 0x45, 0x52, 0xda, 0x44, 0x28, 0x82, 0xd9, + 0x22, 0xc5, 0xda, 0x00, 0x8a, 0x48, 0x27, 0xcf, 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, 0x88, 0xd2, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xcf, + 0xcb, 0xcf, 0xad, 0x04, 0x27, 0xbc, 0xe4, 0xfc, 0x1c, 0x7d, 0x8c, 0x08, 0x2e, 0xa9, 0x2c, 0x48, + 0x2d, 0x4e, 0x62, 0x03, 0x2b, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x10, 0x9a, 0x30, 0xaf, + 0x3e, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -175,6 +261,7 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + RequestBandRates(ctx context.Context, in *MsgRequestBandRates, opts ...grpc.CallOption) (*MsgRequestBandRatesResponse, error) } type msgClient struct { @@ -194,11 +281,21 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) RequestBandRates(ctx context.Context, in *MsgRequestBandRates, opts ...grpc.CallOption) (*MsgRequestBandRatesResponse, error) { + out := new(MsgRequestBandRatesResponse) + err := c.cc.Invoke(ctx, "/reserve.oracle.Msg/RequestBandRates", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + RequestBandRates(context.Context, *MsgRequestBandRates) (*MsgRequestBandRatesResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -208,6 +305,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) RequestBandRates(ctx context.Context, req *MsgRequestBandRates) (*MsgRequestBandRatesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RequestBandRates not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -231,6 +331,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_RequestBandRates_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRequestBandRates) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RequestBandRates(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/reserve.oracle.Msg/RequestBandRates", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RequestBandRates(ctx, req.(*MsgRequestBandRates)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "reserve.oracle.Msg", HandlerType: (*MsgServer)(nil), @@ -239,6 +357,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "RequestBandRates", + Handler: _Msg_RequestBandRates_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "reserve/oracle/tx.proto", @@ -307,6 +429,64 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgRequestBandRates) 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 *MsgRequestBandRates) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestBandRates) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RequestId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.RequestId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRequestBandRatesResponse) 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 *MsgRequestBandRatesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestBandRatesResponse) 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 @@ -342,6 +522,31 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgRequestBandRates) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.RequestId != 0 { + n += 1 + sovTx(uint64(m.RequestId)) + } + return n +} + +func (m *MsgRequestBandRatesResponse) 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 } @@ -513,6 +718,157 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRequestBandRates) 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: MsgRequestBandRates: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestBandRates: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) + } + m.RequestId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestId |= 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 *MsgRequestBandRatesResponse) 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: MsgRequestBandRatesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestBandRatesResponse: 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 diff --git a/x/oracle/utils/packet_utils.go b/x/oracle/utils/packet_utils.go new file mode 100644 index 00000000..6c43a771 --- /dev/null +++ b/x/oracle/utils/packet_utils.go @@ -0,0 +1,323 @@ +package utils + +import ( + "encoding/binary" + "fmt" + "reflect" + "errors" +) + +// ENCODE + +// Encode uses obi encoding scheme to encode the given input into bytes. +func encodeImpl(v interface{}) ([]byte, error) { + rv := reflect.ValueOf(v) + switch rv.Kind() { + case reflect.Uint8: + return EncodeUnsigned8(uint8(rv.Uint())), nil + case reflect.Uint16: + return EncodeUnsigned16(uint16(rv.Uint())), nil + case reflect.Uint32: + return EncodeUnsigned32(uint32(rv.Uint())), nil + case reflect.Uint64: + return EncodeUnsigned64(uint64(rv.Uint())), nil + case reflect.Int8: + return EncodeSigned8(int8(rv.Int())), nil + case reflect.Int16: + return EncodeSigned16(int16(rv.Int())), nil + case reflect.Int32: + return EncodeSigned32(int32(rv.Int())), nil + case reflect.Int64: + return EncodeSigned64(int64(rv.Int())), nil + case reflect.String: + return EncodeString(rv.String()), nil + case reflect.Slice: + if rv.Type().Elem().Kind() == reflect.Uint8 { + return EncodeBytes(rv.Bytes()), nil + } + + res := EncodeUnsigned32(uint32(rv.Len())) + for idx := 0; idx < rv.Len(); idx++ { + each, err := Encode(rv.Index(idx).Interface()) + if err != nil { + return nil, err + } + res = append(res, each...) + } + return res, nil + case reflect.Struct: + res := []byte{} + for idx := 0; idx < rv.NumField(); idx++ { + each, err := Encode(rv.Field(idx).Interface()) + if err != nil { + return nil, err + } + res = append(res, each...) + } + return res, nil + default: + return nil, fmt.Errorf("obi: unsupported value type: %s", rv.Kind()) + } +} + +// Encode uses obi encoding scheme to encode the given input(s) into bytes. +func Encode(v ...interface{}) ([]byte, error) { + res := []byte{} + for _, each := range v { + encoded, err := encodeImpl(each) + if err != nil { + return nil, err + } + res = append(res, encoded...) + } + return res, nil +} + +// MustEncode uses obi encoding scheme to encode the given input into bytes. Panics on error. +func MustEncode(v ...interface{}) []byte { + res, err := Encode(v...) + if err != nil { + panic(err) + } + return res +} + +// EncodeUnsigned8 takes an `uint8` variable and encodes it into a byte array +func EncodeUnsigned8(v uint8) []byte { + return []byte{v} +} + +// EncodeUnsigned16 takes an `uint16` variable and encodes it into a byte array +func EncodeUnsigned16(v uint16) []byte { + bytes := make([]byte, 2) + binary.BigEndian.PutUint16(bytes, v) + return bytes +} + +// EncodeUnsigned32 takes an `uint32` variable and encodes it into a byte array +func EncodeUnsigned32(v uint32) []byte { + bytes := make([]byte, 4) + binary.BigEndian.PutUint32(bytes, v) + return bytes +} + +// EncodeUnsigned64 takes an `uint64` variable and encodes it into a byte array +func EncodeUnsigned64(v uint64) []byte { + bytes := make([]byte, 8) + binary.BigEndian.PutUint64(bytes, v) + return bytes +} + +// EncodeSigned8 takes an `int8` variable and encodes it into a byte array +func EncodeSigned8(v int8) []byte { + return EncodeUnsigned8(uint8(v)) +} + +// EncodeSigned16 takes an `int16` variable and encodes it into a byte array +func EncodeSigned16(v int16) []byte { + return EncodeUnsigned16(uint16(v)) +} + +// EncodeSigned32 takes an `int32` variable and encodes it into a byte array +func EncodeSigned32(v int32) []byte { + return EncodeUnsigned32(uint32(v)) +} + +// EncodeSigned64 takes an `int64` variable and encodes it into a byte array +func EncodeSigned64(v int64) []byte { + return EncodeUnsigned64(uint64(v)) +} + +// EncodeBytes takes a `[]byte` variable and encodes it into a byte array +func EncodeBytes(v []byte) []byte { + return append(EncodeUnsigned32(uint32(len(v))), v...) +} + +// EncodeString takes a `string` variable and encodes it into a byte array +func EncodeString(v string) []byte { + return append(EncodeUnsigned32(uint32(len(v))), []byte(v)...) +} + +// DECODE + +func decodeImpl(data []byte, v interface{}) ([]byte, error) { + rv := reflect.ValueOf(v) + if rv.Kind() != reflect.Ptr || rv.IsNil() { + return nil, errors.New("obi: decode into non-ptr type") + } + ev := rv.Elem() + switch ev.Kind() { + case reflect.Uint8: + val, rem, err := DecodeUnsigned8(data) + ev.SetUint(uint64(val)) + return rem, err + case reflect.Uint16: + val, rem, err := DecodeUnsigned16(data) + ev.SetUint(uint64(val)) + return rem, err + case reflect.Uint32: + val, rem, err := DecodeUnsigned32(data) + ev.SetUint(uint64(val)) + return rem, err + case reflect.Uint64: + val, rem, err := DecodeUnsigned64(data) + ev.SetUint(uint64(val)) + return rem, err + case reflect.Int8: + val, rem, err := DecodeSigned8(data) + ev.SetInt(int64(val)) + return rem, err + case reflect.Int16: + val, rem, err := DecodeSigned16(data) + ev.SetInt(int64(val)) + return rem, err + case reflect.Int32: + val, rem, err := DecodeSigned32(data) + ev.SetInt(int64(val)) + return rem, err + case reflect.Int64: + val, rem, err := DecodeSigned64(data) + ev.SetInt(int64(val)) + return rem, err + case reflect.String: + val, rem, err := DecodeString(data) + ev.SetString(val) + return rem, err + case reflect.Slice: + if ev.Type().Elem().Kind() == reflect.Uint8 { + val, rem, err := DecodeBytes(data) + ev.SetBytes(val) + return rem, err + } + length, rem, err := DecodeUnsigned32(data) + if err != nil { + return nil, err + } + slice := reflect.MakeSlice(ev.Type(), int(length), int(length)) + for idx := 0; idx < int(length); idx++ { + var err error + rem, err = decodeImpl(rem, slice.Index(idx).Addr().Interface()) + if err != nil { + return nil, err + } + } + ev.Set(slice) + return rem, nil + case reflect.Struct: + rem := data + for idx := 0; idx < ev.NumField(); idx++ { + var err error + rem, err = decodeImpl(rem, ev.Field(idx).Addr().Interface()) + if err != nil { + return nil, err + } + } + return rem, nil + default: + return nil, fmt.Errorf("obi: unsupported value type: %s", ev.Kind()) + } +} + +// Decode uses obi encoding scheme to decode the given input(s). +func Decode(data []byte, v ...interface{}) error { + var err error + rem := data + for _, each := range v { + rem, err = decodeImpl(rem, each) + if err != nil { + return err + } + } + if len(rem) != 0 { + return errors.New("obi: not all data was consumed while decoding") + } + return nil +} + +// MustDecode uses obi encoding scheme to decode the given input. Panics on error. +func MustDecode(data []byte, v ...interface{}) { + err := Decode(data, v...) + if err != nil { + panic(err) + } +} + +// DecodeUnsigned16 decodes the input bytes into `uint8` and returns the remaining bytes. +func DecodeUnsigned8(data []byte) (uint8, []byte, error) { + if len(data) < 1 { + return 0, nil, errors.New("obi: out of range") + } + return data[0], data[1:], nil +} + +// DecodeUnsigned16 decodes the input bytes into `uint16` and returns the remaining bytes. +func DecodeUnsigned16(data []byte) (uint16, []byte, error) { + if len(data) < 2 { + return 0, nil, errors.New("obi: out of range") + } + return binary.BigEndian.Uint16(data[:2]), data[2:], nil +} + +// DecodeUnsigned32 decodes the input bytes into `uint32` and returns the remaining bytes. +func DecodeUnsigned32(data []byte) (uint32, []byte, error) { + if len(data) < 4 { + return 0, nil, errors.New("obi: out of range") + } + return binary.BigEndian.Uint32(data[:4]), data[4:], nil +} + +// DecodeUnsigned64 decodes the input bytes into `uint64` and returns the remaining bytes. +func DecodeUnsigned64(data []byte) (uint64, []byte, error) { + if len(data) < 8 { + return 0, nil, errors.New("obi: out of range") + } + return binary.BigEndian.Uint64(data[:8]), data[8:], nil +} + +// DecodeSigned8 decodes the input bytes into `uint64` and returns the remaining bytes. +func DecodeSigned8(data []byte) (int8, []byte, error) { + unsigned, rem, err := DecodeUnsigned8(data) + return int8(unsigned), rem, err +} + +// DecodeSigned16 decodes the input bytes into `uint64` and returns the remaining bytes. +func DecodeSigned16(data []byte) (int16, []byte, error) { + unsigned, rem, err := DecodeUnsigned16(data) + return int16(unsigned), rem, err +} + +// DecodeSigned32 decodes the input bytes into `uint64` and returns the remaining bytes. +func DecodeSigned32(data []byte) (int32, []byte, error) { + unsigned, rem, err := DecodeUnsigned32(data) + return int32(unsigned), rem, err +} + +// DecodeSigned64 decodes the input bytes into `uint64` and returns the remaining bytes. +func DecodeSigned64(data []byte) (int64, []byte, error) { + unsigned, rem, err := DecodeUnsigned64(data) + return int64(unsigned), rem, err +} + +// DecodeBytes decodes the input bytes and returns bytes result and the remaining bytes. +func DecodeBytes(data []byte) ([]byte, []byte, error) { + length, rem, err := DecodeUnsigned32(data) + if err != nil { + return nil, nil, err + } + if uint32(len(rem)) < length { + return nil, nil, errors.New("obi: out of range") + } + return rem[:length], rem[length:], nil +} + +// DecodeString decodes the input bytes and returns string result and the remaining bytes. +func DecodeString(data []byte) (string, []byte, error) { + length, rem, err := DecodeUnsigned32(data) + if err != nil { + return "", nil, err + } + if uint32(len(rem)) < length { + return "", nil, errors.New("obi: out of range") + } + return string(rem[:length]), rem[length:], nil +} diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index db919dcc..863e4701 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -33,9 +33,9 @@ func (k *Keeper) CreateNewVault( } // Calculate collateral ratio - price := k.OracleKeeper.GetPrice(ctx, denom) + price := k.OracleKeeper.GetPrice(ctx, denom, "USD") // TODO: recalculate with denom decimal? - collateralValue := math.LegacyNewDecFromInt(collateral.Amount).Mul(price) + collateralValue := math.LegacyNewDecFromInt(collateral.Amount).Mul(*price) ratio := collateralValue.QuoInt(mint.Amount) if ratio.LT(vmParams.MinCollateralRatio) { @@ -135,8 +135,8 @@ func (k *Keeper) MintCoin( params := k.GetParams(ctx) lockedCoin := vault.CollateralLocked - price := k.OracleKeeper.GetPrice(ctx, lockedCoin.Denom) - lockedValue := math.LegacyNewDecFromInt(lockedCoin.Amount).Mul(price) + price := k.OracleKeeper.GetPrice(ctx, lockedCoin.Denom, "USD") + lockedValue := math.LegacyNewDecFromInt(lockedCoin.Amount).Mul(*price) feeAmount := math.LegacyNewDecFromInt(mint.Amount).Mul(params.MintingFee).TruncateInt() feeCoin := sdk.NewCoin(mint.Denom, feeAmount) @@ -278,8 +278,8 @@ func (k *Keeper) WithdrawFromVault( } newLock := vault.CollateralLocked.Sub(collateral) - price := k.OracleKeeper.GetPrice(ctx, collateral.Denom) - newLockValue := math.LegacyNewDecFromInt(newLock.Amount).Mul(price) + price := k.OracleKeeper.GetPrice(ctx, collateral.Denom, "USD") + newLockValue := math.LegacyNewDecFromInt(newLock.Amount).Mul(*price) ratio := newLockValue.Quo(math.LegacyNewDecFromInt(vault.Debt.Amount)) if ratio.LT(vm.Params.MinCollateralRatio) { @@ -344,8 +344,8 @@ func (k *Keeper) GetLiquidations( liquidations := make(map[string]*types.Liquidation) err := k.VaultsManager.Walk(ctx, nil, func(key string, vm types.VaultMamager) (bool, error) { - price := k.OracleKeeper.GetPrice(ctx, vm.Denom) - prices[vm.Denom] = price + price := k.OracleKeeper.GetPrice(ctx, vm.Denom, "USD") + prices[vm.Denom] = *price liquidationRatios[vm.Denom] = vm.Params.LiquidationRatio liquidations[vm.Denom] = types.NewEmptyLiquidation(vm.Denom) diff --git a/x/vaults/types/expected_keepers.go b/x/vaults/types/expected_keepers.go index d319bb9f..f085a692 100644 --- a/x/vaults/types/expected_keepers.go +++ b/x/vaults/types/expected_keepers.go @@ -29,6 +29,6 @@ type BankKeeper interface { } type OracleKeeper interface { - GetPrice(ctx context.Context, denom string) math.LegacyDec + GetPrice(ctx context.Context, base, quote string) *math.LegacyDec AddNewSymbolToBandOracleRequest(ctx context.Context, symbol string, oracleScriptId int64) error }