diff --git a/app/abci.go b/app/abci.go deleted file mode 100644 index 94b34cc3..00000000 --- a/app/abci.go +++ /dev/null @@ -1,84 +0,0 @@ -package app - -import ( - "bytes" - "crypto/rand" - "encoding/json" - "fmt" - - abci "github.com/cometbft/cometbft/abci/types" - - "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type ( - // VoteExtensionHandler defines a dummy vote extension handler for SimApp. - // - // NOTE: This implementation is solely used for testing purposes. DO NOT use - // in a production application! - VoteExtensionHandler struct{} - - // VoteExtension defines the structure used to create a dummy vote extension. - VoteExtension struct { - Hash []byte - Height int64 - Data []byte - } -) - -func NewVoteExtensionHandler() *VoteExtensionHandler { - return &VoteExtensionHandler{} -} - -func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { - bApp.SetExtendVoteHandler(h.ExtendVote()) - bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension()) -} - -func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { - return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { - buf := make([]byte, 1024) - - _, err := rand.Read(buf) - if err != nil { - return nil, fmt.Errorf("failed to generate random vote extension data: %w", err) - } - - ve := VoteExtension{ - Hash: req.Hash, - Height: req.Height, - Data: buf, - } - - bz, err := json.Marshal(ve) - if err != nil { - return nil, fmt.Errorf("failed to encode vote extension: %w", err) - } - - return &abci.ResponseExtendVote{VoteExtension: bz}, nil - } -} - -func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler { - return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { - var ve VoteExtension - - if err := json.Unmarshal(req.VoteExtension, &ve); err != nil { - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil - } - - switch { - case req.Height != ve.Height: - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil - - case !bytes.Equal(req.Hash, ve.Hash): - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil - - case len(ve.Data) != 1024: - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil - } - - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil - } -} diff --git a/app/app.go b/app/app.go index fe624923..7d33180d 100644 --- a/app/app.go +++ b/app/app.go @@ -37,6 +37,7 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" @@ -119,6 +120,7 @@ import ( ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" @@ -147,6 +149,7 @@ import ( schedulertypes "github.com/Team-Kujira/core/x/scheduler/types" "github.com/Team-Kujira/core/x/oracle" + oracleabci "github.com/Team-Kujira/core/x/oracle/abci" oraclekeeper "github.com/Team-Kujira/core/x/oracle/keeper" oracletypes "github.com/Team-Kujira/core/x/oracle/types" @@ -283,6 +286,8 @@ func New( wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *App { + baseAppOptions = append(baseAppOptions, baseapp.SetOptimisticExecution()) + interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, SigningOptions: signing.Options{ @@ -302,39 +307,6 @@ func New( std.RegisterLegacyAminoCodec(legacyAmino) std.RegisterInterfaces(interfaceRegistry) - // Below we could construct and set an application specific mempool and - // ABCI 1.0 PrepareProposal and ProcessProposal handlers. These defaults are - // already set in the SDK's BaseApp, this shows an example of how to override - // them. - // - // Example: - // - // bApp := baseapp.NewBaseApp(...) - // nonceMempool := mempool.NewSenderNonceMempool() - // abciPropHandler := NewDefaultProposalHandler(nonceMempool, bApp) - // - // bApp.SetMempool(nonceMempool) - // bApp.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) - // bApp.SetProcessProposal(abciPropHandler.ProcessProposalHandler()) - // - // Alternatively, you can construct BaseApp options, append those to - // baseAppOptions and pass them to NewBaseApp. - // - // Example: - // - // prepareOpt = func(app *baseapp.BaseApp) { - // abciPropHandler := baseapp.NewDefaultProposalHandler(nonceMempool, app) - // app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) - // } - // baseAppOptions = append(baseAppOptions, prepareOpt) - - // create and set dummy vote extension handler - voteExtOp := func(bApp *baseapp.BaseApp) { - voteExtHandler := NewVoteExtensionHandler() - voteExtHandler.SetHandlers(bApp) - } - baseAppOptions = append(baseAppOptions, voteExtOp) - bApp := baseapp.NewBaseApp(Name, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) @@ -634,6 +606,19 @@ func New( authority, ) + voteExtHandler := oracleabci.NewVoteExtHandler( + logger, + app.OracleKeeper, + ) + + oracleConfig, err := oracleabci.ReadOracleConfig(appOpts) + if err != nil { + panic(fmt.Sprintf("error while reading oracle config: %s", err)) + } + + bApp.SetExtendVoteHandler(voteExtHandler.ExtendVoteHandler(oracleConfig)) + bApp.SetVerifyVoteExtensionHandler(voteExtHandler.VerifyVoteExtensionHandler(oracleConfig)) + denomKeeper := denomkeeper.NewKeeper( appCodec, keys[denomtypes.StoreKey], @@ -878,6 +863,7 @@ func New( upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), + ibctm.NewAppModule(), params.NewAppModule(app.ParamsKeeper), transferModule, @@ -1122,6 +1108,20 @@ func New( app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) + nonceMempool := mempool.NewSenderNonceMempool() + propHandler := oracleabci.NewProposalHandler( + logger, + app.OracleKeeper, + app.StakingKeeper, + app.ModuleManager, + nonceMempool, + bApp, + ) + bApp.SetMempool(nonceMempool) + bApp.SetPrepareProposal(propHandler.PrepareProposal()) + bApp.SetProcessProposal(propHandler.ProcessProposal()) + bApp.SetPreBlocker(propHandler.PreBlocker) + // must be before Loading version // requires the snapshot store to be created and registered as a BaseAppOption // see cmd/wasmd/root.go: 206 - 214 approx diff --git a/app/openapiconsole/console.go b/app/openapiconsole/console.go index 465f5bbb..dd50faad 100644 --- a/app/openapiconsole/console.go +++ b/app/openapiconsole/console.go @@ -13,7 +13,7 @@ var index embed.FS func Handler(title, specURL string) http.HandlerFunc { t, _ := template.ParseFS(index, "index.tpl") - return func(w http.ResponseWriter, req *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { t.Execute(w, struct { //nolint:errcheck Title string URL string diff --git a/cmd/kujirad/cmd/root.go b/cmd/kujirad/cmd/root.go index 8974efa0..4c32d1fc 100644 --- a/cmd/kujirad/cmd/root.go +++ b/cmd/kujirad/cmd/root.go @@ -15,6 +15,7 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/Team-Kujira/core/app" "github.com/Team-Kujira/core/app/params" + oracleabci "github.com/Team-Kujira/core/x/oracle/abci" tmcfg "github.com/cometbft/cometbft/config" tmcli "github.com/cometbft/cometbft/libs/cli" dbm "github.com/cosmos/cosmos-db" @@ -146,7 +147,8 @@ func initAppConfig() (string, interface{}) { type CustomAppConfig struct { serverconfig.Config - WASM WASMConfig `mapstructure:"wasm"` + WASM WASMConfig `mapstructure:"wasm"` + Oracle oracleabci.OracleConfig `mapstructure:"oracle"` } // Optionally allow the chain developer to overwrite the SDK's default @@ -173,6 +175,9 @@ func initAppConfig() (string, interface{}) { LruSize: 1, QueryGasLimit: 30000000, }, + Oracle: oracleabci.OracleConfig{ + Endpoint: "http://localhost:10171/api/v1/prices", + }, } customAppTemplate := serverconfig.DefaultConfigTemplate + ` @@ -181,7 +186,11 @@ func initAppConfig() (string, interface{}) { query_gas_limit = 30000000 # This is the number of wasm vm instances we keep cached in memory for speed-up # Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally - lru_size = 0` + lru_size = 0 + +[oracle] + # Endpoint to query oracle prices for vote extension + endpoint = "http://localhost:10171/api/v1/prices"` return customAppTemplate, customAppConfig } diff --git a/go.mod b/go.mod index b86fb957..38f974f6 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.21 require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.2.0 - cosmossdk.io/simapp v0.0.0-20231107193120-9814f684b9dd cosmossdk.io/store v1.0.2 // cosmossdk.io/tools/rosetta v0.2.1 // cosmossdk.io/x/upgrade v0.0.0 @@ -22,7 +21,7 @@ require ( github.com/google/gofuzz v1.2.0 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/pkg/errors v0.9.1 + github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.17.0 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.8.0 diff --git a/go.sum b/go.sum index 2376fd62..b3cbc90d 100644 --- a/go.sum +++ b/go.sum @@ -203,8 +203,6 @@ cosmossdk.io/log v1.3.0 h1:L0Z0XstClo2kOU4h3V1iDoE5Ji64sg5HLOogzGg67Oo= cosmossdk.io/log v1.3.0/go.mod h1:HIDyvWLqZe2ovlWabsDN4aPMpY/nUEquAhgfTf2ZzB8= cosmossdk.io/math v1.2.0 h1:8gudhTkkD3NxOP2YyyJIYYmt6dQ55ZfJkDOaxXpy7Ig= cosmossdk.io/math v1.2.0/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= -cosmossdk.io/simapp v0.0.0-20231107193120-9814f684b9dd h1:KwV+LjYFc4N+KwUrPtCfKW6m+zIdCI0kz1Zr+RrDW/Y= -cosmossdk.io/simapp v0.0.0-20231107193120-9814f684b9dd/go.mod h1:qnOJ7OPtF1kNzces9lnB3vpeMhQu4uQE9i+h0+vb+RA= cosmossdk.io/store v1.0.2 h1:lSg5BTvJBHUDwswNNyeh4K/CbqiHER73VU4nDNb8uk0= cosmossdk.io/store v1.0.2/go.mod h1:EFtENTqVTuWwitGW1VwaBct+yDagk7oG/axBMPH+FXs= cosmossdk.io/tools/confix v0.1.0 h1:2OOZTtQsDT5e7P3FM5xqM0bPfluAxZlAwxqaDmYBE+E= diff --git a/proto/kujira/oracle/genesis.proto b/proto/kujira/oracle/genesis.proto index 1e2ee109..4687551f 100644 --- a/proto/kujira/oracle/genesis.proto +++ b/proto/kujira/oracle/genesis.proto @@ -10,12 +10,9 @@ option go_package = "github.com/Team-Kujira/core/x/oracle/types"; // GenesisState defines the oracle module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; - repeated FeederDelegation feeder_delegations = 2 [(gogoproto.nullable) = false]; - repeated ExchangeRateTuple exchange_rates = 3 + repeated ExchangeRateTuple exchange_rates = 2 [(gogoproto.castrepeated) = "ExchangeRateTuples", (gogoproto.nullable) = false]; - repeated MissCounter miss_counters = 4 [(gogoproto.nullable) = false]; - repeated AggregateExchangeRatePrevote aggregate_exchange_rate_prevotes = 5 [(gogoproto.nullable) = false]; - repeated AggregateExchangeRateVote aggregate_exchange_rate_votes = 6 [(gogoproto.nullable) = false]; + repeated MissCounter miss_counters = 3 [(gogoproto.nullable) = false]; } // FeederDelegation is the address for where oracle feeder authority are diff --git a/proto/kujira/oracle/oracle.proto b/proto/kujira/oracle/oracle.proto index c573c52d..1b9022b0 100644 --- a/proto/kujira/oracle/oracle.proto +++ b/proto/kujira/oracle/oracle.proto @@ -58,34 +58,6 @@ message Denom { string name = 1 [(gogoproto.moretags) = "yaml:\"name\""]; } -// struct for aggregate prevoting on the ExchangeRateVote. -// The purpose of aggregate prevote is to hide vote exchange rates with hash -// which is formatted as hex string in SHA256("{salt}:{exchange rate}{denom},...,{exchange rate}{denom}:{voter}") -message AggregateExchangeRatePrevote { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - string hash = 1 [(gogoproto.moretags) = "yaml:\"hash\""]; - string voter = 2 [(gogoproto.moretags) = "yaml:\"voter\""]; - uint64 submit_block = 3 [(gogoproto.moretags) = "yaml:\"submit_block\""]; -} - -// MsgAggregateExchangeRateVote - struct for voting on exchange rates. -message AggregateExchangeRateVote { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - repeated ExchangeRateTuple exchange_rate_tuples = 1 [ - (gogoproto.moretags) = "yaml:\"exchange_rate_tuples\"", - (gogoproto.castrepeated) = "ExchangeRateTuples", - (gogoproto.nullable) = false - ]; - - string voter = 2 [(gogoproto.moretags) = "yaml:\"voter\""]; -} - // ExchangeRateTuple - struct to store interpreted exchange rates data to store message ExchangeRateTuple { option (gogoproto.equal) = false; diff --git a/proto/kujira/oracle/query.proto b/proto/kujira/oracle/query.proto index 038652b2..46f7e571 100644 --- a/proto/kujira/oracle/query.proto +++ b/proto/kujira/oracle/query.proto @@ -25,36 +25,11 @@ service Query { option (google.api.http).get = "/oracle/denoms/actives"; } - // FeederDelegation returns feeder delegation of a validator - rpc FeederDelegation(QueryFeederDelegationRequest) returns (QueryFeederDelegationResponse) { - option (google.api.http).get = "/oracle/validators/{validator_addr}/feeder"; - } - // MissCounter returns oracle miss counter of a validator rpc MissCounter(QueryMissCounterRequest) returns (QueryMissCounterResponse) { option (google.api.http).get = "/oracle/validators/{validator_addr}/miss"; } - // AggregatePrevote returns an aggregate prevote of a validator - rpc AggregatePrevote(QueryAggregatePrevoteRequest) returns (QueryAggregatePrevoteResponse) { - option (google.api.http).get = "/oracle/validators/{validator_addr}/aggregate_prevote"; - } - - // AggregatePrevotes returns aggregate prevotes of all validators - rpc AggregatePrevotes(QueryAggregatePrevotesRequest) returns (QueryAggregatePrevotesResponse) { - option (google.api.http).get = "/oracle/validators/aggregate_prevotes"; - } - - // AggregateVote returns an aggregate vote of a validator - rpc AggregateVote(QueryAggregateVoteRequest) returns (QueryAggregateVoteResponse) { - option (google.api.http).get = "/oracle/valdiators/{validator_addr}/aggregate_vote"; - } - - // AggregateVotes returns aggregate votes of all validators - rpc AggregateVotes(QueryAggregateVotesRequest) returns (QueryAggregateVotesResponse) { - option (google.api.http).get = "/oracle/validators/aggregate_votes"; - } - // Params queries all parameters. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/oracle/params"; @@ -110,22 +85,6 @@ message QueryVoteTargetsResponse { repeated string vote_targets = 1; } -// QueryFeederDelegationRequest is the request type for the Query/FeederDelegation RPC method. -message QueryFeederDelegationRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator defines the validator address to query for. - string validator_addr = 1; -} - -// QueryFeederDelegationResponse is response type for the -// Query/FeederDelegation RPC method. -message QueryFeederDelegationResponse { - // feeder_addr defines the feeder delegation of a validator - string feeder_addr = 1; -} - // QueryMissCounterRequest is the request type for the Query/MissCounter RPC method. message QueryMissCounterRequest { option (gogoproto.equal) = false; @@ -142,58 +101,6 @@ message QueryMissCounterResponse { uint64 miss_counter = 1; } -// QueryAggregatePrevoteRequest is the request type for the Query/AggregatePrevote RPC method. -message QueryAggregatePrevoteRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator defines the validator address to query for. - string validator_addr = 1; -} - -// QueryAggregatePrevoteResponse is response type for the -// Query/AggregatePrevote RPC method. -message QueryAggregatePrevoteResponse { - // aggregate_prevote defines oracle aggregate prevote submitted by a validator in the current vote period - AggregateExchangeRatePrevote aggregate_prevote = 1 [(gogoproto.nullable) = false]; - ; -} - -// QueryAggregatePrevotesRequest is the request type for the Query/AggregatePrevotes RPC method. -message QueryAggregatePrevotesRequest {} - -// QueryAggregatePrevotesResponse is response type for the -// Query/AggregatePrevotes RPC method. -message QueryAggregatePrevotesResponse { - // aggregate_prevotes defines all oracle aggregate prevotes submitted in the current vote period - repeated AggregateExchangeRatePrevote aggregate_prevotes = 1 [(gogoproto.nullable) = false]; -} - -// QueryAggregateVoteRequest is the request type for the Query/AggregateVote RPC method. -message QueryAggregateVoteRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator defines the validator address to query for. - string validator_addr = 1; -} - -// QueryAggregateVoteResponse is response type for the -// Query/AggregateVote RPC method. -message QueryAggregateVoteResponse { - // aggregate_vote defines oracle aggregate vote submitted by a validator in the current vote period - AggregateExchangeRateVote aggregate_vote = 1 [(gogoproto.nullable) = false]; -} - -// QueryAggregateVotesRequest is the request type for the Query/AggregateVotes RPC method. -message QueryAggregateVotesRequest {} - -// QueryAggregateVotesResponse is response type for the -// Query/AggregateVotes RPC method. -message QueryAggregateVotesResponse { - // aggregate_votes defines all oracle aggregate votes submitted in the current vote period - repeated AggregateExchangeRateVote aggregate_votes = 1 [(gogoproto.nullable) = false]; -} // QueryParamsRequest is the request type for the Query/Params RPC method. message QueryParamsRequest {} diff --git a/proto/kujira/oracle/tx.proto b/proto/kujira/oracle/tx.proto index 5731bd79..aac8331b 100644 --- a/proto/kujira/oracle/tx.proto +++ b/proto/kujira/oracle/tx.proto @@ -9,17 +9,6 @@ option go_package = "github.com/Team-Kujira/core/x/oracle/types"; // Msg defines the oracle Msg service. service Msg { - // AggregateExchangeRatePrevote defines a method for submitting - // aggregate exchange rate prevote - rpc AggregateExchangeRatePrevote(MsgAggregateExchangeRatePrevote) returns (MsgAggregateExchangeRatePrevoteResponse); - - // AggregateExchangeRateVote defines a method for submitting - // aggregate exchange rate vote - rpc AggregateExchangeRateVote(MsgAggregateExchangeRateVote) returns (MsgAggregateExchangeRateVoteResponse); - - // DelegateFeedConsent defines a method for setting the feeder delegation - rpc DelegateFeedConsent(MsgDelegateFeedConsent) returns (MsgDelegateFeedConsentResponse); - // AddRequiredDenom adds a new price to the required list of prices rpc AddRequiredDenom(MsgAddRequiredDenom) returns (MsgAddRequiredDenomResponse); @@ -30,48 +19,6 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } -// MsgAggregateExchangeRatePrevote represents a message to submit -// aggregate exchange rate prevote. -message MsgAggregateExchangeRatePrevote { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string hash = 1 [(gogoproto.moretags) = "yaml:\"hash\""]; - string feeder = 2 [(gogoproto.moretags) = "yaml:\"feeder\""]; - string validator = 3 [(gogoproto.moretags) = "yaml:\"validator\""]; -} - -// MsgAggregateExchangeRatePrevoteResponse defines the Msg/AggregateExchangeRatePrevote response type. -message MsgAggregateExchangeRatePrevoteResponse {} - -// MsgAggregateExchangeRateVote represents a message to submit -// aggregate exchange rate vote. -message MsgAggregateExchangeRateVote { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string salt = 1 [(gogoproto.moretags) = "yaml:\"salt\""]; - string exchange_rates = 2 [(gogoproto.moretags) = "yaml:\"exchange_rates\""]; - string feeder = 3 [(gogoproto.moretags) = "yaml:\"feeder\""]; - string validator = 4 [(gogoproto.moretags) = "yaml:\"validator\""]; -} - -// MsgAggregateExchangeRateVoteResponse defines the Msg/AggregateExchangeRateVote response type. -message MsgAggregateExchangeRateVoteResponse {} - -// MsgDelegateFeedConsent represents a message to -// delegate oracle voting rights to another address. -message MsgDelegateFeedConsent { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string operator = 1 [(gogoproto.moretags) = "yaml:\"operator\""]; - string delegate = 2 [(gogoproto.moretags) = "yaml:\"delegate\""]; -} - -// MsgDelegateFeedConsentResponse defines the Msg/DelegateFeedConsent response type. -message MsgDelegateFeedConsentResponse {} - // MsgAddRequiredDenom represents a message to add a denom to the whitelist message MsgAddRequiredDenom { option (cosmos.msg.v1.signer) = "authority"; diff --git a/x/denom/client/cli/query.go b/x/denom/client/cli/query.go index a424ac24..59f4b33e 100644 --- a/x/denom/client/cli/query.go +++ b/x/denom/client/cli/query.go @@ -42,7 +42,7 @@ func GetParams() *cobra.Command { Use: "params [flags]", Short: "Get the params for the x/denom module", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/denom/types/denoms.go b/x/denom/types/denoms.go index 06aa432f..2c6a3d4e 100644 --- a/x/denom/types/denoms.go +++ b/x/denom/types/denoms.go @@ -60,7 +60,7 @@ func DeconstructDenom(denom string) (creator string, nonce string, err error) { // NewdenomDenomMintCoinsRestriction creates and returns a BankMintingRestrictionFn that only allows minting of // valid denom denoms func NewdenomDenomMintCoinsRestriction() banktypes.MintingRestrictionFn { - return func(ctx context.Context, coinsToMint sdk.Coins) error { + return func(_ context.Context, coinsToMint sdk.Coins) error { for _, coin := range coinsToMint { _, _, err := DeconstructDenom(coin.Denom) if err != nil { diff --git a/x/oracle/abci/config.go b/x/oracle/abci/config.go new file mode 100644 index 00000000..0e6fa7e3 --- /dev/null +++ b/x/oracle/abci/config.go @@ -0,0 +1,27 @@ +package abci + +import ( + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/spf13/cast" +) + +type OracleConfig struct { + Endpoint string `mapstructure:"endpoint"` +} + +const ( + flagOracleEndpoint = "oracle.endpoint" +) + +// ReadOracleConfig reads the wasm specifig configuration +func ReadOracleConfig(opts servertypes.AppOptions) (OracleConfig, error) { + cfg := OracleConfig{} + var err error + if v := opts.Get(flagOracleEndpoint); v != nil { + if cfg.Endpoint, err = cast.ToStringE(v); err != nil { + return cfg, err + } + } + + return cfg, nil +} diff --git a/x/oracle/abci/proposal.go b/x/oracle/abci/proposal.go new file mode 100644 index 00000000..9169fad6 --- /dev/null +++ b/x/oracle/abci/proposal.go @@ -0,0 +1,395 @@ +package abci + +import ( + "encoding/json" + "errors" + "fmt" + "sort" + + "cosmossdk.io/core/appmodule" + "cosmossdk.io/log" + "cosmossdk.io/math" + "github.com/Team-Kujira/core/x/oracle/keeper" + "github.com/Team-Kujira/core/x/oracle/types" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/mempool" + "github.com/cosmos/cosmos-sdk/types/module" +) + +// StakeWeightedPrices defines the structure a proposer should use to calculate +// and submit the stake-weighted prices for a given set of supported currency +// pairs, in addition to the vote extensions used to calculate them. This is so +// validators can verify the proposer's calculations. +type StakeWeightedPrices struct { + StakeWeightedPrices map[string]math.LegacyDec + ExtendedCommitInfo abci.ExtendedCommitInfo + MissCounter map[string]sdk.ValAddress +} + +type ProposalHandler struct { + logger log.Logger + keeper keeper.Keeper + valStore baseapp.ValidatorStore + baseapp.DefaultProposalHandler + ModuleManager *module.Manager +} + +func NewProposalHandler(logger log.Logger, keeper keeper.Keeper, valStore baseapp.ValidatorStore, ModuleManager *module.Manager, mp mempool.Mempool, txVerifier baseapp.ProposalTxVerifier) *ProposalHandler { + return &ProposalHandler{ + logger: logger, + keeper: keeper, + valStore: valStore, + ModuleManager: ModuleManager, + DefaultProposalHandler: *baseapp.NewDefaultProposalHandler(mp, txVerifier), + } +} + +// PrepareProposalHandler returns the implementation for processing an +// ABCI proposal. +// - Default PrepareProposalHandler selects regular txs +// - Appends vote extension tx at the end +func (h *ProposalHandler) PrepareProposal() sdk.PrepareProposalHandler { + return func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + defaultHandler := h.DefaultProposalHandler.PrepareProposalHandler() + defaultResponse, err := defaultHandler(ctx, req) + if err != nil { + return nil, err + } + + proposalTxs := defaultResponse.Txs + + // Note: Upgrade height should be equal to vote extension enable height + cp := ctx.ConsensusParams() + extsEnabled := cp.Abci != nil && req.Height > cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0 + if !extsEnabled { + return &abci.ResponsePrepareProposal{ + Txs: proposalTxs, + }, nil + } + + err = baseapp.ValidateVoteExtensions(ctx, h.valStore, req.Height, ctx.ChainID(), req.LocalLastCommit) + if err != nil { + return nil, err + } + + stakeWeightedPrices, missMap, err := h.ComputeStakeWeightedPricesAndMissMap(ctx, req.LocalLastCommit) + if err != nil { + return nil, errors.New("failed to compute stake-weighted oracle prices") + } + + injectedVoteExtTx := StakeWeightedPrices{ + StakeWeightedPrices: stakeWeightedPrices, + ExtendedCommitInfo: req.LocalLastCommit, + MissCounter: missMap, + } + + // Encode vote extension to bytes + bz, err := json.Marshal(injectedVoteExtTx) + if err != nil { + h.logger.Error("failed to encode injected vote extension tx", "err", err) + return nil, errors.New("failed to encode injected vote extension tx") + } + + // Inject vote extension tx into the proposal s.t. validators can decode, verify, + // and store the canonical stake-weighted average prices. + proposalTxs = append(proposalTxs, bz) + return &abci.ResponsePrepareProposal{ + Txs: proposalTxs, + }, nil + } +} + +// ProcessProposalHandler returns the implementation for processing an +// ABCI proposal +// - Validate vote extension tx +// - Validate regular tx with default PrepareProposalHandler +func (h *ProposalHandler) ProcessProposal() sdk.ProcessProposalHandler { + return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + reReq := *req + var injectedVoteExtTx StakeWeightedPrices + if len(req.Txs) > 0 { + lastTx := req.Txs[len(req.Txs)-1] + if err := json.Unmarshal(lastTx, &injectedVoteExtTx); err == nil { + h.logger.Debug("handling injected vote extension tx") + err := baseapp.ValidateVoteExtensions(ctx, h.valStore, req.Height, ctx.ChainID(), injectedVoteExtTx.ExtendedCommitInfo) + if err != nil { + return nil, err + } + + // Verify the proposer's stake-weighted oracle prices & miss counter by computing the same + // calculation and comparing the results. + stakeWeightedPrices, missMap, err := h.ComputeStakeWeightedPricesAndMissMap(ctx, injectedVoteExtTx.ExtendedCommitInfo) + if err != nil { + return nil, errors.New("failed to compute stake-weighted oracle prices") + } + + // compare stakeWeightedPrices + if err := CompareOraclePrices(injectedVoteExtTx.StakeWeightedPrices, stakeWeightedPrices); err != nil { + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil + } + + // compare missMap + if err := CompareMissMap(injectedVoteExtTx.MissCounter, missMap); err != nil { + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil + } + + // Exclude last tx if it's vote extension tx + reReq.Txs = reReq.Txs[:len(reReq.Txs)-1] + } + } + + defaultHandler := h.DefaultProposalHandler.ProcessProposalHandler() + return defaultHandler(ctx, &reReq) + } +} + +// cosmos-sdk/types/module/module.go#L753 +// PreBlock performs begin block functionality for upgrade module. +// It takes the current context as a parameter and returns a boolean value +// indicating whether the migration was successfully executed or not. +func (h *ProposalHandler) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + paramsChanged := false + for _, moduleName := range h.ModuleManager.OrderPreBlockers { + if module, ok := h.ModuleManager.Modules[moduleName].(appmodule.HasPreBlocker); ok { + rsp, err := module.PreBlock(ctx) + if err != nil { + return nil, err + } + if rsp.IsConsensusParamsChanged() { + paramsChanged = true + } + } + } + + for _, txBytes := range req.Txs { + var injectedVoteExtTx StakeWeightedPrices + if err := json.Unmarshal(txBytes, &injectedVoteExtTx); err != nil { + h.logger.Debug("Skipping regular tx, not one of our vote", "tx", string(txBytes)) + continue + } + + // Clear all exchange rates + h.keeper.IterateExchangeRates(ctx, func(denom string, _ math.LegacyDec) (stop bool) { + h.keeper.DeleteExchangeRate(ctx, denom) + return false + }) + + for _, valAddr := range injectedVoteExtTx.MissCounter { + h.keeper.SetMissCounter(ctx, valAddr, h.keeper.GetMissCounter(ctx, valAddr)+1) + } + + // set oracle prices using the passed in context, which will make these prices available in the current block + h.keeper.SetOraclePrices(ctx, injectedVoteExtTx.StakeWeightedPrices) + + // Do slash who did miss voting over threshold and + // reset miss counters of all validators at the last block of slash window + params := h.keeper.GetParams(ctx) + if IsPeriodLastBlock(ctx, params.SlashWindow) { + h.keeper.SlashAndResetMissCounters(ctx) + } + } + + return &sdk.ResponsePreBlock{ + ConsensusParamsChanged: paramsChanged, + }, nil +} + +func IsPeriodLastBlock(ctx sdk.Context, blocksPerPeriod uint64) bool { + return (uint64(ctx.BlockHeight())+1)%blocksPerPeriod == 0 +} + +func CompareOraclePrices(p1, p2 map[string]math.LegacyDec) error { + for denom, p := range p1 { + if p2[denom].IsNil() || !p.Equal(p2[denom]) { + return errors.New("oracle prices mismatch") + } + } + + for denom, p := range p2 { + if p1[denom].IsNil() || !p.Equal(p1[denom]) { + return errors.New("oracle prices mismatch") + } + } + + return nil +} + +func CompareMissMap(m1, m2 map[string]sdk.ValAddress) error { + for valAddrStr, valAddr := range m1 { + if _, ok := m2[valAddrStr]; !ok { + return errors.New("oracle missMap mismatch") + } + if valAddr.String() != valAddrStr { + return errors.New("invalid oracle missMap") + } + } + + for valAddrStr, valAddr := range m2 { + if _, ok := m1[valAddrStr]; !ok { + return errors.New("oracle missMap mismatch") + } + if valAddr.String() != valAddrStr { + return errors.New("invalid oracle missMap") + } + } + + return nil +} + +func (h *ProposalHandler) GetBallotByDenom(ci abci.ExtendedCommitInfo, validatorClaimMap map[string]types.Claim, validatorConsensusAddrMap map[string]sdk.ValAddress) (votes map[string]types.ExchangeRateBallot) { + votes = map[string]types.ExchangeRateBallot{} + + for _, v := range ci.Votes { + valAddr := validatorConsensusAddrMap[sdk.ConsAddress(v.Validator.Address).String()] + claim, ok := validatorClaimMap[valAddr.String()] + if ok { + power := claim.Power + + var voteExt OracleVoteExtension + if err := json.Unmarshal(v.VoteExtension, &voteExt); err != nil { + h.logger.Error("failed to decode vote extension", "err", err, "validator", fmt.Sprintf("%x", v.Validator.Address)) + return votes + } + + for base, price := range voteExt.Prices { + tmpPower := power + if !price.IsPositive() { + // Make the power of abstain vote zero + tmpPower = 0 + } + + votes[base] = append(votes[base], + types.NewVoteForTally( + price, + base, + valAddr, + tmpPower, + ), + ) + } + } + } + + // sort created ballot + for denom, ballot := range votes { + sort.Sort(ballot) + votes[denom] = ballot + } + + return votes +} + +func (h *ProposalHandler) ComputeStakeWeightedPricesAndMissMap(ctx sdk.Context, ci abci.ExtendedCommitInfo) (map[string]math.LegacyDec, map[string]sdk.ValAddress, error) { + params := h.keeper.GetParams(ctx) + + // Build claim map over all validators in active set + stakeWeightedPrices := make(map[string]math.LegacyDec) // base -> average stake-weighted price + validatorClaimMap := make(map[string]types.Claim) + validatorConsensusAddrMap := make(map[string]sdk.ValAddress) + + maxValidators, err := h.keeper.StakingKeeper.MaxValidators(ctx) + if err != nil { + return nil, nil, err + } + iterator, err := h.keeper.StakingKeeper.ValidatorsPowerStoreIterator(ctx) + if err != nil { + return nil, nil, err + } + + defer iterator.Close() + + powerReduction := h.keeper.StakingKeeper.PowerReduction(ctx) + + i := 0 + for ; iterator.Valid() && i < int(maxValidators); iterator.Next() { + validator, err := h.keeper.StakingKeeper.Validator(ctx, iterator.Value()) + if err != nil { + return nil, nil, err + } + + // Exclude not bonded validator + if validator.IsBonded() { + valAddrStr := validator.GetOperator() + valAddr, err := sdk.ValAddressFromBech32(valAddrStr) + if err != nil { + return nil, nil, err + } + + validatorClaimMap[valAddr.String()] = types.NewClaim(validator.GetConsensusPower(powerReduction), 0, 0, valAddr) + + consAddr, err := validator.GetConsAddr() + if err != nil { + return nil, nil, err + } + validatorConsensusAddrMap[sdk.ConsAddress(consAddr).String()] = valAddr + i++ + } + } + + voteMap := h.GetBallotByDenom(ci, validatorClaimMap, validatorConsensusAddrMap) + + // Keep track, if a voter submitted a price deviating too much + missMap := map[string]sdk.ValAddress{} + + // Iterate through ballots and update exchange rates; drop if not enough votes have been achieved. + for denom, ballot := range voteMap { + bondedTokens, err := h.keeper.StakingKeeper.TotalBondedTokens(ctx) + if err != nil { + return nil, nil, err + } + + totalBondedPower := sdk.TokensToConsensusPower(bondedTokens, h.keeper.StakingKeeper.PowerReduction(ctx)) + voteThreshold := h.keeper.VoteThreshold(ctx) + thresholdVotes := voteThreshold.MulInt64(totalBondedPower).RoundInt() + ballotPower := math.NewInt(ballot.Power()) + + if !ballotPower.IsZero() && ballotPower.GTE(thresholdVotes) { + exchangeRate, err := keeper.Tally( + ctx, ballot, params.MaxDeviation, validatorClaimMap, missMap, + ) + if err != nil { + return nil, nil, err + } + + stakeWeightedPrices[denom] = exchangeRate + } + } + + //--------------------------- + // Do miss counting & slashing + denomMap := map[string]map[string]struct{}{} + var voteTargets []string + voteTargets = append(voteTargets, params.RequiredDenoms...) + + for _, denom := range voteTargets { + denomMap[denom] = map[string]struct{}{} + } + + for denom, votes := range voteMap { + for _, vote := range votes { + // ignore denoms, not requested in voteTargets + _, ok := denomMap[denom] + if !ok { + continue + } + + denomMap[denom][vote.Voter.String()] = struct{}{} + } + } + + // Check if each validator is missing a required denom price + for _, claim := range validatorClaimMap { + for _, denom := range voteTargets { + _, ok := denomMap[denom][claim.Recipient.String()] + if !ok { + missMap[claim.Recipient.String()] = claim.Recipient + break + } + } + } + + return stakeWeightedPrices, missMap, nil +} diff --git a/x/oracle/abci/proposal_test.go b/x/oracle/abci/proposal_test.go new file mode 100644 index 00000000..49bb7e4b --- /dev/null +++ b/x/oracle/abci/proposal_test.go @@ -0,0 +1,901 @@ +package abci_test + +import ( + "bytes" + "encoding/json" + "fmt" + "sort" + "testing" + "time" + + "cosmossdk.io/math" + "github.com/stretchr/testify/require" + + "github.com/Team-Kujira/core/x/oracle/types" + + "github.com/Team-Kujira/core/x/oracle/abci" + "github.com/Team-Kujira/core/x/oracle/keeper" + cometabci "github.com/cometbft/cometbft/abci/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + protoio "github.com/cosmos/gogoproto/io" + "github.com/cosmos/gogoproto/proto" +) + +var ( + ValAddrs = keeper.ValAddrs + ValPubKeys []cryptotypes.PubKey + ValPrivKeys []*ed25519.PrivKey +) + +func init() { + for i := 0; i < 5; i++ { + privKey := ed25519.GenPrivKey() + ValPrivKeys = append(ValPrivKeys, privKey) + pubKey := &ed25519.PubKey{Key: privKey.PubKey().Bytes()} + ValPubKeys = append(ValPubKeys, pubKey) + } +} + +func SetupTest(t *testing.T) (keeper.TestInput, *abci.ProposalHandler) { + input := keeper.CreateTestInput(t) + + power := int64(100) + amt := sdk.TokensFromConsensusPower(power, sdk.DefaultPowerReduction) + sh := stakingkeeper.NewMsgServerImpl(&input.StakingKeeper) + ctx := input.Ctx + mm := module.NewManager() + + // Validator created + _, err := sh.CreateValidator(ctx, keeper.NewTestMsgCreateValidator(ValAddrs[0], ValPubKeys[0], amt)) + require.NoError(t, err) + _, err = sh.CreateValidator(ctx, keeper.NewTestMsgCreateValidator(ValAddrs[1], ValPubKeys[1], amt)) + require.NoError(t, err) + _, err = sh.CreateValidator(ctx, keeper.NewTestMsgCreateValidator(ValAddrs[2], ValPubKeys[2], amt)) + require.NoError(t, err) + input.StakingKeeper.EndBlocker(ctx) + + h := abci.NewProposalHandler( + input.Ctx.Logger(), + input.OracleKeeper, + input.StakingKeeper, + mm, // module manager + nil, // mempool + nil, // bApp + ) + + params := types.DefaultParams() + params.RequiredDenoms = []string{"BTC", "ETH"} + input.OracleKeeper.SetParams(ctx, params) + + return input, h +} + +func TestGetBallotByDenom(t *testing.T) { + _, h := SetupTest(t) + power := int64(100) + + // organize votes by denom + voteExt1 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25000), + "ETH": math.LegacyNewDec(2200), + }, + } + voteExt2 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25030), + "ETH": math.LegacyNewDec(2180), + }, + } + voteExt1Bytes, err := json.Marshal(voteExt1) + require.NoError(t, err) + voteExt2Bytes, err := json.Marshal(voteExt2) + require.NoError(t, err) + + consAddrMap := map[string]sdk.ValAddress{ + sdk.ConsAddress(ValPubKeys[0].Address().Bytes()).String(): ValAddrs[0], + sdk.ConsAddress(ValPubKeys[1].Address().Bytes()).String(): ValAddrs[1], + sdk.ConsAddress(ValPubKeys[2].Address().Bytes()).String(): ValAddrs[2], + } + + ballotMap := h.GetBallotByDenom(cometabci.ExtendedCommitInfo{ + Votes: []cometabci.ExtendedVoteInfo{ + { + Validator: cometabci.Validator{ + Address: ValPubKeys[0].Address().Bytes(), + }, + VoteExtension: voteExt1Bytes, + }, + { + Validator: cometabci.Validator{ + Address: ValPubKeys[1].Address().Bytes(), + }, + VoteExtension: voteExt2Bytes, + }, + }, + }, map[string]types.Claim{ + ValAddrs[0].String(): { + Power: power, + WinCount: 0, + Recipient: ValAddrs[0], + }, + ValAddrs[1].String(): { + Power: power, + WinCount: 0, + Recipient: ValAddrs[1], + }, + ValAddrs[2].String(): { + Power: power, + WinCount: 0, + Recipient: ValAddrs[2], + }, + }, consAddrMap) + + ethBallot := types.ExchangeRateBallot{ + types.NewVoteForTally(math.LegacyNewDec(2200), "ETH", ValAddrs[0], power), + types.NewVoteForTally(math.LegacyNewDec(2180), "ETH", ValAddrs[1], power), + } + btcBallot := types.ExchangeRateBallot{ + types.NewVoteForTally(math.LegacyNewDec(25000), "BTC", ValAddrs[0], power), + types.NewVoteForTally(math.LegacyNewDec(25030), "BTC", ValAddrs[1], power), + } + sort.Sort(ethBallot) + sort.Sort(btcBallot) + sort.Sort(ballotMap["ETH"]) + sort.Sort(ballotMap["BTC"]) + + require.Equal(t, ethBallot, ballotMap["ETH"]) + require.Equal(t, btcBallot, ballotMap["BTC"]) +} + +func TestComputeStakeWeightedPricesAndMissMap(t *testing.T) { + input, h := SetupTest(t) + + // organize votes by denom + voteExt1 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25000), + "ETH": math.LegacyNewDec(2200), + }, + } + voteExt2 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25030), + "ETH": math.LegacyNewDec(2180), + }, + } + voteExt1Bytes, err := json.Marshal(voteExt1) + require.NoError(t, err) + voteExt2Bytes, err := json.Marshal(voteExt2) + require.NoError(t, err) + + params := types.DefaultParams() + params.RequiredDenoms = []string{"BTC", "ETH"} + input.OracleKeeper.SetParams(input.Ctx, params) + + stakeWeightedPrices, missMap, err := h.ComputeStakeWeightedPricesAndMissMap(input.Ctx, cometabci.ExtendedCommitInfo{ + Votes: []cometabci.ExtendedVoteInfo{ + { + Validator: cometabci.Validator{ + Address: ValPubKeys[0].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt1Bytes, + }, + { + Validator: cometabci.Validator{ + Address: ValPubKeys[1].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt2Bytes, + }, + }, + }) + require.NoError(t, err) + require.Equal(t, math.LegacyNewDec(2180).String(), stakeWeightedPrices["ETH"].String()) + require.Equal(t, math.LegacyNewDec(25000).String(), stakeWeightedPrices["BTC"].String()) + require.Nil(t, missMap[ValAddrs[0].String()]) + require.Nil(t, missMap[ValAddrs[1].String()]) + require.NotNil(t, missMap[ValAddrs[2].String()]) +} + +func TestCompareOraclePrices(t *testing.T) { + testCases := []struct { + p1 map[string]math.LegacyDec + p2 map[string]math.LegacyDec + expEqual bool + }{ + { + p1: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + }, + p2: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + }, + expEqual: true, + }, + { + p1: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + }, + p2: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2200), + }, + expEqual: false, + }, + { + p1: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + }, + p2: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + "BTC": math.LegacyNewDec(43000), + }, + expEqual: false, + }, + { + p1: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + "BTC": math.LegacyNewDec(43000), + }, + p2: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + }, + expEqual: false, + }, + { + p1: nil, + p2: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + }, + expEqual: false, + }, + { + p1: map[string]math.LegacyDec{ + "ATOM": math.LegacyNewDec(10), + "ETH": math.LegacyNewDec(2300), + }, + p2: nil, + expEqual: false, + }, + { + p1: nil, + p2: nil, + expEqual: true, + }, + } + + for i, tc := range testCases { + t.Run(fmt.Sprintf("Case %d", i), func(t *testing.T) { + err := abci.CompareOraclePrices(tc.p1, tc.p2) + if tc.expEqual { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} + +func TestCompareMissMap(t *testing.T) { + testCases := []struct { + m1 map[string]sdk.ValAddress + m2 map[string]sdk.ValAddress + expEqual bool + }{ + { + m1: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[1], + }, + m2: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[1], + }, + expEqual: true, + }, + { + m1: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[1], + }, + m2: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[2].String(): ValAddrs[2], + }, + expEqual: false, + }, + { + m1: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[1], + }, + m2: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[2], + }, + expEqual: false, + }, + { + m1: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[1], + }, + m2: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[2].String(): ValAddrs[1], + }, + expEqual: false, + }, + { + m1: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[1], + }, + m2: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + }, + expEqual: false, + }, + { + m1: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + }, + m2: map[string]sdk.ValAddress{ + ValAddrs[0].String(): ValAddrs[0], + ValAddrs[1].String(): ValAddrs[1], + }, + expEqual: false, + }, + { + m1: map[string]sdk.ValAddress{}, + m2: nil, + expEqual: true, + }, + } + + for i, tc := range testCases { + t.Run(fmt.Sprintf("Case %d", i), func(t *testing.T) { + err := abci.CompareMissMap(tc.m1, tc.m2) + if tc.expEqual { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} + +func TestPrepareProposal(t *testing.T) { + input, h := SetupTest(t) + + params := types.DefaultParams() + params.RequiredDenoms = []string{"BTC", "ETH"} + input.OracleKeeper.SetParams(input.Ctx, params) + + handler := h.PrepareProposal() + + consParams := input.Ctx.ConsensusParams() + consParams.Abci = &cmtproto.ABCIParams{ + VoteExtensionsEnableHeight: 1, + } + input.Ctx = input.Ctx.WithConsensusParams(consParams) + + // Handler before vote extension enable + res, err := handler(input.Ctx, &cometabci.RequestPrepareProposal{ + Height: 1, + Txs: [][]byte{}, + LocalLastCommit: cometabci.ExtendedCommitInfo{}, + }) + require.NoError(t, err) + require.Len(t, res.Txs, 0) + + // Invalid vote extension data + invalidLocalLastCommit := cometabci.ExtendedCommitInfo{ + Votes: []cometabci.ExtendedVoteInfo{ + { + Validator: cometabci.Validator{ + Address: ValPubKeys[0].Address().Bytes(), + Power: 1, + }, + VoteExtension: []byte{}, + }, + { + Validator: cometabci.Validator{ + Address: ValPubKeys[1].Address().Bytes(), + Power: 1, + }, + VoteExtension: []byte{}, + }, + }, + } + _, err = handler(input.Ctx, &cometabci.RequestPrepareProposal{ + Height: 2, + Txs: [][]byte{}, + LocalLastCommit: invalidLocalLastCommit, + }) + require.Error(t, err) + + // Valid vote extension data + voteExt1 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25000), + "ETH": math.LegacyNewDec(2200), + }, + } + voteExt2 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25030), + "ETH": math.LegacyNewDec(2180), + }, + } + voteExt1Bytes, err := json.Marshal(voteExt1) + require.NoError(t, err) + voteExt2Bytes, err := json.Marshal(voteExt2) + require.NoError(t, err) + marshalDelimitedFn := func(msg proto.Message) ([]byte, error) { + var buf bytes.Buffer + if err := protoio.NewDelimitedWriter(&buf).WriteMsg(msg); err != nil { + return nil, err + } + + return buf.Bytes(), nil + } + + cve := cmtproto.CanonicalVoteExtension{ + Extension: voteExt1Bytes, + Height: 3 - 1, // the vote extension was signed in the previous height + Round: 1, + ChainId: input.Ctx.ChainID(), + } + + ext1SignBytes, err := marshalDelimitedFn(&cve) + require.NoError(t, err) + + signature1, err := ValPrivKeys[0].Sign(ext1SignBytes) + require.NoError(t, err) + + cve = cmtproto.CanonicalVoteExtension{ + Extension: voteExt2Bytes, + Height: 3 - 1, // the vote extension was signed in the previous height + Round: 1, + ChainId: input.Ctx.ChainID(), + } + + ext2SignBytes, err := marshalDelimitedFn(&cve) + require.NoError(t, err) + + signature2, err := ValPrivKeys[1].Sign(ext2SignBytes) + require.NoError(t, err) + + localLastCommit := cometabci.ExtendedCommitInfo{ + Round: 1, + Votes: []cometabci.ExtendedVoteInfo{ + { + BlockIdFlag: cmtproto.BlockIDFlagCommit, + Validator: cometabci.Validator{ + Address: ValPubKeys[0].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt1Bytes, + ExtensionSignature: signature1, + }, + { + BlockIdFlag: cmtproto.BlockIDFlagCommit, + Validator: cometabci.Validator{ + Address: ValPubKeys[1].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt2Bytes, + ExtensionSignature: signature2, + }, + }, + } + res, err = handler(input.Ctx, &cometabci.RequestPrepareProposal{ + Height: 3, + Txs: [][]byte{}, + LocalLastCommit: localLastCommit, + }) + require.NoError(t, err) + require.Len(t, res.Txs, 1) // Check injectedVoteExtTx + injectedVoteExtTx := abci.StakeWeightedPrices{ + StakeWeightedPrices: map[string]math.LegacyDec{ + "ETH": math.LegacyNewDec(2180), + "BTC": math.LegacyNewDec(25000), + }, + ExtendedCommitInfo: localLastCommit, + MissCounter: map[string]sdk.ValAddress{ + ValAddrs[2].String(): ValAddrs[2], + }, + } + injectedBytes, err := json.Marshal(injectedVoteExtTx) + require.NoError(t, err) + require.Equal(t, string(injectedBytes), string(res.Txs[0])) + + // Threshold check + localLastCommit = cometabci.ExtendedCommitInfo{ + Round: 1, + Votes: []cometabci.ExtendedVoteInfo{ + { + BlockIdFlag: cmtproto.BlockIDFlagCommit, + Validator: cometabci.Validator{ + Address: ValPubKeys[0].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt1Bytes, + ExtensionSignature: signature1, + }, + { + BlockIdFlag: cmtproto.BlockIDFlagAbsent, + Validator: cometabci.Validator{ + Address: ValPubKeys[1].Address().Bytes(), + Power: 1, + }, + VoteExtension: []byte{}, + ExtensionSignature: []byte{}, + }, + }, + } + _, err = handler(input.Ctx, &cometabci.RequestPrepareProposal{ + Height: 3, + Txs: [][]byte{}, + LocalLastCommit: localLastCommit, + }) + require.Error(t, err) +} + +func TestProcessProposal(t *testing.T) { + input, h := SetupTest(t) + + handler := h.ProcessProposal() + + consParams := input.Ctx.ConsensusParams() + consParams.Abci = &cmtproto.ABCIParams{ + VoteExtensionsEnableHeight: 2, + } + input.Ctx = input.Ctx.WithConsensusParams(consParams) + + // Valid vote extension data + voteExt1 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25000), + "ETH": math.LegacyNewDec(2200), + }, + } + voteExt2 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25030), + "ETH": math.LegacyNewDec(2180), + }, + } + voteExt1Bytes, err := json.Marshal(voteExt1) + require.NoError(t, err) + voteExt2Bytes, err := json.Marshal(voteExt2) + require.NoError(t, err) + marshalDelimitedFn := func(msg proto.Message) ([]byte, error) { + var buf bytes.Buffer + if err := protoio.NewDelimitedWriter(&buf).WriteMsg(msg); err != nil { + return nil, err + } + + return buf.Bytes(), nil + } + + cve := cmtproto.CanonicalVoteExtension{ + Extension: voteExt1Bytes, + Height: 3 - 1, // the vote extension was signed in the previous height + Round: 1, + ChainId: input.Ctx.ChainID(), + } + + ext1SignBytes, err := marshalDelimitedFn(&cve) + require.NoError(t, err) + + signature1, err := ValPrivKeys[0].Sign(ext1SignBytes) + require.NoError(t, err) + + cve = cmtproto.CanonicalVoteExtension{ + Extension: voteExt2Bytes, + Height: 3 - 1, // the vote extension was signed in the previous height + Round: 1, + ChainId: input.Ctx.ChainID(), + } + + ext2SignBytes, err := marshalDelimitedFn(&cve) + require.NoError(t, err) + + signature2, err := ValPrivKeys[1].Sign(ext2SignBytes) + require.NoError(t, err) + + localLastCommit := cometabci.ExtendedCommitInfo{ + Round: 1, + Votes: []cometabci.ExtendedVoteInfo{ + { + BlockIdFlag: cmtproto.BlockIDFlagCommit, + Validator: cometabci.Validator{ + Address: ValPubKeys[0].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt1Bytes, + ExtensionSignature: signature1, + }, + { + BlockIdFlag: cmtproto.BlockIDFlagCommit, + Validator: cometabci.Validator{ + Address: ValPubKeys[1].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt2Bytes, + ExtensionSignature: signature2, + }, + }, + } + + // Invalid missMap calculation + injectedVoteExtTx := abci.StakeWeightedPrices{ + StakeWeightedPrices: map[string]math.LegacyDec{ + "ETH": math.LegacyNewDec(2180), + "BTC": math.LegacyNewDec(25000), + }, + ExtendedCommitInfo: localLastCommit, + MissCounter: map[string]sdk.ValAddress{ + ValAddrs[1].String(): ValAddrs[1], + }, + } + injectedBytes, err := json.Marshal(injectedVoteExtTx) + require.NoError(t, err) + + res, err := handler(input.Ctx, &cometabci.RequestProcessProposal{ + Txs: [][]byte{injectedBytes}, + ProposedLastCommit: cometabci.CommitInfo{}, + Misbehavior: []cometabci.Misbehavior{}, + Hash: []byte{}, + Height: 3, + Time: time.Time{}, + NextValidatorsHash: []byte{}, + ProposerAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, res.Status, cometabci.ResponseProcessProposal_REJECT) + + // Invalid stake weighted prices calculation + injectedVoteExtTx = abci.StakeWeightedPrices{ + StakeWeightedPrices: map[string]math.LegacyDec{ + "ETH": math.LegacyNewDec(2180), + "BTC": math.LegacyNewDec(25500), + }, + ExtendedCommitInfo: localLastCommit, + MissCounter: map[string]sdk.ValAddress{ + ValAddrs[2].String(): ValAddrs[2], + }, + } + injectedBytes, err = json.Marshal(injectedVoteExtTx) + require.NoError(t, err) + + res, err = handler(input.Ctx, &cometabci.RequestProcessProposal{ + Txs: [][]byte{injectedBytes}, + ProposedLastCommit: cometabci.CommitInfo{}, + Misbehavior: []cometabci.Misbehavior{}, + Hash: []byte{}, + Height: 3, + Time: time.Time{}, + NextValidatorsHash: []byte{}, + ProposerAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, res.Status, cometabci.ResponseProcessProposal_REJECT) + + // Empty txs + res, err = handler(input.Ctx, &cometabci.RequestProcessProposal{ + Txs: [][]byte{}, + ProposedLastCommit: cometabci.CommitInfo{}, + Misbehavior: []cometabci.Misbehavior{}, + Hash: []byte{}, + Height: 3, + Time: time.Time{}, + NextValidatorsHash: []byte{}, + ProposerAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, res.Status, cometabci.ResponseProcessProposal_ACCEPT) + + // Not decode-able last tx + res, err = handler(input.Ctx, &cometabci.RequestProcessProposal{ + Txs: [][]byte{{0x0}}, + ProposedLastCommit: cometabci.CommitInfo{}, + Misbehavior: []cometabci.Misbehavior{}, + Hash: []byte{}, + Height: 3, + Time: time.Time{}, + NextValidatorsHash: []byte{}, + ProposerAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, res.Status, cometabci.ResponseProcessProposal_ACCEPT) + + // Accurate vote extension + injectedVoteExtTx = abci.StakeWeightedPrices{ + StakeWeightedPrices: map[string]math.LegacyDec{ + "ETH": math.LegacyNewDec(2180), + "BTC": math.LegacyNewDec(25000), + }, + ExtendedCommitInfo: localLastCommit, + MissCounter: map[string]sdk.ValAddress{ + ValAddrs[2].String(): ValAddrs[2], + }, + } + injectedBytes, err = json.Marshal(injectedVoteExtTx) + require.NoError(t, err) + + res, err = handler(input.Ctx, &cometabci.RequestProcessProposal{ + Txs: [][]byte{injectedBytes}, + ProposedLastCommit: cometabci.CommitInfo{}, + Misbehavior: []cometabci.Misbehavior{}, + Hash: []byte{}, + Height: 3, + Time: time.Time{}, + NextValidatorsHash: []byte{}, + ProposerAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, res.Status, cometabci.ResponseProcessProposal_ACCEPT) +} + +func TestPreBlocker(t *testing.T) { + input, h := SetupTest(t) + + input.OracleKeeper.SetOraclePrices(input.Ctx, map[string]math.LegacyDec{ + "LTC": math.LegacyNewDec(100), + }) + _, err := input.OracleKeeper.GetExchangeRate(input.Ctx, "LTC") + require.NoError(t, err) + + consParams := input.Ctx.ConsensusParams() + consParams.Abci = &cmtproto.ABCIParams{ + VoteExtensionsEnableHeight: 2, + } + input.Ctx = input.Ctx.WithConsensusParams(consParams) + + // Valid vote extension data + voteExt1 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25000), + "ETH": math.LegacyNewDec(2200), + }, + } + voteExt2 := abci.OracleVoteExtension{ + Height: 1, + Prices: map[string]math.LegacyDec{ + "BTC": math.LegacyNewDec(25030), + "ETH": math.LegacyNewDec(2180), + }, + } + voteExt1Bytes, err := json.Marshal(voteExt1) + require.NoError(t, err) + voteExt2Bytes, err := json.Marshal(voteExt2) + require.NoError(t, err) + marshalDelimitedFn := func(msg proto.Message) ([]byte, error) { + var buf bytes.Buffer + if err := protoio.NewDelimitedWriter(&buf).WriteMsg(msg); err != nil { + return nil, err + } + + return buf.Bytes(), nil + } + + cve := cmtproto.CanonicalVoteExtension{ + Extension: voteExt1Bytes, + Height: 3 - 1, // the vote extension was signed in the previous height + Round: 1, + ChainId: input.Ctx.ChainID(), + } + + ext1SignBytes, err := marshalDelimitedFn(&cve) + require.NoError(t, err) + + signature1, err := ValPrivKeys[0].Sign(ext1SignBytes) + require.NoError(t, err) + + cve = cmtproto.CanonicalVoteExtension{ + Extension: voteExt2Bytes, + Height: 3 - 1, // the vote extension was signed in the previous height + Round: 1, + ChainId: input.Ctx.ChainID(), + } + + ext2SignBytes, err := marshalDelimitedFn(&cve) + require.NoError(t, err) + + signature2, err := ValPrivKeys[1].Sign(ext2SignBytes) + require.NoError(t, err) + + localLastCommit := cometabci.ExtendedCommitInfo{ + Round: 1, + Votes: []cometabci.ExtendedVoteInfo{ + { + BlockIdFlag: cmtproto.BlockIDFlagCommit, + Validator: cometabci.Validator{ + Address: ValPubKeys[0].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt1Bytes, + ExtensionSignature: signature1, + }, + { + BlockIdFlag: cmtproto.BlockIDFlagCommit, + Validator: cometabci.Validator{ + Address: ValPubKeys[1].Address().Bytes(), + Power: 1, + }, + VoteExtension: voteExt2Bytes, + ExtensionSignature: signature2, + }, + }, + } + + // Accurate vote extension + injectedVoteExtTx := abci.StakeWeightedPrices{ + StakeWeightedPrices: map[string]math.LegacyDec{ + "ETH": math.LegacyNewDec(2180), + "BTC": math.LegacyNewDec(25000), + }, + ExtendedCommitInfo: localLastCommit, + MissCounter: map[string]sdk.ValAddress{ + ValAddrs[2].String(): ValAddrs[2], + }, + } + injectedBytes, err := json.Marshal(injectedVoteExtTx) + require.NoError(t, err) + + res, err := h.PreBlocker(input.Ctx, &cometabci.RequestFinalizeBlock{ + Txs: [][]byte{injectedBytes}, + DecidedLastCommit: cometabci.CommitInfo{}, + Misbehavior: []cometabci.Misbehavior{}, + Hash: []byte{}, + Height: 3, + Time: time.Time{}, + NextValidatorsHash: []byte{}, + ProposerAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, res.ConsensusParamsChanged, false) + + ethPrice, err := input.OracleKeeper.GetExchangeRate(input.Ctx, "ETH") + require.NoError(t, err) + require.Equal(t, ethPrice.String(), injectedVoteExtTx.StakeWeightedPrices["ETH"].String()) + btcPrice, err := input.OracleKeeper.GetExchangeRate(input.Ctx, "BTC") + require.NoError(t, err) + require.Equal(t, btcPrice.String(), injectedVoteExtTx.StakeWeightedPrices["BTC"].String()) + _, err = input.OracleKeeper.GetExchangeRate(input.Ctx, "LTC") + require.Error(t, err) + + val0MissCount := input.OracleKeeper.GetMissCounter(input.Ctx, ValAddrs[0]) + require.Equal(t, val0MissCount, uint64(0)) + val1MissCount := input.OracleKeeper.GetMissCounter(input.Ctx, ValAddrs[1]) + require.Equal(t, val1MissCount, uint64(0)) + val2MissCount := input.OracleKeeper.GetMissCounter(input.Ctx, ValAddrs[2]) + require.Equal(t, val2MissCount, uint64(1)) +} diff --git a/x/oracle/abci/vote_extensions.go b/x/oracle/abci/vote_extensions.go new file mode 100644 index 00000000..393bb751 --- /dev/null +++ b/x/oracle/abci/vote_extensions.go @@ -0,0 +1,134 @@ +package abci + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "time" + + "cosmossdk.io/log" + "cosmossdk.io/math" + "github.com/Team-Kujira/core/x/oracle/keeper" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type VoteExtHandler struct { + logger log.Logger + currentBlock int64 // current block height + lastPriceSyncTS time.Time // last time we synced prices + + Keeper keeper.Keeper +} + +func NewVoteExtHandler( + logger log.Logger, + keeper keeper.Keeper, +) *VoteExtHandler { + return &VoteExtHandler{ + logger: logger, + Keeper: keeper, + } +} + +// OracleVoteExtension defines the canonical vote extension structure. +type OracleVoteExtension struct { + Height int64 + Prices map[string]math.LegacyDec +} + +type PricesResponse struct { + Prices map[string]math.LegacyDec `json:"prices"` +} + +func (h *VoteExtHandler) ExtendVoteHandler(oracleConfig OracleConfig) sdk.ExtendVoteHandler { + return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + h.currentBlock = req.Height + h.lastPriceSyncTS = time.Now() + + h.logger.Info("computing oracle prices for vote extension", "height", req.Height, "time", h.lastPriceSyncTS, "endpoint", oracleConfig.Endpoint) + + emptyVoteExt := OracleVoteExtension{ + Height: req.Height, + Prices: map[string]math.LegacyDec{}, + } + + // Encode vote extension to bytes + emptyVoteExtBz, err := json.Marshal(emptyVoteExt) + if err != nil { + return nil, fmt.Errorf("failed to marshal vote extension: %w", err) + } + + res, err := http.Get(oracleConfig.Endpoint) + if err != nil { + h.logger.Error("failed to query endpoint", err) + return &abci.ResponseExtendVote{VoteExtension: emptyVoteExtBz}, nil + } + defer res.Body.Close() + + resBody, err := io.ReadAll(res.Body) + if err != nil { + h.logger.Error("failed to read response body", err) + return &abci.ResponseExtendVote{VoteExtension: emptyVoteExtBz}, nil + } + + prices := PricesResponse{} + err = json.Unmarshal(resBody, &prices) + if err != nil { + h.logger.Error("failed to unmarshal prices", err) + return &abci.ResponseExtendVote{VoteExtension: emptyVoteExtBz}, nil + } + + computedPrices := prices.Prices + + // produce a canonical vote extension + voteExt := OracleVoteExtension{ + Height: req.Height, + Prices: computedPrices, + } + + h.logger.Info("computed prices", "prices", computedPrices) + + // Encode vote extension to bytes + bz, err := json.Marshal(voteExt) + if err != nil { + return nil, fmt.Errorf("failed to marshal vote extension: %w", err) + } + + return &abci.ResponseExtendVote{VoteExtension: bz}, nil + } +} + +func (h *VoteExtHandler) VerifyVoteExtensionHandler(_ OracleConfig) sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + var voteExt OracleVoteExtension + + if len(req.VoteExtension) == 0 { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } + + err := json.Unmarshal(req.VoteExtension, &voteExt) + if err != nil { + // NOTE: It is safe to return an error as the Cosmos SDK will capture all + // errors, log them, and reject the proposal. + return nil, fmt.Errorf("failed to unmarshal vote extension: %w", err) + } + + if voteExt.Height != req.Height { + return nil, fmt.Errorf("vote extension height does not match request height; expected: %d, got: %d", req.Height, voteExt.Height) + } + + // Verify incoming prices from a validator are valid. Note, verification during + // VerifyVoteExtensionHandler MUST be deterministic. + if err := h.verifyOraclePrices(ctx, voteExt.Prices); err != nil { + return nil, fmt.Errorf("failed to verify oracle prices from validator %X: %w", req.ValidatorAddress, err) + } + + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} + +func (h *VoteExtHandler) verifyOraclePrices(_ sdk.Context, _ map[string]math.LegacyDec) error { + return nil +} diff --git a/x/oracle/abci/vote_extensions_test.go b/x/oracle/abci/vote_extensions_test.go new file mode 100644 index 00000000..3a5d617c --- /dev/null +++ b/x/oracle/abci/vote_extensions_test.go @@ -0,0 +1,82 @@ +package abci_test + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/Team-Kujira/core/x/oracle/abci" + "github.com/Team-Kujira/core/x/oracle/keeper" + cometabci "github.com/cometbft/cometbft/abci/types" + "github.com/stretchr/testify/require" +) + +func TestDecoding(t *testing.T) { + resBody := []byte(`{"prices":{"BTC":"47375.706652541026694000","ETH":"2649.328939436595054949","USDT":"1.000661260343873178"}}`) + prices := abci.PricesResponse{} + err := json.Unmarshal(resBody, &prices) + require.NoError(t, err) +} + +func TestExtendVoteHandler(t *testing.T) { + input := keeper.CreateTestInput(t) + + testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + res.WriteHeader(http.StatusOK) + res.Write([]byte(`{"prices":{"BTC":"47375.706652541026694000","ETH":"2649.328939436595054949","USDT":"1.000661260343873178"}}`)) + })) + defer func() { testServer.Close() }() + + h := abci.NewVoteExtHandler(input.Ctx.Logger(), input.OracleKeeper) + handler := h.ExtendVoteHandler(abci.OracleConfig{ + Endpoint: testServer.URL, + }) + res, err := handler(input.Ctx, &cometabci.RequestExtendVote{ + Hash: []byte{}, + Height: 3, + Time: time.Time{}, + Txs: [][]byte{}, + ProposedLastCommit: cometabci.CommitInfo{}, + Misbehavior: []cometabci.Misbehavior{}, + NextValidatorsHash: []byte{}, + ProposerAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, string(res.VoteExtension), `{"Height":3,"Prices":{"BTC":"47375.706652541026694000","ETH":"2649.328939436595054949","USDT":"1.000661260343873178"}}`) +} + +func TestVerifyVoteExtensionHandler(t *testing.T) { + input := keeper.CreateTestInput(t) + + testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + res.WriteHeader(http.StatusOK) + res.Write([]byte(`{"prices":{"BTC":"47375.706652541026694000","ETH":"2649.328939436595054949","USDT":"1.000661260343873178"}}`)) + })) + defer func() { testServer.Close() }() + + h := abci.NewVoteExtHandler(input.Ctx.Logger(), input.OracleKeeper) + handler := h.VerifyVoteExtensionHandler(abci.OracleConfig{ + Endpoint: testServer.URL, + }) + + // Height's same + res, err := handler(input.Ctx, &cometabci.RequestVerifyVoteExtension{ + Hash: []byte{}, + Height: 3, + VoteExtension: []byte(`{"Height":3,"Prices":{"BTC":"47375.706652541026694000","ETH":"2649.328939436595054949","USDT":"1.000661260343873178"}}`), + ValidatorAddress: []byte{}, + }) + require.NoError(t, err) + require.Equal(t, res.Status, cometabci.ResponseVerifyVoteExtension_ACCEPT) + + // Height different case + _, err = handler(input.Ctx, &cometabci.RequestVerifyVoteExtension{ + Hash: []byte{}, + Height: 2, + VoteExtension: []byte(`{"Height":3,"Prices":{"BTC":"47375.706652541026694000","ETH":"2649.328939436595054949","USDT":"1.000661260343873178"}}`), + ValidatorAddress: []byte{}, + }) + require.Error(t, err) +} diff --git a/x/oracle/abci_test.go b/x/oracle/abci_test.go deleted file mode 100644 index 75cf9de2..00000000 --- a/x/oracle/abci_test.go +++ /dev/null @@ -1,539 +0,0 @@ -package oracle_test - -import ( - "fmt" - "math" - "sort" - "testing" - - sdkmath "cosmossdk.io/math" - "github.com/cometbft/cometbft/libs/rand" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/require" - - "github.com/Team-Kujira/core/x/oracle/keeper" - "github.com/Team-Kujira/core/x/oracle/types" -) - -func TestOracleThreshold(t *testing.T) { - input, h := setup(t) - exchangeRateStr := randomExchangeRate.String() + types.TestDenomD - - // Case 1. - // Less than the threshold signs, exchange rate consensus fails - salt := "fc5bb0bc63e54b2918d9334bf3259f5dc575e8d7a4df4e836dd80f1ad62aa89b" - hash := types.GetAggregateVoteHash(salt, exchangeRateStr, keeper.ValAddrs[0]) - prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, keeper.Addrs[0], keeper.ValAddrs[0]) - voteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, keeper.Addrs[0], keeper.ValAddrs[0]) - - _, err1 := h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(0), prevoteMsg) - _, err2 := h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err1) - require.NoError(t, err2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - _, err := input.OracleKeeper.GetExchangeRate(input.Ctx.WithBlockHeight(1), types.TestDenomD) - require.Error(t, err) - - // Case 2. - // More than the threshold signs, exchange rate consensus succeeds - salt = "fc5bb0bc63e54b2918d9334bf3259f5dc575e8d7a4df4e836dd80f1ad62aa89b" - hash = types.GetAggregateVoteHash(salt, exchangeRateStr, keeper.ValAddrs[0]) - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, keeper.Addrs[0], keeper.ValAddrs[0]) - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, keeper.Addrs[0], keeper.ValAddrs[0]) - - _, err1 = h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(0), prevoteMsg) - _, err2 = h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err1) - require.NoError(t, err2) - - salt = "4c81c928f466a08b07171def7aeb2b3c266df7bb7486158a15a2291a7d55c8f9" - hash = types.GetAggregateVoteHash(salt, exchangeRateStr, keeper.ValAddrs[1]) - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, keeper.Addrs[1], keeper.ValAddrs[1]) - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, keeper.Addrs[1], keeper.ValAddrs[1]) - - _, err1 = h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(0), prevoteMsg) - _, err2 = h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err1) - require.NoError(t, err2) - - salt = "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80" - hash = types.GetAggregateVoteHash(salt, exchangeRateStr, keeper.ValAddrs[2]) - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, keeper.Addrs[2], keeper.ValAddrs[2]) - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, keeper.Addrs[2], keeper.ValAddrs[2]) - - _, err1 = h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(0), prevoteMsg) - _, err2 = h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err1) - require.NoError(t, err2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - rate, err := input.OracleKeeper.GetExchangeRate(input.Ctx.WithBlockHeight(1), types.TestDenomD) - require.NoError(t, err) - require.Equal(t, randomExchangeRate, rate) - - // Case 3. - // Increase voting power of absent validator, exchange rate consensus fails - val, _ := input.StakingKeeper.GetValidator(input.Ctx, keeper.ValAddrs[2]) - input.StakingKeeper.Delegate(input.Ctx.WithBlockHeight(0), keeper.Addrs[2], stakingAmt.MulRaw(3), stakingtypes.Unbonded, val, false) - - salt = "fc5bb0bc63e54b2918d9334bf3259f5dc575e8d7a4df4e836dd80f1ad62aa89b" - hash = types.GetAggregateVoteHash(salt, exchangeRateStr, keeper.ValAddrs[0]) - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, keeper.Addrs[0], keeper.ValAddrs[0]) - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, keeper.Addrs[0], keeper.ValAddrs[0]) - - _, err1 = h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(0), prevoteMsg) - _, err2 = h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err1) - require.NoError(t, err2) - - salt = "4c81c928f466a08b07171def7aeb2b3c266df7bb7486158a15a2291a7d55c8f9" - hash = types.GetAggregateVoteHash(salt, exchangeRateStr, keeper.ValAddrs[1]) - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, keeper.Addrs[1], keeper.ValAddrs[1]) - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, keeper.Addrs[1], keeper.ValAddrs[1]) - - _, err1 = h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(0), prevoteMsg) - _, err2 = h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err1) - require.NoError(t, err2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - _, err = input.OracleKeeper.GetExchangeRate(input.Ctx.WithBlockHeight(1), types.TestDenomD) - require.Error(t, err) -} - -func TestOracleDrop(t *testing.T) { - input, h := setup(t) - - input.OracleKeeper.SetExchangeRate(input.Ctx, types.TestDenomC, randomExchangeRate) - - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 0) - - // Immediately swap halt after an illiquid oracle vote - input.OracleKeeper.EndBlocker(input.Ctx) - - _, err := input.OracleKeeper.GetExchangeRate(input.Ctx, types.TestDenomC) - require.Error(t, err) -} - -func TestOracleTally(t *testing.T) { - input, _ := setup(t) - - ballot := types.ExchangeRateBallot{} - rates, valAddrs, stakingKeeper := types.GenerateRandomTestCase() - input.OracleKeeper.StakingKeeper = stakingKeeper - h := keeper.NewMsgServerImpl(input.OracleKeeper) - for i, rate := range rates { - - decExchangeRate := sdkmath.LegacyNewDecWithPrec(int64(rate*math.Pow10(keeper.OracleDecPrecision)), int64(keeper.OracleDecPrecision)) - exchangeRateStr := decExchangeRate.String() + types.TestDenomD - - salt := fmt.Sprintf("%d", i) - hash := types.GetAggregateVoteHash(salt, exchangeRateStr, valAddrs[i]) - prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, sdk.AccAddress(valAddrs[i]), valAddrs[i]) - voteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, sdk.AccAddress(valAddrs[i]), valAddrs[i]) - - _, err1 := h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(0), prevoteMsg) - _, err2 := h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err1) - require.NoError(t, err2) - - power := stakingAmt.QuoRaw(types.MicroUnit).Int64() - if decExchangeRate.IsZero() { - power = int64(0) - } - - vote := types.NewVoteForTally( - decExchangeRate, types.TestDenomD, valAddrs[i], power) - ballot = append(ballot, vote) - - // change power of every three validator - if i%3 == 0 { - stakingKeeper.Validators()[i].SetConsensusPower(int64(i + 1)) - } - } - - validatorClaimMap := make(map[string]types.Claim) - for _, valAddr := range valAddrs { - val, _ := stakingKeeper.Validator(input.Ctx, valAddr) - validatorClaimMap[valAddr.String()] = types.Claim{ - Power: val.GetConsensusPower(sdk.DefaultPowerReduction), - Weight: int64(0), - WinCount: int64(0), - Recipient: valAddr, - } - } - sort.Sort(ballot) - weightedMedian, _ := ballot.WeightedMedian() - standardDeviation, _ := ballot.StandardDeviation() - maxSpread := weightedMedian.Mul(input.OracleKeeper.MaxDeviation(input.Ctx)) - - if standardDeviation.GT(maxSpread) { - maxSpread = standardDeviation - } - - expectedValidatorClaimMap := make(map[string]types.Claim) - for _, valAddr := range valAddrs { - val, _ := stakingKeeper.Validator(input.Ctx, valAddr) - expectedValidatorClaimMap[valAddr.String()] = types.Claim{ - Power: val.GetConsensusPower(sdk.DefaultPowerReduction), - Weight: int64(0), - WinCount: int64(0), - Recipient: valAddr, - } - } - - for _, vote := range ballot { - if (vote.ExchangeRate.GTE(weightedMedian.Sub(maxSpread)) && - vote.ExchangeRate.LTE(weightedMedian.Add(maxSpread))) || - !vote.ExchangeRate.IsPositive() { - key := vote.Voter.String() - claim := expectedValidatorClaimMap[key] - claim.Weight += vote.Power - claim.WinCount++ - expectedValidatorClaimMap[key] = claim - } - } - - missMap := map[string]sdk.ValAddress{} - - tallyMedian, _ := keeper.Tally(input.Ctx, ballot, input.OracleKeeper.MaxDeviation(input.Ctx), validatorClaimMap, missMap) - - require.Equal(t, validatorClaimMap, expectedValidatorClaimMap) - require.Equal(t, tallyMedian.MulInt64(100).TruncateInt(), weightedMedian.MulInt64(100).TruncateInt()) -} - -func TestOracleTallyTiming(t *testing.T) { - input, h := setup(t) - - // all the keeper.Addrs vote for the block ... not last period block yet, so tally fails - for i := range keeper.Addrs[:2] { - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomD, Amount: randomExchangeRate}}, i) - } - - params := input.OracleKeeper.GetParams(input.Ctx) - params.VotePeriod = 10 // set vote period to 10 for now, for convenience - input.OracleKeeper.SetParams(input.Ctx, params) - require.Equal(t, 0, int(input.Ctx.BlockHeight())) - - input.OracleKeeper.EndBlocker(input.Ctx) - _, err := input.OracleKeeper.GetExchangeRate(input.Ctx, types.TestDenomD) - require.Error(t, err) - - input.Ctx = input.Ctx.WithBlockHeight(int64(params.VotePeriod - 1)) - - input.OracleKeeper.EndBlocker(input.Ctx) - _, err = input.OracleKeeper.GetExchangeRate(input.Ctx, types.TestDenomD) - require.NoError(t, err) -} - -func TestOracleRewardBand(t *testing.T) { - input, h := setup(t) - params := input.OracleKeeper.GetParams(input.Ctx) - params.RequiredDenoms = []string{types.TestDenomC} - input.OracleKeeper.SetParams(input.Ctx, params) - - rewardSpread := randomExchangeRate.Mul(input.OracleKeeper.MaxDeviation(input.Ctx)) - - // no one will miss the vote - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Sub(rewardSpread)}}, 0) - - // Account 2, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 1) - - // Account 3, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Add(rewardSpread)}}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) - - // Account 1 will miss the vote due to raward band condition - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Sub(rewardSpread.Add(sdkmath.LegacyOneDec()))}}, 0) - - // Account 2, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 1) - - // Account 3, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Add(rewardSpread)}}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) - - // no one will miss the vote if someone submits an extra denom - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Sub(rewardSpread)}}, 0) - - // Account 2, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 1) - - // Account 3, DenomC + Denom D - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{ - {Denom: types.TestDenomC, Amount: randomExchangeRate.Add(rewardSpread)}, - {Denom: types.TestDenomE, Amount: randomExchangeRate.Add(rewardSpread)}, - }, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) - - // no one will miss the vote if there is threshold of an extra denom - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Sub(rewardSpread)}}, 0) - - // Account 2, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{ - {Denom: types.TestDenomC, Amount: randomExchangeRate}, - {Denom: types.TestDenomE, Amount: randomExchangeRate.Add(rewardSpread)}, - }, 1) - - // Account 3, DenomC + Denom D - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{ - {Denom: types.TestDenomC, Amount: randomExchangeRate.Add(rewardSpread)}, - {Denom: types.TestDenomE, Amount: randomExchangeRate.Add(rewardSpread)}, - }, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) -} - -func TestOracleEnsureSorted(t *testing.T) { - input, h := setup(t) - - for i := 0; i < 100; i++ { - exchangeRateA1 := sdkmath.LegacyNewDecWithPrec(int64(rand.Uint64()%100000000), 6).MulInt64(types.MicroUnit) - exchangeRateB1 := sdkmath.LegacyNewDecWithPrec(int64(rand.Uint64()%100000000), 6).MulInt64(types.MicroUnit) - - exchangeRateA2 := sdkmath.LegacyNewDecWithPrec(int64(rand.Uint64()%100000000), 6).MulInt64(types.MicroUnit) - exchangeRateB2 := sdkmath.LegacyNewDecWithPrec(int64(rand.Uint64()%100000000), 6).MulInt64(types.MicroUnit) - - exchangeRateA3 := sdkmath.LegacyNewDecWithPrec(int64(rand.Uint64()%100000000), 6).MulInt64(types.MicroUnit) - exchangeRateB3 := sdkmath.LegacyNewDecWithPrec(int64(rand.Uint64()%100000000), 6).MulInt64(types.MicroUnit) - - // Account 1, DenomB, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomB, Amount: exchangeRateB1}, {Denom: types.TestDenomC, Amount: exchangeRateA1}}, 0) - - // Account 2, DenomB, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomB, Amount: exchangeRateB2}, {Denom: types.TestDenomC, Amount: exchangeRateA2}}, 1) - - // Account 3, DenomB, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomB, Amount: exchangeRateA3}, {Denom: types.TestDenomC, Amount: exchangeRateB3}}, 2) - - require.NotPanics(t, func() { - input.OracleKeeper.EndBlocker(input.Ctx) - }) - } -} - -func TestInvalidVotesSlashing(t *testing.T) { - input, h := setup(t) - params := input.OracleKeeper.GetParams(input.Ctx) - params.RequiredDenoms = []string{types.TestDenomC} - input.OracleKeeper.SetParams(input.Ctx, params) - - votePeriodsPerWindow := sdkmath.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))).QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))).TruncateInt64() - slashFraction := input.OracleKeeper.SlashFraction(input.Ctx) - minValidPerWindow := input.OracleKeeper.MinValidPerWindow(input.Ctx) - - for i := uint64(0); i < uint64(sdkmath.LegacyOneDec().Sub(minValidPerWindow).MulInt64(votePeriodsPerWindow).TruncateInt64()); i++ { - input.Ctx = input.Ctx.WithBlockHeight(input.Ctx.BlockHeight() + 1) - - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 0) - - // Account 2, DenomC, miss vote - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Add(sdkmath.LegacyNewDec(100000000000000))}}, 1) - - // Account 3, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - require.Equal(t, i+1, input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - } - - validator, _ := input.StakingKeeper.Validator(input.Ctx, keeper.ValAddrs[1]) - require.Equal(t, stakingAmt, validator.GetBondedTokens()) - - // one more miss vote will inccur keeper.ValAddrs[1] slashing - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 0) - - // Account 2, DenomC, miss vote - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate.Add(sdkmath.LegacyNewDec(100000000000000))}}, 1) - - // Account 3, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 2) - - input.Ctx = input.Ctx.WithBlockHeight(votePeriodsPerWindow - 1) - input.OracleKeeper.EndBlocker(input.Ctx) - validator, _ = input.StakingKeeper.Validator(input.Ctx, keeper.ValAddrs[1]) - require.Equal(t, sdkmath.LegacyOneDec().Sub(slashFraction).MulInt(stakingAmt).TruncateInt(), validator.GetBondedTokens()) -} - -func TestRequiredDenomsSlashing(t *testing.T) { - input, h := setup(t) - - votePeriodsPerWindow := sdkmath.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))).QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))).TruncateInt64() - slashFraction := input.OracleKeeper.SlashFraction(input.Ctx) - minValidPerWindow := input.OracleKeeper.MinValidPerWindow(input.Ctx) - - for i := uint64(0); i < uint64(sdkmath.LegacyOneDec().Sub(minValidPerWindow).MulInt64(votePeriodsPerWindow).TruncateInt64()); i++ { - input.Ctx = input.Ctx.WithBlockHeight(input.Ctx.BlockHeight() + 1) - - // Account 2, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 1) - // Account 3, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - require.Equal(t, i+1, input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - } - - validator, _ := input.StakingKeeper.Validator(input.Ctx, keeper.ValAddrs[0]) - require.Equal(t, stakingAmt, validator.GetBondedTokens()) - - // one more miss vote will inccur Account 1 slashing - - // Account 2, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 1) - // Account 3, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 2) - - input.Ctx = input.Ctx.WithBlockHeight(votePeriodsPerWindow - 1) - input.OracleKeeper.EndBlocker(input.Ctx) - validator, _ = input.StakingKeeper.Validator(input.Ctx, keeper.ValAddrs[0]) - require.Equal(t, sdkmath.LegacyOneDec().Sub(slashFraction).MulInt(stakingAmt).TruncateInt(), validator.GetBondedTokens()) -} - -func TestNotPassedBallotSlashing(t *testing.T) { - input, h := setup(t) - params := input.OracleKeeper.GetParams(input.Ctx) - params.RequiredDenoms = []string{types.TestDenomC} - input.OracleKeeper.SetParams(input.Ctx, params) - - input.Ctx = input.Ctx.WithBlockHeight(input.Ctx.BlockHeight() + 1) - - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 0) - - input.OracleKeeper.EndBlocker(input.Ctx) - // Not slashing accounts that have voted - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) -} - -func TestAbstainSlashing(t *testing.T) { - input, h := setup(t) - params := input.OracleKeeper.GetParams(input.Ctx) - params.RequiredDenoms = []string{types.TestDenomC} - input.OracleKeeper.SetParams(input.Ctx, params) - - votePeriodsPerWindow := sdkmath.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))).QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))).TruncateInt64() - minValidPerWindow := input.OracleKeeper.MinValidPerWindow(input.Ctx) - - for i := uint64(0); i <= uint64(sdkmath.LegacyOneDec().Sub(minValidPerWindow).MulInt64(votePeriodsPerWindow).TruncateInt64()); i++ { - input.Ctx = input.Ctx.WithBlockHeight(input.Ctx.BlockHeight() + 1) - - // Account 1, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 0) - - // Account 2, DenomC, abstain vote - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: sdkmath.LegacyZeroDec()}}, 1) - - // Account 3, DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - require.Equal(t, uint64(0), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - } - - validator, _ := input.StakingKeeper.Validator(input.Ctx, keeper.ValAddrs[1]) - require.Equal(t, stakingAmt, validator.GetBondedTokens()) -} - -func TestVoteTargets(t *testing.T) { - input, h := setup(t) - params := input.OracleKeeper.GetParams(input.Ctx) - params.RequiredDenoms = []string{types.TestDenomC, types.TestDenomD} - input.OracleKeeper.SetParams(input.Ctx, params) - - // DenomC - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 0) - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 1) - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - // missed D - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(1), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) - - // delete DenomD - params.RequiredDenoms = []string{types.TestDenomC} - input.OracleKeeper.SetParams(input.Ctx, params) - - // DenomC, missing - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{}, 0) - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{}, 1) - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - require.Equal(t, uint64(2), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(2), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(2), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) - - // DenomC, no missing - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 0) - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 1) - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: randomExchangeRate}}, 2) - - input.OracleKeeper.EndBlocker(input.Ctx) - - require.Equal(t, uint64(2), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[0])) - require.Equal(t, uint64(2), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[1])) - require.Equal(t, uint64(2), input.OracleKeeper.GetMissCounter(input.Ctx, keeper.ValAddrs[2])) -} - -func TestAbstainWithSmallStakingPower(t *testing.T) { - input, h := setupWithSmallVotingPower(t) - - makeAggregatePrevoteAndVote(t, input, h, 0, sdk.DecCoins{{Denom: types.TestDenomC, Amount: sdkmath.LegacyZeroDec()}}, 0) - - input.OracleKeeper.EndBlocker(input.Ctx) - _, err := input.OracleKeeper.GetExchangeRate(input.Ctx, types.TestDenomC) - require.Error(t, err) -} - -func makeAggregatePrevoteAndVote(t *testing.T, input keeper.TestInput, h types.MsgServer, height int64, rates sdk.DecCoins, idx int) { - // Account 1, DenomD - salt := "fc5bb0bc63e54b2918d9334bf3259f5dc575e8d7a4df4e836dd80f1ad62aa89b" - hash := types.GetAggregateVoteHash(salt, rates.String(), keeper.ValAddrs[idx]) - - prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, keeper.Addrs[idx], keeper.ValAddrs[idx]) - _, err := h.AggregateExchangeRatePrevote(input.Ctx.WithBlockHeight(height), prevoteMsg) - require.NoError(t, err) - - voteMsg := types.NewMsgAggregateExchangeRateVote(salt, rates.String(), keeper.Addrs[idx], keeper.ValAddrs[idx]) - _, err = h.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(height+1), voteMsg) - require.NoError(t, err) -} diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index 71f31b8f..4009b61b 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -27,10 +27,7 @@ func GetQueryCmd() *cobra.Command { GetCmdQueryExchangeRates(), GetCmdQueryActives(), GetCmdQueryParams(), - GetCmdQueryFeederDelegation(), GetCmdQueryMissCounter(), - GetCmdQueryAggregatePrevote(), - GetCmdQueryAggregateVote(), ) return oracleQueryCmd @@ -96,7 +93,7 @@ Query the active list of assets recognized by the types. $ kujirad query oracle actives `), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -122,7 +119,7 @@ func GetCmdQueryParams() *cobra.Command { Use: "params", Args: cobra.NoArgs, Short: "Query the current Oracle params", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -142,46 +139,6 @@ func GetCmdQueryParams() *cobra.Command { return cmd } -// GetCmdQueryFeederDelegation implements the query feeder delegation command -func GetCmdQueryFeederDelegation() *cobra.Command { - cmd := &cobra.Command{ - Use: "feeder [validator]", - Args: cobra.ExactArgs(1), - Short: "Query the oracle feeder delegate account", - Long: strings.TrimSpace(` -Query the account the validator's oracle voting right is delegated to. - -$ kujirad query oracle feeder kujiravaloper... -`), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - valString := args[0] - validator, err := sdk.ValAddressFromBech32(valString) - if err != nil { - return err - } - - res, err := queryClient.FeederDelegation( - context.Background(), - &types.QueryFeederDelegationRequest{ValidatorAddr: validator.String()}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - return cmd -} - // GetCmdQueryMissCounter implements the query miss counter of the validator command func GetCmdQueryMissCounter() *cobra.Command { cmd := &cobra.Command{ @@ -221,115 +178,3 @@ $ kujirad query oracle miss kujiravaloper... flags.AddQueryFlagsToCmd(cmd) return cmd } - -// GetCmdQueryAggregatePrevote implements the query aggregate prevote of the validator command -func GetCmdQueryAggregatePrevote() *cobra.Command { - cmd := &cobra.Command{ - Use: "aggregate-prevotes [validator]", - Args: cobra.RangeArgs(0, 1), - Short: "Query outstanding oracle aggregate prevotes.", - Long: strings.TrimSpace(` -Query outstanding oracle aggregate prevotes. - -$ kujirad query oracle aggregate-prevotes - -Or, can filter with voter address - -$ kujirad query oracle aggregate-prevotes kujiravaloper... -`), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - if len(args) == 0 { - res, err := queryClient.AggregatePrevotes( - context.Background(), - &types.QueryAggregatePrevotesRequest{}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - } - - valString := args[0] - validator, err := sdk.ValAddressFromBech32(valString) - if err != nil { - return err - } - - res, err := queryClient.AggregatePrevote( - context.Background(), - &types.QueryAggregatePrevoteRequest{ValidatorAddr: validator.String()}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - return cmd -} - -// GetCmdQueryAggregateVote implements the query aggregate prevote of the validator command -func GetCmdQueryAggregateVote() *cobra.Command { - cmd := &cobra.Command{ - Use: "aggregate-votes [validator]", - Args: cobra.RangeArgs(0, 1), - Short: "Query outstanding oracle aggregate votes.", - Long: strings.TrimSpace(` -Query outstanding oracle aggregate vote. - -$ kujirad query oracle aggregate-votes - -Or, can filter with voter address - -$ kujirad query oracle aggregate-votes kujiravaloper... -`), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - if len(args) == 0 { - res, err := queryClient.AggregateVotes( - context.Background(), - &types.QueryAggregateVotesRequest{}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - } - - valString := args[0] - validator, err := sdk.ValAddressFromBech32(valString) - if err != nil { - return err - } - - res, err := queryClient.AggregateVote( - context.Background(), - &types.QueryAggregateVoteRequest{ValidatorAddr: validator.String()}, - ) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - return cmd -} diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index e41dee64..2aeac3f8 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -1,17 +1,7 @@ package cli import ( - "fmt" - "strings" - - "github.com/pkg/errors" - - "github.com/Team-Kujira/core/x/oracle/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" ) @@ -26,171 +16,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - oracleTxCmd.AddCommand( - GetCmdDelegateFeederPermission(), - GetCmdAggregateExchangeRatePrevote(), - GetCmdAggregateExchangeRateVote(), - ) + oracleTxCmd.AddCommand() return oracleTxCmd } - -// GetCmdDelegateFeederPermission will create a feeder permission delegation tx and sign it with the given key. -func GetCmdDelegateFeederPermission() *cobra.Command { - cmd := &cobra.Command{ - Use: "set-feeder [feeder]", - Args: cobra.ExactArgs(1), - Short: "Delegate the permission to vote for the oracle to an address", - Long: strings.TrimSpace(` -Delegate the permission to submit exchange rate votes for the oracle to an address. - -Delegation can keep your validator operator key offline and use a separate replaceable key online. - -$ kujirad tx oracle set-feeder kujira1... - -where "kujira1..." is the address you want to delegate your voting rights to. -`), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - // Get from address - voter := clientCtx.GetFromAddress() - - // The address the right is being delegated from - validator := sdk.ValAddress(voter) - - feederStr := args[0] - feeder, err := sdk.AccAddressFromBech32(feederStr) - if err != nil { - return err - } - - msgs := []sdk.Msg{types.NewMsgDelegateFeedConsent(validator, feeder)} - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// GetCmdAggregateExchangeRatePrevote will create a aggregateExchangeRatePrevote tx and sign it with the given key. -func GetCmdAggregateExchangeRatePrevote() *cobra.Command { - cmd := &cobra.Command{ - Use: "aggregate-prevote [salt] [exchange-rates] [validator]", - Args: cobra.RangeArgs(2, 3), - Short: "Submit an oracle aggregate prevote for the exchange rates", - Long: strings.TrimSpace(` -Submit an oracle aggregate prevote for the exchange rates of multiple denoms. -The purpose of aggregate prevote is to hide aggregate exchange rate vote with hash which is formatted -as hex string in SHA256("{salt}:{exchange_rate}{denom},...,{exchange_rate}{denom}:{voter}") - -# Aggregate Prevote -$ kujirad tx oracle aggregate-prevote 1234 0.1ATOM,1.001USDT - -where "ATOM,USDT" is the denominating currencies, and "0.1.0,1.001" is the exchange rates of USD from the voter's point of view. - -If voting from a voting delegate, set "validator" to the address of the validator to vote on behalf of: -$ kujirad tx oracle aggregate-prevote 1234 0.1ATOM,1.001USDT kujiravaloper1... -`), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - salt := args[0] - exchangeRatesStr := args[1] - _, err = types.ParseExchangeRateTuples(exchangeRatesStr) - if err != nil { - return fmt.Errorf("given exchange_rates {%s} is not a valid format; exchange_rate should be formatted as DecCoins; %s", exchangeRatesStr, err.Error()) - } - - // Get from address - voter := clientCtx.GetFromAddress() - - // By default the voter is voting on behalf of itself - validator := sdk.ValAddress(voter) - - // Override validator if validator is given - if len(args) == 3 { - parsedVal, err := sdk.ValAddressFromBech32(args[2]) - if err != nil { - return errors.Wrap(err, "validator address is invalid") - } - validator = parsedVal - } - - hash := types.GetAggregateVoteHash(salt, exchangeRatesStr, validator) - msgs := []sdk.Msg{types.NewMsgAggregateExchangeRatePrevote(hash, voter, validator)} - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// GetCmdAggregateExchangeRateVote will create a aggregateExchangeRateVote tx and sign it with the given key. -func GetCmdAggregateExchangeRateVote() *cobra.Command { - cmd := &cobra.Command{ - Use: "aggregate-vote [salt] [exchange-rates] [validator]", - Args: cobra.RangeArgs(2, 3), - Short: "Submit an oracle aggregate vote for the exchange_rates of Luna", - Long: strings.TrimSpace(` -Submit a aggregate vote for the exchange_rates of Luna w.r.t the input denom. Companion to a prevote submitted in the previous vote period. - -$ kujirad tx oracle aggregate-vote 1234 0.1ATOM,1.001USDT - -where "ATOM,USDT" is the denominating currencies, and "0.1.0,1.001" is the exchange rates of USD from the voter's point of view. - -"salt" should match the salt used to generate the SHA256 hex in the aggregated pre-vote. - -If voting from a voting delegate, set "validator" to the address of the validator to vote on behalf of: -$ kujirad tx oracle aggregate-vote 1234 0.1ATOM,1.001USDT kujiravaloper1.... -`), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - salt := args[0] - exchangeRatesStr := args[1] - _, err = types.ParseExchangeRateTuples(exchangeRatesStr) - if err != nil { - return fmt.Errorf("given exchange_rate {%s} is not a valid format; exchange rate should be formatted as DecCoin; %s", exchangeRatesStr, err.Error()) - } - - // Get from address - voter := clientCtx.GetFromAddress() - - // By default the voter is voting on behalf of itself - validator := sdk.ValAddress(voter) - - // Override validator if validator is given - if len(args) == 3 { - parsedVal, err := sdk.ValAddressFromBech32(args[2]) - if err != nil { - return errors.Wrap(err, "validator address is invalid") - } - validator = parsedVal - } - - msgs := []sdk.Msg{types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, voter, validator)} - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/oracle/exported/alias.go b/x/oracle/exported/alias.go deleted file mode 100644 index 42b83702..00000000 --- a/x/oracle/exported/alias.go +++ /dev/null @@ -1,11 +0,0 @@ -// DONTCOVER -// -//nolint:deadcode -package exported - -import "github.com/Team-Kujira/core/x/oracle/types" - -type ( - MsgAggregateExchangeRatePrevote = types.MsgAggregateExchangeRatePrevote - MsgAggregateExchangeRateVote = types.MsgAggregateExchangeRateVote -) diff --git a/x/oracle/genesis.go b/x/oracle/genesis.go index 9f7a227e..6b726664 100644 --- a/x/oracle/genesis.go +++ b/x/oracle/genesis.go @@ -13,20 +13,6 @@ import ( // InitGenesis initialize default parameters // and the keeper's address to pubkey map func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data *types.GenesisState) { - for _, d := range data.FeederDelegations { - voter, err := sdk.ValAddressFromBech32(d.ValidatorAddress) - if err != nil { - panic(err) - } - - feeder, err := sdk.AccAddressFromBech32(d.FeederAddress) - if err != nil { - panic(err) - } - - keeper.SetFeederDelegation(ctx, voter, feeder) - } - for _, ex := range data.ExchangeRates { keeper.SetExchangeRate(ctx, ex.Denom, ex.ExchangeRate) } @@ -40,24 +26,6 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data *types.GenesisState keeper.SetMissCounter(ctx, operator, mc.MissCounter) } - for _, ap := range data.AggregateExchangeRatePrevotes { - valAddr, err := sdk.ValAddressFromBech32(ap.Voter) - if err != nil { - panic(err) - } - - keeper.SetAggregateExchangeRatePrevote(ctx, valAddr, ap) - } - - for _, av := range data.AggregateExchangeRateVotes { - valAddr, err := sdk.ValAddressFromBech32(av.Voter) - if err != nil { - panic(err) - } - - keeper.SetAggregateExchangeRateVote(ctx, valAddr, av) - } - err := keeper.SetParams(ctx, data.Params) if err != nil { panic(err) @@ -75,14 +43,6 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data *types.GenesisState // with InitGenesis func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { params := keeper.GetParams(ctx) - feederDelegations := []types.FeederDelegation{} - keeper.IterateFeederDelegations(ctx, func(valAddr sdk.ValAddress, feederAddr sdk.AccAddress) (stop bool) { - feederDelegations = append(feederDelegations, types.FeederDelegation{ - FeederAddress: feederAddr.String(), - ValidatorAddress: valAddr.String(), - }) - return false - }) exchangeRates := []types.ExchangeRateTuple{} keeper.IterateExchangeRates(ctx, func(denom string, rate math.LegacyDec) (stop bool) { @@ -99,22 +59,7 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { return false }) - aggregateExchangeRatePrevotes := []types.AggregateExchangeRatePrevote{} - keeper.IterateAggregateExchangeRatePrevotes(ctx, func(_ sdk.ValAddress, aggregatePrevote types.AggregateExchangeRatePrevote) (stop bool) { - aggregateExchangeRatePrevotes = append(aggregateExchangeRatePrevotes, aggregatePrevote) - return false - }) - - aggregateExchangeRateVotes := []types.AggregateExchangeRateVote{} - keeper.IterateAggregateExchangeRateVotes(ctx, func(_ sdk.ValAddress, aggregateVote types.AggregateExchangeRateVote) bool { - aggregateExchangeRateVotes = append(aggregateExchangeRateVotes, aggregateVote) - return false - }) - return types.NewGenesisState(params, exchangeRates, - feederDelegations, - missCounters, - aggregateExchangeRatePrevotes, - aggregateExchangeRateVotes) + missCounters) } diff --git a/x/oracle/genesis_test.go b/x/oracle/genesis_test.go index 3394cc01..2a411e07 100644 --- a/x/oracle/genesis_test.go +++ b/x/oracle/genesis_test.go @@ -14,10 +14,7 @@ import ( func TestExportInitGenesis(t *testing.T) { input, _ := setup(t) - input.OracleKeeper.SetFeederDelegation(input.Ctx, keeper.ValAddrs[0], keeper.Addrs[1]) input.OracleKeeper.SetExchangeRate(input.Ctx, "denom", math.LegacyNewDec(123)) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, keeper.ValAddrs[0], types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{123}, keeper.ValAddrs[0], uint64(2))) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, keeper.ValAddrs[0], types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Denom: "foo", ExchangeRate: math.LegacyNewDec(123)}}, keeper.ValAddrs[0])) input.OracleKeeper.SetMissCounter(input.Ctx, keeper.ValAddrs[0], 10) genesis := oracle.ExportGenesis(input.Ctx, input.OracleKeeper) @@ -35,29 +32,6 @@ func TestInitGenesis(t *testing.T) { oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis) }) - genesis.FeederDelegations = []types.FeederDelegation{{ - FeederAddress: keeper.Addrs[0].String(), - ValidatorAddress: "invalid", - }} - - require.Panics(t, func() { - oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis) - }) - - genesis.FeederDelegations = []types.FeederDelegation{{ - FeederAddress: "invalid", - ValidatorAddress: keeper.ValAddrs[0].String(), - }} - - require.Panics(t, func() { - oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis) - }) - - genesis.FeederDelegations = []types.FeederDelegation{{ - FeederAddress: keeper.Addrs[0].String(), - ValidatorAddress: keeper.ValAddrs[0].String(), - }} - genesis.MissCounters = []types.MissCounter{ { ValidatorAddress: "invalid", @@ -76,54 +50,6 @@ func TestInitGenesis(t *testing.T) { }, } - genesis.AggregateExchangeRatePrevotes = []types.AggregateExchangeRatePrevote{ - { - Hash: "hash", - Voter: "invalid", - SubmitBlock: 100, - }, - } - - require.Panics(t, func() { - oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis) - }) - - genesis.AggregateExchangeRatePrevotes = []types.AggregateExchangeRatePrevote{ - { - Hash: "hash", - Voter: keeper.ValAddrs[0].String(), - SubmitBlock: 100, - }, - } - - genesis.AggregateExchangeRateVotes = []types.AggregateExchangeRateVote{ - { - ExchangeRateTuples: []types.ExchangeRateTuple{ - { - Denom: "ukrw", - ExchangeRate: math.LegacyNewDec(10), - }, - }, - Voter: "invalid", - }, - } - - require.Panics(t, func() { - oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis) - }) - - genesis.AggregateExchangeRateVotes = []types.AggregateExchangeRateVote{ - { - ExchangeRateTuples: []types.ExchangeRateTuple{ - { - Denom: "ukrw", - ExchangeRate: math.LegacyNewDec(10), - }, - }, - Voter: keeper.ValAddrs[0].String(), - }, - } - require.NotPanics(t, func() { oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis) }) diff --git a/x/oracle/keeper/abci.go b/x/oracle/keeper/abci.go index c77873d2..5e327695 100644 --- a/x/oracle/keeper/abci.go +++ b/x/oracle/keeper/abci.go @@ -3,7 +3,6 @@ package keeper import ( "time" - "cosmossdk.io/math" "github.com/Team-Kujira/core/x/oracle/types" "github.com/cosmos/cosmos-sdk/telemetry" @@ -11,144 +10,8 @@ import ( ) // EndBlocker is called at the end of every block -func (k Keeper) EndBlocker(ctx sdk.Context) error { +func (k Keeper) EndBlocker(_ sdk.Context) error { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - params := k.GetParams(ctx) - if IsPeriodLastBlock(ctx, params.VotePeriod) { - // Build claim map over all validators in active set - validatorClaimMap := make(map[string]types.Claim) - - maxValidators, err := k.StakingKeeper.MaxValidators(ctx) - if err != nil { - return err - } - iterator, err := k.StakingKeeper.ValidatorsPowerStoreIterator(ctx) - if err != nil { - return err - } - - defer iterator.Close() - - powerReduction := k.StakingKeeper.PowerReduction(ctx) - - i := 0 - for ; iterator.Valid() && i < int(maxValidators); iterator.Next() { - validator, err := k.StakingKeeper.Validator(ctx, iterator.Value()) - if err != nil { - return err - } - - // Exclude not bonded validator - if validator.IsBonded() { - valAddrStr := validator.GetOperator() - valAddr, err := sdk.ValAddressFromBech32(valAddrStr) - if err != nil { - return err - } - - validatorClaimMap[valAddr.String()] = types.NewClaim(validator.GetConsensusPower(powerReduction), 0, 0, valAddr) - i++ - } - } - - // voteTargets defines the symbol (ticker) denoms that we require votes on - var voteTargets []string - voteTargets = append(voteTargets, params.RequiredDenoms...) - - // Clear all exchange rates - k.IterateExchangeRates(ctx, func(denom string, _ math.LegacyDec) (stop bool) { - k.DeleteExchangeRate(ctx, denom) - return false - }) - - // Organize votes to ballot by denom - voteMap := k.OrganizeBallotByDenom(ctx, validatorClaimMap) - - // Keep track, if a voter submitted a price deviating too much - missMap := map[string]sdk.ValAddress{} - - // Iterate through ballots and update exchange rates; drop if not enough votes have been achieved. - for denom, ballot := range voteMap { - bondedTokens, err := k.StakingKeeper.TotalBondedTokens(ctx) - if err != nil { - return err - } - - totalBondedPower := sdk.TokensToConsensusPower(bondedTokens, k.StakingKeeper.PowerReduction(ctx)) - voteThreshold := k.VoteThreshold(ctx) - thresholdVotes := voteThreshold.MulInt64(totalBondedPower).RoundInt() - ballotPower := math.NewInt(ballot.Power()) - - if !ballotPower.IsZero() && ballotPower.GTE(thresholdVotes) { - exchangeRate, err := Tally( - ctx, ballot, params.MaxDeviation, validatorClaimMap, missMap, - ) - if err != nil { - return err - } - - // Set the exchange rate, emit ABCI event - k.SetExchangeRateWithEvent(ctx, denom, exchangeRate) - } - } - - //--------------------------- - // Do miss counting & slashing - denomMap := map[string]map[string]struct{}{} - - for _, denom := range voteTargets { - denomMap[denom] = map[string]struct{}{} - } - - for denom, votes := range voteMap { - for _, vote := range votes { - // ignore denoms, not requested in voteTargets - _, ok := denomMap[denom] - if !ok { - continue - } - - denomMap[denom][vote.Voter.String()] = struct{}{} - } - } - - // Check if each validator is missing a required denom price - for _, claim := range validatorClaimMap { - for _, denom := range voteTargets { - _, ok := denomMap[denom][claim.Recipient.String()] - if !ok { - missMap[claim.Recipient.String()] = claim.Recipient - break - } - } - } - - for _, valAddr := range missMap { - k.SetMissCounter(ctx, valAddr, k.GetMissCounter(ctx, valAddr)+1) - } - - // // Distribute rewards to ballot winners - // k.RewardBallotWinners( - // ctx, - // (int64)(params.VotePeriod), - // (int64)(params.RewardDistributionWindow), - // voteTargets, - // validatorClaimMap, - // ) - - // Clear the ballot - k.ClearBallots(ctx, params.VotePeriod) - } - - // Do slash who did miss voting over threshold and - // reset miss counters of all validators at the last block of slash window - if IsPeriodLastBlock(ctx, params.SlashWindow) { - k.SlashAndResetMissCounters(ctx) - } return nil } - -func IsPeriodLastBlock(ctx sdk.Context, blocksPerPeriod uint64) bool { - return (uint64(ctx.BlockHeight())+1)%blocksPerPeriod == 0 -} diff --git a/x/oracle/keeper/ballot.go b/x/oracle/keeper/ballot.go deleted file mode 100644 index 7c616af5..00000000 --- a/x/oracle/keeper/ballot.go +++ /dev/null @@ -1,70 +0,0 @@ -package keeper - -import ( - "sort" - - "github.com/Team-Kujira/core/x/oracle/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// OrganizeBallotByDenom collects all oracle votes for the period, categorized by the votes' denom parameter -func (k Keeper) OrganizeBallotByDenom(ctx sdk.Context, validatorClaimMap map[string]types.Claim) (votes map[string]types.ExchangeRateBallot) { - votes = map[string]types.ExchangeRateBallot{} - - // Organize aggregate votes - aggregateHandler := func(voterAddr sdk.ValAddress, vote types.AggregateExchangeRateVote) (stop bool) { - // organize ballot only for the active validators - claim, ok := validatorClaimMap[vote.Voter] - - if ok { - power := claim.Power - for _, tuple := range vote.ExchangeRateTuples { - tmpPower := power - if !tuple.ExchangeRate.IsPositive() { - // Make the power of abstain vote zero - tmpPower = 0 - } - - votes[tuple.Denom] = append(votes[tuple.Denom], - types.NewVoteForTally( - tuple.ExchangeRate, - tuple.Denom, - voterAddr, - tmpPower, - ), - ) - } - } - - return false - } - - k.IterateAggregateExchangeRateVotes(ctx, aggregateHandler) - - // sort created ballot - for denom, ballot := range votes { - sort.Sort(ballot) - votes[denom] = ballot - } - - return votes -} - -// ClearBallots clears all tallied prevotes and votes from the store -func (k Keeper) ClearBallots(ctx sdk.Context, votePeriod uint64) { - // Clear all aggregate prevotes - k.IterateAggregateExchangeRatePrevotes(ctx, func(voterAddr sdk.ValAddress, aggregatePrevote types.AggregateExchangeRatePrevote) (stop bool) { - if ctx.BlockHeight() > int64(aggregatePrevote.SubmitBlock+votePeriod) { - k.DeleteAggregateExchangeRatePrevote(ctx, voterAddr) - } - - return false - }) - - // Clear all aggregate votes - k.IterateAggregateExchangeRateVotes(ctx, func(voterAddr sdk.ValAddress, aggregateVote types.AggregateExchangeRateVote) (stop bool) { - k.DeleteAggregateExchangeRateVote(ctx, voterAddr) - return false - }) -} diff --git a/x/oracle/keeper/ballot_test.go b/x/oracle/keeper/ballot_test.go deleted file mode 100644 index fe6b1cd6..00000000 --- a/x/oracle/keeper/ballot_test.go +++ /dev/null @@ -1,147 +0,0 @@ -package keeper - -import ( - "sort" - "testing" - - "cosmossdk.io/math" - "github.com/stretchr/testify/require" - - "github.com/Team-Kujira/core/x/oracle/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" -) - -func TestOrganizeAggregate(t *testing.T) { - input := CreateTestInput(t) - - power := int64(100) - amt := sdk.TokensFromConsensusPower(power, sdk.DefaultPowerReduction) - sh := stakingkeeper.NewMsgServerImpl(&input.StakingKeeper) - ctx := input.Ctx - - // Validator created - _, err := sh.CreateValidator(ctx, NewTestMsgCreateValidator(ValAddrs[0], ValPubKeys[0], amt)) - require.NoError(t, err) - _, err = sh.CreateValidator(ctx, NewTestMsgCreateValidator(ValAddrs[1], ValPubKeys[1], amt)) - require.NoError(t, err) - _, err = sh.CreateValidator(ctx, NewTestMsgCreateValidator(ValAddrs[2], ValPubKeys[2], amt)) - require.NoError(t, err) - input.StakingKeeper.EndBlocker(ctx) - - sdrBallot := types.ExchangeRateBallot{ - types.NewVoteForTally(math.LegacyNewDec(17), types.TestDenomD, ValAddrs[0], power), - types.NewVoteForTally(math.LegacyNewDec(10), types.TestDenomD, ValAddrs[1], power), - types.NewVoteForTally(math.LegacyNewDec(6), types.TestDenomD, ValAddrs[2], power), - } - krwBallot := types.ExchangeRateBallot{ - types.NewVoteForTally(math.LegacyNewDec(1000), types.TestDenomC, ValAddrs[0], power), - types.NewVoteForTally(math.LegacyNewDec(1300), types.TestDenomC, ValAddrs[1], power), - types.NewVoteForTally(math.LegacyNewDec(2000), types.TestDenomC, ValAddrs[2], power), - } - - for i := range sdrBallot { - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, ValAddrs[i], - types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{ - {Denom: sdrBallot[i].Denom, ExchangeRate: sdrBallot[i].ExchangeRate}, - {Denom: krwBallot[i].Denom, ExchangeRate: krwBallot[i].ExchangeRate}, - }, ValAddrs[i])) - } - - // organize votes by denom - ballotMap := input.OracleKeeper.OrganizeBallotByDenom(input.Ctx, map[string]types.Claim{ - ValAddrs[0].String(): { - Power: power, - WinCount: 0, - Recipient: ValAddrs[0], - }, - ValAddrs[1].String(): { - Power: power, - WinCount: 0, - Recipient: ValAddrs[1], - }, - ValAddrs[2].String(): { - Power: power, - WinCount: 0, - Recipient: ValAddrs[2], - }, - }) - - // sort each ballot for comparison - sort.Sort(sdrBallot) - sort.Sort(krwBallot) - sort.Sort(ballotMap[types.TestDenomD]) - sort.Sort(ballotMap[types.TestDenomC]) - - require.Equal(t, sdrBallot, ballotMap[types.TestDenomD]) - require.Equal(t, krwBallot, ballotMap[types.TestDenomC]) -} - -func TestClearBallots(t *testing.T) { - input := CreateTestInput(t) - - power := int64(100) - amt := sdk.TokensFromConsensusPower(power, sdk.DefaultPowerReduction) - sh := stakingkeeper.NewMsgServerImpl(&input.StakingKeeper) - ctx := input.Ctx - - // Validator created - _, err := sh.CreateValidator(ctx, NewTestMsgCreateValidator(ValAddrs[0], ValPubKeys[0], amt)) - require.NoError(t, err) - _, err = sh.CreateValidator(ctx, NewTestMsgCreateValidator(ValAddrs[1], ValPubKeys[1], amt)) - require.NoError(t, err) - _, err = sh.CreateValidator(ctx, NewTestMsgCreateValidator(ValAddrs[2], ValPubKeys[2], amt)) - require.NoError(t, err) - input.StakingKeeper.EndBlocker(ctx) - - sdrBallot := types.ExchangeRateBallot{ - types.NewVoteForTally(math.LegacyNewDec(17), types.TestDenomD, ValAddrs[0], power), - types.NewVoteForTally(math.LegacyNewDec(10), types.TestDenomD, ValAddrs[1], power), - types.NewVoteForTally(math.LegacyNewDec(6), types.TestDenomD, ValAddrs[2], power), - } - krwBallot := types.ExchangeRateBallot{ - types.NewVoteForTally(math.LegacyNewDec(1000), types.TestDenomC, ValAddrs[0], power), - types.NewVoteForTally(math.LegacyNewDec(1300), types.TestDenomC, ValAddrs[1], power), - types.NewVoteForTally(math.LegacyNewDec(2000), types.TestDenomC, ValAddrs[2], power), - } - - for i := range sdrBallot { - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, ValAddrs[i], types.AggregateExchangeRatePrevote{ - Hash: "", - Voter: ValAddrs[i].String(), - SubmitBlock: uint64(input.Ctx.BlockHeight()), - }) - - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, ValAddrs[i], - types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{ - {Denom: sdrBallot[i].Denom, ExchangeRate: sdrBallot[i].ExchangeRate}, - {Denom: krwBallot[i].Denom, ExchangeRate: krwBallot[i].ExchangeRate}, - }, ValAddrs[i])) - } - - input.OracleKeeper.ClearBallots(input.Ctx, 5) - - prevoteCounter := 0 - voteCounter := 0 - input.OracleKeeper.IterateAggregateExchangeRatePrevotes(input.Ctx, func(_ sdk.ValAddress, _ types.AggregateExchangeRatePrevote) bool { - prevoteCounter++ - return false - }) - input.OracleKeeper.IterateAggregateExchangeRateVotes(input.Ctx, func(_ sdk.ValAddress, _ types.AggregateExchangeRateVote) bool { - voteCounter++ - return false - }) - - require.Equal(t, prevoteCounter, 3) - require.Equal(t, voteCounter, 0) - - input.OracleKeeper.ClearBallots(input.Ctx.WithBlockHeight(input.Ctx.BlockHeight()+6), 5) - - prevoteCounter = 0 - input.OracleKeeper.IterateAggregateExchangeRatePrevotes(input.Ctx, func(_ sdk.ValAddress, _ types.AggregateExchangeRatePrevote) bool { - prevoteCounter++ - return false - }) - require.Equal(t, prevoteCounter, 0) -} diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index f853e7eb..ae76b43c 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Keeper of the oracle store @@ -124,44 +123,6 @@ func (k Keeper) IterateExchangeRates(ctx sdk.Context, handler func(denom string, } } -//----------------------------------- -// Oracle delegation logic - -// GetFeederDelegation gets the account address that the validator operator delegated oracle vote rights to -func (k Keeper) GetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress) sdk.AccAddress { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.GetFeederDelegationKey(operator)) - if bz == nil { - // By default the right is delegated to the validator itself - return sdk.AccAddress(operator) - } - - return sdk.AccAddress(bz) -} - -// SetFeederDelegation sets the account address that the validator operator delegated oracle vote rights to -func (k Keeper) SetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress) { - store := ctx.KVStore(k.storeKey) - store.Set(types.GetFeederDelegationKey(operator), delegatedFeeder.Bytes()) -} - -// IterateFeederDelegations iterates over the feed delegates and performs a callback function. -func (k Keeper) IterateFeederDelegations(ctx sdk.Context, - handler func(delegator sdk.ValAddress, delegate sdk.AccAddress) (stop bool), -) { - store := ctx.KVStore(k.storeKey) - iter := storetypes.KVStorePrefixIterator(store, types.FeederDelegationKey) - defer iter.Close() - for ; iter.Valid(); iter.Next() { - delegator := sdk.ValAddress(iter.Key()[2:]) - delegate := sdk.AccAddress(iter.Value()) - - if handler(delegator, delegate) { - break - } - } -} - //----------------------------------- // Miss counter logic @@ -211,121 +172,26 @@ func (k Keeper) IterateMissCounters(ctx sdk.Context, } } -//----------------------------------- -// AggregateExchangeRatePrevote logic - -// GetAggregateExchangeRatePrevote retrieves an oracle prevote from the store -func (k Keeper) GetAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress) (aggregatePrevote types.AggregateExchangeRatePrevote, err error) { - store := ctx.KVStore(k.storeKey) - b := store.Get(types.GetAggregateExchangeRatePrevoteKey(voter)) - if b == nil { - err = errors.Wrap(types.ErrNoAggregatePrevote, voter.String()) - return - } - k.cdc.MustUnmarshal(b, &aggregatePrevote) - return -} - -// SetAggregateExchangeRatePrevote set an oracle aggregate prevote to the store -func (k Keeper) SetAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress, prevote types.AggregateExchangeRatePrevote) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&prevote) - - store.Set(types.GetAggregateExchangeRatePrevoteKey(voter), bz) -} - -// DeleteAggregateExchangeRatePrevote deletes an oracle prevote from the store -func (k Keeper) DeleteAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetAggregateExchangeRatePrevoteKey(voter)) -} - -// IterateAggregateExchangeRatePrevotes iterates rate over prevotes in the store -func (k Keeper) IterateAggregateExchangeRatePrevotes(ctx sdk.Context, handler func(voterAddr sdk.ValAddress, aggregatePrevote types.AggregateExchangeRatePrevote) (stop bool)) { - store := ctx.KVStore(k.storeKey) - iter := storetypes.KVStorePrefixIterator(store, types.AggregateExchangeRatePrevoteKey) - defer iter.Close() - for ; iter.Valid(); iter.Next() { - voterAddr := sdk.ValAddress(iter.Key()[2:]) - - var aggregatePrevote types.AggregateExchangeRatePrevote - k.cdc.MustUnmarshal(iter.Value(), &aggregatePrevote) - if handler(voterAddr, aggregatePrevote) { - break - } - } -} - //----------------------------------- // AggregateExchangeRateVote logic -// GetAggregateExchangeRateVote retrieves an oracle prevote from the store -func (k Keeper) GetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress) (aggregateVote types.AggregateExchangeRateVote, err error) { - store := ctx.KVStore(k.storeKey) - b := store.Get(types.GetAggregateExchangeRateVoteKey(voter)) - if b == nil { - err = errors.Wrap(types.ErrNoAggregateVote, voter.String()) - return - } - k.cdc.MustUnmarshal(b, &aggregateVote) - return -} - -// SetAggregateExchangeRateVote adds an oracle aggregate prevote to the store -func (k Keeper) SetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress, vote types.AggregateExchangeRateVote) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&vote) - store.Set(types.GetAggregateExchangeRateVoteKey(voter), bz) -} - -// DeleteAggregateExchangeRateVote deletes an oracle prevote from the store -func (k Keeper) DeleteAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetAggregateExchangeRateVoteKey(voter)) +func (k Keeper) GetSubspace() paramstypes.Subspace { + return k.paramSpace } -// IterateAggregateExchangeRateVotes iterates rate over prevotes in the store -func (k Keeper) IterateAggregateExchangeRateVotes(ctx sdk.Context, handler func(voterAddr sdk.ValAddress, aggregateVote types.AggregateExchangeRateVote) (stop bool)) { - store := ctx.KVStore(k.storeKey) - iter := storetypes.KVStorePrefixIterator(store, types.AggregateExchangeRateVoteKey) - defer iter.Close() - for ; iter.Valid(); iter.Next() { - voterAddr := sdk.ValAddress(iter.Key()[2:]) - - var aggregateVote types.AggregateExchangeRateVote - k.cdc.MustUnmarshal(iter.Value(), &aggregateVote) - if handler(voterAddr, aggregateVote) { - break - } +func (k Keeper) SetOraclePrices(ctx sdk.Context, prices map[string]math.LegacyDec) { + for b, q := range prices { + k.SetExchangeRateWithEvent(ctx, b, q) } } -// ValidateFeeder return the given feeder is allowed to feed the message or not -func (k Keeper) ValidateFeeder(ctx sdk.Context, feederAddr sdk.AccAddress, validatorAddr sdk.ValAddress) error { - if !feederAddr.Equals(validatorAddr) { - delegate := k.GetFeederDelegation(ctx, validatorAddr) - if !delegate.Equals(feederAddr) { - return errors.Wrap(types.ErrNoVotingPermission, feederAddr.String()) - } - } - - // Check that the given validator exists - val, err := k.StakingKeeper.Validator(ctx, validatorAddr) - if err != nil { - return err +type ( + CurrencyPair struct { + Base string + Quote string } +) - if val == nil || !val.IsBonded() { - return errors.Wrapf(stakingtypes.ErrNoValidatorFound, "validator %s is not active set", validatorAddr.String()) - } - - if err != nil { - return err - } - - return nil -} - -func (k Keeper) GetSubspace() paramstypes.Subspace { - return k.paramSpace +func (cp CurrencyPair) String() string { + return cp.Base + cp.Quote } diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index 4b215939..76162c90 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -1,7 +1,6 @@ package keeper import ( - "bytes" "testing" "cosmossdk.io/math" @@ -10,9 +9,6 @@ import ( "github.com/Team-Kujira/core/x/oracle/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestExchangeRate(t *testing.T) { @@ -139,41 +135,6 @@ func TestParams(t *testing.T) { require.Equal(t, storedParams, newParams) } -func TestFeederDelegation(t *testing.T) { - input := CreateTestInput(t) - - // Test default getters and setters - delegate := input.OracleKeeper.GetFeederDelegation(input.Ctx, ValAddrs[0]) - require.Equal(t, Addrs[0], delegate) - - input.OracleKeeper.SetFeederDelegation(input.Ctx, ValAddrs[0], Addrs[1]) - delegate = input.OracleKeeper.GetFeederDelegation(input.Ctx, ValAddrs[0]) - require.Equal(t, Addrs[1], delegate) -} - -func TestIterateFeederDelegations(t *testing.T) { - input := CreateTestInput(t) - - // Test default getters and setters - delegate := input.OracleKeeper.GetFeederDelegation(input.Ctx, ValAddrs[0]) - require.Equal(t, Addrs[0], delegate) - - input.OracleKeeper.SetFeederDelegation(input.Ctx, ValAddrs[0], Addrs[1]) - - var delegators []sdk.ValAddress - var delegates []sdk.AccAddress - input.OracleKeeper.IterateFeederDelegations(input.Ctx, func(delegator sdk.ValAddress, delegate sdk.AccAddress) (stop bool) { - delegators = append(delegators, delegator) - delegates = append(delegates, delegate) - return false - }) - - require.Equal(t, 1, len(delegators)) - require.Equal(t, 1, len(delegates)) - require.Equal(t, ValAddrs[0], delegators[0]) - require.Equal(t, Addrs[1], delegates[0]) -} - func TestMissCounter(t *testing.T) { input := CreateTestInput(t) @@ -214,144 +175,3 @@ func TestIterateMissCounters(t *testing.T) { require.Equal(t, ValAddrs[1], operators[0]) require.Equal(t, missCounter, missCounters[0]) } - -func TestAggregatePrevoteAddDelete(t *testing.T) { - input := CreateTestInput(t) - - hash := types.GetAggregateVoteHash("salt", "100ukrw,1000uusd", sdk.ValAddress(Addrs[0])) - aggregatePrevote := types.NewAggregateExchangeRatePrevote(hash, sdk.ValAddress(Addrs[0]), 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, sdk.ValAddress(Addrs[0]), aggregatePrevote) - - KPrevote, err := input.OracleKeeper.GetAggregateExchangeRatePrevote(input.Ctx, sdk.ValAddress(Addrs[0])) - require.NoError(t, err) - require.Equal(t, aggregatePrevote, KPrevote) - - input.OracleKeeper.DeleteAggregateExchangeRatePrevote(input.Ctx, sdk.ValAddress(Addrs[0])) - _, err = input.OracleKeeper.GetAggregateExchangeRatePrevote(input.Ctx, sdk.ValAddress(Addrs[0])) - require.Error(t, err) -} - -func TestAggregatePrevoteIterate(t *testing.T) { - input := CreateTestInput(t) - - hash := types.GetAggregateVoteHash("salt", "100ukrw,1000uusd", sdk.ValAddress(Addrs[0])) - aggregatePrevote1 := types.NewAggregateExchangeRatePrevote(hash, sdk.ValAddress(Addrs[0]), 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, sdk.ValAddress(Addrs[0]), aggregatePrevote1) - - hash2 := types.GetAggregateVoteHash("salt", "100ukrw,1000uusd", sdk.ValAddress(Addrs[1])) - aggregatePrevote2 := types.NewAggregateExchangeRatePrevote(hash2, sdk.ValAddress(Addrs[1]), 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, sdk.ValAddress(Addrs[1]), aggregatePrevote2) - - i := 0 - bigger := bytes.Compare(Addrs[0], Addrs[1]) - input.OracleKeeper.IterateAggregateExchangeRatePrevotes(input.Ctx, func(voter sdk.ValAddress, p types.AggregateExchangeRatePrevote) (stop bool) { - if (i == 0 && bigger == -1) || (i == 1 && bigger == 1) { - require.Equal(t, aggregatePrevote1, p) - require.Equal(t, voter.String(), p.Voter) - } else { - require.Equal(t, aggregatePrevote2, p) - require.Equal(t, voter.String(), p.Voter) - } - - i++ - return false - }) -} - -func TestAggregateVoteAddDelete(t *testing.T) { - input := CreateTestInput(t) - - aggregateVote := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{ - {Denom: "foo", ExchangeRate: math.LegacyNewDec(-1)}, - {Denom: "foo", ExchangeRate: math.LegacyNewDec(0)}, - {Denom: "foo", ExchangeRate: math.LegacyNewDec(1)}, - }, sdk.ValAddress(Addrs[0])) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, sdk.ValAddress(Addrs[0]), aggregateVote) - - KVote, err := input.OracleKeeper.GetAggregateExchangeRateVote(input.Ctx, sdk.ValAddress(Addrs[0])) - require.NoError(t, err) - require.Equal(t, aggregateVote, KVote) - - input.OracleKeeper.DeleteAggregateExchangeRateVote(input.Ctx, sdk.ValAddress(Addrs[0])) - _, err = input.OracleKeeper.GetAggregateExchangeRateVote(input.Ctx, sdk.ValAddress(Addrs[0])) - require.Error(t, err) -} - -func TestAggregateVoteIterate(t *testing.T) { - input := CreateTestInput(t) - - aggregateVote1 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{ - {Denom: "foo", ExchangeRate: math.LegacyNewDec(-1)}, - {Denom: "foo", ExchangeRate: math.LegacyNewDec(0)}, - {Denom: "foo", ExchangeRate: math.LegacyNewDec(1)}, - }, sdk.ValAddress(Addrs[0])) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, sdk.ValAddress(Addrs[0]), aggregateVote1) - - aggregateVote2 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{ - {Denom: "foo", ExchangeRate: math.LegacyNewDec(-1)}, - {Denom: "foo", ExchangeRate: math.LegacyNewDec(0)}, - {Denom: "foo", ExchangeRate: math.LegacyNewDec(1)}, - }, sdk.ValAddress(Addrs[1])) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, sdk.ValAddress(Addrs[1]), aggregateVote2) - - i := 0 - bigger := bytes.Compare(address.MustLengthPrefix(Addrs[0]), address.MustLengthPrefix(Addrs[1])) - input.OracleKeeper.IterateAggregateExchangeRateVotes(input.Ctx, func(voter sdk.ValAddress, p types.AggregateExchangeRateVote) (stop bool) { - if (i == 0 && bigger == -1) || (i == 1 && bigger == 1) { - require.Equal(t, aggregateVote1, p) - require.Equal(t, voter.String(), p.Voter) - } else { - require.Equal(t, aggregateVote2, p) - require.Equal(t, voter.String(), p.Voter) - } - - i++ - return false - }) -} - -func TestValidateFeeder(t *testing.T) { - // initial setup - input := CreateTestInput(t) - addr, val := ValAddrs[0], ValPubKeys[0] - addr1, val1 := ValAddrs[1], ValPubKeys[1] - amt := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction) - sh := stakingkeeper.NewMsgServerImpl(&input.StakingKeeper) - ctx := input.Ctx - - // Validator created - _, err := sh.CreateValidator(ctx, NewTestMsgCreateValidator(addr, val, amt)) - require.NoError(t, err) - _, err = sh.CreateValidator(ctx, NewTestMsgCreateValidator(addr1, val1, amt)) - require.NoError(t, err) - input.StakingKeeper.EndBlocker(ctx) - params, _ := input.StakingKeeper.GetParams(ctx) - - require.Equal( - t, input.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr)), - sdk.NewCoins(sdk.NewCoin(params.BondDenom, InitTokens.Sub(amt))), - ) - validatorI, _ := input.StakingKeeper.Validator(ctx, addr) - require.Equal(t, amt, validatorI.GetBondedTokens()) - require.Equal( - t, input.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr1)), - sdk.NewCoins(sdk.NewCoin(params.BondDenom, InitTokens.Sub(amt))), - ) - validator1I, _ := input.StakingKeeper.Validator(ctx, addr) - require.Equal(t, amt, validator1I.GetBondedTokens()) - - require.NoError(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr), sdk.ValAddress(addr))) - require.NoError(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr1), sdk.ValAddress(addr1))) - - // delegate works - input.OracleKeeper.SetFeederDelegation(input.Ctx, sdk.ValAddress(addr), sdk.AccAddress(addr1)) - require.NoError(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr1), sdk.ValAddress(addr))) - require.Error(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(Addrs[2]), sdk.ValAddress(addr))) - - // only active validators can do oracle votes - validator, err := input.StakingKeeper.GetValidator(input.Ctx, sdk.ValAddress(addr)) - require.NoError(t, err) - validator.Status = stakingtypes.Unbonded - input.StakingKeeper.SetValidator(input.Ctx, validator) - require.Error(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr1), sdk.ValAddress(addr))) -} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 7ba8579c..3136aaf0 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -6,9 +6,7 @@ import ( "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/Team-Kujira/core/x/oracle/types" ) @@ -23,155 +21,6 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { return &msgServer{Keeper: keeper} } -func (ms msgServer) AggregateExchangeRatePrevote(goCtx context.Context, msg *types.MsgAggregateExchangeRatePrevote) (*types.MsgAggregateExchangeRatePrevoteResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - valAddr, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return nil, err - } - - feederAddr, err := sdk.AccAddressFromBech32(msg.Feeder) - if err != nil { - return nil, err - } - - if err := ms.ValidateFeeder(ctx, feederAddr, valAddr); err != nil { - return nil, err - } - - // Convert hex string to votehash - voteHash, err := types.AggregateVoteHashFromHexString(msg.Hash) - if err != nil { - return nil, errors.Wrap(types.ErrInvalidHash, err.Error()) - } - - aggregatePrevote := types.NewAggregateExchangeRatePrevote(voteHash, valAddr, uint64(ctx.BlockHeight())) - ms.SetAggregateExchangeRatePrevote(ctx, valAddr, aggregatePrevote) - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAggregatePrevote, - sdk.NewAttribute(types.AttributeKeyVoter, msg.Validator), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Feeder), - ), - }) - - return &types.MsgAggregateExchangeRatePrevoteResponse{}, nil -} - -func (ms msgServer) AggregateExchangeRateVote(goCtx context.Context, msg *types.MsgAggregateExchangeRateVote) (*types.MsgAggregateExchangeRateVoteResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - valAddr, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return nil, err - } - - feederAddr, err := sdk.AccAddressFromBech32(msg.Feeder) - if err != nil { - return nil, err - } - - if err := ms.ValidateFeeder(ctx, feederAddr, valAddr); err != nil { - return nil, err - } - - params := ms.GetParams(ctx) - - aggregatePrevote, err := ms.GetAggregateExchangeRatePrevote(ctx, valAddr) - if err != nil { - return nil, errors.Wrap(types.ErrNoAggregatePrevote, msg.Validator) - } - - // Check a msg is submitted proper period - if (uint64(ctx.BlockHeight())/params.VotePeriod)-(aggregatePrevote.SubmitBlock/params.VotePeriod) != 1 { - return nil, types.ErrRevealPeriodMissMatch - } - - exchangeRateTuples, err := types.ParseExchangeRateTuples(msg.ExchangeRates) - if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidCoins, err.Error()) - } - - // // check all denoms are in the vote target - // for _, tuple := range exchangeRateTuples { - // if !ms.IsVoteTarget(ctx, tuple.Denom) { - // return nil, errors.Wrap(types.ErrUnknownDenom, tuple.Denom) - // } - // } - - // Verify a exchange rate with aggregate prevote hash - hash := types.GetAggregateVoteHash(msg.Salt, msg.ExchangeRates, valAddr) - if aggregatePrevote.Hash != hash.String() { - return nil, errors.Wrapf(types.ErrVerificationFailed, "must be given %s not %s", aggregatePrevote.Hash, hash) - } - - // Move aggregate prevote to aggregate vote with given exchange rates - ms.SetAggregateExchangeRateVote(ctx, valAddr, types.NewAggregateExchangeRateVote(exchangeRateTuples, valAddr)) - ms.DeleteAggregateExchangeRatePrevote(ctx, valAddr) - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAggregateVote, - sdk.NewAttribute(types.AttributeKeyVoter, msg.Validator), - sdk.NewAttribute(types.AttributeKeyExchangeRates, msg.ExchangeRates), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Feeder), - ), - }) - - return &types.MsgAggregateExchangeRateVoteResponse{}, nil -} - -func (ms msgServer) DelegateFeedConsent(goCtx context.Context, msg *types.MsgDelegateFeedConsent) (*types.MsgDelegateFeedConsentResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - operatorAddr, err := sdk.ValAddressFromBech32(msg.Operator) - if err != nil { - return nil, err - } - - delegateAddr, err := sdk.AccAddressFromBech32(msg.Delegate) - if err != nil { - return nil, err - } - - // Check the delegator is a validator - val, err := ms.StakingKeeper.Validator(ctx, operatorAddr) - if err != nil { - return nil, err - } - - if val == nil { - return nil, errors.Wrap(stakingtypes.ErrNoValidatorFound, msg.Operator) - } - - // Set the delegation - ms.SetFeederDelegation(ctx, operatorAddr, delegateAddr) - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeFeedDelegate, - sdk.NewAttribute(types.AttributeKeyFeeder, msg.Delegate), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Operator), - ), - }) - - return &types.MsgDelegateFeedConsentResponse{}, nil -} - func (ms msgServer) AddRequiredDenom(goCtx context.Context, msg *types.MsgAddRequiredDenom) (*types.MsgAddRequiredDenomResponse, error) { if ms.authority != msg.Authority { return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, msg.Authority) diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index e3eceb97..af9c14f6 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -1,7 +1,6 @@ package keeper import ( - "fmt" "testing" "cosmossdk.io/math" @@ -14,133 +13,6 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) -func TestMsgServer_FeederDelegation(t *testing.T) { - input, msgServer := setup(t) - - salt := "1" - hash := types.GetAggregateVoteHash(salt, randomExchangeRate.String()+types.TestDenomD, ValAddrs[0]) - - // Case 1: empty message - delegateFeedConsentMsg := types.MsgDelegateFeedConsent{} - _, err := msgServer.DelegateFeedConsent(input.Ctx, &delegateFeedConsentMsg) - require.Error(t, err) - - // Case 2: Normal Prevote - without delegation - prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRatePrevote(input.Ctx, prevoteMsg) - require.NoError(t, err) - - // Case 2.1: Normal Prevote - with delegation fails - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[1], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRatePrevote(input.Ctx, prevoteMsg) - require.Error(t, err) - - // Case 2.2: Normal Vote - without delegation - voteMsg := types.NewMsgAggregateExchangeRateVote(salt, randomExchangeRate.String()+types.TestDenomD, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err) - - // Case 2.3: Normal Vote - with delegation fails - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, randomExchangeRate.String()+types.TestDenomD, Addrs[1], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.Error(t, err) - - // Case 3: Normal MsgDelegateFeedConsent succeeds - msg := types.NewMsgDelegateFeedConsent(ValAddrs[0], Addrs[1]) - _, err = msgServer.DelegateFeedConsent(input.Ctx, msg) - require.NoError(t, err) - - // Case 4.1: Normal Prevote - without delegation fails - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[2], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRatePrevote(input.Ctx, prevoteMsg) - require.Error(t, err) - - // Case 4.2: Normal Prevote - with delegation succeeds - prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[1], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRatePrevote(input.Ctx, prevoteMsg) - require.NoError(t, err) - - // Case 4.3: Normal Vote - without delegation fails - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, randomExchangeRate.String()+types.TestDenomD, Addrs[2], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.Error(t, err) - - // Case 4.4: Normal Vote - with delegation succeeds - voteMsg = types.NewMsgAggregateExchangeRateVote(salt, randomExchangeRate.String()+types.TestDenomD, Addrs[1], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx.WithBlockHeight(1), voteMsg) - require.NoError(t, err) -} - -func TestMsgServer_AggregatePrevoteVote(t *testing.T) { - input, msgServer := setup(t) - - salt := "1" - exchangeRatesStr := fmt.Sprintf("1000.23%s,0.29%s,0.27%s", types.TestDenomC, types.TestDenomB, types.TestDenomD) - otherExchangeRateStr := fmt.Sprintf("1000.12%s,0.29%s,0.27%s", types.TestDenomC, types.TestDenomB, types.TestDenomB) - unintendedExchageRateStr := fmt.Sprintf("1000.23%s,0.29%s,0.27%s", types.TestDenomC, types.TestDenomB, types.TestDenomE) - invalidExchangeRateStr := fmt.Sprintf("1000.23%s,0.29%s,0.27", types.TestDenomC, types.TestDenomB) - - hash := types.GetAggregateVoteHash(salt, exchangeRatesStr, ValAddrs[0]) - - aggregateExchangeRatePrevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[0], ValAddrs[0]) - _, err := msgServer.AggregateExchangeRatePrevote(input.Ctx, aggregateExchangeRatePrevoteMsg) - require.NoError(t, err) - - // Unauthorized feeder - aggregateExchangeRatePrevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[1], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRatePrevote(input.Ctx, aggregateExchangeRatePrevoteMsg) - require.Error(t, err) - - // Invalid addr - aggregateExchangeRatePrevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, sdk.AccAddress{}, ValAddrs[0]) - _, err = msgServer.AggregateExchangeRatePrevote(input.Ctx, aggregateExchangeRatePrevoteMsg) - require.Error(t, err) - - // Invalid validator addr - aggregateExchangeRatePrevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[0], sdk.ValAddress{}) - _, err = msgServer.AggregateExchangeRatePrevote(input.Ctx, aggregateExchangeRatePrevoteMsg) - require.Error(t, err) - - // Invalid reveal period - aggregateExchangeRateVoteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx, aggregateExchangeRateVoteMsg) - require.Error(t, err) - - // Invalid reveal period - input.Ctx = input.Ctx.WithBlockHeight(2) - aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx, aggregateExchangeRateVoteMsg) - require.Error(t, err) - - // Other exchange rate with valid real period - input.Ctx = input.Ctx.WithBlockHeight(1) - aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, otherExchangeRateStr, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx, aggregateExchangeRateVoteMsg) - require.Error(t, err) - - // Invalid exchange rate with valid real period - input.Ctx = input.Ctx.WithBlockHeight(1) - aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, invalidExchangeRateStr, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx, aggregateExchangeRateVoteMsg) - require.Error(t, err) - - // Unauthorized feeder - aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, invalidExchangeRateStr, Addrs[1], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx, aggregateExchangeRateVoteMsg) - require.Error(t, err) - - // Unintended denom vote - aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, unintendedExchageRateStr, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx, aggregateExchangeRateVoteMsg) - require.Error(t, err) - - // Valid exchange rate reveal submission - input.Ctx = input.Ctx.WithBlockHeight(1) - aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, Addrs[0], ValAddrs[0]) - _, err = msgServer.AggregateExchangeRateVote(input.Ctx, aggregateExchangeRateVoteMsg) - require.NoError(t, err) -} - var ( stakingAmt = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) randomExchangeRate = math.LegacyNewDec(1700) diff --git a/x/oracle/keeper/querier.go b/x/oracle/keeper/querier.go index 0392803f..75fbb35a 100644 --- a/x/oracle/keeper/querier.go +++ b/x/oracle/keeper/querier.go @@ -70,7 +70,7 @@ func (q querier) Actives(c context.Context, _ *types.QueryActivesRequest) (*type ctx := sdk.UnwrapSDKContext(c) denoms := []string{} - q.IterateExchangeRates(ctx, func(denom string, rate math.LegacyDec) (stop bool) { + q.IterateExchangeRates(ctx, func(denom string, _ math.LegacyDec) (stop bool) { denoms = append(denoms, denom) return false }) @@ -78,23 +78,6 @@ func (q querier) Actives(c context.Context, _ *types.QueryActivesRequest) (*type return &types.QueryActivesResponse{Actives: denoms}, nil } -// FeederDelegation queries the account address that the validator operator delegated oracle vote rights to -func (q querier) FeederDelegation(c context.Context, req *types.QueryFeederDelegationRequest) (*types.QueryFeederDelegationResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr) - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - - ctx := sdk.UnwrapSDKContext(c) - return &types.QueryFeederDelegationResponse{ - FeederAddr: q.GetFeederDelegation(ctx, valAddr).String(), - }, nil -} - // MissCounter queries oracle miss counter of a validator func (q querier) MissCounter(c context.Context, req *types.QueryMissCounterRequest) (*types.QueryMissCounterResponse, error) { if req == nil { @@ -111,77 +94,3 @@ func (q querier) MissCounter(c context.Context, req *types.QueryMissCounterReque MissCounter: q.GetMissCounter(ctx, valAddr), }, nil } - -// AggregatePrevote queries an aggregate prevote of a validator -func (q querier) AggregatePrevote(c context.Context, req *types.QueryAggregatePrevoteRequest) (*types.QueryAggregatePrevoteResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr) - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - - ctx := sdk.UnwrapSDKContext(c) - prevote, err := q.GetAggregateExchangeRatePrevote(ctx, valAddr) - if err != nil { - return nil, err - } - - return &types.QueryAggregatePrevoteResponse{ - AggregatePrevote: prevote, - }, nil -} - -// AggregatePrevotes queries aggregate prevotes of all validators -func (q querier) AggregatePrevotes(c context.Context, _ *types.QueryAggregatePrevotesRequest) (*types.QueryAggregatePrevotesResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - var prevotes []types.AggregateExchangeRatePrevote - q.IterateAggregateExchangeRatePrevotes(ctx, func(_ sdk.ValAddress, prevote types.AggregateExchangeRatePrevote) bool { - prevotes = append(prevotes, prevote) - return false - }) - - return &types.QueryAggregatePrevotesResponse{ - AggregatePrevotes: prevotes, - }, nil -} - -// AggregateVote queries an aggregate vote of a validator -func (q querier) AggregateVote(c context.Context, req *types.QueryAggregateVoteRequest) (*types.QueryAggregateVoteResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr) - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - - ctx := sdk.UnwrapSDKContext(c) - vote, err := q.GetAggregateExchangeRateVote(ctx, valAddr) - if err != nil { - return nil, err - } - - return &types.QueryAggregateVoteResponse{ - AggregateVote: vote, - }, nil -} - -// AggregateVotes queries aggregate votes of all validators -func (q querier) AggregateVotes(c context.Context, _ *types.QueryAggregateVotesRequest) (*types.QueryAggregateVotesResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - var votes []types.AggregateExchangeRateVote - q.IterateAggregateExchangeRateVotes(ctx, func(_ sdk.ValAddress, vote types.AggregateExchangeRateVote) bool { - votes = append(votes, vote) - return false - }) - - return &types.QueryAggregateVotesResponse{ - AggregateVotes: votes, - }, nil -} diff --git a/x/oracle/keeper/querier_test.go b/x/oracle/keeper/querier_test.go index 9bd2739a..af0dd27c 100644 --- a/x/oracle/keeper/querier_test.go +++ b/x/oracle/keeper/querier_test.go @@ -1,8 +1,6 @@ package keeper import ( - "bytes" - "sort" "testing" "cosmossdk.io/math" @@ -98,123 +96,3 @@ func TestQueryActives(t *testing.T) { require.Equal(t, targetDenoms, res.Actives) } - -func TestQueryFeederDelegation(t *testing.T) { - input := CreateTestInput(t) - querier := NewQuerier(input.OracleKeeper) - - input.OracleKeeper.SetFeederDelegation(input.Ctx, ValAddrs[0], Addrs[1]) - - // empty request - _, err := querier.FeederDelegation(input.Ctx, nil) - require.Error(t, err) - - res, err := querier.FeederDelegation(input.Ctx, &types.QueryFeederDelegationRequest{ - ValidatorAddr: ValAddrs[0].String(), - }) - require.NoError(t, err) - - require.Equal(t, Addrs[1].String(), res.FeederAddr) -} - -func TestQueryAggregatePrevote(t *testing.T) { - input := CreateTestInput(t) - querier := NewQuerier(input.OracleKeeper) - - prevote1 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[0], 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, ValAddrs[0], prevote1) - prevote2 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[1], 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, ValAddrs[1], prevote2) - - // validator 0 address params - res, err := querier.AggregatePrevote(input.Ctx, &types.QueryAggregatePrevoteRequest{ - ValidatorAddr: ValAddrs[0].String(), - }) - require.NoError(t, err) - require.Equal(t, prevote1, res.AggregatePrevote) - - // empty request - _, err = querier.AggregatePrevote(input.Ctx, nil) - require.Error(t, err) - - // validator 1 address params - res, err = querier.AggregatePrevote(input.Ctx, &types.QueryAggregatePrevoteRequest{ - ValidatorAddr: ValAddrs[1].String(), - }) - require.NoError(t, err) - require.Equal(t, prevote2, res.AggregatePrevote) -} - -func TestQueryAggregatePrevotes(t *testing.T) { - input := CreateTestInput(t) - querier := NewQuerier(input.OracleKeeper) - - prevote1 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[0], 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, ValAddrs[0], prevote1) - prevote2 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[1], 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, ValAddrs[1], prevote2) - prevote3 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[2], 0) - input.OracleKeeper.SetAggregateExchangeRatePrevote(input.Ctx, ValAddrs[2], prevote3) - - expectedPrevotes := []types.AggregateExchangeRatePrevote{prevote1, prevote2, prevote3} - sort.SliceStable(expectedPrevotes, func(i, j int) bool { - addr1, _ := sdk.ValAddressFromBech32(expectedPrevotes[i].Voter) - addr2, _ := sdk.ValAddressFromBech32(expectedPrevotes[j].Voter) - return bytes.Compare(addr1, addr2) == -1 - }) - - res, err := querier.AggregatePrevotes(input.Ctx, &types.QueryAggregatePrevotesRequest{}) - require.NoError(t, err) - require.Equal(t, expectedPrevotes, res.AggregatePrevotes) -} - -func TestQueryAggregateVote(t *testing.T) { - input := CreateTestInput(t) - querier := NewQuerier(input.OracleKeeper) - - vote1 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Denom: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[0]) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, ValAddrs[0], vote1) - vote2 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Denom: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[1]) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, ValAddrs[1], vote2) - - // empty request - _, err := querier.AggregateVote(input.Ctx, nil) - require.Error(t, err) - - // validator 0 address params - res, err := querier.AggregateVote(input.Ctx, &types.QueryAggregateVoteRequest{ - ValidatorAddr: ValAddrs[0].String(), - }) - require.NoError(t, err) - require.Equal(t, vote1, res.AggregateVote) - - // validator 1 address params - res, err = querier.AggregateVote(input.Ctx, &types.QueryAggregateVoteRequest{ - ValidatorAddr: ValAddrs[1].String(), - }) - require.NoError(t, err) - require.Equal(t, vote2, res.AggregateVote) -} - -func TestQueryAggregateVotes(t *testing.T) { - input := CreateTestInput(t) - querier := NewQuerier(input.OracleKeeper) - - vote1 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Denom: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[0]) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, ValAddrs[0], vote1) - vote2 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Denom: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[1]) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, ValAddrs[1], vote2) - vote3 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Denom: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[2]) - input.OracleKeeper.SetAggregateExchangeRateVote(input.Ctx, ValAddrs[2], vote3) - - expectedVotes := []types.AggregateExchangeRateVote{vote1, vote2, vote3} - sort.SliceStable(expectedVotes, func(i, j int) bool { - addr1, _ := sdk.ValAddressFromBech32(expectedVotes[i].Voter) - addr2, _ := sdk.ValAddressFromBech32(expectedVotes[j].Voter) - return bytes.Compare(addr1, addr2) == -1 - }) - - res, err := querier.AggregateVotes(input.Ctx, &types.QueryAggregateVotesRequest{}) - require.NoError(t, err) - require.Equal(t, expectedVotes, res.AggregateVotes) -} diff --git a/x/oracle/keeper/tally_test.go b/x/oracle/keeper/tally_test.go new file mode 100644 index 00000000..8cf1735c --- /dev/null +++ b/x/oracle/keeper/tally_test.go @@ -0,0 +1,87 @@ +package keeper + +import ( + "math" + "sort" + "testing" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/Team-Kujira/core/x/oracle/types" +) + +func TestOracleTally(t *testing.T) { + input, _ := setup(t) + + ballot := types.ExchangeRateBallot{} + rates, valAddrs, stakingKeeper := types.GenerateRandomTestCase() + input.OracleKeeper.StakingKeeper = stakingKeeper + for i, rate := range rates { + decExchangeRate := sdkmath.LegacyNewDecWithPrec(int64(rate*math.Pow10(OracleDecPrecision)), int64(OracleDecPrecision)) + + power := stakingAmt.QuoRaw(types.MicroUnit).Int64() + if decExchangeRate.IsZero() { + power = int64(0) + } + + vote := types.NewVoteForTally( + decExchangeRate, types.TestDenomD, valAddrs[i], power) + ballot = append(ballot, vote) + + // change power of every three validator + if i%3 == 0 { + stakingKeeper.Validators()[i].SetConsensusPower(int64(i + 1)) + } + } + + validatorClaimMap := make(map[string]types.Claim) + for _, valAddr := range valAddrs { + val, _ := stakingKeeper.Validator(input.Ctx, valAddr) + validatorClaimMap[valAddr.String()] = types.Claim{ + Power: val.GetConsensusPower(sdk.DefaultPowerReduction), + Weight: int64(0), + WinCount: int64(0), + Recipient: valAddr, + } + } + sort.Sort(ballot) + weightedMedian, _ := ballot.WeightedMedian() + standardDeviation, _ := ballot.StandardDeviation() + maxSpread := weightedMedian.Mul(input.OracleKeeper.MaxDeviation(input.Ctx)) + + if standardDeviation.GT(maxSpread) { + maxSpread = standardDeviation + } + + expectedValidatorClaimMap := make(map[string]types.Claim) + for _, valAddr := range valAddrs { + val, _ := stakingKeeper.Validator(input.Ctx, valAddr) + expectedValidatorClaimMap[valAddr.String()] = types.Claim{ + Power: val.GetConsensusPower(sdk.DefaultPowerReduction), + Weight: int64(0), + WinCount: int64(0), + Recipient: valAddr, + } + } + + for _, vote := range ballot { + if (vote.ExchangeRate.GTE(weightedMedian.Sub(maxSpread)) && + vote.ExchangeRate.LTE(weightedMedian.Add(maxSpread))) || + !vote.ExchangeRate.IsPositive() { + key := vote.Voter.String() + claim := expectedValidatorClaimMap[key] + claim.Weight += vote.Power + claim.WinCount++ + expectedValidatorClaimMap[key] = claim + } + } + + missMap := map[string]sdk.ValAddress{} + + tallyMedian, _ := Tally(input.Ctx, ballot, input.OracleKeeper.MaxDeviation(input.Ctx), validatorClaimMap, missMap) + + require.Equal(t, validatorClaimMap, expectedValidatorClaimMap) + require.Equal(t, tallyMedian.MulInt64(100).TruncateInt(), weightedMedian.MulInt64(100).TruncateInt()) +} diff --git a/x/oracle/simulation/decoder.go b/x/oracle/simulation/decoder.go index bf81a474..a712e7c6 100644 --- a/x/oracle/simulation/decoder.go +++ b/x/oracle/simulation/decoder.go @@ -30,16 +30,6 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { cdc.MustUnmarshal(kvA.Value, &counterA) cdc.MustUnmarshal(kvB.Value, &counterB) return fmt.Sprintf("%v\n%v", counterA.Value, counterB.Value) - case bytes.Equal(kvA.Key[:1], types.AggregateExchangeRatePrevoteKey): - var prevoteA, prevoteB types.AggregateExchangeRatePrevote - cdc.MustUnmarshal(kvA.Value, &prevoteA) - cdc.MustUnmarshal(kvB.Value, &prevoteB) - return fmt.Sprintf("%v\n%v", prevoteA, prevoteB) - case bytes.Equal(kvA.Key[:1], types.AggregateExchangeRateVoteKey): - var voteA, voteB types.AggregateExchangeRateVote - cdc.MustUnmarshal(kvA.Value, &voteA) - cdc.MustUnmarshal(kvB.Value, &voteB) - return fmt.Sprintf("%v\n%v", voteA, voteB) default: panic(fmt.Sprintf("invalid oracle key prefix %X", kvA.Key[:1])) } diff --git a/x/oracle/simulation/decoder_test.go b/x/oracle/simulation/decoder_test.go index ab7f87ac..4bf986b4 100644 --- a/x/oracle/simulation/decoder_test.go +++ b/x/oracle/simulation/decoder_test.go @@ -40,19 +40,11 @@ func TestDecodeDistributionStore(t *testing.T) { exchangeRate := math.LegacyNewDecWithPrec(1234, 1) missCounter := uint64(23) - aggregatePrevote := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash([]byte("12345")), valAddr, 123) - aggregateVote := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{ - {Denom: denomA, ExchangeRate: math.LegacyNewDecWithPrec(1234, 1)}, - {Denom: denomB, ExchangeRate: math.LegacyNewDecWithPrec(4321, 1)}, - }, valAddr) - kvPairs := kv.Pairs{ Pairs: []kv.Pair{ {Key: types.ExchangeRateKey, Value: cdc.MustMarshal(&sdk.DecProto{Dec: exchangeRate})}, {Key: types.FeederDelegationKey, Value: feederAddr.Bytes()}, {Key: types.MissCounterKey, Value: cdc.MustMarshal(&gogotypes.UInt64Value{Value: missCounter})}, - {Key: types.AggregateExchangeRatePrevoteKey, Value: cdc.MustMarshal(&aggregatePrevote)}, - {Key: types.AggregateExchangeRateVoteKey, Value: cdc.MustMarshal(&aggregateVote)}, {Key: []byte{0x99}, Value: []byte{0x99}}, }, } @@ -64,8 +56,6 @@ func TestDecodeDistributionStore(t *testing.T) { {"ExchangeRate", fmt.Sprintf("%v\n%v", exchangeRate, exchangeRate)}, {"FeederDelegation", fmt.Sprintf("%v\n%v", feederAddr, feederAddr)}, {"MissCounter", fmt.Sprintf("%v\n%v", missCounter, missCounter)}, - {"AggregatePrevote", fmt.Sprintf("%v\n%v", aggregatePrevote, aggregatePrevote)}, - {"AggregateVote", fmt.Sprintf("%v\n%v", aggregateVote, aggregateVote)}, {"other", ""}, } diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 612d8ef2..0c97222d 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -108,10 +108,7 @@ func RandomizedGenState(simState *module.SimulationState) { MinValidPerWindow: minValidPerWindow, }, []types.ExchangeRateTuple{}, - []types.FeederDelegation{}, []types.MissCounter{}, - []types.AggregateExchangeRatePrevote{}, - []types.AggregateExchangeRateVote{}, ) bz, err := json.MarshalIndent(&oracleGenesis.Params, "", " ") diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index 4ff3aee3..b5eb0224 100644 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -3,269 +3,25 @@ package simulation // DONTCOVER import ( - "math/rand" - "strings" - - "cosmossdk.io/math" - simappparams "cosmossdk.io/simapp/params" "github.com/Team-Kujira/core/x/oracle/keeper" "github.com/Team-Kujira/core/x/oracle/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" ) -// Simulation operation weights constants -// -//nolint:gosec //these aren't hard coded credentials -const ( - OpWeightMsgAggregateExchangeRatePrevote = "op_weight_msg_exchange_rate_aggregate_prevote" - OpWeightMsgAggregateExchangeRateVote = "op_weight_msg_exchange_rate_aggregate_vote" - OpWeightMsgDelegateFeedConsent = "op_weight_msg_exchange_feed_consent" - - salt = "fc5bb0bc63e54b2918d9334bf3259f5dc575e8d7a4df4e836dd80f1ad62aa89b" -) - var ( - whitelist = []string{types.TestDenomA, types.TestDenomB, types.TestDenomC} - voteHashMap = make(map[string]string) DefaultWeightMsgSend = 100 DefaultWeightMsgSetWithdrawAddress = 50 ) // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - appParams simtypes.AppParams, + _ simtypes.AppParams, _ codec.JSONCodec, - ak types.AccountKeeper, - bk types.BankKeeper, - k keeper.Keeper, + _ types.AccountKeeper, + _ types.BankKeeper, + _ keeper.Keeper, ) simulation.WeightedOperations { - var ( - weightMsgAggregateExchangeRatePrevote int - weightMsgAggregateExchangeRateVote int - weightMsgDelegateFeedConsent int - ) - appParams.GetOrGenerate(OpWeightMsgAggregateExchangeRatePrevote, &weightMsgAggregateExchangeRatePrevote, nil, - func(_ *rand.Rand) { - weightMsgAggregateExchangeRatePrevote = DefaultWeightMsgSend * 2 - }, - ) - - appParams.GetOrGenerate(OpWeightMsgAggregateExchangeRateVote, &weightMsgAggregateExchangeRateVote, nil, - func(_ *rand.Rand) { - weightMsgAggregateExchangeRateVote = DefaultWeightMsgSend * 2 - }, - ) - - appParams.GetOrGenerate(OpWeightMsgDelegateFeedConsent, &weightMsgDelegateFeedConsent, nil, - func(_ *rand.Rand) { - weightMsgDelegateFeedConsent = DefaultWeightMsgSetWithdrawAddress - }, - ) - - return simulation.WeightedOperations{ - simulation.NewWeightedOperation( - weightMsgAggregateExchangeRatePrevote, - SimulateMsgAggregateExchangeRatePrevote(ak, bk, k), - ), - simulation.NewWeightedOperation( - weightMsgAggregateExchangeRateVote, - SimulateMsgAggregateExchangeRateVote(ak, bk, k), - ), - simulation.NewWeightedOperation( - weightMsgDelegateFeedConsent, - SimulateMsgDelegateFeedConsent(ak, bk, k), - ), - } -} - -// SimulateMsgAggregateExchangeRatePrevote generates a MsgAggregateExchangeRatePrevote with random values. -func SimulateMsgAggregateExchangeRatePrevote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { - return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - simAccount, _ := simtypes.RandomAcc(r, accs) - address := sdk.ValAddress(simAccount.Address) - - // ensure the validator exists - val, _ := k.StakingKeeper.Validator(ctx, address) - if val == nil || !val.IsBonded() { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRatePrevote, "unable to find validator"), nil, nil - } - - exchangeRatesStr := "" - for _, denom := range whitelist { - price := math.LegacyNewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 10000)), int64(1)) - exchangeRatesStr += price.String() + denom + "," - } - - exchangeRatesStr = strings.TrimRight(exchangeRatesStr, ",") - voteHash := types.GetAggregateVoteHash(salt, exchangeRatesStr, address) - - feederAddr := k.GetFeederDelegation(ctx, address) - feederSimAccount, _ := simtypes.FindAccount(accs, feederAddr) - - feederAccount := ak.GetAccount(ctx, feederAddr) - spendable := bk.SpendableCoins(ctx, feederAccount.GetAddress()) - - fees, err := simtypes.RandomFees(r, ctx, spendable) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRatePrevote, "unable to generate fees"), nil, err - } - - msg := types.NewMsgAggregateExchangeRatePrevote(voteHash, feederAddr, address) - - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := simtestutil.GenSignedMockTx( - r, - txGen, - []sdk.Msg{msg}, - fees, - simtestutil.DefaultGenTxGas, - chainID, - []uint64{feederAccount.GetAccountNumber()}, - []uint64{feederAccount.GetSequence()}, - feederSimAccount.PrivKey, - ) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err - } - - _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err - } - - voteHashMap[address.String()] = exchangeRatesStr - - return simtypes.NewOperationMsg(msg, true, ""), nil, nil - } -} - -// SimulateMsgAggregateExchangeRateVote generates a MsgAggregateExchangeRateVote with random values. -func SimulateMsgAggregateExchangeRateVote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { - return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - simAccount, _ := simtypes.RandomAcc(r, accs) - address := sdk.ValAddress(simAccount.Address) - - // ensure the validator exists - val, _ := k.StakingKeeper.Validator(ctx, address) - if val == nil || !val.IsBonded() { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "unable to find validator"), nil, nil - } - - // ensure vote hash exists - exchangeRatesStr, ok := voteHashMap[address.String()] - if !ok { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "vote hash not exists"), nil, nil - } - - // get prevote - prevote, err := k.GetAggregateExchangeRatePrevote(ctx, address) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "prevote not found"), nil, nil - } - - params := k.GetParams(ctx) - if (uint64(ctx.BlockHeight())/params.VotePeriod)-(prevote.SubmitBlock/params.VotePeriod) != 1 { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "reveal period of submitted vote do not match with registered prevote"), nil, nil - } - - feederAddr := k.GetFeederDelegation(ctx, address) - feederSimAccount, _ := simtypes.FindAccount(accs, feederAddr) - feederAccount := ak.GetAccount(ctx, feederAddr) - spendableCoins := bk.SpendableCoins(ctx, feederAddr) - - fees, err := simtypes.RandomFees(r, ctx, spendableCoins) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "unable to generate fees"), nil, err - } - - msg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, feederAddr, address) - - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := simtestutil.GenSignedMockTx( - r, - txGen, - []sdk.Msg{msg}, - fees, - simtestutil.DefaultGenTxGas, - chainID, - []uint64{feederAccount.GetAccountNumber()}, - []uint64{feederAccount.GetSequence()}, - feederSimAccount.PrivKey, - ) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err - } - - _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err - } - - return simtypes.NewOperationMsg(msg, true, ""), nil, nil - } -} - -// SimulateMsgDelegateFeedConsent generates a MsgDelegateFeedConsent with random values. -func SimulateMsgDelegateFeedConsent(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { - return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - simAccount, _ := simtypes.RandomAcc(r, accs) - delegateAccount, _ := simtypes.RandomAcc(r, accs) - valAddress := sdk.ValAddress(simAccount.Address) - delegateValAddress := sdk.ValAddress(delegateAccount.Address) - account := ak.GetAccount(ctx, simAccount.Address) - - // ensure the validator exists - val, _ := k.StakingKeeper.Validator(ctx, valAddress) - if val == nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDelegateFeedConsent, "unable to find validator"), nil, nil - } - - // ensure the target address is not a validator - val2, _ := k.StakingKeeper.Validator(ctx, delegateValAddress) - if val2 != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDelegateFeedConsent, "unable to delegate to validator"), nil, nil - } - - spendableCoins := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendableCoins) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "unable to generate fees"), nil, err - } - - msg := types.NewMsgDelegateFeedConsent(valAddress, delegateAccount.Address) - - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := simtestutil.GenSignedMockTx( - r, - txGen, - []sdk.Msg{msg}, - fees, - simtestutil.DefaultGenTxGas, - chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - simAccount.PrivKey, - ) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err - } - - _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err - } - - return simtypes.NewOperationMsg(msg, true, ""), nil, nil - } + return simulation.WeightedOperations{} } diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 38e775fc..f3cc7cad 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -11,9 +11,6 @@ import ( // 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(&MsgAggregateExchangeRatePrevote{}, "oracle/MsgAggregateExchangeRatePrevote", nil) - cdc.RegisterConcrete(&MsgAggregateExchangeRateVote{}, "oracle/MsgAggregateExchangeRateVote", nil) - cdc.RegisterConcrete(&MsgDelegateFeedConsent{}, "oracle/MsgDelegateFeedConsent", nil) cdc.RegisterConcrete(&MsgAddRequiredDenom{}, "oracle/MsgAddRequiredDenom", nil) cdc.RegisterConcrete(&MsgRemoveRequiredDenom{}, "oracle/MsgRemoveRequiredDenom", nil) cdc.RegisterConcrete(&MsgUpdateParams{}, "oracle/MsgUpdateParams", nil) @@ -22,9 +19,6 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterfaces registers the x/oracle interfaces types with the interface registry func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgDelegateFeedConsent{}, - &MsgAggregateExchangeRatePrevote{}, - &MsgAggregateExchangeRateVote{}, &MsgAddRequiredDenom{}, &MsgRemoveRequiredDenom{}, &MsgUpdateParams{}, diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index c7194aae..d78500e3 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -7,17 +7,12 @@ import ( // NewGenesisState creates a new GenesisState object func NewGenesisState( params Params, rates []ExchangeRateTuple, - feederDelegations []FeederDelegation, missCounters []MissCounter, - aggregateExchangeRatePrevotes []AggregateExchangeRatePrevote, - aggregateExchangeRateVotes []AggregateExchangeRateVote, + missCounters []MissCounter, ) *GenesisState { return &GenesisState{ - Params: params, - ExchangeRates: rates, - FeederDelegations: feederDelegations, - MissCounters: missCounters, - AggregateExchangeRatePrevotes: aggregateExchangeRatePrevotes, - AggregateExchangeRateVotes: aggregateExchangeRateVotes, + Params: params, + ExchangeRates: rates, + MissCounters: missCounters, } } @@ -25,10 +20,7 @@ func NewGenesisState( func DefaultGenesisState() *GenesisState { return NewGenesisState(DefaultParams(), []ExchangeRateTuple{}, - []FeederDelegation{}, - []MissCounter{}, - []AggregateExchangeRatePrevote{}, - []AggregateExchangeRateVote{}) + []MissCounter{}) } // ValidateGenesis validates the oracle genesis state diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index 319ab946..0057a812 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -26,12 +26,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the oracle module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - FeederDelegations []FeederDelegation `protobuf:"bytes,2,rep,name=feeder_delegations,json=feederDelegations,proto3" json:"feeder_delegations"` - ExchangeRates ExchangeRateTuples `protobuf:"bytes,3,rep,name=exchange_rates,json=exchangeRates,proto3,castrepeated=ExchangeRateTuples" json:"exchange_rates"` - MissCounters []MissCounter `protobuf:"bytes,4,rep,name=miss_counters,json=missCounters,proto3" json:"miss_counters"` - AggregateExchangeRatePrevotes []AggregateExchangeRatePrevote `protobuf:"bytes,5,rep,name=aggregate_exchange_rate_prevotes,json=aggregateExchangeRatePrevotes,proto3" json:"aggregate_exchange_rate_prevotes"` - AggregateExchangeRateVotes []AggregateExchangeRateVote `protobuf:"bytes,6,rep,name=aggregate_exchange_rate_votes,json=aggregateExchangeRateVotes,proto3" json:"aggregate_exchange_rate_votes"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + ExchangeRates ExchangeRateTuples `protobuf:"bytes,2,rep,name=exchange_rates,json=exchangeRates,proto3,castrepeated=ExchangeRateTuples" json:"exchange_rates"` + MissCounters []MissCounter `protobuf:"bytes,3,rep,name=miss_counters,json=missCounters,proto3" json:"miss_counters"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -74,13 +71,6 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetFeederDelegations() []FeederDelegation { - if m != nil { - return m.FeederDelegations - } - return nil -} - func (m *GenesisState) GetExchangeRates() ExchangeRateTuples { if m != nil { return m.ExchangeRates @@ -95,20 +85,6 @@ func (m *GenesisState) GetMissCounters() []MissCounter { return nil } -func (m *GenesisState) GetAggregateExchangeRatePrevotes() []AggregateExchangeRatePrevote { - if m != nil { - return m.AggregateExchangeRatePrevotes - } - return nil -} - -func (m *GenesisState) GetAggregateExchangeRateVotes() []AggregateExchangeRateVote { - if m != nil { - return m.AggregateExchangeRateVotes - } - return nil -} - // FeederDelegation is the address for where oracle feeder authority are // delegated to. By default this struct is only used at genesis to feed in // default feeder addresses. @@ -227,38 +203,32 @@ func init() { func init() { proto.RegisterFile("kujira/oracle/genesis.proto", fileDescriptor_fb93724cfbd1d6a0) } var fileDescriptor_fb93724cfbd1d6a0 = []byte{ - // 482 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xd1, 0x6a, 0x13, 0x41, - 0x14, 0x86, 0xb3, 0x6d, 0x2c, 0x38, 0x49, 0x4a, 0x3b, 0x28, 0x84, 0x95, 0x6e, 0x62, 0x40, 0x08, - 0x16, 0x77, 0x69, 0xfb, 0x04, 0x8d, 0xad, 0x5e, 0x88, 0x50, 0xd6, 0xe0, 0x85, 0x20, 0xcb, 0xc9, - 0xee, 0xc9, 0x76, 0x35, 0xbb, 0xb3, 0xce, 0x99, 0x84, 0xea, 0x53, 0xf8, 0x1c, 0x5e, 0xfb, 0x10, - 0xbd, 0xec, 0xa5, 0x57, 0x2a, 0xc9, 0x8b, 0x48, 0x66, 0xb6, 0xcd, 0x66, 0x6d, 0xc5, 0xab, 0x84, - 0xf3, 0x7f, 0xe7, 0xff, 0x7f, 0x76, 0x66, 0xd8, 0xa3, 0x8f, 0xd3, 0x0f, 0x89, 0x04, 0x4f, 0x48, - 0x08, 0x27, 0xe8, 0xc5, 0x98, 0x21, 0x25, 0xe4, 0xe6, 0x52, 0x28, 0xc1, 0x5b, 0x46, 0x74, 0x8d, - 0x68, 0x3f, 0x88, 0x45, 0x2c, 0xb4, 0xe2, 0x2d, 0xff, 0x19, 0xc8, 0xb6, 0xd7, 0x1d, 0xcc, 0x4f, - 0xa1, 0x39, 0xa1, 0xa0, 0x54, 0x90, 0x37, 0x02, 0x42, 0x6f, 0x76, 0x30, 0x42, 0x05, 0x07, 0x5e, - 0x28, 0x92, 0xcc, 0xe8, 0xbd, 0xef, 0x75, 0xd6, 0x7c, 0x69, 0x22, 0xdf, 0x28, 0x50, 0xc8, 0x8f, - 0xd8, 0x56, 0x0e, 0x12, 0x52, 0x6a, 0x5b, 0x5d, 0xab, 0xdf, 0x38, 0x7c, 0xe8, 0xae, 0x55, 0x70, - 0xcf, 0xb4, 0x38, 0xa8, 0x5f, 0xfe, 0xec, 0xd4, 0xfc, 0x02, 0xe5, 0x43, 0xc6, 0xc7, 0x88, 0x11, - 0xca, 0x20, 0xc2, 0x09, 0xc6, 0xa0, 0x12, 0x91, 0x51, 0x7b, 0xa3, 0xbb, 0xd9, 0x6f, 0x1c, 0x76, - 0x2a, 0x06, 0x2f, 0x34, 0x78, 0x72, 0xc3, 0x15, 0x56, 0xbb, 0xe3, 0xca, 0x9c, 0x78, 0xc8, 0xb6, - 0xf1, 0x22, 0x3c, 0x87, 0x2c, 0xc6, 0x40, 0x82, 0x42, 0x6a, 0x6f, 0x6a, 0xc7, 0x6e, 0xc5, 0xf1, - 0xb4, 0x80, 0x7c, 0x50, 0x38, 0x9c, 0xe6, 0x13, 0x1c, 0xd8, 0x4b, 0xcb, 0x6f, 0xbf, 0x3a, 0xfc, - 0x2f, 0x89, 0xfc, 0x16, 0x96, 0x66, 0xc4, 0x4f, 0x59, 0x2b, 0x4d, 0x88, 0x82, 0x50, 0x4c, 0x33, - 0x85, 0x92, 0xda, 0x75, 0x9d, 0x61, 0x57, 0x32, 0x5e, 0x27, 0x44, 0xcf, 0x0d, 0x52, 0x14, 0x6e, - 0xa6, 0xab, 0x11, 0xf1, 0x2f, 0xac, 0x0b, 0x71, 0x2c, 0x97, 0xdd, 0x31, 0x58, 0x6b, 0x1d, 0xe4, - 0x12, 0x67, 0x62, 0xd9, 0xfe, 0x9e, 0x76, 0xde, 0xaf, 0x38, 0x1f, 0x5f, 0xaf, 0x95, 0xbb, 0x9e, - 0x99, 0x9d, 0x22, 0x6a, 0x0f, 0xfe, 0xc1, 0x10, 0xff, 0xc4, 0xf6, 0xee, 0xca, 0x36, 0xc1, 0x5b, - 0x3a, 0xb8, 0xff, 0x3f, 0xc1, 0x6f, 0x57, 0xa9, 0x36, 0xdc, 0x05, 0x50, 0x6f, 0xcc, 0x76, 0xaa, - 0xe7, 0xc8, 0x9f, 0xb0, 0xed, 0xe2, 0x12, 0x40, 0x14, 0x49, 0x24, 0x73, 0x83, 0xee, 0xfb, 0x2d, - 0x33, 0x3d, 0x36, 0x43, 0xbe, 0xcf, 0x76, 0x67, 0x30, 0x49, 0x22, 0x50, 0x62, 0x45, 0x6e, 0x68, - 0x72, 0xe7, 0x46, 0x28, 0xe0, 0xde, 0x7b, 0xd6, 0x28, 0x7d, 0xf9, 0xdb, 0x77, 0xad, 0xdb, 0x77, - 0xf9, 0x63, 0xd6, 0x2c, 0x9f, 0xac, 0xce, 0xa8, 0xfb, 0x8d, 0xd2, 0xb1, 0x0d, 0x4e, 0x2e, 0xe7, - 0x8e, 0x75, 0x35, 0x77, 0xac, 0xdf, 0x73, 0xc7, 0xfa, 0xba, 0x70, 0x6a, 0x57, 0x0b, 0xa7, 0xf6, - 0x63, 0xe1, 0xd4, 0xde, 0x3d, 0x8d, 0x13, 0x75, 0x3e, 0x1d, 0xb9, 0xa1, 0x48, 0xbd, 0x21, 0x42, - 0xfa, 0xec, 0x95, 0x79, 0x63, 0xa1, 0x90, 0xe8, 0x5d, 0x5c, 0x3f, 0x35, 0xf5, 0x39, 0x47, 0x1a, - 0x6d, 0xe9, 0xa7, 0x74, 0xf4, 0x27, 0x00, 0x00, 0xff, 0xff, 0xd4, 0x13, 0xee, 0x53, 0xca, 0x03, - 0x00, 0x00, + // 396 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xd1, 0x8a, 0xd3, 0x40, + 0x14, 0x86, 0x93, 0xdd, 0x65, 0xc1, 0x49, 0xb3, 0xac, 0x83, 0x42, 0x89, 0x90, 0xad, 0x05, 0x61, + 0x51, 0xcc, 0xb0, 0xbb, 0x4f, 0x60, 0xdd, 0xd5, 0x0b, 0x11, 0x24, 0xee, 0x95, 0x20, 0x65, 0x32, + 0x39, 0x9b, 0x8e, 0x26, 0x99, 0x30, 0x67, 0x52, 0xea, 0x5b, 0xf8, 0x1c, 0x3e, 0x49, 0x2f, 0x7b, + 0xe9, 0x95, 0x4a, 0xfb, 0x00, 0xbe, 0x82, 0x34, 0x13, 0x6d, 0x5a, 0x7b, 0x35, 0xc3, 0xff, 0xfd, + 0xe7, 0xfc, 0xe7, 0xc0, 0x21, 0x8f, 0x3e, 0xd7, 0x9f, 0xa4, 0xe6, 0x4c, 0x69, 0x2e, 0x72, 0x60, + 0x19, 0x94, 0x80, 0x12, 0xa3, 0x4a, 0x2b, 0xa3, 0xa8, 0x6f, 0x61, 0x64, 0x61, 0xf0, 0x20, 0x53, + 0x99, 0x6a, 0x08, 0x5b, 0xff, 0xac, 0x29, 0x08, 0xb6, 0x3b, 0xd8, 0xa7, 0x65, 0xa1, 0x50, 0x58, + 0x28, 0x64, 0x09, 0x47, 0x60, 0xd3, 0x8b, 0x04, 0x0c, 0xbf, 0x60, 0x42, 0xc9, 0xd2, 0xf2, 0xe1, + 0x6f, 0x97, 0xf4, 0x5e, 0xdb, 0xc8, 0xf7, 0x86, 0x1b, 0xa0, 0x57, 0xe4, 0xb8, 0xe2, 0x9a, 0x17, + 0xd8, 0x77, 0x07, 0xee, 0xb9, 0x77, 0xf9, 0x30, 0xda, 0x1a, 0x21, 0x7a, 0xd7, 0xc0, 0xd1, 0xd1, + 0xfc, 0xc7, 0x99, 0x13, 0xb7, 0x56, 0x2a, 0xc8, 0x09, 0xcc, 0xc4, 0x84, 0x97, 0x19, 0x8c, 0x35, + 0x37, 0x80, 0xfd, 0x83, 0xc1, 0xe1, 0xb9, 0x77, 0x39, 0xd8, 0x29, 0xbe, 0x69, 0x4d, 0x31, 0x37, + 0x70, 0x5b, 0x57, 0x39, 0x8c, 0x82, 0x75, 0x9f, 0x6f, 0x3f, 0xcf, 0xe8, 0x7f, 0x08, 0x63, 0x1f, + 0x3a, 0x1a, 0xd2, 0x1b, 0xe2, 0x17, 0x12, 0x71, 0x2c, 0x54, 0x5d, 0x1a, 0xd0, 0xd8, 0x3f, 0x6c, + 0x32, 0x82, 0x9d, 0x8c, 0xb7, 0x12, 0xf1, 0xa5, 0xb5, 0xb4, 0x53, 0xf6, 0x8a, 0x8d, 0x84, 0xc3, + 0x3b, 0x72, 0xfa, 0x0a, 0x20, 0x05, 0x7d, 0x0d, 0x39, 0x64, 0xdc, 0x48, 0x55, 0xd2, 0x27, 0xe4, + 0xe4, 0xae, 0xd1, 0xc6, 0x3c, 0x4d, 0x35, 0xa0, 0x5d, 0xfe, 0x5e, 0xec, 0x5b, 0xf5, 0x85, 0x15, + 0xe9, 0x33, 0x72, 0x7f, 0xca, 0x73, 0x99, 0x72, 0xa3, 0x36, 0xce, 0x83, 0xc6, 0x79, 0xfa, 0x0f, + 0xb4, 0xe6, 0xe1, 0x47, 0xe2, 0x75, 0x46, 0xd9, 0x5f, 0xeb, 0xee, 0xaf, 0xa5, 0x8f, 0x49, 0xaf, + 0xbb, 0x6a, 0x93, 0x71, 0x14, 0x7b, 0x9d, 0x3d, 0x46, 0xd7, 0xf3, 0x65, 0xe8, 0x2e, 0x96, 0xa1, + 0xfb, 0x6b, 0x19, 0xba, 0x5f, 0x57, 0xa1, 0xb3, 0x58, 0x85, 0xce, 0xf7, 0x55, 0xe8, 0x7c, 0x78, + 0x9a, 0x49, 0x33, 0xa9, 0x93, 0x48, 0xa8, 0x82, 0xdd, 0x02, 0x2f, 0x9e, 0xbf, 0xb1, 0xe7, 0x21, + 0x94, 0x06, 0x36, 0xfb, 0x7b, 0x25, 0xe6, 0x4b, 0x05, 0x98, 0x1c, 0x37, 0x57, 0x70, 0xf5, 0x27, + 0x00, 0x00, 0xff, 0xff, 0x7b, 0x19, 0x13, 0x2d, 0x85, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -281,34 +251,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.AggregateExchangeRateVotes) > 0 { - for iNdEx := len(m.AggregateExchangeRateVotes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AggregateExchangeRateVotes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } - if len(m.AggregateExchangeRatePrevotes) > 0 { - for iNdEx := len(m.AggregateExchangeRatePrevotes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AggregateExchangeRatePrevotes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } if len(m.MissCounters) > 0 { for iNdEx := len(m.MissCounters) - 1; iNdEx >= 0; iNdEx-- { { @@ -320,7 +262,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } } if len(m.ExchangeRates) > 0 { @@ -334,20 +276,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - } - if len(m.FeederDelegations) > 0 { - for iNdEx := len(m.FeederDelegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FeederDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0x12 } } @@ -455,12 +383,6 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) - if len(m.FeederDelegations) > 0 { - for _, e := range m.FeederDelegations { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } if len(m.ExchangeRates) > 0 { for _, e := range m.ExchangeRates { l = e.Size() @@ -473,18 +395,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.AggregateExchangeRatePrevotes) > 0 { - for _, e := range m.AggregateExchangeRatePrevotes { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.AggregateExchangeRateVotes) > 0 { - for _, e := range m.AggregateExchangeRateVotes { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -590,40 +500,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeederDelegations", 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.FeederDelegations = append(m.FeederDelegations, FeederDelegation{}) - if err := m.FeederDelegations[len(m.FeederDelegations)-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 ExchangeRates", wireType) } @@ -657,7 +533,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MissCounters", wireType) } @@ -691,74 +567,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregateExchangeRatePrevotes", 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.AggregateExchangeRatePrevotes = append(m.AggregateExchangeRatePrevotes, AggregateExchangeRatePrevote{}) - if err := m.AggregateExchangeRatePrevotes[len(m.AggregateExchangeRatePrevotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregateExchangeRateVotes", 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.AggregateExchangeRateVotes = append(m.AggregateExchangeRateVotes, AggregateExchangeRateVote{}) - if err := m.AggregateExchangeRateVotes[len(m.AggregateExchangeRateVotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index 55c2ab54..e5cbb139 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -1,19 +1,13 @@ package types import ( - "github.com/cometbft/cometbft/crypto/tmhash" - "cosmossdk.io/errors" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // ensure Msg interface compliance at compile time var ( - _ sdk.Msg = &MsgDelegateFeedConsent{} - _ sdk.Msg = &MsgAggregateExchangeRatePrevote{} - _ sdk.Msg = &MsgAggregateExchangeRateVote{} _ sdk.Msg = &MsgAddRequiredDenom{} _ sdk.Msg = &MsgRemoveRequiredDenom{} _ sdk.Msg = &MsgUpdateParams{} @@ -21,173 +15,14 @@ var ( // oracle message types const ( - TypeMsgDelegateFeedConsent = "delegate_feeder" - TypeMsgAggregateExchangeRatePrevote = "aggregate_exchange_rate_prevote" - TypeMsgAggregateExchangeRateVote = "aggregate_exchange_rate_vote" - TypeMsgAddRequiredDenom = "add_price" - TypeMsgRemoveRequiredDenom = "remove_price" - TypeMsgUpdateParams = "update_params" + TypeMsgAddRequiredDenom = "add_price" + TypeMsgRemoveRequiredDenom = "remove_price" + TypeMsgUpdateParams = "update_params" ) //------------------------------------------------- //------------------------------------------------- -// NewMsgAggregateExchangeRatePrevote returns MsgAggregateExchangeRatePrevote instance -func NewMsgAggregateExchangeRatePrevote(hash AggregateVoteHash, feeder sdk.AccAddress, validator sdk.ValAddress) *MsgAggregateExchangeRatePrevote { - return &MsgAggregateExchangeRatePrevote{ - Hash: hash.String(), - Feeder: feeder.String(), - Validator: validator.String(), - } -} - -// Route implements sdk.Msg -func (msg MsgAggregateExchangeRatePrevote) Route() string { return RouterKey } - -// Type implements sdk.Msg -func (msg MsgAggregateExchangeRatePrevote) Type() string { return TypeMsgAggregateExchangeRatePrevote } - -// GetSigners implements sdk.Msg -func (msg MsgAggregateExchangeRatePrevote) GetSigners() []sdk.AccAddress { - feeder, err := sdk.AccAddressFromBech32(msg.Feeder) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{feeder} -} - -// ValidateBasic Implements sdk.Msg -func (msg MsgAggregateExchangeRatePrevote) ValidateBasic() error { - _, err := AggregateVoteHashFromHexString(msg.Hash) - if err != nil { - return errors.Wrapf(ErrInvalidHash, "Invalid vote hash (%s)", err) - } - - // HEX encoding doubles the hash length - if len(msg.Hash) != tmhash.TruncatedSize*2 { - return ErrInvalidHashLength - } - - _, err = sdk.AccAddressFromBech32(msg.Feeder) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid feeder address (%s)", err) - } - - _, err = sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid operator address (%s)", err) - } - - return nil -} - -// NewMsgAggregateExchangeRateVote returns MsgAggregateExchangeRateVote instance -func NewMsgAggregateExchangeRateVote(salt string, exchangeRates string, feeder sdk.AccAddress, validator sdk.ValAddress) *MsgAggregateExchangeRateVote { - return &MsgAggregateExchangeRateVote{ - Salt: salt, - ExchangeRates: exchangeRates, - Feeder: feeder.String(), - Validator: validator.String(), - } -} - -// Route implements sdk.Msg -func (msg MsgAggregateExchangeRateVote) Route() string { return RouterKey } - -// Type implements sdk.Msg -func (msg MsgAggregateExchangeRateVote) Type() string { return TypeMsgAggregateExchangeRateVote } - -// GetSigners implements sdk.Msg -func (msg MsgAggregateExchangeRateVote) GetSigners() []sdk.AccAddress { - feeder, err := sdk.AccAddressFromBech32(msg.Feeder) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{feeder} -} - -// ValidateBasic implements sdk.Msg -func (msg MsgAggregateExchangeRateVote) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Feeder) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid feeder address (%s)", err) - } - - _, err = sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid operator address (%s)", err) - } - - if l := len(msg.ExchangeRates); l == 0 { - return errors.Wrap(sdkerrors.ErrUnknownRequest, "must provide at least one oracle exchange rate") - } else if l > 4096 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "exchange rates string can not exceed 4096 characters") - } - - exchangeRates, err := ParseExchangeRateTuples(msg.ExchangeRates) - if err != nil { - return errors.Wrap(sdkerrors.ErrInvalidCoins, "failed to parse exchange rates string cause: "+err.Error()) - } - - for _, exchangeRate := range exchangeRates { - // Check overflow bit length - if exchangeRate.ExchangeRate.BigInt().BitLen() > 255+math.LegacyDecimalPrecisionBits { - return errors.Wrap(ErrInvalidExchangeRate, "overflow") - } - } - - if len(msg.Salt) != 64 { - return ErrInvalidSaltLength - } - _, err = AggregateVoteHashFromHexString(msg.Salt) - if err != nil { - return errors.Wrap(ErrInvalidSaltFormat, "salt must be a valid hex string") - } - - return nil -} - -// NewMsgDelegateFeedConsent creates a MsgDelegateFeedConsent instance -func NewMsgDelegateFeedConsent(operatorAddress sdk.ValAddress, feederAddress sdk.AccAddress) *MsgDelegateFeedConsent { - return &MsgDelegateFeedConsent{ - Operator: operatorAddress.String(), - Delegate: feederAddress.String(), - } -} - -// Route implements sdk.Msg -func (msg MsgDelegateFeedConsent) Route() string { return RouterKey } - -// Type implements sdk.Msg -func (msg MsgDelegateFeedConsent) Type() string { return TypeMsgDelegateFeedConsent } - -// GetSigners implements sdk.Msg -func (msg MsgDelegateFeedConsent) GetSigners() []sdk.AccAddress { - operator, err := sdk.ValAddressFromBech32(msg.Operator) - if err != nil { - panic(err) - } - - return []sdk.AccAddress{sdk.AccAddress(operator)} -} - -// ValidateBasic implements sdk.Msg -func (msg MsgDelegateFeedConsent) ValidateBasic() error { - _, err := sdk.ValAddressFromBech32(msg.Operator) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid operator address (%s)", err) - } - - _, err = sdk.AccAddressFromBech32(msg.Delegate) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid delegate address (%s)", err) - } - - return nil -} - // NewMsgAddRequiredDenom creates a MsgAddRequiredDenom instance func NewMsgAddRequiredDenom(symbol string) *MsgAddRequiredDenom { return &MsgAddRequiredDenom{ diff --git a/x/oracle/types/msgs_test.go b/x/oracle/types/msgs_test.go index 95de9483..429d36cf 100644 --- a/x/oracle/types/msgs_test.go +++ b/x/oracle/types/msgs_test.go @@ -2,120 +2,8 @@ package types_test import ( "math/rand" - "testing" - - "cosmossdk.io/math" - "github.com/Team-Kujira/core/x/oracle/types" - - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" ) -func TestMsgFeederDelegation(t *testing.T) { - addrs := []sdk.AccAddress{ - sdk.AccAddress([]byte("addr1_______________")), - sdk.AccAddress([]byte("addr2_______________")), - } - - tests := []struct { - delegator sdk.ValAddress - delegate sdk.AccAddress - expectPass bool - }{ - {sdk.ValAddress(addrs[0]), addrs[1], true}, - {sdk.ValAddress{}, addrs[1], false}, - {sdk.ValAddress(addrs[0]), sdk.AccAddress{}, false}, - {nil, nil, false}, - } - - for i, tc := range tests { - msg := types.NewMsgDelegateFeedConsent(tc.delegator, tc.delegate) - if tc.expectPass { - require.Nil(t, msg.ValidateBasic(), "test: %v", i) - } else { - require.NotNil(t, msg.ValidateBasic(), "test: %v", i) - } - } -} - -func TestMsgAggregateExchangeRatePrevote(t *testing.T) { - addrs := []sdk.AccAddress{ - sdk.AccAddress([]byte("addr1_______________")), - } - - exchangeRates := sdk.DecCoins{ - sdk.NewDecCoinFromDec( - types.TestDenomD, - math.LegacyOneDec(), - ), - sdk.NewDecCoinFromDec( - types.TestDenomC, - math.LegacyNewDecWithPrec(32121, 1), - ), - } - bz := types.GetAggregateVoteHash("1", exchangeRates.String(), sdk.ValAddress(addrs[0])) - - tests := []struct { - hash types.AggregateVoteHash - exchangeRates sdk.DecCoins - voter sdk.AccAddress - expectPass bool - }{ - {bz, exchangeRates, addrs[0], true}, - {bz[1:], exchangeRates, addrs[0], false}, - {bz, exchangeRates, sdk.AccAddress{}, false}, - {types.AggregateVoteHash{}, exchangeRates, addrs[0], false}, - } - - for i, tc := range tests { - msg := types.NewMsgAggregateExchangeRatePrevote(tc.hash, tc.voter, sdk.ValAddress(tc.voter)) - if tc.expectPass { - require.NoError(t, msg.ValidateBasic(), "test: %v", i) - } else { - require.Error(t, msg.ValidateBasic(), "test: %v", i) - } - } -} - -func TestMsgAggregateExchangeRateVote(t *testing.T) { - addrs := []sdk.AccAddress{ - sdk.AccAddress([]byte("addr1_______________")), - } - - invalidExchangeRates := "a,b" - exchangeRates := "1.0foo,1232.132bar" - abstainExchangeRates := "0.0foo,1232.132bar" - overFlowExchangeRates := "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0foo,1232.132bar" - - tests := []struct { - voter sdk.AccAddress - validator sdk.ValAddress - salt string - exchangeRates string - expectPass bool - }{ - {addrs[0], sdk.ValAddress(addrs[0]), "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80", exchangeRates, true}, - {addrs[0], sdk.ValAddress(addrs[0]), "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80", invalidExchangeRates, false}, - {addrs[0], sdk.ValAddress(addrs[0]), "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80", abstainExchangeRates, true}, - {addrs[0], sdk.ValAddress(addrs[0]), "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80", overFlowExchangeRates, false}, - {sdk.AccAddress{}, sdk.ValAddress(addrs[0]), "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80", exchangeRates, false}, - {addrs[0], sdk.ValAddress(addrs[0]), "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80", "", false}, - {addrs[0], sdk.ValAddress(addrs[0]), "", randSeq(4097), false}, - {addrs[0], sdk.ValAddress{}, "fc246cf5a18c7a650a6a226ebc589d49a9a814d6f1f586405e8726e5cf2a7d80", abstainExchangeRates, false}, - {addrs[0], sdk.ValAddress(addrs[0]), "", abstainExchangeRates, false}, - } - - for i, tc := range tests { - msg := types.NewMsgAggregateExchangeRateVote(tc.salt, tc.exchangeRates, tc.voter, tc.validator) - if tc.expectPass { - require.Nil(t, msg.ValidateBasic(), "test: %v", i) - } else { - require.NotNil(t, msg.ValidateBasic(), "test: %v", i) - } - } -} - var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func randSeq(n int) string { diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index b4eefa9f..ae079eef 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -136,85 +136,6 @@ func (m *Denom) XXX_DiscardUnknown() { var xxx_messageInfo_Denom proto.InternalMessageInfo -// struct for aggregate prevoting on the ExchangeRateVote. -// The purpose of aggregate prevote is to hide vote exchange rates with hash -// which is formatted as hex string in SHA256("{salt}:{exchange rate}{denom},...,{exchange rate}{denom}:{voter}") -type AggregateExchangeRatePrevote struct { - Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty" yaml:"hash"` - Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty" yaml:"voter"` - SubmitBlock uint64 `protobuf:"varint,3,opt,name=submit_block,json=submitBlock,proto3" json:"submit_block,omitempty" yaml:"submit_block"` -} - -func (m *AggregateExchangeRatePrevote) Reset() { *m = AggregateExchangeRatePrevote{} } -func (*AggregateExchangeRatePrevote) ProtoMessage() {} -func (*AggregateExchangeRatePrevote) Descriptor() ([]byte, []int) { - return fileDescriptor_8fffe8fb5ee63325, []int{2} -} -func (m *AggregateExchangeRatePrevote) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AggregateExchangeRatePrevote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AggregateExchangeRatePrevote.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 *AggregateExchangeRatePrevote) XXX_Merge(src proto.Message) { - xxx_messageInfo_AggregateExchangeRatePrevote.Merge(m, src) -} -func (m *AggregateExchangeRatePrevote) XXX_Size() int { - return m.Size() -} -func (m *AggregateExchangeRatePrevote) XXX_DiscardUnknown() { - xxx_messageInfo_AggregateExchangeRatePrevote.DiscardUnknown(m) -} - -var xxx_messageInfo_AggregateExchangeRatePrevote proto.InternalMessageInfo - -// MsgAggregateExchangeRateVote - struct for voting on exchange rates. -type AggregateExchangeRateVote struct { - ExchangeRateTuples ExchangeRateTuples `protobuf:"bytes,1,rep,name=exchange_rate_tuples,json=exchangeRateTuples,proto3,castrepeated=ExchangeRateTuples" json:"exchange_rate_tuples" yaml:"exchange_rate_tuples"` - Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty" yaml:"voter"` -} - -func (m *AggregateExchangeRateVote) Reset() { *m = AggregateExchangeRateVote{} } -func (*AggregateExchangeRateVote) ProtoMessage() {} -func (*AggregateExchangeRateVote) Descriptor() ([]byte, []int) { - return fileDescriptor_8fffe8fb5ee63325, []int{3} -} -func (m *AggregateExchangeRateVote) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AggregateExchangeRateVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AggregateExchangeRateVote.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 *AggregateExchangeRateVote) XXX_Merge(src proto.Message) { - xxx_messageInfo_AggregateExchangeRateVote.Merge(m, src) -} -func (m *AggregateExchangeRateVote) XXX_Size() int { - return m.Size() -} -func (m *AggregateExchangeRateVote) XXX_DiscardUnknown() { - xxx_messageInfo_AggregateExchangeRateVote.DiscardUnknown(m) -} - -var xxx_messageInfo_AggregateExchangeRateVote proto.InternalMessageInfo - // ExchangeRateTuple - struct to store interpreted exchange rates data to store type ExchangeRateTuple struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` @@ -224,7 +145,7 @@ type ExchangeRateTuple struct { func (m *ExchangeRateTuple) Reset() { *m = ExchangeRateTuple{} } func (*ExchangeRateTuple) ProtoMessage() {} func (*ExchangeRateTuple) Descriptor() ([]byte, []int) { - return fileDescriptor_8fffe8fb5ee63325, []int{4} + return fileDescriptor_8fffe8fb5ee63325, []int{2} } func (m *ExchangeRateTuple) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -256,63 +177,53 @@ var xxx_messageInfo_ExchangeRateTuple proto.InternalMessageInfo func init() { proto.RegisterType((*Params)(nil), "kujira.oracle.Params") proto.RegisterType((*Denom)(nil), "kujira.oracle.Denom") - proto.RegisterType((*AggregateExchangeRatePrevote)(nil), "kujira.oracle.AggregateExchangeRatePrevote") - proto.RegisterType((*AggregateExchangeRateVote)(nil), "kujira.oracle.AggregateExchangeRateVote") proto.RegisterType((*ExchangeRateTuple)(nil), "kujira.oracle.ExchangeRateTuple") } func init() { proto.RegisterFile("kujira/oracle/oracle.proto", fileDescriptor_8fffe8fb5ee63325) } var fileDescriptor_8fffe8fb5ee63325 = []byte{ - // 762 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x3f, 0x6f, 0xfb, 0x44, - 0x18, 0x8e, 0x69, 0x1b, 0x7e, 0xb9, 0x24, 0xfd, 0x63, 0x42, 0x31, 0x29, 0x8a, 0xa3, 0x43, 0xa0, - 0x08, 0x89, 0x58, 0x85, 0x01, 0x11, 0x58, 0x30, 0x81, 0x85, 0x0e, 0xd1, 0xa9, 0x2a, 0xa2, 0x8b, - 0xb9, 0xd8, 0x87, 0x7d, 0xd4, 0xf6, 0x85, 0x3b, 0xe7, 0x4f, 0xbf, 0x01, 0x0b, 0x12, 0x23, 0x63, - 0x07, 0x26, 0x98, 0xf9, 0x0e, 0x1d, 0x3b, 0x22, 0x06, 0x03, 0xed, 0xc2, 0x9c, 0x4f, 0x80, 0xee, - 0xce, 0x69, 0xf3, 0xa7, 0x43, 0x60, 0x4a, 0x9e, 0xe7, 0x79, 0xdf, 0xe7, 0x7d, 0x7d, 0xef, 0xbd, - 0x36, 0x68, 0x5e, 0x8d, 0xbf, 0xa5, 0x1c, 0x3b, 0x8c, 0x63, 0x3f, 0x26, 0xc5, 0x4f, 0x77, 0xc4, - 0x59, 0xc6, 0xcc, 0xba, 0xd6, 0xba, 0x9a, 0x6c, 0x36, 0x42, 0x16, 0x32, 0xa5, 0x38, 0xf2, 0x9f, - 0x0e, 0x6a, 0xb6, 0x7c, 0x26, 0x12, 0x26, 0x9c, 0x21, 0x16, 0xc4, 0x99, 0x9c, 0x0e, 0x49, 0x86, - 0x4f, 0x1d, 0x9f, 0xd1, 0x54, 0xeb, 0xf0, 0xe7, 0x32, 0x28, 0x0f, 0x30, 0xc7, 0x89, 0x30, 0x3f, - 0x00, 0xd5, 0x09, 0xcb, 0x88, 0x37, 0x22, 0x9c, 0xb2, 0xc0, 0x32, 0xda, 0x46, 0x67, 0xd7, 0x3d, - 0x9e, 0xe7, 0xb6, 0x79, 0x8d, 0x93, 0xb8, 0x07, 0x97, 0x44, 0x88, 0x80, 0x44, 0x03, 0x05, 0x4c, - 0x1f, 0xec, 0x2b, 0x2d, 0x8b, 0x38, 0x11, 0x11, 0x8b, 0x03, 0xeb, 0xa5, 0xb6, 0xd1, 0xa9, 0xb8, - 0x1f, 0xdf, 0xe6, 0x76, 0xe9, 0x8f, 0xdc, 0x3e, 0xd1, 0x3d, 0x88, 0xe0, 0xaa, 0x4b, 0x99, 0x93, - 0xe0, 0x2c, 0xea, 0x9e, 0x91, 0x10, 0xfb, 0xd7, 0x7d, 0xe2, 0xcf, 0x73, 0xfb, 0xd5, 0x25, 0xfb, - 0x47, 0x0b, 0x88, 0xea, 0x92, 0x38, 0x5f, 0x60, 0xf3, 0x6b, 0x50, 0x4f, 0xf0, 0xcc, 0x0b, 0xc8, - 0x84, 0xe2, 0x8c, 0xb2, 0xd4, 0xda, 0x51, 0x35, 0x3e, 0xda, 0xae, 0x46, 0x43, 0xd7, 0x58, 0x71, - 0x80, 0xa8, 0x96, 0xe0, 0x59, 0x7f, 0x01, 0xcd, 0x4f, 0xc1, 0x01, 0x27, 0xdf, 0x8d, 0x29, 0x27, - 0x81, 0x17, 0x90, 0x94, 0x25, 0xc2, 0xda, 0x6d, 0xef, 0x74, 0x2a, 0x6e, 0x73, 0x9e, 0xdb, 0xc7, - 0xda, 0x60, 0x2d, 0x00, 0xa2, 0xfd, 0x05, 0xd3, 0x57, 0x84, 0x3c, 0x0b, 0x11, 0x63, 0x11, 0x79, - 0xdf, 0x70, 0xec, 0xab, 0x3e, 0xf7, 0xfe, 0xc7, 0x59, 0xac, 0x5a, 0x40, 0x54, 0x57, 0xc4, 0xe7, - 0x05, 0x36, 0x7b, 0xa0, 0xa6, 0x23, 0xa6, 0x34, 0x0d, 0xd8, 0xd4, 0x2a, 0xab, 0x51, 0xbd, 0x36, - 0xcf, 0xed, 0x57, 0x96, 0xf3, 0xb5, 0x0a, 0x51, 0x55, 0xc1, 0x2f, 0x15, 0x32, 0x05, 0x68, 0x24, - 0x34, 0xf5, 0x26, 0x38, 0xa6, 0x81, 0x9c, 0xe6, 0xc2, 0xe3, 0x65, 0xd5, 0xa6, 0xbb, 0x5d, 0x9b, - 0x27, 0xc5, 0x71, 0x3e, 0x63, 0x04, 0xd1, 0x51, 0x42, 0xd3, 0x0b, 0xc9, 0x0e, 0x08, 0x2f, 0x8a, - 0x5e, 0x82, 0x2a, 0x27, 0x53, 0xcc, 0x03, 0x6f, 0x88, 0xd3, 0xc0, 0x7a, 0xa1, 0x6a, 0x7d, 0xb8, - 0x5d, 0x2d, 0x73, 0x71, 0xf2, 0x8f, 0xf9, 0x10, 0x01, 0x8d, 0x5c, 0x9c, 0x06, 0xe6, 0x57, 0xa0, - 0x32, 0x8d, 0x68, 0x46, 0x62, 0x2a, 0x32, 0xab, 0xd2, 0xde, 0xe9, 0x54, 0xdf, 0x6b, 0x74, 0x57, - 0x56, 0xa3, 0xab, 0x66, 0xe3, 0xbe, 0x25, 0xeb, 0xcd, 0x73, 0xfb, 0x50, 0x1b, 0x3e, 0x26, 0xc1, - 0x5f, 0xfe, 0xb4, 0x2b, 0x2a, 0xe4, 0x8c, 0x8a, 0x0c, 0x3d, 0xb9, 0xf5, 0x5e, 0xfc, 0x74, 0x63, - 0x97, 0xfe, 0xb9, 0xb1, 0x0d, 0xd8, 0x03, 0x7b, 0x2a, 0xc2, 0x7c, 0x13, 0xec, 0xa6, 0x38, 0x21, - 0x6a, 0x3b, 0x2a, 0xee, 0xc1, 0x3c, 0xb7, 0xab, 0xda, 0x4e, 0xb2, 0x10, 0x29, 0xb1, 0x57, 0xfb, - 0xfe, 0xc6, 0x2e, 0x15, 0xb9, 0x25, 0xf8, 0x9b, 0x01, 0xde, 0xf8, 0x24, 0x0c, 0x39, 0x09, 0x71, - 0x46, 0x3e, 0x9b, 0xf9, 0x11, 0x4e, 0x43, 0x82, 0x70, 0x46, 0x06, 0x9c, 0xc8, 0x3b, 0x2e, 0x3d, - 0x23, 0x2c, 0xa2, 0x4d, 0x4f, 0xc9, 0x42, 0xa4, 0x44, 0xf3, 0x6d, 0xb0, 0x27, 0x83, 0x79, 0xb1, - 0x5b, 0x87, 0xf3, 0xdc, 0xae, 0x3d, 0x2d, 0x0e, 0x87, 0x48, 0xcb, 0xea, 0x6e, 0x8c, 0x87, 0x09, - 0xcd, 0xbc, 0x61, 0xcc, 0xfc, 0x2b, 0xb5, 0x26, 0xab, 0x77, 0x63, 0x49, 0x95, 0x77, 0x43, 0x41, - 0x57, 0xa2, 0xb5, 0xbe, 0xff, 0x36, 0xc0, 0xeb, 0xcf, 0xf6, 0x7d, 0x21, 0x9b, 0xfe, 0xc1, 0x00, - 0x0d, 0x52, 0x90, 0x1e, 0xc7, 0x72, 0x77, 0xc7, 0xa3, 0x98, 0x08, 0xcb, 0x50, 0x23, 0x68, 0xaf, - 0x8d, 0x60, 0x39, 0xff, 0x5c, 0x06, 0xea, 0xf1, 0x3f, 0xdd, 0xa5, 0xe7, 0xbc, 0xe4, 0x64, 0xcc, - 0x8d, 0x4c, 0x81, 0x4c, 0xb2, 0xc1, 0x6d, 0x7b, 0x3e, 0x6b, 0xcf, 0xf8, 0xab, 0x01, 0x8e, 0x36, - 0x0a, 0x48, 0x2f, 0xb5, 0xdf, 0xc5, 0x44, 0x96, 0xbc, 0x14, 0x0d, 0x91, 0x96, 0xe5, 0x3b, 0x69, - 0xa5, 0xed, 0xa2, 0xf6, 0x7f, 0x7b, 0x27, 0xad, 0x38, 0x40, 0x54, 0x5b, 0x7e, 0xb6, 0xd5, 0x6e, - 0xdd, 0xfe, 0xed, 0x7d, 0xcb, 0xb8, 0xbb, 0x6f, 0x19, 0x7f, 0xdd, 0xb7, 0x8c, 0x1f, 0x1f, 0x5a, - 0xa5, 0xbb, 0x87, 0x56, 0xe9, 0xf7, 0x87, 0x56, 0xe9, 0xf2, 0x9d, 0x90, 0x66, 0xd1, 0x78, 0xd8, - 0xf5, 0x59, 0xe2, 0x9c, 0x13, 0x9c, 0xbc, 0xfb, 0x85, 0xfe, 0x6e, 0xf8, 0x8c, 0x13, 0x67, 0xb6, - 0xf8, 0x7c, 0x64, 0xd7, 0x23, 0x22, 0x86, 0x65, 0xf5, 0xe6, 0x7f, 0xff, 0xdf, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x57, 0xf0, 0xd5, 0x10, 0x5c, 0x06, 0x00, 0x00, + // 639 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x3d, 0x6f, 0xd3, 0x40, + 0x18, 0xb6, 0x69, 0x1b, 0x9a, 0x4b, 0xd2, 0x0f, 0x13, 0x8a, 0x95, 0x4a, 0x76, 0x74, 0x08, 0x14, + 0x21, 0x61, 0xab, 0x30, 0x20, 0x02, 0x93, 0x09, 0x2c, 0x74, 0xa8, 0xac, 0x0a, 0x44, 0x17, 0x73, + 0xb1, 0x8f, 0xf8, 0xa8, 0xed, 0x0b, 0xe7, 0xcb, 0x47, 0xff, 0x01, 0x23, 0x23, 0x63, 0x07, 0x26, + 0xf8, 0x23, 0x1d, 0x3b, 0x22, 0x06, 0x83, 0xda, 0x85, 0xd9, 0xbf, 0x00, 0xf9, 0xce, 0x29, 0x09, + 0x62, 0x28, 0x4c, 0xf6, 0xf3, 0x3c, 0xef, 0xfb, 0x3c, 0xaf, 0xee, 0x0b, 0xb4, 0x0e, 0x47, 0x6f, + 0x09, 0x43, 0x36, 0x65, 0xc8, 0x8f, 0x70, 0xf9, 0xb1, 0x86, 0x8c, 0x72, 0xaa, 0x35, 0xa4, 0x66, + 0x49, 0xb2, 0xd5, 0x1c, 0xd0, 0x01, 0x15, 0x8a, 0x5d, 0xfc, 0xc9, 0xa2, 0x96, 0xe1, 0xd3, 0x34, + 0xa6, 0xa9, 0xdd, 0x47, 0x29, 0xb6, 0xc7, 0x3b, 0x7d, 0xcc, 0xd1, 0x8e, 0xed, 0x53, 0x92, 0x48, + 0x1d, 0x7e, 0xaa, 0x80, 0xca, 0x1e, 0x62, 0x28, 0x4e, 0xb5, 0x07, 0xa0, 0x36, 0xa6, 0x1c, 0x7b, + 0x43, 0xcc, 0x08, 0x0d, 0x74, 0xb5, 0xad, 0x76, 0x96, 0x9d, 0xad, 0x3c, 0x33, 0xb5, 0x23, 0x14, + 0x47, 0x5d, 0x38, 0x27, 0x42, 0x17, 0x14, 0x68, 0x4f, 0x00, 0xcd, 0x07, 0x6b, 0x42, 0xe3, 0x21, + 0xc3, 0x69, 0x48, 0xa3, 0x40, 0xbf, 0xd2, 0x56, 0x3b, 0x55, 0xe7, 0xf1, 0x49, 0x66, 0x2a, 0xdf, + 0x32, 0x73, 0x5b, 0xce, 0x90, 0x06, 0x87, 0x16, 0xa1, 0x76, 0x8c, 0x78, 0x68, 0xed, 0xe2, 0x01, + 0xf2, 0x8f, 0x7a, 0xd8, 0xcf, 0x33, 0xf3, 0xfa, 0x9c, 0xfd, 0x85, 0x05, 0x74, 0x1b, 0x05, 0xb1, + 0x3f, 0xc3, 0xda, 0x6b, 0xd0, 0x88, 0xd1, 0xd4, 0x0b, 0xf0, 0x98, 0x20, 0x4e, 0x68, 0xa2, 0x2f, + 0x89, 0x8c, 0x47, 0x97, 0xcb, 0x68, 0xca, 0x8c, 0x05, 0x07, 0xe8, 0xd6, 0x63, 0x34, 0xed, 0xcd, + 0xa0, 0xf6, 0x04, 0xac, 0x33, 0xfc, 0x6e, 0x44, 0x18, 0x0e, 0xbc, 0x00, 0x27, 0x34, 0x4e, 0xf5, + 0xe5, 0xf6, 0x52, 0xa7, 0xea, 0xb4, 0xf2, 0xcc, 0xdc, 0x92, 0x06, 0x7f, 0x14, 0x40, 0x77, 0x6d, + 0xc6, 0xf4, 0x04, 0x51, 0xac, 0x45, 0x1a, 0xa1, 0x34, 0xf4, 0xde, 0x30, 0xe4, 0x8b, 0x39, 0x57, + 0xfe, 0x63, 0x2d, 0x16, 0x2d, 0xa0, 0xdb, 0x10, 0xc4, 0xb3, 0x12, 0x6b, 0x5d, 0x50, 0x97, 0x15, + 0x13, 0x92, 0x04, 0x74, 0xa2, 0x57, 0xc4, 0x56, 0xdd, 0xc8, 0x33, 0xf3, 0xda, 0x7c, 0xbf, 0x54, + 0xa1, 0x5b, 0x13, 0xf0, 0xa5, 0x40, 0x5a, 0x0a, 0x9a, 0x31, 0x49, 0xbc, 0x31, 0x8a, 0x48, 0x50, + 0xec, 0xe6, 0xcc, 0xe3, 0xaa, 0x18, 0xd3, 0xb9, 0xdc, 0x98, 0xdb, 0xe5, 0x72, 0xfe, 0xc5, 0x08, + 0xba, 0x9b, 0x31, 0x49, 0x5e, 0x14, 0xec, 0x1e, 0x66, 0x65, 0xe8, 0x01, 0xa8, 0x31, 0x3c, 0x41, + 0x2c, 0xf0, 0xfa, 0x28, 0x09, 0xf4, 0x55, 0x91, 0xf5, 0xf0, 0x72, 0x59, 0xda, 0x6c, 0xe5, 0x2f, + 0xfa, 0xa1, 0x0b, 0x24, 0x72, 0x50, 0x12, 0x68, 0xaf, 0x40, 0x75, 0x12, 0x12, 0x8e, 0x23, 0x92, + 0x72, 0xbd, 0xda, 0x5e, 0xea, 0xd4, 0xee, 0x35, 0xad, 0x85, 0xab, 0x61, 0x89, 0xbd, 0x71, 0x6e, + 0x15, 0x79, 0x79, 0x66, 0x6e, 0x48, 0xc3, 0x8b, 0x26, 0xf8, 0xf9, 0xbb, 0x59, 0x15, 0x25, 0xbb, + 0x24, 0xe5, 0xee, 0x6f, 0xb7, 0xee, 0xea, 0xc7, 0x63, 0x53, 0xf9, 0x79, 0x6c, 0xaa, 0xb0, 0x0b, + 0x56, 0x44, 0x85, 0x76, 0x13, 0x2c, 0x27, 0x28, 0xc6, 0xe2, 0x76, 0x54, 0x9d, 0xf5, 0x3c, 0x33, + 0x6b, 0xd2, 0xae, 0x60, 0xa1, 0x2b, 0xc4, 0x6e, 0xfd, 0xfd, 0xb1, 0xa9, 0x94, 0xbd, 0x0a, 0xfc, + 0xa2, 0x82, 0xcd, 0xa7, 0x53, 0x3f, 0x44, 0xc9, 0x00, 0xbb, 0x88, 0xe3, 0xfd, 0xd1, 0x30, 0xc2, + 0xda, 0x6d, 0xb0, 0x22, 0xce, 0x50, 0xe9, 0xb4, 0x91, 0x67, 0x66, 0x5d, 0x3a, 0x09, 0x1a, 0xba, + 0x52, 0x2e, 0xce, 0x3d, 0x2e, 0x9b, 0x3d, 0x86, 0x38, 0x2e, 0xef, 0xd6, 0xbf, 0x9d, 0xfb, 0x05, + 0x07, 0xe8, 0xd6, 0xf1, 0xdc, 0x38, 0x8b, 0xd3, 0x3a, 0xbd, 0x93, 0x33, 0x43, 0x3d, 0x3d, 0x33, + 0xd4, 0x1f, 0x67, 0x86, 0xfa, 0xe1, 0xdc, 0x50, 0x4e, 0xcf, 0x0d, 0xe5, 0xeb, 0xb9, 0xa1, 0x1c, + 0xdc, 0x19, 0x10, 0x1e, 0x8e, 0xfa, 0x96, 0x4f, 0x63, 0x7b, 0x1f, 0xa3, 0xf8, 0xee, 0x73, 0xf9, + 0x36, 0xf9, 0x94, 0x61, 0x7b, 0x3a, 0x7b, 0xa2, 0xf8, 0xd1, 0x10, 0xa7, 0xfd, 0x8a, 0x78, 0x5d, + 0xee, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xcd, 0x96, 0xa6, 0xc0, 0x04, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -509,92 +420,6 @@ func (m *Denom) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *AggregateExchangeRatePrevote) 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 *AggregateExchangeRatePrevote) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AggregateExchangeRatePrevote) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.SubmitBlock != 0 { - i = encodeVarintOracle(dAtA, i, uint64(m.SubmitBlock)) - i-- - dAtA[i] = 0x18 - } - if len(m.Voter) > 0 { - i -= len(m.Voter) - copy(dAtA[i:], m.Voter) - i = encodeVarintOracle(dAtA, i, uint64(len(m.Voter))) - i-- - dAtA[i] = 0x12 - } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintOracle(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *AggregateExchangeRateVote) 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 *AggregateExchangeRateVote) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AggregateExchangeRateVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Voter) > 0 { - i -= len(m.Voter) - copy(dAtA[i:], m.Voter) - i = encodeVarintOracle(dAtA, i, uint64(len(m.Voter))) - i-- - dAtA[i] = 0x12 - } - if len(m.ExchangeRateTuples) > 0 { - for iNdEx := len(m.ExchangeRateTuples) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ExchangeRateTuples[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintOracle(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func (m *ExchangeRateTuple) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -696,45 +521,6 @@ func (m *Denom) Size() (n int) { return n } -func (m *AggregateExchangeRatePrevote) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovOracle(uint64(l)) - } - l = len(m.Voter) - if l > 0 { - n += 1 + l + sovOracle(uint64(l)) - } - if m.SubmitBlock != 0 { - n += 1 + sovOracle(uint64(m.SubmitBlock)) - } - return n -} - -func (m *AggregateExchangeRateVote) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ExchangeRateTuples) > 0 { - for _, e := range m.ExchangeRateTuples { - l = e.Size() - n += 1 + l + sovOracle(uint64(l)) - } - } - l = len(m.Voter) - if l > 0 { - n += 1 + l + sovOracle(uint64(l)) - } - return n -} - func (m *ExchangeRateTuple) Size() (n int) { if m == nil { return 0 @@ -1162,255 +948,6 @@ func (m *Denom) Unmarshal(dAtA []byte) error { } return nil } -func (m *AggregateExchangeRatePrevote) 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: AggregateExchangeRatePrevote: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AggregateExchangeRatePrevote: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", 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.Hash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Voter", 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.Voter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SubmitBlock", wireType) - } - m.SubmitBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowOracle - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SubmitBlock |= 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 *AggregateExchangeRateVote) 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: AggregateExchangeRateVote: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AggregateExchangeRateVote: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRateTuples", 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.ExchangeRateTuples = append(m.ExchangeRateTuples, ExchangeRateTuple{}) - if err := m.ExchangeRateTuples[len(m.ExchangeRateTuples)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Voter", 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.Voter = 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 *ExchangeRateTuple) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index 0f63859d..4df17875 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -70,8 +70,8 @@ func (p *Params) ParamSetPairs() paramstypes.ParamSetPairs { paramstypes.NewParamSetPair(KeySlashFraction, &p.SlashFraction, validateSlashFraction), paramstypes.NewParamSetPair(KeySlashWindow, &p.SlashWindow, validateSlashWindow), paramstypes.NewParamSetPair(KeyMinValidPerWindow, &p.MinValidPerWindow, validateMinValidPerWindow), - paramstypes.NewParamSetPair(KeyRewardBand, &p.RewardBand, func(i interface{}) error { return nil }), - paramstypes.NewParamSetPair(KeyWhitelist, &p.Whitelist, func(i interface{}) error { return nil }), + paramstypes.NewParamSetPair(KeyRewardBand, &p.RewardBand, func(_ interface{}) error { return nil }), + paramstypes.NewParamSetPair(KeyWhitelist, &p.Whitelist, func(_ interface{}) error { return nil }), } } diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 65f9ca23..1d097d22 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -364,92 +364,6 @@ func (m *QueryVoteTargetsResponse) GetVoteTargets() []string { return nil } -// QueryFeederDelegationRequest is the request type for the Query/FeederDelegation RPC method. -type QueryFeederDelegationRequest struct { - // validator defines the validator address to query for. - ValidatorAddr string `protobuf:"bytes,1,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"` -} - -func (m *QueryFeederDelegationRequest) Reset() { *m = QueryFeederDelegationRequest{} } -func (m *QueryFeederDelegationRequest) String() string { return proto.CompactTextString(m) } -func (*QueryFeederDelegationRequest) ProtoMessage() {} -func (*QueryFeederDelegationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{8} -} -func (m *QueryFeederDelegationRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryFeederDelegationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryFeederDelegationRequest.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 *QueryFeederDelegationRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFeederDelegationRequest.Merge(m, src) -} -func (m *QueryFeederDelegationRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryFeederDelegationRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFeederDelegationRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryFeederDelegationRequest proto.InternalMessageInfo - -// QueryFeederDelegationResponse is response type for the -// Query/FeederDelegation RPC method. -type QueryFeederDelegationResponse struct { - // feeder_addr defines the feeder delegation of a validator - FeederAddr string `protobuf:"bytes,1,opt,name=feeder_addr,json=feederAddr,proto3" json:"feeder_addr,omitempty"` -} - -func (m *QueryFeederDelegationResponse) Reset() { *m = QueryFeederDelegationResponse{} } -func (m *QueryFeederDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*QueryFeederDelegationResponse) ProtoMessage() {} -func (*QueryFeederDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{9} -} -func (m *QueryFeederDelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryFeederDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryFeederDelegationResponse.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 *QueryFeederDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFeederDelegationResponse.Merge(m, src) -} -func (m *QueryFeederDelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryFeederDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFeederDelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryFeederDelegationResponse proto.InternalMessageInfo - -func (m *QueryFeederDelegationResponse) GetFeederAddr() string { - if m != nil { - return m.FeederAddr - } - return "" -} - // QueryMissCounterRequest is the request type for the Query/MissCounter RPC method. type QueryMissCounterRequest struct { // validator defines the validator address to query for. @@ -460,7 +374,7 @@ func (m *QueryMissCounterRequest) Reset() { *m = QueryMissCounterRequest func (m *QueryMissCounterRequest) String() string { return proto.CompactTextString(m) } func (*QueryMissCounterRequest) ProtoMessage() {} func (*QueryMissCounterRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{10} + return fileDescriptor_b180a0d90a2c8cf7, []int{8} } func (m *QueryMissCounterRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -500,7 +414,7 @@ func (m *QueryMissCounterResponse) Reset() { *m = QueryMissCounterRespon func (m *QueryMissCounterResponse) String() string { return proto.CompactTextString(m) } func (*QueryMissCounterResponse) ProtoMessage() {} func (*QueryMissCounterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{11} + return fileDescriptor_b180a0d90a2c8cf7, []int{9} } func (m *QueryMissCounterResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -536,346 +450,6 @@ func (m *QueryMissCounterResponse) GetMissCounter() uint64 { return 0 } -// QueryAggregatePrevoteRequest is the request type for the Query/AggregatePrevote RPC method. -type QueryAggregatePrevoteRequest struct { - // validator defines the validator address to query for. - ValidatorAddr string `protobuf:"bytes,1,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"` -} - -func (m *QueryAggregatePrevoteRequest) Reset() { *m = QueryAggregatePrevoteRequest{} } -func (m *QueryAggregatePrevoteRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAggregatePrevoteRequest) ProtoMessage() {} -func (*QueryAggregatePrevoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{12} -} -func (m *QueryAggregatePrevoteRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregatePrevoteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregatePrevoteRequest.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 *QueryAggregatePrevoteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregatePrevoteRequest.Merge(m, src) -} -func (m *QueryAggregatePrevoteRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregatePrevoteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregatePrevoteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregatePrevoteRequest proto.InternalMessageInfo - -// QueryAggregatePrevoteResponse is response type for the -// Query/AggregatePrevote RPC method. -type QueryAggregatePrevoteResponse struct { - // aggregate_prevote defines oracle aggregate prevote submitted by a validator in the current vote period - AggregatePrevote AggregateExchangeRatePrevote `protobuf:"bytes,1,opt,name=aggregate_prevote,json=aggregatePrevote,proto3" json:"aggregate_prevote"` -} - -func (m *QueryAggregatePrevoteResponse) Reset() { *m = QueryAggregatePrevoteResponse{} } -func (m *QueryAggregatePrevoteResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAggregatePrevoteResponse) ProtoMessage() {} -func (*QueryAggregatePrevoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{13} -} -func (m *QueryAggregatePrevoteResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregatePrevoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregatePrevoteResponse.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 *QueryAggregatePrevoteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregatePrevoteResponse.Merge(m, src) -} -func (m *QueryAggregatePrevoteResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregatePrevoteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregatePrevoteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregatePrevoteResponse proto.InternalMessageInfo - -func (m *QueryAggregatePrevoteResponse) GetAggregatePrevote() AggregateExchangeRatePrevote { - if m != nil { - return m.AggregatePrevote - } - return AggregateExchangeRatePrevote{} -} - -// QueryAggregatePrevotesRequest is the request type for the Query/AggregatePrevotes RPC method. -type QueryAggregatePrevotesRequest struct { -} - -func (m *QueryAggregatePrevotesRequest) Reset() { *m = QueryAggregatePrevotesRequest{} } -func (m *QueryAggregatePrevotesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAggregatePrevotesRequest) ProtoMessage() {} -func (*QueryAggregatePrevotesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{14} -} -func (m *QueryAggregatePrevotesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregatePrevotesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregatePrevotesRequest.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 *QueryAggregatePrevotesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregatePrevotesRequest.Merge(m, src) -} -func (m *QueryAggregatePrevotesRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregatePrevotesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregatePrevotesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregatePrevotesRequest proto.InternalMessageInfo - -// QueryAggregatePrevotesResponse is response type for the -// Query/AggregatePrevotes RPC method. -type QueryAggregatePrevotesResponse struct { - // aggregate_prevotes defines all oracle aggregate prevotes submitted in the current vote period - AggregatePrevotes []AggregateExchangeRatePrevote `protobuf:"bytes,1,rep,name=aggregate_prevotes,json=aggregatePrevotes,proto3" json:"aggregate_prevotes"` -} - -func (m *QueryAggregatePrevotesResponse) Reset() { *m = QueryAggregatePrevotesResponse{} } -func (m *QueryAggregatePrevotesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAggregatePrevotesResponse) ProtoMessage() {} -func (*QueryAggregatePrevotesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{15} -} -func (m *QueryAggregatePrevotesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregatePrevotesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregatePrevotesResponse.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 *QueryAggregatePrevotesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregatePrevotesResponse.Merge(m, src) -} -func (m *QueryAggregatePrevotesResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregatePrevotesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregatePrevotesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregatePrevotesResponse proto.InternalMessageInfo - -func (m *QueryAggregatePrevotesResponse) GetAggregatePrevotes() []AggregateExchangeRatePrevote { - if m != nil { - return m.AggregatePrevotes - } - return nil -} - -// QueryAggregateVoteRequest is the request type for the Query/AggregateVote RPC method. -type QueryAggregateVoteRequest struct { - // validator defines the validator address to query for. - ValidatorAddr string `protobuf:"bytes,1,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"` -} - -func (m *QueryAggregateVoteRequest) Reset() { *m = QueryAggregateVoteRequest{} } -func (m *QueryAggregateVoteRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAggregateVoteRequest) ProtoMessage() {} -func (*QueryAggregateVoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{16} -} -func (m *QueryAggregateVoteRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregateVoteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregateVoteRequest.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 *QueryAggregateVoteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregateVoteRequest.Merge(m, src) -} -func (m *QueryAggregateVoteRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregateVoteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregateVoteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregateVoteRequest proto.InternalMessageInfo - -// QueryAggregateVoteResponse is response type for the -// Query/AggregateVote RPC method. -type QueryAggregateVoteResponse struct { - // aggregate_vote defines oracle aggregate vote submitted by a validator in the current vote period - AggregateVote AggregateExchangeRateVote `protobuf:"bytes,1,opt,name=aggregate_vote,json=aggregateVote,proto3" json:"aggregate_vote"` -} - -func (m *QueryAggregateVoteResponse) Reset() { *m = QueryAggregateVoteResponse{} } -func (m *QueryAggregateVoteResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAggregateVoteResponse) ProtoMessage() {} -func (*QueryAggregateVoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{17} -} -func (m *QueryAggregateVoteResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregateVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregateVoteResponse.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 *QueryAggregateVoteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregateVoteResponse.Merge(m, src) -} -func (m *QueryAggregateVoteResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregateVoteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregateVoteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregateVoteResponse proto.InternalMessageInfo - -func (m *QueryAggregateVoteResponse) GetAggregateVote() AggregateExchangeRateVote { - if m != nil { - return m.AggregateVote - } - return AggregateExchangeRateVote{} -} - -// QueryAggregateVotesRequest is the request type for the Query/AggregateVotes RPC method. -type QueryAggregateVotesRequest struct { -} - -func (m *QueryAggregateVotesRequest) Reset() { *m = QueryAggregateVotesRequest{} } -func (m *QueryAggregateVotesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAggregateVotesRequest) ProtoMessage() {} -func (*QueryAggregateVotesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{18} -} -func (m *QueryAggregateVotesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregateVotesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregateVotesRequest.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 *QueryAggregateVotesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregateVotesRequest.Merge(m, src) -} -func (m *QueryAggregateVotesRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregateVotesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregateVotesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregateVotesRequest proto.InternalMessageInfo - -// QueryAggregateVotesResponse is response type for the -// Query/AggregateVotes RPC method. -type QueryAggregateVotesResponse struct { - // aggregate_votes defines all oracle aggregate votes submitted in the current vote period - AggregateVotes []AggregateExchangeRateVote `protobuf:"bytes,1,rep,name=aggregate_votes,json=aggregateVotes,proto3" json:"aggregate_votes"` -} - -func (m *QueryAggregateVotesResponse) Reset() { *m = QueryAggregateVotesResponse{} } -func (m *QueryAggregateVotesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAggregateVotesResponse) ProtoMessage() {} -func (*QueryAggregateVotesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{19} -} -func (m *QueryAggregateVotesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAggregateVotesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAggregateVotesResponse.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 *QueryAggregateVotesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAggregateVotesResponse.Merge(m, src) -} -func (m *QueryAggregateVotesResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAggregateVotesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAggregateVotesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAggregateVotesResponse proto.InternalMessageInfo - -func (m *QueryAggregateVotesResponse) GetAggregateVotes() []AggregateExchangeRateVote { - if m != nil { - return m.AggregateVotes - } - return nil -} - // QueryParamsRequest is the request type for the Query/Params RPC method. type QueryParamsRequest struct { } @@ -884,7 +458,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{20} + return fileDescriptor_b180a0d90a2c8cf7, []int{10} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -923,7 +497,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b180a0d90a2c8cf7, []int{21} + return fileDescriptor_b180a0d90a2c8cf7, []int{11} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -968,18 +542,8 @@ func init() { proto.RegisterType((*QueryActivesResponse)(nil), "kujira.oracle.QueryActivesResponse") proto.RegisterType((*QueryVoteTargetsRequest)(nil), "kujira.oracle.QueryVoteTargetsRequest") proto.RegisterType((*QueryVoteTargetsResponse)(nil), "kujira.oracle.QueryVoteTargetsResponse") - proto.RegisterType((*QueryFeederDelegationRequest)(nil), "kujira.oracle.QueryFeederDelegationRequest") - proto.RegisterType((*QueryFeederDelegationResponse)(nil), "kujira.oracle.QueryFeederDelegationResponse") proto.RegisterType((*QueryMissCounterRequest)(nil), "kujira.oracle.QueryMissCounterRequest") proto.RegisterType((*QueryMissCounterResponse)(nil), "kujira.oracle.QueryMissCounterResponse") - proto.RegisterType((*QueryAggregatePrevoteRequest)(nil), "kujira.oracle.QueryAggregatePrevoteRequest") - proto.RegisterType((*QueryAggregatePrevoteResponse)(nil), "kujira.oracle.QueryAggregatePrevoteResponse") - proto.RegisterType((*QueryAggregatePrevotesRequest)(nil), "kujira.oracle.QueryAggregatePrevotesRequest") - proto.RegisterType((*QueryAggregatePrevotesResponse)(nil), "kujira.oracle.QueryAggregatePrevotesResponse") - proto.RegisterType((*QueryAggregateVoteRequest)(nil), "kujira.oracle.QueryAggregateVoteRequest") - proto.RegisterType((*QueryAggregateVoteResponse)(nil), "kujira.oracle.QueryAggregateVoteResponse") - proto.RegisterType((*QueryAggregateVotesRequest)(nil), "kujira.oracle.QueryAggregateVotesRequest") - proto.RegisterType((*QueryAggregateVotesResponse)(nil), "kujira.oracle.QueryAggregateVotesResponse") proto.RegisterType((*QueryParamsRequest)(nil), "kujira.oracle.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "kujira.oracle.QueryParamsResponse") } @@ -987,74 +551,53 @@ func init() { func init() { proto.RegisterFile("kujira/oracle/query.proto", fileDescriptor_b180a0d90a2c8cf7) } var fileDescriptor_b180a0d90a2c8cf7 = []byte{ - // 1061 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x97, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0xbd, 0xd0, 0xa6, 0xf4, 0x39, 0x36, 0xc9, 0x90, 0x16, 0x67, 0x93, 0xda, 0xed, 0xb6, - 0x69, 0x8c, 0x93, 0xec, 0xb6, 0x0e, 0x08, 0x29, 0x52, 0x25, 0x92, 0x06, 0x84, 0x4a, 0x11, 0xc5, - 0x2a, 0x41, 0xe2, 0x80, 0x99, 0xec, 0x0e, 0x9b, 0x25, 0xb1, 0xc7, 0xdd, 0x59, 0x5b, 0x89, 0xaa, - 0x0a, 0xa9, 0x27, 0x24, 0x0e, 0x54, 0xaa, 0xc4, 0x95, 0x70, 0x45, 0x7c, 0x0d, 0xa4, 0x1e, 0x2b, - 0x71, 0x41, 0x1c, 0x0a, 0x4a, 0x38, 0xf0, 0x31, 0x90, 0x67, 0xde, 0xae, 0x77, 0xed, 0x75, 0x6c, - 0xd2, 0xd3, 0x26, 0xf3, 0xde, 0xfe, 0xdf, 0x6f, 0xfe, 0x9e, 0x79, 0xcf, 0x86, 0xd9, 0xdd, 0xf6, - 0x37, 0x9e, 0x4f, 0x2d, 0xee, 0x53, 0x7b, 0x8f, 0x59, 0x0f, 0xda, 0xcc, 0x3f, 0x30, 0x5b, 0x3e, - 0x0f, 0x38, 0xc9, 0xa9, 0x90, 0xa9, 0x42, 0xfa, 0x8c, 0xcb, 0x5d, 0x2e, 0x23, 0x56, 0xf7, 0x2f, - 0x95, 0xa4, 0xcf, 0xbb, 0x9c, 0xbb, 0x7b, 0xcc, 0xa2, 0x2d, 0xcf, 0xa2, 0xcd, 0x26, 0x0f, 0x68, - 0xe0, 0xf1, 0xa6, 0xc0, 0xa8, 0x9e, 0x54, 0x57, 0x0f, 0x8c, 0x15, 0x6d, 0x2e, 0x1a, 0x5c, 0x58, - 0xdb, 0x54, 0x30, 0xab, 0x73, 0x73, 0x9b, 0x05, 0xf4, 0xa6, 0x65, 0x73, 0xaf, 0xa9, 0xe2, 0xc6, - 0x1a, 0x14, 0x3e, 0xed, 0xd2, 0xbc, 0xbf, 0x6f, 0xef, 0xd0, 0xa6, 0xcb, 0x6a, 0x34, 0x60, 0x35, - 0xf6, 0xa0, 0xcd, 0x44, 0x40, 0x66, 0xe0, 0xac, 0xc3, 0x9a, 0xbc, 0x51, 0xd0, 0x2e, 0x6b, 0xe5, - 0xf3, 0x35, 0xf5, 0xcf, 0xda, 0x6b, 0xdf, 0x1d, 0x96, 0x32, 0xff, 0x1e, 0x96, 0x32, 0x06, 0x83, - 0xd9, 0x94, 0x77, 0x45, 0x8b, 0x37, 0x05, 0x23, 0x1f, 0x42, 0x8e, 0xe1, 0x7a, 0xdd, 0xa7, 0x01, - 0x53, 0x22, 0x1b, 0x57, 0x9f, 0xbd, 0x28, 0x65, 0xfe, 0x7c, 0x51, 0x9a, 0x53, 0x5c, 0xc2, 0xd9, - 0x35, 0x3d, 0x6e, 0x35, 0x68, 0xb0, 0x63, 0xde, 0x65, 0x2e, 0xb5, 0x0f, 0x36, 0x99, 0x5d, 0x9b, - 0x64, 0x31, 0x45, 0x63, 0x2e, 0xa5, 0x8c, 0x40, 0x46, 0xe3, 0x47, 0x0d, 0xf4, 0xb4, 0x28, 0x52, - 0xec, 0x43, 0x3e, 0x41, 0x21, 0x0a, 0xda, 0xe5, 0x57, 0xcb, 0xd9, 0xea, 0xbc, 0xa9, 0xea, 0x9b, - 0x5d, 0x5f, 0x4c, 0xf4, 0xc5, 0xdc, 0x64, 0xf6, 0x6d, 0xee, 0x35, 0x37, 0x56, 0xbb, 0x90, 0xbf, - 0xfc, 0x55, 0x5a, 0x72, 0xbd, 0x60, 0xa7, 0xbd, 0x6d, 0xda, 0xbc, 0x61, 0xa1, 0x8f, 0xea, 0xb1, - 0x22, 0x9c, 0x5d, 0x2b, 0x38, 0x68, 0x31, 0x11, 0xbe, 0x23, 0x6a, 0xb9, 0x38, 0xb4, 0x30, 0x2e, - 0xc0, 0x1b, 0x92, 0x6b, 0xdd, 0x0e, 0xbc, 0x4e, 0x8f, 0xf7, 0x06, 0xcc, 0x24, 0x97, 0x11, 0xb4, - 0x00, 0xe7, 0xa8, 0x5a, 0x92, 0x84, 0xe7, 0x6b, 0xe1, 0xbf, 0xc6, 0x2c, 0xbc, 0x29, 0xdf, 0xd8, - 0xe2, 0x01, 0xbb, 0x4f, 0x7d, 0x97, 0x05, 0x91, 0xd8, 0x2d, 0xfc, 0xf0, 0x12, 0x21, 0x14, 0xbc, - 0x02, 0x93, 0x1d, 0x1e, 0xb0, 0x7a, 0xa0, 0xd6, 0x51, 0x35, 0xdb, 0xe9, 0xa5, 0x1a, 0x9f, 0xc0, - 0xbc, 0x7c, 0xfd, 0x03, 0xc6, 0x1c, 0xe6, 0x6f, 0xb2, 0x3d, 0xe6, 0xca, 0x73, 0x15, 0x7e, 0xfe, - 0x0b, 0x90, 0xef, 0xd0, 0x3d, 0xcf, 0xa1, 0x01, 0xf7, 0xeb, 0xd4, 0x71, 0x7c, 0x3c, 0x08, 0xb9, - 0x68, 0x75, 0xdd, 0x71, 0xfc, 0xd8, 0x81, 0x78, 0x0f, 0x2e, 0x0d, 0x11, 0x44, 0xa8, 0x12, 0x64, - 0xbf, 0x96, 0xb1, 0xb8, 0x1c, 0xa8, 0xa5, 0xae, 0x96, 0x71, 0x07, 0x37, 0xfb, 0xb1, 0x27, 0xc4, - 0x6d, 0xde, 0x6e, 0x06, 0xcc, 0x3f, 0x35, 0x4d, 0xe8, 0x4e, 0x42, 0xab, 0xe7, 0x4e, 0xc3, 0x13, - 0xa2, 0x6e, 0xab, 0x75, 0x29, 0x75, 0xa6, 0x96, 0x6d, 0xf4, 0x52, 0x23, 0x77, 0xd6, 0x5d, 0xd7, - 0xef, 0xee, 0x83, 0xdd, 0xf3, 0x59, 0xd7, 0xbd, 0x53, 0xf3, 0x7c, 0x8b, 0xee, 0x0c, 0x0a, 0x22, - 0xd4, 0x97, 0x30, 0x4d, 0xc3, 0x58, 0xbd, 0xa5, 0x82, 0x52, 0x34, 0x5b, 0x5d, 0x32, 0x13, 0x6d, - 0xc2, 0x8c, 0x34, 0xe2, 0xc7, 0x1e, 0xf5, 0x36, 0xce, 0x74, 0x8f, 0x6f, 0x6d, 0x8a, 0xf6, 0xd5, - 0x31, 0x4a, 0x43, 0x00, 0xa2, 0xf3, 0xf4, 0x58, 0x83, 0xe2, 0xb0, 0x0c, 0x64, 0xfc, 0x0a, 0xc8, - 0x00, 0x63, 0x78, 0xa9, 0x4e, 0x01, 0x39, 0xdd, 0x0f, 0x29, 0x8c, 0xbb, 0x78, 0xdd, 0xa3, 0xb7, - 0xb7, 0x5e, 0xc6, 0x74, 0x81, 0xed, 0xa1, 0x4f, 0x0d, 0x77, 0xf3, 0x19, 0xe4, 0x7b, 0xbb, 0x89, - 0xd9, 0x5d, 0x1e, 0x67, 0x27, 0x5b, 0xbd, 0x6d, 0xe4, 0x68, 0x5c, 0xde, 0x98, 0x4f, 0x2b, 0x1a, - 0xb9, 0xdc, 0x81, 0xb9, 0xd4, 0x28, 0x32, 0x7d, 0x0e, 0xaf, 0x27, 0x99, 0x42, 0x7b, 0xff, 0x2f, - 0x54, 0x3e, 0x01, 0x25, 0x8c, 0x19, 0x20, 0xb2, 0xee, 0x3d, 0xea, 0xd3, 0x46, 0x44, 0x73, 0x07, - 0xfb, 0x54, 0xb8, 0x8a, 0x14, 0xab, 0x30, 0xd1, 0x92, 0x2b, 0xe8, 0xc8, 0x85, 0xbe, 0xe2, 0x2a, - 0x1d, 0x2b, 0x61, 0x6a, 0xf5, 0xb7, 0x2c, 0x9c, 0x95, 0x62, 0xe4, 0x07, 0x0d, 0x26, 0xe3, 0x58, - 0x64, 0xb1, 0xef, 0xfd, 0x61, 0x43, 0x47, 0x2f, 0x8f, 0x4e, 0x54, 0x88, 0xc6, 0xf2, 0xe3, 0xdf, - 0xff, 0x79, 0xfa, 0xca, 0x75, 0x72, 0x2d, 0x1c, 0x7c, 0x72, 0x3e, 0x09, 0xeb, 0xa1, 0x7c, 0x3e, - 0xb2, 0x12, 0x8d, 0x9f, 0x7c, 0xaf, 0x41, 0x2e, 0x31, 0x23, 0xc8, 0xc8, 0x4a, 0xa1, 0x47, 0xfa, - 0x5b, 0x63, 0x64, 0x22, 0xd4, 0x82, 0x84, 0x2a, 0x91, 0x4b, 0x7d, 0x50, 0xc9, 0x29, 0x44, 0x7c, - 0x38, 0x87, 0x13, 0x80, 0x18, 0x69, 0xe2, 0xc9, 0xa9, 0xa1, 0x5f, 0x3d, 0x31, 0x07, 0x4b, 0x17, - 0x65, 0xe9, 0x02, 0xb9, 0xd8, 0x57, 0x1a, 0x07, 0x09, 0xf9, 0x59, 0x83, 0xa9, 0xfe, 0xce, 0x4c, - 0x96, 0xd2, 0x94, 0x87, 0x0c, 0x04, 0x7d, 0x79, 0xbc, 0x64, 0xe4, 0xa9, 0x4a, 0x9e, 0x65, 0x52, - 0x09, 0x79, 0xa2, 0x3b, 0x2a, 0xac, 0x87, 0xc9, 0x5b, 0xfc, 0xc8, 0x52, 0x33, 0x80, 0x3c, 0xd1, - 0x20, 0x1b, 0xeb, 0xd7, 0xe4, 0x7a, 0x5a, 0xc5, 0xc1, 0xe1, 0xa0, 0x2f, 0x8e, 0xcc, 0x43, 0xa8, - 0x1b, 0x12, 0xaa, 0x42, 0xca, 0xe3, 0x40, 0x75, 0xc7, 0x01, 0xf9, 0x55, 0x83, 0xa9, 0xfe, 0x7e, - 0x98, 0x6e, 0xdb, 0x90, 0x49, 0x91, 0x6e, 0xdb, 0xb0, 0x29, 0x60, 0xdc, 0x92, 0x84, 0xef, 0x92, - 0x77, 0xc6, 0x21, 0x1c, 0xe8, 0xc5, 0xe4, 0x27, 0x0d, 0xa6, 0x07, 0xda, 0x37, 0x19, 0x0b, 0x21, - 0x3a, 0x6e, 0x2b, 0x63, 0x66, 0x23, 0xf1, 0x8a, 0x24, 0x5e, 0x24, 0x0b, 0x29, 0xc4, 0x83, 0xc3, - 0x82, 0x1c, 0x6a, 0x90, 0x4b, 0xf4, 0xbe, 0xf4, 0x9b, 0x98, 0xd6, 0xff, 0xd3, 0x6f, 0x62, 0x6a, - 0x6f, 0x37, 0xd6, 0x24, 0xd5, 0xdb, 0xa4, 0x1a, 0xa3, 0x72, 0xbc, 0x91, 0x3e, 0x4a, 0x13, 0x9f, - 0x6a, 0x90, 0x4f, 0xb6, 0x67, 0x32, 0xba, 0x72, 0x64, 0x5f, 0x65, 0x9c, 0x54, 0xa4, 0xac, 0x48, - 0xca, 0x6b, 0xc4, 0x38, 0xd1, 0x3b, 0x65, 0x9c, 0x0b, 0x13, 0xaa, 0xed, 0x92, 0x2b, 0x69, 0x15, - 0x12, 0x7d, 0x5d, 0x37, 0x4e, 0x4a, 0xc1, 0xe2, 0x17, 0x65, 0xf1, 0x29, 0x92, 0x0f, 0x8b, 0xab, - 0x3e, 0xbe, 0xb1, 0xf9, 0xec, 0xa8, 0xa8, 0x3d, 0x3f, 0x2a, 0x6a, 0x7f, 0x1f, 0x15, 0xb5, 0x27, - 0xc7, 0xc5, 0xcc, 0xf3, 0xe3, 0x62, 0xe6, 0x8f, 0xe3, 0x62, 0xe6, 0x8b, 0x4a, 0xec, 0x1b, 0xf1, - 0x7d, 0x46, 0x1b, 0x2b, 0x1f, 0xa9, 0x9f, 0x1e, 0x36, 0xf7, 0x99, 0xb5, 0x1f, 0xca, 0xc8, 0x6f, - 0xc6, 0xdb, 0x13, 0xf2, 0x17, 0xc6, 0xea, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x16, 0x65, 0xb4, - 0x31, 0xfd, 0x0c, 0x00, 0x00, + // 729 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xc7, 0xbb, 0xbf, 0x1f, 0x7f, 0x64, 0x4a, 0x89, 0x19, 0x0b, 0x96, 0x05, 0xb7, 0xb0, 0x08, + 0x54, 0x94, 0x1d, 0xfe, 0xdc, 0x48, 0x3c, 0x50, 0x30, 0x31, 0xa8, 0x89, 0x6e, 0x88, 0x07, 0x2f, + 0xcd, 0x74, 0x77, 0xb2, 0xac, 0xb0, 0x3b, 0x65, 0x66, 0xda, 0x40, 0x08, 0x17, 0x4f, 0x26, 0x1e, + 0x24, 0x31, 0xd1, 0x2b, 0x67, 0x5f, 0x09, 0x47, 0x12, 0x2f, 0xc6, 0x03, 0x1a, 0xf0, 0xe0, 0xcb, + 0x30, 0x9d, 0x99, 0x6d, 0xbb, 0x58, 0xc1, 0xd3, 0x74, 0x9f, 0xe7, 0x99, 0xef, 0xf3, 0xe9, 0xcc, + 0xf7, 0x19, 0x30, 0xba, 0x5d, 0x7f, 0x1d, 0x32, 0x8c, 0x28, 0xc3, 0xde, 0x0e, 0x41, 0xbb, 0x75, + 0xc2, 0xf6, 0x9d, 0x1a, 0xa3, 0x82, 0xc2, 0x9c, 0x4a, 0x39, 0x2a, 0x65, 0xe6, 0x03, 0x1a, 0x50, + 0x99, 0x41, 0xcd, 0x5f, 0xaa, 0xc8, 0x1c, 0x0f, 0x28, 0x0d, 0x76, 0x08, 0xc2, 0xb5, 0x10, 0xe1, + 0x38, 0xa6, 0x02, 0x8b, 0x90, 0xc6, 0x5c, 0x67, 0xcd, 0xb4, 0xba, 0x5a, 0x74, 0xce, 0xf2, 0x28, + 0x8f, 0x28, 0x47, 0x55, 0xcc, 0x09, 0x6a, 0x2c, 0x56, 0x89, 0xc0, 0x8b, 0xc8, 0xa3, 0x61, 0xac, + 0xf2, 0xf6, 0x0a, 0x28, 0xbc, 0x68, 0xd2, 0x3c, 0xda, 0xf3, 0xb6, 0x70, 0x1c, 0x10, 0x17, 0x0b, + 0xe2, 0x92, 0xdd, 0x3a, 0xe1, 0x02, 0xe6, 0x41, 0xaf, 0x4f, 0x62, 0x1a, 0x15, 0x8c, 0x09, 0xa3, + 0x34, 0xe0, 0xaa, 0x8f, 0x95, 0x1b, 0x6f, 0x8f, 0x8b, 0x99, 0x5f, 0xc7, 0xc5, 0x8c, 0x4d, 0xc0, + 0x68, 0x97, 0xbd, 0xbc, 0x46, 0x63, 0x4e, 0xe0, 0x63, 0x90, 0x23, 0x3a, 0x5e, 0x61, 0x58, 0x10, + 0x25, 0x52, 0x9e, 0x3a, 0x39, 0x2b, 0x66, 0xbe, 0x9d, 0x15, 0xc7, 0x14, 0x17, 0xf7, 0xb7, 0x9d, + 0x90, 0xa2, 0x08, 0x8b, 0x2d, 0xe7, 0x29, 0x09, 0xb0, 0xb7, 0xbf, 0x4e, 0x3c, 0x77, 0x90, 0x74, + 0x28, 0xda, 0x63, 0x5d, 0xda, 0x70, 0xcd, 0x68, 0x7f, 0x34, 0x80, 0xd9, 0x2d, 0xab, 0x29, 0xf6, + 0xc0, 0x50, 0x8a, 0x82, 0x17, 0x8c, 0x89, 0xff, 0x4b, 0xd9, 0xa5, 0x71, 0x47, 0xf5, 0x77, 0x9a, + 0xe7, 0xe2, 0xe8, 0x73, 0x71, 0xd6, 0x89, 0xb7, 0x46, 0xc3, 0xb8, 0xbc, 0xdc, 0x84, 0xfc, 0xfc, + 0xbd, 0x78, 0x3f, 0x08, 0xc5, 0x56, 0xbd, 0xea, 0x78, 0x34, 0x42, 0xfa, 0x1c, 0xd5, 0x32, 0xcf, + 0xfd, 0x6d, 0x24, 0xf6, 0x6b, 0x84, 0x27, 0x7b, 0xb8, 0x9b, 0xeb, 0x84, 0xe6, 0xf6, 0x30, 0xb8, + 0x25, 0xb9, 0x56, 0x3d, 0x11, 0x36, 0xda, 0xbc, 0x0b, 0x20, 0x9f, 0x0e, 0x6b, 0xd0, 0x02, 0xe8, + 0xc7, 0x2a, 0x24, 0x09, 0x07, 0xdc, 0xe4, 0xd3, 0x1e, 0x05, 0xb7, 0xe5, 0x8e, 0x97, 0x54, 0x90, + 0x4d, 0xcc, 0x02, 0x22, 0x5a, 0x62, 0x0f, 0xf5, 0xe5, 0xa5, 0x52, 0x5a, 0x70, 0x12, 0x0c, 0x36, + 0xa8, 0x20, 0x15, 0xa1, 0xe2, 0x5a, 0x35, 0xdb, 0x68, 0x97, 0xda, 0x1b, 0x5a, 0xf9, 0x59, 0xc8, + 0xf9, 0x1a, 0xad, 0xc7, 0x82, 0xb0, 0xe4, 0xea, 0xa7, 0xc1, 0x50, 0x03, 0xef, 0x84, 0x3e, 0x16, + 0x94, 0x55, 0xb0, 0xef, 0x33, 0xed, 0x81, 0x5c, 0x2b, 0xba, 0xea, 0xfb, 0xac, 0xc3, 0x0b, 0x09, + 0x4a, 0x4a, 0xab, 0x8d, 0x12, 0x85, 0x9c, 0x57, 0x3c, 0x15, 0x97, 0x52, 0x3d, 0x6e, 0x36, 0x6a, + 0x97, 0xda, 0x79, 0x00, 0xe5, 0xf6, 0xe7, 0x98, 0xe1, 0xa8, 0xf5, 0xff, 0x36, 0xf4, 0x19, 0x26, + 0x51, 0xad, 0xb7, 0x0c, 0xfa, 0x6a, 0x32, 0x22, 0x95, 0xb2, 0x4b, 0xc3, 0x4e, 0x6a, 0x86, 0x1c, + 0x55, 0x5e, 0xee, 0x69, 0xde, 0xa2, 0xab, 0x4b, 0x97, 0x3e, 0xf5, 0x82, 0x5e, 0x29, 0x06, 0xdf, + 0x1b, 0x60, 0xb0, 0xd3, 0x2d, 0x70, 0xf6, 0xd2, 0xfe, 0xbf, 0x0d, 0x84, 0x59, 0xba, 0xbe, 0x50, + 0x21, 0xda, 0x0f, 0xde, 0x7c, 0xf9, 0xf9, 0xe1, 0xbf, 0x19, 0x78, 0x37, 0x19, 0x4a, 0x39, 0x3b, + 0x1c, 0x1d, 0xc8, 0xf5, 0x10, 0xa5, 0x4c, 0x09, 0xdf, 0x19, 0x20, 0x97, 0xf2, 0x2f, 0xbc, 0xb6, + 0x53, 0x72, 0x46, 0xe6, 0xbd, 0x7f, 0xa8, 0xd4, 0x50, 0xd3, 0x12, 0xaa, 0x08, 0xef, 0x5c, 0x82, + 0x4a, 0x4f, 0x08, 0x64, 0xa0, 0x5f, 0xbb, 0x13, 0xda, 0xdd, 0xc4, 0xd3, 0x8e, 0x36, 0xa7, 0xae, + 0xac, 0xd1, 0xad, 0x2d, 0xd9, 0xba, 0x00, 0x47, 0x2e, 0xb5, 0xd6, 0x26, 0x87, 0x47, 0x06, 0xc8, + 0x76, 0x58, 0x07, 0xce, 0x74, 0x13, 0xfd, 0xd3, 0xa7, 0xe6, 0xec, 0xb5, 0x75, 0x1a, 0x60, 0x41, + 0x02, 0xcc, 0xc1, 0x52, 0x02, 0xd0, 0x32, 0x32, 0x47, 0x07, 0x69, 0xab, 0x1f, 0xa2, 0xa6, 0x33, + 0x61, 0x00, 0xfa, 0x94, 0x91, 0xe0, 0x64, 0xb7, 0x26, 0x29, 0xa7, 0x9a, 0xf6, 0x55, 0x25, 0x1a, + 0x61, 0x44, 0x22, 0xdc, 0x84, 0x43, 0x09, 0x82, 0x72, 0x66, 0x79, 0xfd, 0xe4, 0xdc, 0x32, 0x4e, + 0xcf, 0x2d, 0xe3, 0xc7, 0xb9, 0x65, 0x1c, 0x5d, 0x58, 0x99, 0xd3, 0x0b, 0x2b, 0xf3, 0xf5, 0xc2, + 0xca, 0xbc, 0x9a, 0xeb, 0x78, 0x7f, 0x36, 0x09, 0x8e, 0xe6, 0x9f, 0xa8, 0x87, 0xde, 0xa3, 0x8c, + 0xa0, 0xbd, 0x44, 0x46, 0xbe, 0x43, 0xd5, 0x3e, 0xf9, 0x9e, 0x2f, 0xff, 0x0e, 0x00, 0x00, 0xff, + 0xff, 0x91, 0x18, 0x7c, 0x6b, 0x6b, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1075,18 +618,8 @@ type QueryClient interface { ExchangeRates(ctx context.Context, in *QueryExchangeRatesRequest, opts ...grpc.CallOption) (*QueryExchangeRatesResponse, error) // Actives returns all active denoms Actives(ctx context.Context, in *QueryActivesRequest, opts ...grpc.CallOption) (*QueryActivesResponse, error) - // FeederDelegation returns feeder delegation of a validator - FeederDelegation(ctx context.Context, in *QueryFeederDelegationRequest, opts ...grpc.CallOption) (*QueryFeederDelegationResponse, error) // MissCounter returns oracle miss counter of a validator MissCounter(ctx context.Context, in *QueryMissCounterRequest, opts ...grpc.CallOption) (*QueryMissCounterResponse, error) - // AggregatePrevote returns an aggregate prevote of a validator - AggregatePrevote(ctx context.Context, in *QueryAggregatePrevoteRequest, opts ...grpc.CallOption) (*QueryAggregatePrevoteResponse, error) - // AggregatePrevotes returns aggregate prevotes of all validators - AggregatePrevotes(ctx context.Context, in *QueryAggregatePrevotesRequest, opts ...grpc.CallOption) (*QueryAggregatePrevotesResponse, error) - // AggregateVote returns an aggregate vote of a validator - AggregateVote(ctx context.Context, in *QueryAggregateVoteRequest, opts ...grpc.CallOption) (*QueryAggregateVoteResponse, error) - // AggregateVotes returns aggregate votes of all validators - AggregateVotes(ctx context.Context, in *QueryAggregateVotesRequest, opts ...grpc.CallOption) (*QueryAggregateVotesResponse, error) // Params queries all parameters. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } @@ -1126,15 +659,6 @@ func (c *queryClient) Actives(ctx context.Context, in *QueryActivesRequest, opts return out, nil } -func (c *queryClient) FeederDelegation(ctx context.Context, in *QueryFeederDelegationRequest, opts ...grpc.CallOption) (*QueryFeederDelegationResponse, error) { - out := new(QueryFeederDelegationResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Query/FeederDelegation", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) MissCounter(ctx context.Context, in *QueryMissCounterRequest, opts ...grpc.CallOption) (*QueryMissCounterResponse, error) { out := new(QueryMissCounterResponse) err := c.cc.Invoke(ctx, "/kujira.oracle.Query/MissCounter", in, out, opts...) @@ -1144,45 +668,9 @@ func (c *queryClient) MissCounter(ctx context.Context, in *QueryMissCounterReque return out, nil } -func (c *queryClient) AggregatePrevote(ctx context.Context, in *QueryAggregatePrevoteRequest, opts ...grpc.CallOption) (*QueryAggregatePrevoteResponse, error) { - out := new(QueryAggregatePrevoteResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Query/AggregatePrevote", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) AggregatePrevotes(ctx context.Context, in *QueryAggregatePrevotesRequest, opts ...grpc.CallOption) (*QueryAggregatePrevotesResponse, error) { - out := new(QueryAggregatePrevotesResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Query/AggregatePrevotes", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) AggregateVote(ctx context.Context, in *QueryAggregateVoteRequest, opts ...grpc.CallOption) (*QueryAggregateVoteResponse, error) { - out := new(QueryAggregateVoteResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Query/AggregateVote", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) AggregateVotes(ctx context.Context, in *QueryAggregateVotesRequest, opts ...grpc.CallOption) (*QueryAggregateVotesResponse, error) { - out := new(QueryAggregateVotesResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Query/AggregateVotes", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Query/Params", in, out, opts...) +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/kujira.oracle.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -1197,18 +685,8 @@ type QueryServer interface { ExchangeRates(context.Context, *QueryExchangeRatesRequest) (*QueryExchangeRatesResponse, error) // Actives returns all active denoms Actives(context.Context, *QueryActivesRequest) (*QueryActivesResponse, error) - // FeederDelegation returns feeder delegation of a validator - FeederDelegation(context.Context, *QueryFeederDelegationRequest) (*QueryFeederDelegationResponse, error) // MissCounter returns oracle miss counter of a validator MissCounter(context.Context, *QueryMissCounterRequest) (*QueryMissCounterResponse, error) - // AggregatePrevote returns an aggregate prevote of a validator - AggregatePrevote(context.Context, *QueryAggregatePrevoteRequest) (*QueryAggregatePrevoteResponse, error) - // AggregatePrevotes returns aggregate prevotes of all validators - AggregatePrevotes(context.Context, *QueryAggregatePrevotesRequest) (*QueryAggregatePrevotesResponse, error) - // AggregateVote returns an aggregate vote of a validator - AggregateVote(context.Context, *QueryAggregateVoteRequest) (*QueryAggregateVoteResponse, error) - // AggregateVotes returns aggregate votes of all validators - AggregateVotes(context.Context, *QueryAggregateVotesRequest) (*QueryAggregateVotesResponse, error) // Params queries all parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } @@ -1226,24 +704,9 @@ func (*UnimplementedQueryServer) ExchangeRates(ctx context.Context, req *QueryEx func (*UnimplementedQueryServer) Actives(ctx context.Context, req *QueryActivesRequest) (*QueryActivesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Actives not implemented") } -func (*UnimplementedQueryServer) FeederDelegation(ctx context.Context, req *QueryFeederDelegationRequest) (*QueryFeederDelegationResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FeederDelegation not implemented") -} func (*UnimplementedQueryServer) MissCounter(ctx context.Context, req *QueryMissCounterRequest) (*QueryMissCounterResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method MissCounter not implemented") } -func (*UnimplementedQueryServer) AggregatePrevote(ctx context.Context, req *QueryAggregatePrevoteRequest) (*QueryAggregatePrevoteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregatePrevote not implemented") -} -func (*UnimplementedQueryServer) AggregatePrevotes(ctx context.Context, req *QueryAggregatePrevotesRequest) (*QueryAggregatePrevotesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregatePrevotes not implemented") -} -func (*UnimplementedQueryServer) AggregateVote(ctx context.Context, req *QueryAggregateVoteRequest) (*QueryAggregateVoteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregateVote not implemented") -} -func (*UnimplementedQueryServer) AggregateVotes(ctx context.Context, req *QueryAggregateVotesRequest) (*QueryAggregateVotesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregateVotes not implemented") -} func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } @@ -1306,24 +769,6 @@ func _Query_Actives_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } -func _Query_FeederDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFeederDelegationRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FeederDelegation(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Query/FeederDelegation", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FeederDelegation(ctx, req.(*QueryFeederDelegationRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_MissCounter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryMissCounterRequest) if err := dec(in); err != nil { @@ -1342,78 +787,6 @@ func _Query_MissCounter_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Query_AggregatePrevote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAggregatePrevoteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AggregatePrevote(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Query/AggregatePrevote", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AggregatePrevote(ctx, req.(*QueryAggregatePrevoteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_AggregatePrevotes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAggregatePrevotesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AggregatePrevotes(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Query/AggregatePrevotes", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AggregatePrevotes(ctx, req.(*QueryAggregatePrevotesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_AggregateVote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAggregateVoteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AggregateVote(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Query/AggregateVote", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AggregateVote(ctx, req.(*QueryAggregateVoteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_AggregateVotes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAggregateVotesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AggregateVotes(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Query/AggregateVotes", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AggregateVotes(ctx, req.(*QueryAggregateVotesRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryParamsRequest) if err := dec(in); err != nil { @@ -1448,30 +821,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Actives", Handler: _Query_Actives_Handler, }, - { - MethodName: "FeederDelegation", - Handler: _Query_FeederDelegation_Handler, - }, { MethodName: "MissCounter", Handler: _Query_MissCounter_Handler, }, - { - MethodName: "AggregatePrevote", - Handler: _Query_AggregatePrevote_Handler, - }, - { - MethodName: "AggregatePrevotes", - Handler: _Query_AggregatePrevotes_Handler, - }, - { - MethodName: "AggregateVote", - Handler: _Query_AggregateVote_Handler, - }, - { - MethodName: "AggregateVotes", - Handler: _Query_AggregateVotes_Handler, - }, { MethodName: "Params", Handler: _Query_Params_Handler, @@ -1714,66 +1067,6 @@ func (m *QueryVoteTargetsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *QueryFeederDelegationRequest) 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 *QueryFeederDelegationRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFeederDelegationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ValidatorAddr) > 0 { - i -= len(m.ValidatorAddr) - copy(dAtA[i:], m.ValidatorAddr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddr))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryFeederDelegationResponse) 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 *QueryFeederDelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFeederDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FeederAddr) > 0 { - i -= len(m.FeederAddr) - copy(dAtA[i:], m.FeederAddr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FeederAddr))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *QueryMissCounterRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1832,7 +1125,7 @@ func (m *QueryMissCounterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *QueryAggregatePrevoteRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1842,27 +1135,20 @@ func (m *QueryAggregatePrevoteRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAggregatePrevoteRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAggregatePrevoteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ValidatorAddr) > 0 { - i -= len(m.ValidatorAddr) - copy(dAtA[i:], m.ValidatorAddr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddr))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *QueryAggregatePrevoteResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1872,18 +1158,18 @@ func (m *QueryAggregatePrevoteResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAggregatePrevoteResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAggregatePrevoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.AggregatePrevote.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1895,307 +1181,68 @@ func (m *QueryAggregatePrevoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryAggregatePrevotesRequest) 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 encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil -} - -func (m *QueryAggregatePrevotesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *QueryAggregatePrevotesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryExchangeRateRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - return len(dAtA) - i, nil + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryAggregatePrevotesResponse) 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 *QueryExchangeRateResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = m.ExchangeRate.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryAggregatePrevotesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryExchangeRatesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n } -func (m *QueryAggregatePrevotesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryExchangeRatesResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.AggregatePrevotes) > 0 { - for iNdEx := len(m.AggregatePrevotes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AggregatePrevotes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + if len(m.ExchangeRates) > 0 { + for _, e := range m.ExchangeRates { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } - return len(dAtA) - i, nil + return n } -func (m *QueryAggregateVoteRequest) 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 *QueryAggregateVoteRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAggregateVoteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ValidatorAddr) > 0 { - i -= len(m.ValidatorAddr) - copy(dAtA[i:], m.ValidatorAddr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddr))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryAggregateVoteResponse) 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 *QueryAggregateVoteResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAggregateVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.AggregateVote.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryAggregateVotesRequest) 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 *QueryAggregateVotesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAggregateVotesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryAggregateVotesResponse) 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 *QueryAggregateVotesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAggregateVotesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AggregateVotes) > 0 { - for iNdEx := len(m.AggregateVotes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AggregateVotes[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 (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.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 - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryExchangeRateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryExchangeRateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ExchangeRate.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryExchangeRatesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryExchangeRatesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ExchangeRates) > 0 { - for _, e := range m.ExchangeRates { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryActivesRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryActivesRequest) Size() (n int) { + if m == nil { + return 0 } var l int _ = l @@ -2241,32 +1288,6 @@ func (m *QueryVoteTargetsResponse) Size() (n int) { return n } -func (m *QueryFeederDelegationRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ValidatorAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFeederDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FeederAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func (m *QueryMissCounterRequest) Size() (n int) { if m == nil { return 0 @@ -2292,118 +1313,22 @@ func (m *QueryMissCounterResponse) Size() (n int) { return n } -func (m *QueryAggregatePrevoteRequest) Size() (n int) { +func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ValidatorAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } return n } -func (m *QueryAggregatePrevoteResponse) Size() (n int) { +func (m *QueryParamsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.AggregatePrevote.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAggregatePrevotesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryAggregatePrevotesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.AggregatePrevotes) > 0 { - for _, e := range m.AggregatePrevotes { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryAggregateVoteRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ValidatorAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAggregateVoteResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.AggregateVote.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAggregateVotesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryAggregateVotesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.AggregateVotes) > 0 { - for _, e := range m.AggregateVotes { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() + l = m.Params.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -2411,656 +1336,10 @@ func (m *QueryParamsResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryExchangeRateRequest) 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: QueryExchangeRateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryExchangeRateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryExchangeRateResponse) 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: QueryExchangeRateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryExchangeRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ExchangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryExchangeRatesRequest) 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: QueryExchangeRatesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryExchangeRatesRequest: 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 *QueryExchangeRatesResponse) 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: QueryExchangeRatesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryExchangeRatesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRates", 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.ExchangeRates = append(m.ExchangeRates, types.DecCoin{}) - if err := m.ExchangeRates[len(m.ExchangeRates)-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 (m *QueryActivesRequest) 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: QueryActivesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActivesRequest: 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 *QueryActivesResponse) 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: QueryActivesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActivesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Actives", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Actives = append(m.Actives, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryVoteTargetsRequest) 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: QueryVoteTargetsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVoteTargetsRequest: 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 *QueryVoteTargetsResponse) 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: QueryVoteTargetsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVoteTargetsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VoteTargets", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VoteTargets = append(m.VoteTargets, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryFeederDelegationRequest) 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: QueryFeederDelegationRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFeederDelegationRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryFeederDelegationResponse) Unmarshal(dAtA []byte) error { +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryExchangeRateRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3083,15 +1362,15 @@ func (m *QueryFeederDelegationResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFeederDelegationResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryExchangeRateRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFeederDelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryExchangeRateRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeederAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3119,7 +1398,7 @@ func (m *QueryFeederDelegationResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.FeederAddr = string(dAtA[iNdEx:postIndex]) + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3142,7 +1421,7 @@ func (m *QueryFeederDelegationResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryMissCounterRequest) Unmarshal(dAtA []byte) error { +func (m *QueryExchangeRateResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3165,15 +1444,15 @@ func (m *QueryMissCounterRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryMissCounterRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryExchangeRateResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMissCounterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryExchangeRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRate", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3201,77 +1480,10 @@ func (m *QueryMissCounterRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ValidatorAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { + if err := m.ExchangeRate.Unmarshal(dAtA[iNdEx:postIndex]); 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 *QueryMissCounterResponse) 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: QueryMissCounterResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMissCounterResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MissCounter", wireType) - } - m.MissCounter = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MissCounter |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3293,7 +1505,7 @@ func (m *QueryMissCounterResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregatePrevoteRequest) Unmarshal(dAtA []byte) error { +func (m *QueryExchangeRatesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3316,44 +1528,12 @@ func (m *QueryAggregatePrevoteRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregatePrevoteRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryExchangeRatesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregatePrevoteRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryExchangeRatesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3375,7 +1555,7 @@ func (m *QueryAggregatePrevoteRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregatePrevoteResponse) Unmarshal(dAtA []byte) error { +func (m *QueryExchangeRatesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3398,15 +1578,15 @@ func (m *QueryAggregatePrevoteResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregatePrevoteResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryExchangeRatesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregatePrevoteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryExchangeRatesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregatePrevote", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRates", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3433,7 +1613,8 @@ func (m *QueryAggregatePrevoteResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AggregatePrevote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ExchangeRates = append(m.ExchangeRates, types.DecCoin{}) + if err := m.ExchangeRates[len(m.ExchangeRates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3458,7 +1639,7 @@ func (m *QueryAggregatePrevoteResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregatePrevotesRequest) Unmarshal(dAtA []byte) error { +func (m *QueryActivesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3481,10 +1662,10 @@ func (m *QueryAggregatePrevotesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregatePrevotesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryActivesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregatePrevotesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryActivesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3508,7 +1689,7 @@ func (m *QueryAggregatePrevotesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregatePrevotesResponse) Unmarshal(dAtA []byte) error { +func (m *QueryActivesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3531,17 +1712,17 @@ func (m *QueryAggregatePrevotesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregatePrevotesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryActivesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregatePrevotesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryActivesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregatePrevotes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Actives", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3551,25 +1732,23 @@ func (m *QueryAggregatePrevotesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.AggregatePrevotes = append(m.AggregatePrevotes, AggregateExchangeRatePrevote{}) - if err := m.AggregatePrevotes[len(m.AggregatePrevotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Actives = append(m.Actives, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -3592,7 +1771,7 @@ func (m *QueryAggregatePrevotesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregateVoteRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVoteTargetsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3615,44 +1794,12 @@ func (m *QueryAggregateVoteRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregateVoteRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVoteTargetsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregateVoteRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVoteTargetsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3674,7 +1821,7 @@ func (m *QueryAggregateVoteRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregateVoteResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVoteTargetsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3697,17 +1844,17 @@ func (m *QueryAggregateVoteResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregateVoteResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVoteTargetsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregateVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVoteTargetsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregateVote", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VoteTargets", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3717,24 +1864,23 @@ func (m *QueryAggregateVoteResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AggregateVote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.VoteTargets = append(m.VoteTargets, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -3757,7 +1903,7 @@ func (m *QueryAggregateVoteResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregateVotesRequest) Unmarshal(dAtA []byte) error { +func (m *QueryMissCounterRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3780,12 +1926,44 @@ func (m *QueryAggregateVotesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregateVotesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryMissCounterRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregateVotesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryMissCounterRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3807,7 +1985,7 @@ func (m *QueryAggregateVotesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAggregateVotesResponse) Unmarshal(dAtA []byte) error { +func (m *QueryMissCounterResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3830,17 +2008,17 @@ func (m *QueryAggregateVotesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAggregateVotesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryMissCounterResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAggregateVotesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryMissCounterResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregateVotes", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MissCounter", wireType) } - var msglen int + m.MissCounter = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3850,26 +2028,11 @@ func (m *QueryAggregateVotesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.MissCounter |= uint64(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.AggregateVotes = append(m.AggregateVotes, AggregateExchangeRateVote{}) - if err := m.AggregateVotes[len(m.AggregateVotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 30333d51..d54f1186 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_ExchangeRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryExchangeRateRequest @@ -123,60 +121,6 @@ func local_request_Query_Actives_0(ctx context.Context, marshaler runtime.Marsha } -func request_Query_FeederDelegation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFeederDelegationRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["validator_addr"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr") - } - - protoReq.ValidatorAddr, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err) - } - - msg, err := client.FeederDelegation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_FeederDelegation_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFeederDelegationRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["validator_addr"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr") - } - - protoReq.ValidatorAddr, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err) - } - - msg, err := server.FeederDelegation(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_MissCounter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryMissCounterRequest var metadata runtime.ServerMetadata @@ -231,150 +175,6 @@ func local_request_Query_MissCounter_0(ctx context.Context, marshaler runtime.Ma } -func request_Query_AggregatePrevote_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregatePrevoteRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["validator_addr"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr") - } - - protoReq.ValidatorAddr, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err) - } - - msg, err := client.AggregatePrevote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AggregatePrevote_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregatePrevoteRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["validator_addr"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr") - } - - protoReq.ValidatorAddr, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err) - } - - msg, err := server.AggregatePrevote(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_AggregatePrevotes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregatePrevotesRequest - var metadata runtime.ServerMetadata - - msg, err := client.AggregatePrevotes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AggregatePrevotes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregatePrevotesRequest - var metadata runtime.ServerMetadata - - msg, err := server.AggregatePrevotes(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_AggregateVote_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregateVoteRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["validator_addr"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr") - } - - protoReq.ValidatorAddr, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err) - } - - msg, err := client.AggregateVote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AggregateVote_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregateVoteRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["validator_addr"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr") - } - - protoReq.ValidatorAddr, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err) - } - - msg, err := server.AggregateVote(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_AggregateVotes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregateVotesRequest - var metadata runtime.ServerMetadata - - msg, err := client.AggregateVotes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AggregateVotes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAggregateVotesRequest - var metadata runtime.ServerMetadata - - msg, err := server.AggregateVotes(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest var metadata runtime.ServerMetadata @@ -396,14 +196,12 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_ExchangeRate_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 { @@ -411,7 +209,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_ExchangeRate_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) @@ -425,8 +222,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_ExchangeRates_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 { @@ -434,7 +229,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_ExchangeRates_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) @@ -448,8 +242,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Actives_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 { @@ -457,7 +249,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Actives_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) @@ -468,34 +259,9 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_FeederDelegation_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_FeederDelegation_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_FeederDelegation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_MissCounter_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 { @@ -503,7 +269,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_MissCounter_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) @@ -514,103 +279,9 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_AggregatePrevote_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_AggregatePrevote_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_AggregatePrevote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AggregatePrevotes_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_AggregatePrevotes_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_AggregatePrevotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AggregateVote_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_AggregateVote_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_AggregateVote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AggregateVotes_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_AggregateVotes_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_AggregateVotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_Params_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 { @@ -618,7 +289,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_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) @@ -730,26 +400,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_FeederDelegation_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_FeederDelegation_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_FeederDelegation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_MissCounter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -770,86 +420,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_AggregatePrevote_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_AggregatePrevote_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_AggregatePrevote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AggregatePrevotes_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_AggregatePrevotes_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_AggregatePrevotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AggregateVote_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_AggregateVote_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_AggregateVote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AggregateVotes_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_AggregateVotes_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_AggregateVotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -880,18 +450,8 @@ var ( pattern_Query_Actives_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"oracle", "denoms", "actives"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_FeederDelegation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"oracle", "validators", "validator_addr", "feeder"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_MissCounter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"oracle", "validators", "validator_addr", "miss"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_AggregatePrevote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"oracle", "validators", "validator_addr", "aggregate_prevote"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_AggregatePrevotes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"oracle", "validators", "aggregate_prevotes"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_AggregateVote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"oracle", "valdiators", "validator_addr", "aggregate_vote"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_AggregateVotes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"oracle", "validators", "aggregate_votes"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"oracle", "params"}, "", runtime.AssumeColonVerbOpt(true))) ) @@ -902,17 +462,7 @@ var ( forward_Query_Actives_0 = runtime.ForwardResponseMessage - forward_Query_FeederDelegation_0 = runtime.ForwardResponseMessage - forward_Query_MissCounter_0 = runtime.ForwardResponseMessage - forward_Query_AggregatePrevote_0 = runtime.ForwardResponseMessage - - forward_Query_AggregatePrevotes_0 = runtime.ForwardResponseMessage - - forward_Query_AggregateVote_0 = runtime.ForwardResponseMessage - - forward_Query_AggregateVotes_0 = runtime.ForwardResponseMessage - forward_Query_Params_0 = runtime.ForwardResponseMessage ) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 90e0fc7e..c35dc5ca 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -29,242 +29,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgAggregateExchangeRatePrevote represents a message to submit -// aggregate exchange rate prevote. -type MsgAggregateExchangeRatePrevote struct { - Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty" yaml:"hash"` - Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty" yaml:"feeder"` - Validator string `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,omitempty" yaml:"validator"` -} - -func (m *MsgAggregateExchangeRatePrevote) Reset() { *m = MsgAggregateExchangeRatePrevote{} } -func (m *MsgAggregateExchangeRatePrevote) String() string { return proto.CompactTextString(m) } -func (*MsgAggregateExchangeRatePrevote) ProtoMessage() {} -func (*MsgAggregateExchangeRatePrevote) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{0} -} -func (m *MsgAggregateExchangeRatePrevote) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAggregateExchangeRatePrevote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAggregateExchangeRatePrevote.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 *MsgAggregateExchangeRatePrevote) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAggregateExchangeRatePrevote.Merge(m, src) -} -func (m *MsgAggregateExchangeRatePrevote) XXX_Size() int { - return m.Size() -} -func (m *MsgAggregateExchangeRatePrevote) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAggregateExchangeRatePrevote.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAggregateExchangeRatePrevote proto.InternalMessageInfo - -// MsgAggregateExchangeRatePrevoteResponse defines the Msg/AggregateExchangeRatePrevote response type. -type MsgAggregateExchangeRatePrevoteResponse struct { -} - -func (m *MsgAggregateExchangeRatePrevoteResponse) Reset() { - *m = MsgAggregateExchangeRatePrevoteResponse{} -} -func (m *MsgAggregateExchangeRatePrevoteResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAggregateExchangeRatePrevoteResponse) ProtoMessage() {} -func (*MsgAggregateExchangeRatePrevoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{1} -} -func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse.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 *MsgAggregateExchangeRatePrevoteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse.Merge(m, src) -} -func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse proto.InternalMessageInfo - -// MsgAggregateExchangeRateVote represents a message to submit -// aggregate exchange rate vote. -type MsgAggregateExchangeRateVote struct { - Salt string `protobuf:"bytes,1,opt,name=salt,proto3" json:"salt,omitempty" yaml:"salt"` - ExchangeRates string `protobuf:"bytes,2,opt,name=exchange_rates,json=exchangeRates,proto3" json:"exchange_rates,omitempty" yaml:"exchange_rates"` - Feeder string `protobuf:"bytes,3,opt,name=feeder,proto3" json:"feeder,omitempty" yaml:"feeder"` - Validator string `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty" yaml:"validator"` -} - -func (m *MsgAggregateExchangeRateVote) Reset() { *m = MsgAggregateExchangeRateVote{} } -func (m *MsgAggregateExchangeRateVote) String() string { return proto.CompactTextString(m) } -func (*MsgAggregateExchangeRateVote) ProtoMessage() {} -func (*MsgAggregateExchangeRateVote) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{2} -} -func (m *MsgAggregateExchangeRateVote) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAggregateExchangeRateVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAggregateExchangeRateVote.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 *MsgAggregateExchangeRateVote) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAggregateExchangeRateVote.Merge(m, src) -} -func (m *MsgAggregateExchangeRateVote) XXX_Size() int { - return m.Size() -} -func (m *MsgAggregateExchangeRateVote) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAggregateExchangeRateVote.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAggregateExchangeRateVote proto.InternalMessageInfo - -// MsgAggregateExchangeRateVoteResponse defines the Msg/AggregateExchangeRateVote response type. -type MsgAggregateExchangeRateVoteResponse struct { -} - -func (m *MsgAggregateExchangeRateVoteResponse) Reset() { *m = MsgAggregateExchangeRateVoteResponse{} } -func (m *MsgAggregateExchangeRateVoteResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAggregateExchangeRateVoteResponse) ProtoMessage() {} -func (*MsgAggregateExchangeRateVoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{3} -} -func (m *MsgAggregateExchangeRateVoteResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAggregateExchangeRateVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAggregateExchangeRateVoteResponse.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 *MsgAggregateExchangeRateVoteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAggregateExchangeRateVoteResponse.Merge(m, src) -} -func (m *MsgAggregateExchangeRateVoteResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgAggregateExchangeRateVoteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAggregateExchangeRateVoteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAggregateExchangeRateVoteResponse proto.InternalMessageInfo - -// MsgDelegateFeedConsent represents a message to -// delegate oracle voting rights to another address. -type MsgDelegateFeedConsent struct { - Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty" yaml:"operator"` - Delegate string `protobuf:"bytes,2,opt,name=delegate,proto3" json:"delegate,omitempty" yaml:"delegate"` -} - -func (m *MsgDelegateFeedConsent) Reset() { *m = MsgDelegateFeedConsent{} } -func (m *MsgDelegateFeedConsent) String() string { return proto.CompactTextString(m) } -func (*MsgDelegateFeedConsent) ProtoMessage() {} -func (*MsgDelegateFeedConsent) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{4} -} -func (m *MsgDelegateFeedConsent) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgDelegateFeedConsent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgDelegateFeedConsent.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 *MsgDelegateFeedConsent) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDelegateFeedConsent.Merge(m, src) -} -func (m *MsgDelegateFeedConsent) XXX_Size() int { - return m.Size() -} -func (m *MsgDelegateFeedConsent) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDelegateFeedConsent.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgDelegateFeedConsent proto.InternalMessageInfo - -// MsgDelegateFeedConsentResponse defines the Msg/DelegateFeedConsent response type. -type MsgDelegateFeedConsentResponse struct { -} - -func (m *MsgDelegateFeedConsentResponse) Reset() { *m = MsgDelegateFeedConsentResponse{} } -func (m *MsgDelegateFeedConsentResponse) String() string { return proto.CompactTextString(m) } -func (*MsgDelegateFeedConsentResponse) ProtoMessage() {} -func (*MsgDelegateFeedConsentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{5} -} -func (m *MsgDelegateFeedConsentResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgDelegateFeedConsentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgDelegateFeedConsentResponse.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 *MsgDelegateFeedConsentResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDelegateFeedConsentResponse.Merge(m, src) -} -func (m *MsgDelegateFeedConsentResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgDelegateFeedConsentResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDelegateFeedConsentResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgDelegateFeedConsentResponse proto.InternalMessageInfo - // MsgAddRequiredDenom represents a message to add a denom to the whitelist type MsgAddRequiredDenom struct { Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` @@ -275,7 +39,7 @@ func (m *MsgAddRequiredDenom) Reset() { *m = MsgAddRequiredDenom{} } func (m *MsgAddRequiredDenom) String() string { return proto.CompactTextString(m) } func (*MsgAddRequiredDenom) ProtoMessage() {} func (*MsgAddRequiredDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{6} + return fileDescriptor_15c3977432059018, []int{0} } func (m *MsgAddRequiredDenom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,7 +90,7 @@ func (m *MsgAddRequiredDenomResponse) Reset() { *m = MsgAddRequiredDenom func (m *MsgAddRequiredDenomResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddRequiredDenomResponse) ProtoMessage() {} func (*MsgAddRequiredDenomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{7} + return fileDescriptor_15c3977432059018, []int{1} } func (m *MsgAddRequiredDenomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -365,7 +129,7 @@ func (m *MsgRemoveRequiredDenom) Reset() { *m = MsgRemoveRequiredDenom{} func (m *MsgRemoveRequiredDenom) String() string { return proto.CompactTextString(m) } func (*MsgRemoveRequiredDenom) ProtoMessage() {} func (*MsgRemoveRequiredDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{8} + return fileDescriptor_15c3977432059018, []int{2} } func (m *MsgRemoveRequiredDenom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -416,7 +180,7 @@ func (m *MsgRemoveRequiredDenomResponse) Reset() { *m = MsgRemoveRequire func (m *MsgRemoveRequiredDenomResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveRequiredDenomResponse) ProtoMessage() {} func (*MsgRemoveRequiredDenomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{9} + return fileDescriptor_15c3977432059018, []int{3} } func (m *MsgRemoveRequiredDenomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +218,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{10} + return fileDescriptor_15c3977432059018, []int{4} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -505,7 +269,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_15c3977432059018, []int{11} + return fileDescriptor_15c3977432059018, []int{5} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -535,12 +299,6 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgAggregateExchangeRatePrevote)(nil), "kujira.oracle.MsgAggregateExchangeRatePrevote") - proto.RegisterType((*MsgAggregateExchangeRatePrevoteResponse)(nil), "kujira.oracle.MsgAggregateExchangeRatePrevoteResponse") - proto.RegisterType((*MsgAggregateExchangeRateVote)(nil), "kujira.oracle.MsgAggregateExchangeRateVote") - proto.RegisterType((*MsgAggregateExchangeRateVoteResponse)(nil), "kujira.oracle.MsgAggregateExchangeRateVoteResponse") - proto.RegisterType((*MsgDelegateFeedConsent)(nil), "kujira.oracle.MsgDelegateFeedConsent") - proto.RegisterType((*MsgDelegateFeedConsentResponse)(nil), "kujira.oracle.MsgDelegateFeedConsentResponse") proto.RegisterType((*MsgAddRequiredDenom)(nil), "kujira.oracle.MsgAddRequiredDenom") proto.RegisterType((*MsgAddRequiredDenomResponse)(nil), "kujira.oracle.MsgAddRequiredDenomResponse") proto.RegisterType((*MsgRemoveRequiredDenom)(nil), "kujira.oracle.MsgRemoveRequiredDenom") @@ -552,51 +310,33 @@ func init() { func init() { proto.RegisterFile("kujira/oracle/tx.proto", fileDescriptor_15c3977432059018) } var fileDescriptor_15c3977432059018 = []byte{ - // 690 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0x3d, 0x6f, 0x13, 0x4d, - 0x10, 0xc7, 0x7d, 0x4f, 0xf2, 0x44, 0xc9, 0x86, 0xbc, 0x70, 0x79, 0x3f, 0xc2, 0x5d, 0xb4, 0x40, - 0x20, 0x41, 0xf1, 0x89, 0x44, 0xa2, 0x48, 0x15, 0x42, 0xa0, 0x41, 0x96, 0xd0, 0x0a, 0x52, 0xd0, - 0xa0, 0xb5, 0x6f, 0x58, 0x9b, 0xf8, 0xbc, 0x66, 0x77, 0x6d, 0xc5, 0x05, 0x0d, 0x42, 0x40, 0x49, - 0x47, 0x1b, 0x89, 0x0f, 0x00, 0x1f, 0x83, 0x32, 0x25, 0x95, 0x85, 0x92, 0x02, 0x2a, 0x0a, 0x7f, - 0x02, 0x74, 0xb7, 0xe7, 0xcb, 0x39, 0xbe, 0x38, 0x31, 0x0d, 0xd5, 0x59, 0xf3, 0xff, 0xcd, 0xec, - 0x7f, 0xc6, 0x37, 0x7b, 0x68, 0x76, 0xaf, 0xf6, 0xb2, 0x24, 0xa8, 0xcb, 0x05, 0x2d, 0x94, 0xc1, - 0x55, 0xfb, 0xd9, 0xaa, 0xe0, 0x8a, 0x9b, 0x63, 0x3a, 0x9e, 0xd5, 0x71, 0x6b, 0x9a, 0x71, 0xc6, - 0x43, 0xc5, 0x0d, 0x7e, 0x69, 0xc8, 0x9a, 0x2b, 0x70, 0xe9, 0x73, 0xe9, 0xfa, 0x92, 0xb9, 0xf5, - 0x3b, 0xc1, 0x23, 0x12, 0xac, 0xce, 0xaa, 0xfa, 0xa1, 0x35, 0xfc, 0xc5, 0x40, 0x4e, 0x4e, 0xb2, - 0x7b, 0x8c, 0x09, 0x60, 0x54, 0xc1, 0x83, 0xfd, 0x42, 0x91, 0x56, 0x18, 0x10, 0xaa, 0xe0, 0xb1, - 0x80, 0x3a, 0x57, 0x60, 0x5e, 0x43, 0x83, 0x45, 0x2a, 0x8b, 0xf3, 0xc6, 0x92, 0x71, 0x6b, 0x64, - 0x7b, 0xa2, 0xd5, 0x74, 0x46, 0x1b, 0xd4, 0x2f, 0x6f, 0xe2, 0x20, 0x8a, 0x49, 0x28, 0x9a, 0x2b, - 0x68, 0xe8, 0x05, 0x80, 0x07, 0x62, 0xfe, 0xbf, 0x10, 0xbb, 0xdc, 0x6a, 0x3a, 0x63, 0x1a, 0xd3, - 0x71, 0x4c, 0x22, 0xc0, 0x5c, 0x47, 0x23, 0x75, 0x5a, 0x2e, 0x79, 0x54, 0x71, 0x31, 0x3f, 0x10, - 0xd2, 0xd3, 0xad, 0xa6, 0x33, 0xa9, 0xe9, 0x58, 0xc2, 0xe4, 0x04, 0xdb, 0x1c, 0xfe, 0x70, 0xe0, - 0x64, 0x7e, 0x1d, 0x38, 0x19, 0xbc, 0x82, 0x6e, 0x9e, 0x63, 0x98, 0x80, 0xac, 0xf2, 0x8a, 0x04, - 0xfc, 0xdb, 0x40, 0x8b, 0x67, 0xb1, 0xbb, 0x51, 0x67, 0x92, 0x96, 0x55, 0x77, 0x67, 0x41, 0x14, - 0x93, 0x50, 0x34, 0xb7, 0xd0, 0x38, 0x44, 0x89, 0xcf, 0x05, 0x55, 0x20, 0xa3, 0x0e, 0x17, 0x5a, - 0x4d, 0x67, 0x46, 0xe3, 0x9d, 0x3a, 0x26, 0x63, 0x90, 0x38, 0x49, 0x26, 0x66, 0x33, 0xd0, 0xd7, - 0x6c, 0x06, 0xfb, 0x9d, 0xcd, 0x32, 0xba, 0xde, 0xab, 0xdf, 0x78, 0x30, 0x6f, 0x0d, 0x34, 0x9b, - 0x93, 0x6c, 0x07, 0xca, 0x21, 0xf7, 0x10, 0xc0, 0xbb, 0x1f, 0x08, 0x15, 0x65, 0xba, 0x68, 0x98, - 0x57, 0x41, 0x84, 0xe7, 0xeb, 0xb1, 0x4c, 0xb5, 0x9a, 0xce, 0x84, 0x3e, 0xbf, 0xad, 0x60, 0x12, - 0x43, 0x41, 0x82, 0x17, 0xd5, 0x89, 0x06, 0x93, 0x48, 0x68, 0x2b, 0x98, 0xc4, 0x50, 0xc2, 0xee, - 0x12, 0xb2, 0xd3, 0x5d, 0x24, 0x8d, 0x4e, 0x05, 0x1d, 0x79, 0x1e, 0x81, 0x57, 0xb5, 0x92, 0x00, - 0x6f, 0x07, 0x2a, 0xdc, 0x0f, 0xc6, 0x44, 0x6b, 0xaa, 0xc8, 0x45, 0x49, 0x35, 0x22, 0x9b, 0x89, - 0x31, 0xc5, 0x12, 0x26, 0x27, 0x58, 0xf0, 0x2f, 0xc8, 0x86, 0x9f, 0xe7, 0xe5, 0xee, 0x37, 0x54, - 0xc7, 0x31, 0x89, 0x80, 0xcd, 0xf1, 0x37, 0x3f, 0xbf, 0xae, 0x9e, 0xa4, 0xe2, 0xab, 0xe8, 0x4a, - 0x8a, 0x8b, 0xd8, 0xe5, 0x7b, 0x3d, 0x4e, 0x02, 0x3e, 0xaf, 0xc3, 0x3f, 0x35, 0xaa, 0x27, 0x9a, - 0x62, 0x24, 0xf6, 0xfa, 0xc9, 0x40, 0x13, 0x39, 0xc9, 0x9e, 0x56, 0xbd, 0x60, 0x61, 0xa8, 0xa0, - 0xbe, 0xfc, 0x2b, 0x93, 0x5b, 0x68, 0xa8, 0x1a, 0x66, 0x87, 0x26, 0x47, 0xd7, 0x67, 0xb2, 0x1d, - 0x77, 0x54, 0x56, 0x97, 0x4e, 0x7a, 0xd7, 0x38, 0x26, 0x51, 0x5e, 0x97, 0xf7, 0x05, 0x34, 0x77, - 0xca, 0x58, 0xdb, 0xf4, 0xfa, 0xe7, 0xff, 0xd1, 0x40, 0x4e, 0x32, 0xf3, 0x9d, 0x81, 0x16, 0x7b, - 0x5e, 0x55, 0xd9, 0x53, 0x2e, 0xce, 0xb9, 0x29, 0xac, 0xbb, 0xfd, 0xf1, 0x6d, 0x43, 0xe6, 0x6b, - 0xb4, 0x70, 0xf6, 0xad, 0x72, 0xfb, 0x82, 0x45, 0x03, 0xd8, 0xda, 0xe8, 0x03, 0x8e, 0x8f, 0xdf, - 0x43, 0x53, 0x69, 0xbb, 0x7b, 0xa3, 0xbb, 0x56, 0x0a, 0x66, 0xad, 0x5d, 0x08, 0x8b, 0x0f, 0xcb, - 0xa3, 0xc9, 0xae, 0xfd, 0xc3, 0x29, 0xae, 0x4f, 0x31, 0xd6, 0xea, 0xf9, 0x4c, 0xb2, 0xa1, 0xb4, - 0xed, 0x49, 0x69, 0x28, 0x05, 0x4b, 0x6b, 0xa8, 0xc7, 0x0a, 0x98, 0xbb, 0xe8, 0x52, 0xc7, 0xeb, - 0x6f, 0x77, 0xa7, 0x27, 0x75, 0x6b, 0xb9, 0xb7, 0xde, 0xae, 0xbb, 0xbd, 0xf3, 0xed, 0xc8, 0x36, - 0x0e, 0x8f, 0x6c, 0xe3, 0xc7, 0x91, 0x6d, 0x7c, 0x3c, 0xb6, 0x33, 0x87, 0xc7, 0x76, 0xe6, 0xfb, - 0xb1, 0x9d, 0x79, 0xb6, 0xca, 0x4a, 0xaa, 0x58, 0xcb, 0x67, 0x0b, 0xdc, 0x77, 0x9f, 0x00, 0xf5, - 0xd7, 0x1e, 0xe9, 0x2f, 0x72, 0x81, 0x0b, 0x70, 0xf7, 0xe3, 0xcf, 0x7d, 0xa3, 0x0a, 0x32, 0x3f, - 0x14, 0x7e, 0x98, 0x37, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x64, 0x31, 0x1e, 0xf2, 0x0c, 0x08, - 0x00, 0x00, + // 416 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0x2e, 0xcd, 0xca, + 0x2c, 0x4a, 0xd4, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0xe2, 0x85, 0x88, 0xeb, 0x41, 0xc4, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, + 0x32, 0xfa, 0x20, 0x16, 0x44, 0x91, 0x94, 0x78, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, 0x6e, + 0x71, 0xba, 0x7e, 0x99, 0x21, 0x88, 0x82, 0x4a, 0x48, 0xa1, 0x9a, 0x0a, 0xa1, 0x20, 0x72, 0x4a, + 0x2d, 0x8c, 0x5c, 0xc2, 0xbe, 0xc5, 0xe9, 0x8e, 0x29, 0x29, 0x41, 0xa9, 0x85, 0xa5, 0x99, 0x45, + 0xa9, 0x29, 0x2e, 0xa9, 0x79, 0xf9, 0xb9, 0x42, 0x46, 0x5c, 0x9c, 0x89, 0xa5, 0x25, 0x19, 0xf9, + 0x45, 0x99, 0x25, 0x95, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x22, 0x9f, 0xee, 0xc9, 0x0b, + 0x54, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0xc1, 0xa5, 0x94, 0x82, 0x10, 0xca, 0x84, 0x34, 0xb9, 0xd8, + 0x8a, 0x2b, 0x73, 0x93, 0xf2, 0x73, 0x24, 0x98, 0xc0, 0x1a, 0x04, 0x3f, 0xdd, 0x93, 0xe7, 0x85, + 0x68, 0x80, 0x88, 0x2b, 0x05, 0x41, 0x15, 0x58, 0xf1, 0x35, 0x3d, 0xdf, 0xa0, 0x85, 0xd0, 0xaa, + 0x24, 0xcb, 0x25, 0x8d, 0xc5, 0x15, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x4a, 0xed, + 0x8c, 0x5c, 0x62, 0xbe, 0xc5, 0xe9, 0x41, 0xa9, 0xb9, 0xf9, 0x65, 0xa9, 0x03, 0xea, 0x50, 0x05, + 0x2e, 0x39, 0xec, 0x0e, 0x81, 0xbb, 0x75, 0x3a, 0x23, 0x17, 0xbf, 0x6f, 0x71, 0x7a, 0x68, 0x41, + 0x4a, 0x62, 0x49, 0x6a, 0x40, 0x62, 0x51, 0x62, 0x6e, 0x31, 0x59, 0x8e, 0x74, 0xe0, 0x62, 0x2b, + 0x00, 0xeb, 0x06, 0x3b, 0x92, 0xdb, 0x48, 0x54, 0x0f, 0x25, 0x11, 0xe8, 0x41, 0x8c, 0x46, 0x76, + 0x3b, 0x44, 0xb9, 0x52, 0x10, 0x54, 0x1f, 0x86, 0xdb, 0x25, 0xb9, 0xc4, 0xd1, 0x1c, 0x06, 0x73, + 0xb4, 0xd1, 0x3a, 0x26, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x24, 0x2e, 0x01, 0x8c, 0xa4, 0xa0, + 0x84, 0x66, 0x31, 0x96, 0x88, 0x92, 0xd2, 0x22, 0xac, 0x06, 0x66, 0x97, 0x50, 0x36, 0x97, 0x30, + 0xb6, 0x88, 0x54, 0xc5, 0x34, 0x02, 0x8b, 0x32, 0x29, 0x5d, 0xa2, 0x94, 0xc1, 0x2d, 0x0b, 0xe3, + 0xe2, 0x41, 0x89, 0x09, 0x39, 0x4c, 0xed, 0xc8, 0xf2, 0x52, 0x6a, 0xf8, 0xe5, 0x61, 0xe6, 0x3a, + 0xb9, 0x9c, 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, 0x56, 0x7a, 0x66, 0x49, + 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x48, 0x6a, 0x62, 0xae, 0xae, 0x37, 0x24, 0xf7, + 0x25, 0xe7, 0x17, 0xa5, 0xea, 0x57, 0xc0, 0xb3, 0x76, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, + 0x13, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x23, 0x03, 0xbd, 0xfa, 0xf8, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -611,14 +351,6 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // AggregateExchangeRatePrevote defines a method for submitting - // aggregate exchange rate prevote - AggregateExchangeRatePrevote(ctx context.Context, in *MsgAggregateExchangeRatePrevote, opts ...grpc.CallOption) (*MsgAggregateExchangeRatePrevoteResponse, error) - // AggregateExchangeRateVote defines a method for submitting - // aggregate exchange rate vote - AggregateExchangeRateVote(ctx context.Context, in *MsgAggregateExchangeRateVote, opts ...grpc.CallOption) (*MsgAggregateExchangeRateVoteResponse, error) - // DelegateFeedConsent defines a method for setting the feeder delegation - DelegateFeedConsent(ctx context.Context, in *MsgDelegateFeedConsent, opts ...grpc.CallOption) (*MsgDelegateFeedConsentResponse, error) // AddRequiredDenom adds a new price to the required list of prices AddRequiredDenom(ctx context.Context, in *MsgAddRequiredDenom, opts ...grpc.CallOption) (*MsgAddRequiredDenomResponse, error) // RemoveRequiredDenom removes a price from the required list of prices @@ -635,33 +367,6 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) AggregateExchangeRatePrevote(ctx context.Context, in *MsgAggregateExchangeRatePrevote, opts ...grpc.CallOption) (*MsgAggregateExchangeRatePrevoteResponse, error) { - out := new(MsgAggregateExchangeRatePrevoteResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Msg/AggregateExchangeRatePrevote", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) AggregateExchangeRateVote(ctx context.Context, in *MsgAggregateExchangeRateVote, opts ...grpc.CallOption) (*MsgAggregateExchangeRateVoteResponse, error) { - out := new(MsgAggregateExchangeRateVoteResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Msg/AggregateExchangeRateVote", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) DelegateFeedConsent(ctx context.Context, in *MsgDelegateFeedConsent, opts ...grpc.CallOption) (*MsgDelegateFeedConsentResponse, error) { - out := new(MsgDelegateFeedConsentResponse) - err := c.cc.Invoke(ctx, "/kujira.oracle.Msg/DelegateFeedConsent", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) AddRequiredDenom(ctx context.Context, in *MsgAddRequiredDenom, opts ...grpc.CallOption) (*MsgAddRequiredDenomResponse, error) { out := new(MsgAddRequiredDenomResponse) err := c.cc.Invoke(ctx, "/kujira.oracle.Msg/AddRequiredDenom", in, out, opts...) @@ -691,14 +396,6 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { - // AggregateExchangeRatePrevote defines a method for submitting - // aggregate exchange rate prevote - AggregateExchangeRatePrevote(context.Context, *MsgAggregateExchangeRatePrevote) (*MsgAggregateExchangeRatePrevoteResponse, error) - // AggregateExchangeRateVote defines a method for submitting - // aggregate exchange rate vote - AggregateExchangeRateVote(context.Context, *MsgAggregateExchangeRateVote) (*MsgAggregateExchangeRateVoteResponse, error) - // DelegateFeedConsent defines a method for setting the feeder delegation - DelegateFeedConsent(context.Context, *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error) // AddRequiredDenom adds a new price to the required list of prices AddRequiredDenom(context.Context, *MsgAddRequiredDenom) (*MsgAddRequiredDenomResponse, error) // RemoveRequiredDenom removes a price from the required list of prices @@ -711,15 +408,6 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) AggregateExchangeRatePrevote(ctx context.Context, req *MsgAggregateExchangeRatePrevote) (*MsgAggregateExchangeRatePrevoteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregateExchangeRatePrevote not implemented") -} -func (*UnimplementedMsgServer) AggregateExchangeRateVote(ctx context.Context, req *MsgAggregateExchangeRateVote) (*MsgAggregateExchangeRateVoteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregateExchangeRateVote not implemented") -} -func (*UnimplementedMsgServer) DelegateFeedConsent(ctx context.Context, req *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DelegateFeedConsent not implemented") -} func (*UnimplementedMsgServer) AddRequiredDenom(ctx context.Context, req *MsgAddRequiredDenom) (*MsgAddRequiredDenomResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddRequiredDenom not implemented") } @@ -734,60 +422,6 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_AggregateExchangeRatePrevote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAggregateExchangeRatePrevote) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).AggregateExchangeRatePrevote(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Msg/AggregateExchangeRatePrevote", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AggregateExchangeRatePrevote(ctx, req.(*MsgAggregateExchangeRatePrevote)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_AggregateExchangeRateVote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAggregateExchangeRateVote) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).AggregateExchangeRateVote(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Msg/AggregateExchangeRateVote", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AggregateExchangeRateVote(ctx, req.(*MsgAggregateExchangeRateVote)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_DelegateFeedConsent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDelegateFeedConsent) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).DelegateFeedConsent(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kujira.oracle.Msg/DelegateFeedConsent", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DelegateFeedConsent(ctx, req.(*MsgDelegateFeedConsent)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_AddRequiredDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgAddRequiredDenom) if err := dec(in); err != nil { @@ -846,18 +480,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "kujira.oracle.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "AggregateExchangeRatePrevote", - Handler: _Msg_AggregateExchangeRatePrevote_Handler, - }, - { - MethodName: "AggregateExchangeRateVote", - Handler: _Msg_AggregateExchangeRateVote_Handler, - }, - { - MethodName: "DelegateFeedConsent", - Handler: _Msg_DelegateFeedConsent_Handler, - }, { MethodName: "AddRequiredDenom", Handler: _Msg_AddRequiredDenom_Handler, @@ -875,7 +497,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "kujira/oracle/tx.proto", } -func (m *MsgAggregateExchangeRatePrevote) Marshal() (dAtA []byte, err error) { +func (m *MsgAddRequiredDenom) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -885,41 +507,34 @@ func (m *MsgAggregateExchangeRatePrevote) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAggregateExchangeRatePrevote) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddRequiredDenom) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAggregateExchangeRatePrevote) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddRequiredDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Validator) > 0 { - i -= len(m.Validator) - copy(dAtA[i:], m.Validator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Validator))) - i-- - dAtA[i] = 0x1a - } - if len(m.Feeder) > 0 { - i -= len(m.Feeder) - copy(dAtA[i:], m.Feeder) - i = encodeVarintTx(dAtA, i, uint64(len(m.Feeder))) + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) i-- dAtA[i] = 0x12 } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintTx(dAtA, i, uint64(len(m.Hash))) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgAggregateExchangeRatePrevoteResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgAddRequiredDenomResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -929,12 +544,12 @@ func (m *MsgAggregateExchangeRatePrevoteResponse) Marshal() (dAtA []byte, err er return dAtA[:n], nil } -func (m *MsgAggregateExchangeRatePrevoteResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddRequiredDenomResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAggregateExchangeRatePrevoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddRequiredDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -942,7 +557,7 @@ func (m *MsgAggregateExchangeRatePrevoteResponse) MarshalToSizedBuffer(dAtA []by return len(dAtA) - i, nil } -func (m *MsgAggregateExchangeRateVote) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveRequiredDenom) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -952,48 +567,34 @@ func (m *MsgAggregateExchangeRateVote) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAggregateExchangeRateVote) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveRequiredDenom) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAggregateExchangeRateVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveRequiredDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Validator) > 0 { - i -= len(m.Validator) - copy(dAtA[i:], m.Validator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Validator))) - i-- - dAtA[i] = 0x22 - } - if len(m.Feeder) > 0 { - i -= len(m.Feeder) - copy(dAtA[i:], m.Feeder) - i = encodeVarintTx(dAtA, i, uint64(len(m.Feeder))) - i-- - dAtA[i] = 0x1a - } - if len(m.ExchangeRates) > 0 { - i -= len(m.ExchangeRates) - copy(dAtA[i:], m.ExchangeRates) - i = encodeVarintTx(dAtA, i, uint64(len(m.ExchangeRates))) + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) i-- dAtA[i] = 0x12 } - if len(m.Salt) > 0 { - i -= len(m.Salt) - copy(dAtA[i:], m.Salt) - i = encodeVarintTx(dAtA, i, uint64(len(m.Salt))) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgAggregateExchangeRateVoteResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveRequiredDenomResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1003,12 +604,12 @@ func (m *MsgAggregateExchangeRateVoteResponse) Marshal() (dAtA []byte, err error return dAtA[:n], nil } -func (m *MsgAggregateExchangeRateVoteResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveRequiredDenomResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAggregateExchangeRateVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveRequiredDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1016,7 +617,7 @@ func (m *MsgAggregateExchangeRateVoteResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *MsgDelegateFeedConsent) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1026,34 +627,39 @@ func (m *MsgDelegateFeedConsent) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDelegateFeedConsent) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDelegateFeedConsent) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Delegate) > 0 { - i -= len(m.Delegate) - copy(dAtA[i:], m.Delegate) - i = encodeVarintTx(dAtA, i, uint64(len(m.Delegate))) + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x12 } - if len(m.Operator) > 0 { - i -= len(m.Operator) - copy(dAtA[i:], m.Operator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgDelegateFeedConsentResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1063,197 +669,12 @@ func (m *MsgDelegateFeedConsentResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDelegateFeedConsentResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDelegateFeedConsentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgAddRequiredDenom) 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 *MsgAddRequiredDenom) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAddRequiredDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Symbol) > 0 { - i -= len(m.Symbol) - copy(dAtA[i:], m.Symbol) - i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) - i-- - dAtA[i] = 0x12 - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgAddRequiredDenomResponse) 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 *MsgAddRequiredDenomResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAddRequiredDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgRemoveRequiredDenom) 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 *MsgRemoveRequiredDenom) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveRequiredDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Symbol) > 0 { - i -= len(m.Symbol) - copy(dAtA[i:], m.Symbol) - i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) - i-- - dAtA[i] = 0x12 - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRemoveRequiredDenomResponse) 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 *MsgRemoveRequiredDenomResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveRequiredDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Params != nil { - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1272,88 +693,24 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgAggregateExchangeRatePrevote) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Feeder) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Validator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgAggregateExchangeRatePrevoteResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgAggregateExchangeRateVote) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Salt) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ExchangeRates) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Feeder) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Validator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgAggregateExchangeRateVoteResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgDelegateFeedConsent) Size() (n int) { +func (m *MsgAddRequiredDenom) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Operator) + l = len(m.Authority) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Delegate) + l = len(m.Symbol) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgDelegateFeedConsentResponse) Size() (n int) { +func (m *MsgAddRequiredDenomResponse) Size() (n int) { if m == nil { return 0 } @@ -1362,7 +719,7 @@ func (m *MsgDelegateFeedConsentResponse) Size() (n int) { return n } -func (m *MsgAddRequiredDenom) Size() (n int) { +func (m *MsgRemoveRequiredDenom) Size() (n int) { if m == nil { return 0 } @@ -1379,7 +736,7 @@ func (m *MsgAddRequiredDenom) Size() (n int) { return n } -func (m *MsgAddRequiredDenomResponse) Size() (n int) { +func (m *MsgRemoveRequiredDenomResponse) Size() (n int) { if m == nil { return 0 } @@ -1388,7 +745,7 @@ func (m *MsgAddRequiredDenomResponse) Size() (n int) { return n } -func (m *MsgRemoveRequiredDenom) Size() (n int) { +func (m *MsgUpdateParams) Size() (n int) { if m == nil { return 0 } @@ -1398,40 +755,14 @@ func (m *MsgRemoveRequiredDenom) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Symbol) - if l > 0 { + if m.Params != nil { + l = m.Params.Size() n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgRemoveRequiredDenomResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Params != nil { - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { +func (m *MsgUpdateParamsResponse) Size() (n int) { if m == nil { return 0 } @@ -1446,594 +777,6 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgAggregateExchangeRatePrevote) 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: MsgAggregateExchangeRatePrevote: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAggregateExchangeRatePrevote: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", 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.Hash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Feeder", 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.Feeder = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - 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 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.Validator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgAggregateExchangeRatePrevoteResponse) 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: MsgAggregateExchangeRatePrevoteResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAggregateExchangeRatePrevoteResponse: 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 (m *MsgAggregateExchangeRateVote) 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: MsgAggregateExchangeRateVote: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAggregateExchangeRateVote: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Salt", 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.Salt = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRates", 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.ExchangeRates = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Feeder", 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.Feeder = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - 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 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.Validator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgAggregateExchangeRateVoteResponse) 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: MsgAggregateExchangeRateVoteResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAggregateExchangeRateVoteResponse: 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 (m *MsgDelegateFeedConsent) 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: MsgDelegateFeedConsent: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDelegateFeedConsent: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegate", 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.Delegate = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgDelegateFeedConsentResponse) 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: MsgDelegateFeedConsentResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDelegateFeedConsentResponse: 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 (m *MsgAddRequiredDenom) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/vote.go b/x/oracle/types/vote.go index 3762b249..8dbc7513 100644 --- a/x/oracle/types/vote.go +++ b/x/oracle/types/vote.go @@ -10,35 +10,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewAggregateExchangeRatePrevote returns AggregateExchangeRatePrevote object -func NewAggregateExchangeRatePrevote(hash AggregateVoteHash, voter sdk.ValAddress, submitBlock uint64) AggregateExchangeRatePrevote { - return AggregateExchangeRatePrevote{ - Hash: hash.String(), - Voter: voter.String(), - SubmitBlock: submitBlock, - } -} - -// String implement stringify -func (v AggregateExchangeRatePrevote) String() string { - out, _ := yaml.Marshal(v) - return string(out) -} - -// NewAggregateExchangeRateVote creates a AggregateExchangeRateVote instance -func NewAggregateExchangeRateVote(exchangeRateTuples ExchangeRateTuples, voter sdk.ValAddress) AggregateExchangeRateVote { - return AggregateExchangeRateVote{ - ExchangeRateTuples: exchangeRateTuples, - Voter: voter.String(), - } -} - -// String implement stringify -func (v AggregateExchangeRateVote) String() string { - out, _ := yaml.Marshal(v) - return string(out) -} - // NewExchangeRateTuple creates a ExchangeRateTuple instance func NewExchangeRateTuple(denom string, exchangeRate math.LegacyDec) ExchangeRateTuple { return ExchangeRateTuple{ diff --git a/x/scheduler/client/cli/query_hook.go b/x/scheduler/client/cli/query_hook.go index 1db34f3f..b71d1984 100644 --- a/x/scheduler/client/cli/query_hook.go +++ b/x/scheduler/client/cli/query_hook.go @@ -15,7 +15,7 @@ func CmdListHooks() *cobra.Command { cmd := &cobra.Command{ Use: "list-hooks", Short: "list all hooks", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/scheduler/client/cli/query_params.go b/x/scheduler/client/cli/query_params.go index a630e535..8147ab2b 100644 --- a/x/scheduler/client/cli/query_params.go +++ b/x/scheduler/client/cli/query_params.go @@ -14,7 +14,7 @@ func CmdQueryParams() *cobra.Command { Use: "params", Short: "shows the parameters of the module", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/scheduler/keeper/grpc_query_hook.go b/x/scheduler/keeper/grpc_query_hook.go index c3e67a5b..35c6d427 100644 --- a/x/scheduler/keeper/grpc_query_hook.go +++ b/x/scheduler/keeper/grpc_query_hook.go @@ -23,7 +23,7 @@ func (k Keeper) HookAll(c context.Context, req *types.QueryAllHookRequest) (*typ store := ctx.KVStore(k.storeKey) hookStore := prefix.NewStore(store, types.KeyPrefix(types.HookKey)) - pageRes, err := query.Paginate(hookStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(hookStore, req.Pagination, func(_ []byte, value []byte) error { var hook types.Hook if err := k.cdc.Unmarshal(value, &hook); err != nil { return err