diff --git a/proto/oracle/tx.proto b/proto/oracle/tx.proto index 9d3fb33d3d..2e0405d207 100644 --- a/proto/oracle/tx.proto +++ b/proto/oracle/tx.proto @@ -15,6 +15,9 @@ service Msg { // aggregate exchange rate vote rpc AggregateExchangeRateVote(MsgAggregateExchangeRateVote) returns (MsgAggregateExchangeRateVoteResponse); + // Aggregate vote and prevote combines the functionality of prevote and vote into one RPC + rpc AggregateExchangeRateCombinedVote(MsgAggregateExchangeRateCombinedVote) returns (MsgAggregateExchangeRateCombinedVoteResponse); + // DelegateFeedConsent defines a method for setting the feeder delegation rpc DelegateFeedConsent(MsgDelegateFeedConsent) returns (MsgDelegateFeedConsentResponse); } @@ -48,6 +51,22 @@ message MsgAggregateExchangeRateVote { // MsgAggregateExchangeRateVoteResponse defines the Msg/AggregateExchangeRateVote response type. message MsgAggregateExchangeRateVoteResponse {} +// MsgAggregateExchangeRateVote represents a message to submit +// aggregate exchange rate vote. +message MsgAggregateExchangeRateCombinedVote { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string vote_salt = 1 [(gogoproto.moretags) = "yaml:\"vote_salt\""]; + string vote_exchange_rates = 2 [(gogoproto.moretags) = "yaml:\"vote_exchange_rates\""]; + string prevote_hash = 3 [(gogoproto.moretags) = "yaml:\"prevote_hash\""]; + string feeder = 4 [(gogoproto.moretags) = "yaml:\"feeder\""]; + string validator = 5 [(gogoproto.moretags) = "yaml:\"validator\""]; +} + +// MsgAggregateExchangeRateVoteResponse defines the Msg/AggregateExchangeRateVote response type. +message MsgAggregateExchangeRateCombinedVoteResponse {} + // MsgDelegateFeedConsent represents a message to // delegate oracle voting rights to another address. message MsgDelegateFeedConsent { diff --git a/x/oracle/abci_test.go b/x/oracle/abci_test.go index 177fec5c5a..7bec431de0 100755 --- a/x/oracle/abci_test.go +++ b/x/oracle/abci_test.go @@ -630,6 +630,37 @@ func TestOraclePriceSnapshot(t *testing.T) { require.Equal(t, expected2, input.OracleKeeper.GetPriceSnapshot(input.Ctx, 200)) } +func TestOracleCombinedVote(t *testing.T) { + input, h := setup(t) + + input.Ctx = input.Ctx.WithBlockHeight(1) + input.OracleKeeper.SetBaseExchangeRate(input.Ctx, utils.MicroAtomDenom, randomExchangeRate) + + input.Ctx = input.Ctx.WithBlockHeight(2) + makeAggregateCombinedVote(t, input, h, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(1)}}, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(2)}}, 0) + makeAggregateCombinedVote(t, input, h, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(1)}}, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(2)}}, 1) + makeAggregateCombinedVote(t, input, h, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(1)}}, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(2)}}, 2) + oracle.EndBlocker(input.Ctx, input.OracleKeeper) + + // we expect random exchange rate because the vote had no prevote + rate, height, err := input.OracleKeeper.GetBaseExchangeRate(input.Ctx, utils.MicroAtomDenom) + require.NoError(t, err) + require.Equal(t, randomExchangeRate, rate) + require.Equal(t, sdk.NewInt(1), height) + + input.Ctx = input.Ctx.WithBlockHeight(3) + makeAggregateCombinedVote(t, input, h, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(2)}}, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(3)}}, 0) + makeAggregateCombinedVote(t, input, h, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(2)}}, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(3)}}, 1) + makeAggregateCombinedVote(t, input, h, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(2)}}, sdk.DecCoins{{Denom: utils.MicroAtomDenom, Amount: sdk.NewDec(3)}}, 2) + oracle.EndBlocker(input.Ctx, input.OracleKeeper) + + // we expect exchange rate of 2 because the vote had a previous prevote + rate, height, err = input.OracleKeeper.GetBaseExchangeRate(input.Ctx, utils.MicroAtomDenom) + require.NoError(t, err) + require.Equal(t, sdk.NewDec(2), rate) + require.Equal(t, sdk.NewInt(3), height) +} + func makeAggregatePrevoteAndVote(t *testing.T, input keeper.TestInput, h sdk.Handler, height int64, rates sdk.DecCoins, idx int) { // Account 1, SDR salt := "1" @@ -643,3 +674,12 @@ func makeAggregatePrevoteAndVote(t *testing.T, input keeper.TestInput, h sdk.Han _, err = h(input.Ctx.WithBlockHeight(height+1), voteMsg) require.NoError(t, err) } + +func makeAggregateCombinedVote(t *testing.T, input keeper.TestInput, h sdk.Handler, vote_rates sdk.DecCoins, prevote_rates sdk.DecCoins, idx int) { + salt := "1" + + hash := types.GetAggregateVoteHash(salt, prevote_rates.String(), keeper.ValAddrs[idx]) + voteMsg := types.NewMsgAggregateExchangeRateCombinedVote(salt, vote_rates.String(), hash, keeper.Addrs[idx], keeper.ValAddrs[idx]) + _, err := h(input.Ctx, voteMsg) + require.NoError(t, err) +} diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 2c9b3aa745..0a286120a9 100755 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -30,6 +30,7 @@ func GetTxCmd() *cobra.Command { GetCmdDelegateFeederPermission(), GetCmdAggregateExchangeRatePrevote(), GetCmdAggregateExchangeRateVote(), + GetCmdAggregateExchangeRateCombinedVote(), ) return oracleTxCmd @@ -92,11 +93,11 @@ func GetCmdAggregateExchangeRatePrevote() *cobra.Command { Short: "Submit an oracle aggregate prevote for the exchange rates of Luna", Long: strings.TrimSpace(` Submit an oracle aggregate prevote for the exchange rates of Luna denominated in multiple denoms. -The purpose of aggregate prevote is to hide aggregate exchange rate vote with hash which is formatted +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 -$ terrad tx oracle aggregate-prevote 1234 8888.0ukrw,1.243uusd,0.99usdr +$ terrad tx oracle aggregate-prevote 1234 8888.0ukrw,1.243uusd,0.99usdr where "ukrw,uusd,usdr" is the denominating currencies, and "8888.0,1.243,0.99" is the exchange rates of micro Luna in micro denoms from the voter's point of view. @@ -153,18 +154,18 @@ 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", + Short: "Submit an oracle aggregate vote for the exchange_rates of the base denom", 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. +Submit a aggregate vote for the exchange_rates of the base denom w.r.t the input denom. Companion to a prevote submitted in the previous vote period. -$ terrad tx oracle aggregate-vote 1234 8888.0ukrw,1.243uusd,0.99usdr +$ seid tx oracle aggregate-vote 1234 8888.0ukrw,1.243uusd,0.99usdr where "ukrw,uusd,usdr" is the denominating currencies, and "8888.0,1.243,0.99" is the exchange rates of micro Luna in micro denoms from the voter's point of view. -"salt" should match the salt used to generate the SHA256 hex in the aggregated pre-vote. +"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: -$ terrad tx oracle aggregate-vote 1234 8888.0ukrw,1.243uusd,0.99usdr terravaloper1.... +$ seid tx oracle aggregate-vote 1234 8888.0ukrw,1.243uusd,0.99usdr seivaloper1.... `), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -209,3 +210,75 @@ $ terrad tx oracle aggregate-vote 1234 8888.0ukrw,1.243uusd,0.99usdr terravalope return cmd } + +// GetCmdAggregateExchangeRatePrevote will create a aggregateExchangeRatePrevote tx and sign it with the given key. +func GetCmdAggregateExchangeRateCombinedVote() *cobra.Command { + cmd := &cobra.Command{ + Use: "aggregate-combined-vote [vote-salt] [vote-exchange-rates] [prevote-salt] [prevote-exchange-rates] [validator]", + Args: cobra.RangeArgs(4, 5), + Short: "Submit an oracle aggregate vote AND prevote for the exchange rates", + Long: strings.TrimSpace(` +Submit an oracle aggregate vote and prevote for the exchange rates of the base denom denominated in multiple denoms. The vote is a companian to a prevote from the previous vote window. + +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 Combined Vote +$ seid tx oracle aggregate-combined-vote 1234 8888.0ukrw,1.243uusd,0.99usdr 3456 9999.0ukrw,1.111uusd,0.95usdr + +where "ukrw,uusd,usdr" is the denominating currencies, and "8888.0,1.243,0.99" is the exchange rates of micro base denom in micro denoms 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: +$ terrad tx oracle aggregate-combined vote 1234 8888.0ukrw,1.243uusd,0.99usdr 3456 9999.0ukrw,1.111uusd,0.95usdr seivaloper1... +`), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + voteSalt := args[0] + voteExchangeRatesStr := args[1] + prevoteSalt := args[2] + prevoteExchangeRatesStr := args[3] + _, err = types.ParseExchangeRateTuples(voteExchangeRatesStr) + if err != nil { + return fmt.Errorf("given vote exchange_rates {%s} is not a valid format; exchange_rate should be formatted as DecCoins; %s", voteExchangeRatesStr, err.Error()) + } + + _, err = types.ParseExchangeRateTuples(prevoteExchangeRatesStr) + if err != nil { + return fmt.Errorf("given prevote exchange_rates {%s} is not a valid format; exchange_rate should be formatted as DecCoins; %s", prevoteExchangeRatesStr, 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) == 5 { + parsedVal, err := sdk.ValAddressFromBech32(args[4]) + if err != nil { + return errors.Wrap(err, "validator address is invalid") + } + validator = parsedVal + } + + hash := types.GetAggregateVoteHash(prevoteSalt, prevoteExchangeRatesStr, validator) + msgs := []sdk.Msg{types.NewMsgAggregateExchangeRateCombinedVote(voteSalt, voteExchangeRatesStr, hash, voter, validator)} + for _, msg := range msgs { + if err := msg.ValidateBasic(); err != nil { + return err + } + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/rest/tx.go b/x/oracle/client/rest/tx.go index 535090bd1f..1a01884258 100755 --- a/x/oracle/client/rest/tx.go +++ b/x/oracle/client/rest/tx.go @@ -18,6 +18,7 @@ func registerTxHandlers(cliCtx client.Context, rtr *mux.Router) { rtr.HandleFunc(fmt.Sprintf("/oracle/voters/{%s}/feeder", RestVoter), newDelegateHandlerFunction(cliCtx)).Methods("POST") rtr.HandleFunc(fmt.Sprintf("/oracle/voters/{%s}/aggregate_prevote", RestVoter), newAggregatePrevoteHandlerFunction(cliCtx)).Methods("POST") rtr.HandleFunc(fmt.Sprintf("/oracle/voters/{%s}/aggregate_vote", RestVoter), newAggregateVoteHandlerFunction(cliCtx)).Methods("POST") + rtr.HandleFunc(fmt.Sprintf("/oracle/voters/{%s}/aggregate_combined_vote", RestVoter), newAggregateCombinedVoteHandlerFunction(cliCtx)).Methods("POST") } type ( @@ -40,6 +41,16 @@ type ( ExchangeRates string `json:"exchange_rates" yaml:"exchange_rates"` Salt string `json:"salt" yaml:"salt"` } + + aggregateCombinedVoteReq struct { + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + + VoteExchangeRates string `json:"vote_exchange_rates" yaml:"vote_exchange_rates"` + VoteSalt string `json:"vote_salt" yaml:"vote_salt"` + PrevoteHash string `json:"prevote_hash" yaml:"prevote_hash"` + PrevoteExchangeRates string `json:"prevote_exchange_rates" yaml:"prevote_exchange_rates"` + PrevoteSalt string `json:"prevote_salt" yaml:"prevote_salt"` + } ) func newDelegateHandlerFunction(clientCtx client.Context) http.HandlerFunc { @@ -161,3 +172,63 @@ func newAggregateVoteHandlerFunction(clientCtx client.Context) http.HandlerFunc tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg) } } + +func newAggregateCombinedVoteHandlerFunction(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req aggregateCombinedVoteReq + if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) { + return + } + + req.BaseReq = req.BaseReq.Sanitize() + if !req.BaseReq.ValidateBasic(w) { + return + } + + feederAddr, err := sdk.AccAddressFromBech32(req.BaseReq.From) + if rest.CheckBadRequestError(w, err) { + return + } + + voterAddr, ok := checkVoterAddressVar(w, r) + if !ok { + return + } + + // Check validation of tuples + _, err = types.ParseExchangeRateTuples(req.VoteExchangeRates) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + var prevoteHash types.AggregateVoteHash + + // If hash is not given, then retrieve hash from exchange_rate and salt + if len(req.PrevoteHash) == 0 && (len(req.PrevoteExchangeRates) > 0 && len(req.PrevoteSalt) > 0) { + _, err := types.ParseExchangeRateTuples(req.PrevoteExchangeRates) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + prevoteHash = types.GetAggregateVoteHash(req.PrevoteSalt, req.PrevoteExchangeRates, voterAddr) + } else if len(req.PrevoteHash) > 0 { + prevoteHash, err = types.AggregateVoteHashFromHexString(req.PrevoteHash) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + } else { + rest.WriteErrorResponse(w, http.StatusBadRequest, "must provide Hash or (ExchangeRates & Salt)") + return + } + + msg := types.NewMsgAggregateExchangeRateCombinedVote(req.VoteSalt, req.VoteExchangeRates, prevoteHash, feederAddr, voterAddr) + if rest.CheckBadRequestError(w, msg.ValidateBasic()) { + return + } + + tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg) + } +} diff --git a/x/oracle/handler.go b/x/oracle/handler.go index 58c15f54cc..fab99cd3bf 100755 --- a/x/oracle/handler.go +++ b/x/oracle/handler.go @@ -25,6 +25,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgAggregateExchangeRateVote: res, err := msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgAggregateExchangeRateCombinedVote: + res, err := msgServer.AggregateExchangeRateCombinedVote(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized oracle message type: %T", msg) } diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 3186a56f19..d3ab467207 100755 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -543,3 +543,12 @@ func (k Keeper) ValidateLookbackSeconds(ctx sdk.Context, lookbackSeconds int64) return nil } + +func (k Keeper) IsPrevoteFromPreviousWindow(ctx sdk.Context, valAddr sdk.ValAddress) bool { + votePeriod := k.VotePeriod(ctx) + prevote, err := k.GetAggregateExchangeRatePrevote(ctx, valAddr) + if err != nil { + return false + } + return (uint64(ctx.BlockHeight())/votePeriod)-(prevote.SubmitBlock/votePeriod) == 1 +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 7dfb190e8f..db0d47da6a 100755 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -78,15 +78,13 @@ func (ms msgServer) AggregateExchangeRateVote(goCtx context.Context, msg *types. return nil, err } - params := ms.GetParams(ctx) - aggregatePrevote, err := ms.GetAggregateExchangeRatePrevote(ctx, valAddr) if err != nil { return nil, sdkerrors.Wrap(types.ErrNoAggregatePrevote, msg.Validator) } // Check a msg is submitted proper period - if (uint64(ctx.BlockHeight())/params.VotePeriod)-(aggregatePrevote.SubmitBlock/params.VotePeriod) != 1 { + if !ms.IsPrevoteFromPreviousWindow(ctx, valAddr) { return nil, types.ErrRevealPeriodMissMatch } @@ -128,6 +126,49 @@ func (ms msgServer) AggregateExchangeRateVote(goCtx context.Context, msg *types. return &types.MsgAggregateExchangeRateVoteResponse{}, nil } +func (ms msgServer) AggregateExchangeRateCombinedVote(goCtx context.Context, msg *types.MsgAggregateExchangeRateCombinedVote) (*types.MsgAggregateExchangeRateCombinedVoteResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + valAddr, err := sdk.ValAddressFromBech32(msg.Validator) + if err != nil { + return nil, err + } + + var voteErr error + // if there isn't a prevote, we want to no-op the vote so we don't get an error + // this way, it is safe to use combined vote regardless of a missed vote window + if err == nil && ms.IsPrevoteFromPreviousWindow(ctx, valAddr) { + _, voteErr = ms.AggregateExchangeRateVote(goCtx, msg.GetVoteFromCombinedVote()) + } + + _, prevoteErr := ms.AggregateExchangeRatePrevote(goCtx, msg.GetPrevoteFromCombinedVote()) + + if voteErr != nil { + return nil, voteErr + } + if prevoteErr != nil { + return nil, prevoteErr + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeAggregateVote, + sdk.NewAttribute(types.AttributeKeyVoter, msg.Validator), + sdk.NewAttribute(types.AttributeKeyExchangeRates, msg.VoteExchangeRates), + ), + 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.MsgAggregateExchangeRateCombinedVoteResponse{}, nil +} + func (ms msgServer) DelegateFeedConsent(goCtx context.Context, msg *types.MsgDelegateFeedConsent) (*types.MsgDelegateFeedConsentResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index 3eec38e6e1..d4d4b7ee05 100755 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -166,13 +166,12 @@ func SimulateMsgAggregateExchangeRateVote(ak types.AccountKeeper, bk types.BankK } // get prevote - prevote, err := k.GetAggregateExchangeRatePrevote(ctx, address) + _, 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 { + if !k.IsPrevoteFromPreviousWindow(ctx, address) { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "reveal period of submitted vote do not match with registered prevote"), nil, nil } diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 84fa88ef18..ffc281b7d5 100755 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -10,9 +10,11 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgAggregateExchangeRatePrevote{}, "oracle/MsgAggregateExchangeRatePrevote", nil) cdc.RegisterConcrete(&MsgAggregateExchangeRateVote{}, "oracle/MsgAggregateExchangeRateVote", nil) + cdc.RegisterConcrete(&MsgAggregateExchangeRateCombinedVote{}, "oracle/MsgAggregateExchangeRateCombinedVote", nil) cdc.RegisterConcrete(&MsgDelegateFeedConsent{}, "oracle/MsgDelegateFeedConsent", nil) } +// TODO: update here for combined vote func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgAggregateExchangeRatePrevote{}, @@ -20,6 +22,9 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgAggregateExchangeRateVote{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgAggregateExchangeRateCombinedVote{}, + ) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgDelegateFeedConsent{}, ) diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index cb92bfb575..ef72d1f04c 100755 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -12,13 +12,15 @@ var ( _ sdk.Msg = &MsgDelegateFeedConsent{} _ sdk.Msg = &MsgAggregateExchangeRatePrevote{} _ sdk.Msg = &MsgAggregateExchangeRateVote{} + _ sdk.Msg = &MsgAggregateExchangeRateCombinedVote{} ) // oracle message types const ( - TypeMsgDelegateFeedConsent = "delegate_feeder" - TypeMsgAggregateExchangeRatePrevote = "aggregate_exchange_rate_prevote" - TypeMsgAggregateExchangeRateVote = "aggregate_exchange_rate_vote" + TypeMsgDelegateFeedConsent = "delegate_feeder" + TypeMsgAggregateExchangeRatePrevote = "aggregate_exchange_rate_prevote" + TypeMsgAggregateExchangeRateVote = "aggregate_exchange_rate_vote" + TypeMsgAggregateExchangeRateCombinedVote = "aggregate_exchange_rate_combined_vote" ) //------------------------------------------------- @@ -149,6 +151,108 @@ func (msg MsgAggregateExchangeRateVote) ValidateBasic() error { return nil } +// NewMsgAggregateExchangeRatePrevote returns MsgAggregateExchangeRatePrevote instance +func NewMsgAggregateExchangeRateCombinedVote(voteSalt string, voteExchangeRates string, prevoteHash AggregateVoteHash, feeder sdk.AccAddress, validator sdk.ValAddress) *MsgAggregateExchangeRateCombinedVote { + return &MsgAggregateExchangeRateCombinedVote{ + VoteSalt: voteSalt, + VoteExchangeRates: voteExchangeRates, + PrevoteHash: prevoteHash.String(), + Feeder: feeder.String(), + Validator: validator.String(), + } +} + +// Route implements sdk.Msg +func (msg MsgAggregateExchangeRateCombinedVote) Route() string { return RouterKey } + +// Type implements sdk.Msg +func (msg MsgAggregateExchangeRateCombinedVote) Type() string { + return TypeMsgAggregateExchangeRateCombinedVote +} + +// GetSignBytes implements sdk.Msg +func (msg MsgAggregateExchangeRateCombinedVote) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners implements sdk.Msg +func (msg MsgAggregateExchangeRateCombinedVote) GetSigners() []sdk.AccAddress { + feeder, err := sdk.AccAddressFromBech32(msg.Feeder) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{feeder} +} + +func (msg MsgAggregateExchangeRateCombinedVote) GetVoteFromCombinedVote() *MsgAggregateExchangeRateVote { + return &MsgAggregateExchangeRateVote{ + Salt: msg.VoteSalt, + ExchangeRates: msg.VoteExchangeRates, + Feeder: msg.Feeder, + Validator: msg.Validator, + } +} + +func (msg MsgAggregateExchangeRateCombinedVote) GetPrevoteFromCombinedVote() *MsgAggregateExchangeRatePrevote { + return &MsgAggregateExchangeRatePrevote{ + Hash: msg.PrevoteHash, + Feeder: msg.Feeder, + Validator: msg.Validator, + } +} + +// ValidateBasic Implements sdk.Msg +func (msg MsgAggregateExchangeRateCombinedVote) ValidateBasic() error { + + // validate feeder + validator + _, err := sdk.AccAddressFromBech32(msg.Feeder) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid feeder address (%s)", err) + } + + _, err = sdk.ValAddressFromBech32(msg.Validator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid operator address (%s)", err) + } + + // validate the vote info + if l := len(msg.VoteExchangeRates); l == 0 { + return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "must provide at least one oracle exchange rate") + } else if l > 4096 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "exchange rates string can not exceed 4096 characters") + } + + voteExchangeRates, err := ParseExchangeRateTuples(msg.VoteExchangeRates) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "failed to parse exchange rates string cause: "+err.Error()) + } + + for _, exchangeRate := range voteExchangeRates { + // Check overflow bit length + if exchangeRate.ExchangeRate.BigInt().BitLen() > 255+sdk.DecimalPrecisionBits { + return sdkerrors.Wrap(ErrInvalidExchangeRate, "overflow") + } + } + + if len(msg.VoteSalt) > 4 || len(msg.VoteSalt) < 1 { + return sdkerrors.Wrap(ErrInvalidSaltLength, "salt length must be [1, 4]") + } + + // validate the prevote hash + _, err = AggregateVoteHashFromHexString(msg.PrevoteHash) + if err != nil { + return sdkerrors.Wrapf(ErrInvalidHash, "Invalid vote hash (%s)", err) + } + + // HEX encoding doubles the hash length + if len(msg.PrevoteHash) != tmhash.TruncatedSize*2 { + return ErrInvalidHashLength + } + + return nil +} + // NewMsgDelegateFeedConsent creates a MsgDelegateFeedConsent instance func NewMsgDelegateFeedConsent(operatorAddress sdk.ValAddress, feederAddress sdk.AccAddress) *MsgDelegateFeedConsent { return &MsgDelegateFeedConsent{ diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index b657d6a98d..0809be2954 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -187,6 +187,90 @@ func (m *MsgAggregateExchangeRateVoteResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAggregateExchangeRateVoteResponse proto.InternalMessageInfo +// MsgAggregateExchangeRateVote represents a message to submit +// aggregate exchange rate vote. +type MsgAggregateExchangeRateCombinedVote struct { + VoteSalt string `protobuf:"bytes,1,opt,name=vote_salt,json=voteSalt,proto3" json:"vote_salt,omitempty" yaml:"vote_salt"` + VoteExchangeRates string `protobuf:"bytes,2,opt,name=vote_exchange_rates,json=voteExchangeRates,proto3" json:"vote_exchange_rates,omitempty" yaml:"vote_exchange_rates"` + PrevoteHash string `protobuf:"bytes,3,opt,name=prevote_hash,json=prevoteHash,proto3" json:"prevote_hash,omitempty" yaml:"prevote_hash"` + Feeder string `protobuf:"bytes,4,opt,name=feeder,proto3" json:"feeder,omitempty" yaml:"feeder"` + Validator string `protobuf:"bytes,5,opt,name=validator,proto3" json:"validator,omitempty" yaml:"validator"` +} + +func (m *MsgAggregateExchangeRateCombinedVote) Reset() { *m = MsgAggregateExchangeRateCombinedVote{} } +func (m *MsgAggregateExchangeRateCombinedVote) String() string { return proto.CompactTextString(m) } +func (*MsgAggregateExchangeRateCombinedVote) ProtoMessage() {} +func (*MsgAggregateExchangeRateCombinedVote) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5390096518ffda, []int{4} +} +func (m *MsgAggregateExchangeRateCombinedVote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAggregateExchangeRateCombinedVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAggregateExchangeRateCombinedVote.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 *MsgAggregateExchangeRateCombinedVote) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAggregateExchangeRateCombinedVote.Merge(m, src) +} +func (m *MsgAggregateExchangeRateCombinedVote) XXX_Size() int { + return m.Size() +} +func (m *MsgAggregateExchangeRateCombinedVote) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAggregateExchangeRateCombinedVote.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAggregateExchangeRateCombinedVote proto.InternalMessageInfo + +// MsgAggregateExchangeRateVoteResponse defines the Msg/AggregateExchangeRateVote response type. +type MsgAggregateExchangeRateCombinedVoteResponse struct { +} + +func (m *MsgAggregateExchangeRateCombinedVoteResponse) Reset() { + *m = MsgAggregateExchangeRateCombinedVoteResponse{} +} +func (m *MsgAggregateExchangeRateCombinedVoteResponse) String() string { + return proto.CompactTextString(m) +} +func (*MsgAggregateExchangeRateCombinedVoteResponse) ProtoMessage() {} +func (*MsgAggregateExchangeRateCombinedVoteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5390096518ffda, []int{5} +} +func (m *MsgAggregateExchangeRateCombinedVoteResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAggregateExchangeRateCombinedVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAggregateExchangeRateCombinedVoteResponse.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 *MsgAggregateExchangeRateCombinedVoteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAggregateExchangeRateCombinedVoteResponse.Merge(m, src) +} +func (m *MsgAggregateExchangeRateCombinedVoteResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAggregateExchangeRateCombinedVoteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAggregateExchangeRateCombinedVoteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAggregateExchangeRateCombinedVoteResponse proto.InternalMessageInfo + // MsgDelegateFeedConsent represents a message to // delegate oracle voting rights to another address. type MsgDelegateFeedConsent struct { @@ -198,7 +282,7 @@ 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_cb5390096518ffda, []int{4} + return fileDescriptor_cb5390096518ffda, []int{6} } func (m *MsgDelegateFeedConsent) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -235,7 +319,7 @@ func (m *MsgDelegateFeedConsentResponse) Reset() { *m = MsgDelegateFeedC func (m *MsgDelegateFeedConsentResponse) String() string { return proto.CompactTextString(m) } func (*MsgDelegateFeedConsentResponse) ProtoMessage() {} func (*MsgDelegateFeedConsentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5390096518ffda, []int{5} + return fileDescriptor_cb5390096518ffda, []int{7} } func (m *MsgDelegateFeedConsentResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -269,6 +353,8 @@ func init() { proto.RegisterType((*MsgAggregateExchangeRatePrevoteResponse)(nil), "seiprotocol.seichain.oracle.MsgAggregateExchangeRatePrevoteResponse") proto.RegisterType((*MsgAggregateExchangeRateVote)(nil), "seiprotocol.seichain.oracle.MsgAggregateExchangeRateVote") proto.RegisterType((*MsgAggregateExchangeRateVoteResponse)(nil), "seiprotocol.seichain.oracle.MsgAggregateExchangeRateVoteResponse") + proto.RegisterType((*MsgAggregateExchangeRateCombinedVote)(nil), "seiprotocol.seichain.oracle.MsgAggregateExchangeRateCombinedVote") + proto.RegisterType((*MsgAggregateExchangeRateCombinedVoteResponse)(nil), "seiprotocol.seichain.oracle.MsgAggregateExchangeRateCombinedVoteResponse") proto.RegisterType((*MsgDelegateFeedConsent)(nil), "seiprotocol.seichain.oracle.MsgDelegateFeedConsent") proto.RegisterType((*MsgDelegateFeedConsentResponse)(nil), "seiprotocol.seichain.oracle.MsgDelegateFeedConsentResponse") } @@ -276,39 +362,46 @@ func init() { func init() { proto.RegisterFile("oracle/tx.proto", fileDescriptor_cb5390096518ffda) } var fileDescriptor_cb5390096518ffda = []byte{ - // 497 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x7d, 0xa4, 0xaa, 0xda, 0x43, 0x25, 0xe0, 0x16, 0x94, 0x86, 0xca, 0xae, 0x0e, 0x04, - 0x74, 0xc0, 0x46, 0xed, 0x44, 0x61, 0xa0, 0xa5, 0x30, 0x20, 0x45, 0x42, 0x37, 0x30, 0xb0, 0xa0, - 0xab, 0xf3, 0x38, 0x5b, 0x72, 0x73, 0x91, 0xef, 0xa8, 0xd2, 0x1d, 0x09, 0x46, 0x56, 0xb6, 0x8a, - 0x2f, 0xc0, 0xd7, 0x60, 0xcc, 0xc8, 0x64, 0xa1, 0x64, 0x61, 0x62, 0xf0, 0x27, 0x40, 0xbe, 0xb3, - 0x8d, 0x11, 0x69, 0xa2, 0x84, 0xed, 0x72, 0xff, 0xdf, 0xff, 0xde, 0xff, 0xbd, 0x3c, 0x19, 0x37, - 0x45, 0xc2, 0x82, 0x18, 0x7c, 0x35, 0xf0, 0xfa, 0x89, 0x50, 0xc2, 0xbe, 0x29, 0x21, 0xd2, 0xa7, - 0x40, 0xc4, 0x9e, 0x84, 0x28, 0x08, 0x59, 0xd4, 0xf3, 0x0c, 0xd5, 0xde, 0xe0, 0x82, 0x0b, 0xad, - 0xfa, 0xf9, 0xc9, 0x58, 0xc8, 0x57, 0x84, 0xdd, 0x8e, 0xe4, 0x07, 0x9c, 0x27, 0xc0, 0x99, 0x82, - 0x67, 0x83, 0x20, 0x64, 0x3d, 0x0e, 0x94, 0x29, 0x78, 0x99, 0xc0, 0xa9, 0x50, 0x60, 0xdf, 0xc2, - 0x4b, 0x21, 0x93, 0x61, 0x0b, 0x6d, 0xa3, 0x7b, 0xab, 0x87, 0xcd, 0x2c, 0x75, 0x2f, 0x9f, 0xb1, - 0x93, 0x78, 0x9f, 0xe4, 0xb7, 0x84, 0x6a, 0xd1, 0xde, 0xc1, 0xcb, 0x6f, 0x01, 0xba, 0x90, 0xb4, - 0x2e, 0x69, 0xec, 0x5a, 0x96, 0xba, 0x6b, 0x06, 0x33, 0xf7, 0x84, 0x16, 0x80, 0xbd, 0x8b, 0x57, - 0x4f, 0x59, 0x1c, 0x75, 0x99, 0x12, 0x49, 0xab, 0xa1, 0xe9, 0x8d, 0x2c, 0x75, 0xaf, 0x1a, 0xba, - 0x92, 0x08, 0xfd, 0x83, 0xed, 0xaf, 0x7c, 0x3c, 0x77, 0xad, 0x9f, 0xe7, 0xae, 0x45, 0x76, 0xf0, - 0xdd, 0x19, 0x81, 0x29, 0xc8, 0xbe, 0xe8, 0x49, 0x20, 0xbf, 0x10, 0xde, 0xba, 0x88, 0x7d, 0x55, - 0x74, 0x26, 0x59, 0xac, 0xfe, 0xed, 0x2c, 0xbf, 0x25, 0x54, 0x8b, 0xf6, 0x13, 0x7c, 0x05, 0x0a, - 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x48, 0x85, 0xef, 0x8e, 0xbd, 0x40, 0x9c, 0xf8, 0x12, 0xa2, - 0xfb, 0x65, 0x05, 0xfd, 0x43, 0x97, 0xf0, 0x07, 0x7e, 0xf9, 0xcd, 0x3b, 0xeb, 0x83, 0x3c, 0x5e, - 0xd6, 0xc8, 0xde, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xce, 0x17, 0xb4, 0x0a, 0x05, 0x00, - 0x00, + // 611 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xbf, 0x6f, 0xd3, 0x40, + 0x18, 0xcd, 0xb5, 0x69, 0x95, 0x5c, 0x29, 0xa1, 0x4e, 0x81, 0xd4, 0x54, 0x76, 0x39, 0x10, 0x50, + 0x09, 0x6c, 0x68, 0x27, 0x02, 0x03, 0xfd, 0x85, 0x00, 0x29, 0x08, 0x19, 0x89, 0x81, 0x25, 0x72, + 0x92, 0x0f, 0xc7, 0x92, 0x93, 0x8b, 0x7c, 0xa6, 0x4a, 0xf7, 0x4a, 0x30, 0xb2, 0xb2, 0x55, 0xfc, + 0x03, 0x88, 0xff, 0x82, 0x09, 0x75, 0x64, 0xb2, 0x50, 0xb2, 0x30, 0x31, 0xf8, 0x2f, 0x40, 0xbe, + 0xb3, 0x8d, 0x03, 0xf9, 0x41, 0xd2, 0xed, 0xfc, 0xbd, 0xf7, 0xee, 0x7b, 0xdf, 0xf3, 0x9d, 0x8d, + 0x0b, 0xd4, 0x35, 0xeb, 0x0e, 0xe8, 0x5e, 0x57, 0xeb, 0xb8, 0xd4, 0xa3, 0xd2, 0x15, 0x06, 0x36, + 0x5f, 0xd5, 0xa9, 0xa3, 0x31, 0xb0, 0xeb, 0x4d, 0xd3, 0x6e, 0x6b, 0x82, 0x25, 0xaf, 0x5a, 0xd4, + 0xa2, 0x1c, 0xd5, 0xc3, 0x95, 0x90, 0x90, 0xcf, 0x08,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xa9, 0xbc, 0x33, 0xb3, 0x34, 0xf1, 0xf6, 0x05, 0xe1, 0xab, + 0x93, 0xef, 0xdb, 0x6c, 0x8d, 0xd2, 0x5b, 0xc8, 0x4f, 0xcf, 0xbc, 0x45, 0xe2, 0xf9, 0x1d, 0xc2, + 0xc5, 0x61, 0x47, 0x74, 0x7b, 0x52, 0x8b, 0x21, 0x22, 0xf9, 0xc1, 0x0c, 0xa2, 0xd8, 0xc9, 0xee, + 0xb3, 0xaf, 0x3d, 0x05, 0x9d, 0xf6, 0x14, 0xf4, 0xa3, 0xa7, 0xa0, 0x0f, 0x7d, 0x25, 0x73, 0xda, + 0x57, 0x32, 0xdf, 0xfb, 0x4a, 0xe6, 0xf5, 0x5d, 0xcb, 0xf6, 0x9a, 0x6f, 0x6b, 0x5a, 0x9d, 0xb6, + 0x74, 0x06, 0xf6, 0x9d, 0xb8, 0x03, 0x7f, 0xe0, 0x2d, 0xf4, 0xae, 0x1e, 0xff, 0x28, 0x8f, 0x3a, + 0xc0, 0x6a, 0x8b, 0x9c, 0xb2, 0xfd, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x99, 0x4b, 0x0b, 0x32, 0x3f, + 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -329,6 +422,8 @@ type MsgClient interface { // AggregateExchangeRateVote defines a method for submitting // aggregate exchange rate vote AggregateExchangeRateVote(ctx context.Context, in *MsgAggregateExchangeRateVote, opts ...grpc.CallOption) (*MsgAggregateExchangeRateVoteResponse, error) + // Aggregate vote and prevote combines the functionality of prevote and vote into one RPC + AggregateExchangeRateCombinedVote(ctx context.Context, in *MsgAggregateExchangeRateCombinedVote, opts ...grpc.CallOption) (*MsgAggregateExchangeRateCombinedVoteResponse, error) // DelegateFeedConsent defines a method for setting the feeder delegation DelegateFeedConsent(ctx context.Context, in *MsgDelegateFeedConsent, opts ...grpc.CallOption) (*MsgDelegateFeedConsentResponse, error) } @@ -359,6 +454,15 @@ func (c *msgClient) AggregateExchangeRateVote(ctx context.Context, in *MsgAggreg return out, nil } +func (c *msgClient) AggregateExchangeRateCombinedVote(ctx context.Context, in *MsgAggregateExchangeRateCombinedVote, opts ...grpc.CallOption) (*MsgAggregateExchangeRateCombinedVoteResponse, error) { + out := new(MsgAggregateExchangeRateCombinedVoteResponse) + err := c.cc.Invoke(ctx, "/seiprotocol.seichain.oracle.Msg/AggregateExchangeRateCombinedVote", 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, "/seiprotocol.seichain.oracle.Msg/DelegateFeedConsent", in, out, opts...) @@ -376,6 +480,8 @@ type MsgServer interface { // AggregateExchangeRateVote defines a method for submitting // aggregate exchange rate vote AggregateExchangeRateVote(context.Context, *MsgAggregateExchangeRateVote) (*MsgAggregateExchangeRateVoteResponse, error) + // Aggregate vote and prevote combines the functionality of prevote and vote into one RPC + AggregateExchangeRateCombinedVote(context.Context, *MsgAggregateExchangeRateCombinedVote) (*MsgAggregateExchangeRateCombinedVoteResponse, error) // DelegateFeedConsent defines a method for setting the feeder delegation DelegateFeedConsent(context.Context, *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error) } @@ -390,6 +496,9 @@ func (*UnimplementedMsgServer) AggregateExchangeRatePrevote(ctx context.Context, func (*UnimplementedMsgServer) AggregateExchangeRateVote(ctx context.Context, req *MsgAggregateExchangeRateVote) (*MsgAggregateExchangeRateVoteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AggregateExchangeRateVote not implemented") } +func (*UnimplementedMsgServer) AggregateExchangeRateCombinedVote(ctx context.Context, req *MsgAggregateExchangeRateCombinedVote) (*MsgAggregateExchangeRateCombinedVoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AggregateExchangeRateCombinedVote not implemented") +} func (*UnimplementedMsgServer) DelegateFeedConsent(ctx context.Context, req *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DelegateFeedConsent not implemented") } @@ -434,6 +543,24 @@ func _Msg_AggregateExchangeRateVote_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _Msg_AggregateExchangeRateCombinedVote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAggregateExchangeRateCombinedVote) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AggregateExchangeRateCombinedVote(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/seiprotocol.seichain.oracle.Msg/AggregateExchangeRateCombinedVote", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AggregateExchangeRateCombinedVote(ctx, req.(*MsgAggregateExchangeRateCombinedVote)) + } + 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 { @@ -464,6 +591,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AggregateExchangeRateVote", Handler: _Msg_AggregateExchangeRateVote_Handler, }, + { + MethodName: "AggregateExchangeRateCombinedVote", + Handler: _Msg_AggregateExchangeRateCombinedVote_Handler, + }, { MethodName: "DelegateFeedConsent", Handler: _Msg_DelegateFeedConsent_Handler, @@ -614,6 +745,87 @@ func (m *MsgAggregateExchangeRateVoteResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } +func (m *MsgAggregateExchangeRateCombinedVote) 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 *MsgAggregateExchangeRateCombinedVote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAggregateExchangeRateCombinedVote) 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] = 0x2a + } + 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] = 0x22 + } + if len(m.PrevoteHash) > 0 { + i -= len(m.PrevoteHash) + copy(dAtA[i:], m.PrevoteHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrevoteHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.VoteExchangeRates) > 0 { + i -= len(m.VoteExchangeRates) + copy(dAtA[i:], m.VoteExchangeRates) + i = encodeVarintTx(dAtA, i, uint64(len(m.VoteExchangeRates))) + i-- + dAtA[i] = 0x12 + } + if len(m.VoteSalt) > 0 { + i -= len(m.VoteSalt) + copy(dAtA[i:], m.VoteSalt) + i = encodeVarintTx(dAtA, i, uint64(len(m.VoteSalt))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAggregateExchangeRateCombinedVoteResponse) 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 *MsgAggregateExchangeRateCombinedVoteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAggregateExchangeRateCombinedVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgDelegateFeedConsent) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -749,6 +961,44 @@ func (m *MsgAggregateExchangeRateVoteResponse) Size() (n int) { return n } +func (m *MsgAggregateExchangeRateCombinedVote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.VoteSalt) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.VoteExchangeRates) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrevoteHash) + 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 *MsgAggregateExchangeRateCombinedVoteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgDelegateFeedConsent) Size() (n int) { if m == nil { return 0 @@ -1205,6 +1455,266 @@ func (m *MsgAggregateExchangeRateVoteResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgAggregateExchangeRateCombinedVote) 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: MsgAggregateExchangeRateCombinedVote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAggregateExchangeRateCombinedVote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteSalt", 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.VoteSalt = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteExchangeRates", 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.VoteExchangeRates = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevoteHash", 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.PrevoteHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 5: + 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 *MsgAggregateExchangeRateCombinedVoteResponse) 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: MsgAggregateExchangeRateCombinedVoteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAggregateExchangeRateCombinedVoteResponse: 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