From 8b633582f3221ce322145819d354f58b1fe9195c Mon Sep 17 00:00:00 2001 From: taobun Date: Wed, 18 Aug 2021 19:03:44 +0700 Subject: [PATCH 01/11] using authz to manage reporter --- app/app.go | 2 +- app/migrate.go | 4 +- proto/oracle/v1/authz.proto | 12 + proto/oracle/v1/genesis.proto | 3 - proto/oracle/v1/oracle.proto | 10 - proto/oracle/v1/tx.proto | 37 - testing/chain.go | 2 +- x/oracle/ante/ante.go | 132 ++- x/oracle/app_test.go | 4 +- x/oracle/client/cli/tx.go | 66 +- x/oracle/genesis.go | 20 - x/oracle/handler.go | 6 - x/oracle/handler_test.go | 79 +- x/oracle/keeper/grpc_query.go | 33 +- x/oracle/keeper/grpc_query_test.go | 7 +- x/oracle/keeper/keeper.go | 24 +- x/oracle/keeper/msg_server.go | 56 +- x/oracle/keeper/querier.go | 19 +- x/oracle/keeper/report.go | 9 +- x/oracle/keeper/reporter.go | 73 -- x/oracle/keeper/reporter_test.go | 106 --- x/oracle/legacy/v039/types.go | 13 +- x/oracle/types/authz.pb.go | 268 ++++++ x/oracle/types/codec.go | 12 +- x/oracle/types/expected_keepers.go | 11 + x/oracle/types/genesis.go | 4 +- x/oracle/types/genesis.pb.go | 102 +-- x/oracle/types/keys.go | 16 +- x/oracle/types/keys_test.go | 13 - x/oracle/types/msgs.go | 110 +-- x/oracle/types/msgs_test.go | 47 +- x/oracle/types/oracle.pb.go | 454 +++------- x/oracle/types/report_authorization.go | 30 + x/oracle/types/tx.pb.go | 1048 ++---------------------- yoda/execute.go | 5 +- yoda/gas.go | 1 + yoda/handler.go | 4 +- 37 files changed, 773 insertions(+), 2069 deletions(-) create mode 100644 proto/oracle/v1/authz.proto delete mode 100644 x/oracle/keeper/reporter.go delete mode 100644 x/oracle/keeper/reporter_test.go create mode 100644 x/oracle/types/authz.pb.go create mode 100644 x/oracle/types/report_authorization.go diff --git a/app/app.go b/app/app.go index eacace00b..c978922c2 100644 --- a/app/app.go +++ b/app/app.go @@ -344,7 +344,7 @@ func NewBandApp( app.OracleKeeper = oraclekeeper.NewKeeper( appCodec, keys[oracletypes.StoreKey], app.GetSubspace(oracletypes.ModuleName), filepath.Join(homePath, "files"), - authtypes.FeeCollectorName, app.AccountKeeper, app.BankKeeper, &stakingKeeper, app.DistrKeeper, + authtypes.FeeCollectorName, app.AccountKeeper, app.BankKeeper, &stakingKeeper, app.DistrKeeper, app.AuthzKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, scopedOracleKeeper, owasmVM, ) oracleModule := oracle.NewAppModule(app.OracleKeeper) diff --git a/app/migrate.go b/app/migrate.go index db8672b72..48fe5d2a5 100644 --- a/app/migrate.go +++ b/app/migrate.go @@ -105,7 +105,9 @@ $ %s migrate /path/to/genesis.json --chain-id=band-laozi --genesis-time=2020-08- oracleGenesis.Params.IBCRequestEnabled = false oracleGenesis.OracleScripts = oracleGenesisV039.OracleScripts - oracleGenesis.Reporters = oracleGenesisV039.Reporters + + // TODO: Migrate reporters to grant in authz + // oracleGenesis.Reporters = oracleGenesisV039.Reporters for _, dataSource := range oracleGenesisV039.DataSources { oracleGenesis.DataSources = append(oracleGenesis.DataSources, oracletypes.DataSource{ Owner: dataSource.Owner, diff --git a/proto/oracle/v1/authz.proto b/proto/oracle/v1/authz.proto new file mode 100644 index 000000000..3049d4e38 --- /dev/null +++ b/proto/oracle/v1/authz.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package oracle.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/bandprotocol/chain/x/oracle/types"; + +// ReportAuthorization defines authorization for report. +message ReportAuthorization { + option (cosmos_proto.implements_interface) = "Authorization"; +} diff --git a/proto/oracle/v1/genesis.proto b/proto/oracle/v1/genesis.proto index d410b4f37..bb2f7b0c3 100644 --- a/proto/oracle/v1/genesis.proto +++ b/proto/oracle/v1/genesis.proto @@ -15,7 +15,4 @@ message GenesisState { // OracleScripts are list of oracle scripts to be installed during genesis // phase repeated OracleScript oracle_scripts = 3 [ (gogoproto.nullable) = false ]; - // Reporters are mapping between reporter's account address (key) and - // validator's validator address (value) - repeated ReportersPerValidator reporters = 4 [ (gogoproto.nullable) = false ]; } diff --git a/proto/oracle/v1/oracle.proto b/proto/oracle/v1/oracle.proto index a391f07c6..8ed0f115d 100644 --- a/proto/oracle/v1/oracle.proto +++ b/proto/oracle/v1/oracle.proto @@ -353,16 +353,6 @@ message IBCChannel { string channel_id = 2; } -// ReportersPerValidator is list of reporters that is associated with a -// validator -message ReportersPerValidator { - // Validator a validator address - string validator = 1; - // Reporters is a list of reporter account addresses associated with the - // validator - repeated string reporters = 2 [ (gogoproto.nullable) = false ]; -} - // RequestVerification is a message that is constructed and signed by a reporter // to be used as a part of verification of oracle request. message RequestVerification { diff --git a/proto/oracle/v1/tx.proto b/proto/oracle/v1/tx.proto index be5562632..4763c1bcb 100644 --- a/proto/oracle/v1/tx.proto +++ b/proto/oracle/v1/tx.proto @@ -34,12 +34,6 @@ service Msg { // Activate defines a method for applying to be an oracle validator. rpc Activate(MsgActivate) returns (MsgActivateResponse); - - // AddReporter defines a method for adding a new reporter for a validator. - rpc AddReporter(MsgAddReporter) returns (MsgAddReporterResponse); - - // RemoveReporter defines a method for removing an reporter from a validator - rpc RemoveReporter(MsgRemoveReporter) returns (MsgRemoveReporterResponse); } // MsgRequestData is a message for sending a data oracle request. @@ -89,9 +83,6 @@ message MsgReportData { repeated RawReport raw_reports = 2 [ (gogoproto.nullable) = false ]; // Validator is the address of the validator that owns this report. string validator = 3; - // Reporter is the message signer who submits this report transaction for the - // validator. - string reporter = 4; } // MsgReportDataResponse is response data for MsgReportData message @@ -228,31 +219,3 @@ message MsgActivate { // MsgActivateResponse is response data for MsgActivate message message MsgActivateResponse {} - -// MsgAddReporter is a message for adding a new reporter for a validator. -message MsgAddReporter { - option (gogoproto.equal) = true; - // Validator is the validator address who requested to add a new reporter. - // Note that this is the signer. - string validator = 1; - // Reporter is the account address to be added as a reporter to the validator. - string reporter = 2; -} - -// MsgAddReporterResponse is response data for MsgAddReporter message -message MsgAddReporterResponse {} - -// MsgAddReporter is a message for removing an existing reporter from a -// validator. -message MsgRemoveReporter { - option (gogoproto.equal) = true; - // Validator is the validator address who requested to remove an existing - // reporter. Note that this is the signer. - string validator = 1; - // Reporter is the account address to be removed from being the validator's - // reporter. - string reporter = 2; -} - -// MsgRemoveReporterResponse is response data for MsgRemoveReporter message -message MsgRemoveReporterResponse {} diff --git a/testing/chain.go b/testing/chain.go index 63b86f9bb..6821f0581 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -302,7 +302,7 @@ func (chain *TestChain) SendReport(rid types.RequestID, rawReps []types.RawRepor chain.TxConfig, chain.App.GetBaseApp(), chain.GetContext().BlockHeader(), - []sdk.Msg{types.NewMsgReportData(rid, rawReps, sender.ValAddress, sender.Address)}, + []sdk.Msg{types.NewMsgReportData(rid, rawReps, sender.ValAddress)}, chain.ChainID, []uint64{senderAccount.GetAccountNumber()}, []uint64{senderAccount.GetSequence()}, diff --git a/x/oracle/ante/ante.go b/x/oracle/ante/ante.go index d0a5780e2..5f301f850 100644 --- a/x/oracle/ante/ante.go +++ b/x/oracle/ante/ante.go @@ -2,9 +2,11 @@ package ante import ( "fmt" + "sync" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/authz" lru "github.com/hashicorp/golang-lru" "github.com/bandprotocol/chain/v2/x/oracle/keeper" @@ -13,6 +15,7 @@ import ( var ( repTxCount *lru.Cache + mu sync.Mutex nextRepOnlyBlock int64 ) @@ -24,39 +27,28 @@ func init() { } } -func checkValidReportMsg(ctx sdk.Context, oracleKeeper keeper.Keeper, rep *types.MsgReportData) bool { - validator, _ := sdk.ValAddressFromBech32(rep.Validator) - reporter, _ := sdk.AccAddressFromBech32(rep.Reporter) - if !oracleKeeper.IsReporter(ctx, validator, reporter) { - return false - } - if rep.RequestID <= oracleKeeper.GetRequestLastExpired(ctx) { - return false - } +// TODO: Add test on this ante before merge - req, err := oracleKeeper.GetRequest(ctx, rep.RequestID) +func checkValidReportMsg(ctx sdk.Context, oracleKeeper keeper.Keeper, r *types.MsgReportData) error { + validator, err := sdk.ValAddressFromBech32(r.Validator) if err != nil { - return false - } - - reqVals := make([]sdk.ValAddress, len(req.RequestedValidators)) - for idx, reqVal := range req.RequestedValidators { - val, _ := sdk.ValAddressFromBech32(reqVal) - reqVals[idx] = val + return err } + report := types.NewReport(validator, false, r.RawReports) + return oracleKeeper.CheckValidReport(ctx, r.RequestID, report) +} - if !keeper.ContainsVal(reqVals, validator) { - return false - } - if len(rep.RawReports) != len(req.RawRequests) { - return false +func updateCache(val string, rid types.RequestID) (trigger bool) { + key := fmt.Sprintf("%s:%d", val, rid) + mu.Lock() + defer mu.Unlock() + value, ok := repTxCount.Get(key) + nextVal := 1 + if ok { + nextVal = value.(int) + 1 } - for _, report := range rep.RawReports { - if !keeper.ContainsEID(req.RawRequests, report.ExternalID) { - return false - } - } - return true + repTxCount.Add(key, nextVal) + return nextVal > 20 } // NewFeelessReportsAnteHandler returns a new ante handler that waives minimum gas price @@ -64,26 +56,80 @@ func checkValidReportMsg(ctx sdk.Context, oracleKeeper keeper.Keeper, rep *types func NewFeelessReportsAnteHandler(ante sdk.AnteHandler, oracleKeeper keeper.Keeper) sdk.AnteHandler { return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { if ctx.IsCheckTx() && !simulate { - // TODO: Move this out of "FeelessReports" ante handler. isRepOnlyBlock := ctx.BlockHeight() == nextRepOnlyBlock isValidReportTx := true for _, msg := range tx.GetMsgs() { - rep, ok := msg.(*types.MsgReportData) - if !ok || !checkValidReportMsg(ctx, oracleKeeper, rep) { - isValidReportTx = false - break - } - if !isRepOnlyBlock { - key := fmt.Sprintf("%s:%d", rep.Validator, rep.RequestID) - val, ok := repTxCount.Get(key) - nextVal := 1 - if ok { - nextVal = val.(int) + 1 + // Check direct report msg + if dr, ok := msg.(*types.MsgReportData); ok { + // Check if it's not valid report msg, discard this transaction + if err := checkValidReportMsg(ctx, oracleKeeper, dr); err != nil { + return ctx, err } - repTxCount.Add(key, nextVal) - if nextVal > 20 { - nextRepOnlyBlock = ctx.BlockHeight() + 1 + if !isRepOnlyBlock { + if updateCache(dr.Validator, dr.RequestID) { + nextRepOnlyBlock = ctx.BlockHeight() + 1 + } + } + } else { + // Check is the MsgExec from reporter + me, ok := msg.(*authz.MsgExec) + if !ok { + isValidReportTx = false + break + } + + // If cannot get message, then pretend as non-free transaction + msgs, err := me.GetMessages() + if err != nil { + isValidReportTx = false + break } + + grantee, err := sdk.AccAddressFromBech32(me.Grantee) + if err != nil { + isValidReportTx = false + break + } + + allValidReportMsg := true + for _, m := range msgs { + r, ok := m.(*types.MsgReportData) + // If this is not report msg, skip other msgs on this exec msg + if !ok { + allValidReportMsg = false + break + } + + // Fail to parse validator, then discard this transaction + validator, err := sdk.ValAddressFromBech32(r.Validator) + if err != nil { + return ctx, err + } + + // If this grantee is not a reporter of validator, then discard this transaction + if !oracleKeeper.IsReporter(ctx, validator, grantee) { + return ctx, sdkerrors.ErrUnauthorized.Wrap("authorization not found") + } + + // Check if it's not valid report msg, discard this transaction + if err := checkValidReportMsg(ctx, oracleKeeper, r); err != nil { + return ctx, err + } + + // Update cache in case it's a valid report + if !isRepOnlyBlock { + if updateCache(r.Validator, r.RequestID) { + nextRepOnlyBlock = ctx.BlockHeight() + 1 + } + } + } + + // If this exec msg has other non-report msg, disable feeless and skip other msgs in tx + if !allValidReportMsg { + isValidReportTx = false + break + } + } } if isRepOnlyBlock && !isValidReportTx { diff --git a/x/oracle/app_test.go b/x/oracle/app_test.go index e456a0f6f..fa1e60e15 100644 --- a/x/oracle/app_test.go +++ b/x/oracle/app_test.go @@ -65,7 +65,7 @@ func TestSuccessRequestOracleData(t *testing.T) { types.NewRawReport(2, 0, []byte("answer2")), types.NewRawReport(3, 0, []byte("answer3")), }, - testapp.Validators[0].ValAddress, testapp.Validators[0].Address, + testapp.Validators[0].ValAddress, ) res, err = handler(ctx, reportMsg1) require.NotNil(t, res) @@ -88,7 +88,7 @@ func TestSuccessRequestOracleData(t *testing.T) { types.NewRawReport(2, 0, []byte("answer2")), types.NewRawReport(3, 0, []byte("answer3")), }, - testapp.Validators[1].ValAddress, testapp.Validators[1].Address, + testapp.Validators[1].ValAddress, ) res, err = handler(ctx, reportMsg2) require.NotNil(t, res) diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 4bb2342d7..2a8f528eb 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -5,12 +5,14 @@ import ( "io/ioutil" "strconv" "strings" + "time" "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/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/authz" "github.com/spf13/cobra" "github.com/bandprotocol/chain/v2/x/oracle/types" @@ -30,6 +32,7 @@ const ( flagFeeLimit = "fee-limit" flagFee = "fee" flagTreasury = "treasury" + flagExpiration = "expiration" ) // NewTxCmd returns the transaction commands for this module @@ -49,7 +52,7 @@ func NewTxCmd() *cobra.Command { GetCmdEditOracleScript(), GetCmdActivate(), GetCmdAddReporters(), - GetCmdRemoveReporter(), + GetCmdRemoveReporters(), ) return txCmd @@ -589,17 +592,29 @@ $ %s tx oracle add-reporters band1p40yh3zkmhcv0ecqp3mcazy83sa57rgjp07dun band1m5 if err != nil { return err } - validator := sdk.ValAddress(clientCtx.GetFromAddress()) + + exp, err := cmd.Flags().GetInt64(flagExpiration) + if err != nil { + return err + } + + validator := clientCtx.GetFromAddress() msgs := make([]sdk.Msg, len(args)) for i, raw := range args { reporter, err := sdk.AccAddressFromBech32(raw) if err != nil { return err } - msgs[i] = types.NewMsgAddReporter( + msg, err := authz.NewMsgGrant( validator, reporter, + types.NewReportAuthorization(), + time.Unix(exp, 0), ) + if err != nil { + return err + } + msgs[i] = msg err = msgs[i].ValidateBasic() if err != nil { return err @@ -608,20 +623,21 @@ $ %s tx oracle add-reporters band1p40yh3zkmhcv0ecqp3mcazy83sa57rgjp07dun band1m5 return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) }, } + cmd.Flags().Int64(flagExpiration, time.Now().AddDate(2500, 0, 0).Unix(), "The Unix timestamp. Default is 2500 years(forever).") flags.AddTxFlagsToCmd(cmd) return cmd } // GetCmdRemoveReporter implements the remove reporter command handler. -func GetCmdRemoveReporter() *cobra.Command { +func GetCmdRemoveReporters() *cobra.Command { cmd := &cobra.Command{ - Use: "remove-reporter [reporter]", - Short: "Remove an agent from the list of authorized reporters.", - Args: cobra.ExactArgs(1), + Use: "remove-reporters [reporter1] [reporter2] ...", + Short: "Remove agents from the list of authorized reporters.", + Args: cobra.MinimumNArgs(1), Long: strings.TrimSpace( - fmt.Sprintf(`Remove an agent from the list of authorized reporters. + fmt.Sprintf(`Remove agents from the list of authorized reporters. Example: -$ %s tx oracle remove-reporter band1p40yh3zkmhcv0ecqp3mcazy83sa57rgjp07dun --from mykey +$ %s tx oracle remove-reporters band1p40yh3zkmhcv0ecqp3mcazy83sa57rgjp07dun band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs --from mykey `, version.AppName, ), @@ -631,20 +647,26 @@ $ %s tx oracle remove-reporter band1p40yh3zkmhcv0ecqp3mcazy83sa57rgjp07dun --fro if err != nil { return err } - validator := sdk.ValAddress(clientCtx.GetFromAddress()) - reporter, err := sdk.AccAddressFromBech32(args[0]) - if err != nil { - return err - } - msg := types.NewMsgRemoveReporter( - validator, - reporter, - ) - err = msg.ValidateBasic() - if err != nil { - return err + + validator := clientCtx.GetFromAddress() + msgs := make([]sdk.Msg, len(args)) + for i, raw := range args { + reporter, err := sdk.AccAddressFromBech32(raw) + if err != nil { + return err + } + msg := authz.NewMsgRevoke( + validator, + reporter, + sdk.MsgTypeURL(&types.MsgReportData{}), + ) + msgs[i] = &msg + err = msg.ValidateBasic() + if err != nil { + return err + } } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) }, } flags.AddTxFlagsToCmd(cmd) diff --git a/x/oracle/genesis.go b/x/oracle/genesis.go index dcd14cdab..84c3bfd84 100644 --- a/x/oracle/genesis.go +++ b/x/oracle/genesis.go @@ -23,25 +23,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { for _, oracleScript := range data.OracleScripts { _ = k.AddOracleScript(ctx, oracleScript) } - for _, reportersPerValidator := range data.Reporters { - valAddr, err := sdk.ValAddressFromBech32(reportersPerValidator.Validator) - if err != nil { - panic(fmt.Sprintf("unable to parse validator address %s: %v", reportersPerValidator.Validator, err)) - } - for _, reporterBech32 := range reportersPerValidator.Reporters { - reporterAddr, err := sdk.AccAddressFromBech32(reporterBech32) - if err != nil { - panic(fmt.Sprintf("unable to parse reporter address %s: %v", reporterBech32, err)) - } - if valAddr.Equals(sdk.ValAddress(reporterAddr)) { - continue - } - err = k.AddReporter(ctx, valAddr, reporterAddr) - if err != nil { - panic(fmt.Sprintf("unable to add reporter %s: %v", reporterBech32, err)) - } - } - } k.SetPort(ctx, types.PortID) // Only try to bind to port if it is not already bound, since we may already own @@ -62,6 +43,5 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { Params: k.GetParams(ctx), DataSources: k.GetAllDataSources(ctx), OracleScripts: k.GetAllOracleScripts(ctx), - Reporters: k.GetAllReporters(ctx), } } diff --git a/x/oracle/handler.go b/x/oracle/handler.go index 2d051739c..9934e62aa 100644 --- a/x/oracle/handler.go +++ b/x/oracle/handler.go @@ -35,12 +35,6 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgActivate: res, err := msgServer.Activate(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgAddReporter: - res, err := msgServer.AddReporter(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRemoveReporter: - res, err := msgServer.RemoveReporter(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } diff --git a/x/oracle/handler_test.go b/x/oracle/handler_test.go index 80306fe1b..a46a79211 100644 --- a/x/oracle/handler_test.go +++ b/x/oracle/handler_test.go @@ -393,7 +393,7 @@ func TestReportSuccess(t *testing.T) { // Common raw reports for everyone. reports := []types.RawReport{types.NewRawReport(1, 0, []byte("data1")), types.NewRawReport(2, 0, []byte("data2"))} // Validators[0] reports data. - res, err := oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[0].ValAddress, testapp.Validators[0].Address)) + res, err := oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[0].ValAddress)) require.NoError(t, err) require.Equal(t, []types.RequestID{}, k.GetPendingResolveList(ctx)) event := abci.Event{ @@ -405,7 +405,7 @@ func TestReportSuccess(t *testing.T) { } require.Equal(t, abci.Event(event), res.Events[0]) // Validators[1] reports data. Now the request should move to pending resolve. - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[1].ValAddress, testapp.Validators[1].Address)) + res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[1].ValAddress)) require.NoError(t, err) require.Equal(t, []types.RequestID{42}, k.GetPendingResolveList(ctx)) event = abci.Event{ @@ -419,7 +419,7 @@ func TestReportSuccess(t *testing.T) { // Even if we resolve the request, Validators[2] should still be able to report. k.SetPendingResolveList(ctx, []types.RequestID{}) k.ResolveSuccess(ctx, 42, []byte("RESOLVE_RESULT!"), 1234) - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[2].ValAddress, testapp.Validators[2].Address)) + res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[2].ValAddress)) require.NoError(t, err) event = abci.Event{ Type: types.EventTypeReport, @@ -457,32 +457,28 @@ func TestReportFail(t *testing.T) { // Common raw reports for everyone. reports := []types.RawReport{types.NewRawReport(1, 0, []byte("data1")), types.NewRawReport(2, 0, []byte("data2"))} // Bad ID - res, err := oracle.NewHandler(k)(ctx, types.NewMsgReportData(999, reports, testapp.Validators[0].ValAddress, testapp.Validators[0].Address)) + res, err := oracle.NewHandler(k)(ctx, types.NewMsgReportData(999, reports, testapp.Validators[0].ValAddress)) testapp.CheckErrorf(t, err, types.ErrRequestNotFound, "id: 999") require.Nil(t, res) // Not-asked validator - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Alice.ValAddress, testapp.Alice.Address)) + res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Alice.ValAddress)) testapp.CheckErrorf(t, err, types.ErrValidatorNotRequested, "reqID: 42, val: %s", testapp.Alice.ValAddress.String()) require.Nil(t, res) // Too large report data size - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, []types.RawReport{types.NewRawReport(1, 0, []byte("data1")), types.NewRawReport(2, 0, []byte(strings.Repeat("data2", 2000)))}, testapp.Validators[0].ValAddress, testapp.Validators[0].Address)) + res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, []types.RawReport{types.NewRawReport(1, 0, []byte("data1")), types.NewRawReport(2, 0, []byte(strings.Repeat("data2", 2000)))}, testapp.Validators[0].ValAddress)) testapp.CheckErrorf(t, err, types.ErrTooLargeRawReportData, "got: 10000, max: 512") require.Nil(t, res) - // Not an authorized reporter - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[0].ValAddress, testapp.Alice.Address)) - require.ErrorIs(t, err, types.ErrReporterNotAuthorized) - require.Nil(t, res) // Not having all raw reports - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, []types.RawReport{types.NewRawReport(1, 0, []byte("data1"))}, testapp.Validators[0].ValAddress, testapp.Validators[0].Address)) + res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, []types.RawReport{types.NewRawReport(1, 0, []byte("data1"))}, testapp.Validators[0].ValAddress)) require.ErrorIs(t, err, types.ErrInvalidReportSize) require.Nil(t, res) // Incorrect external IDs - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, []types.RawReport{types.NewRawReport(1, 0, []byte("data1")), types.NewRawReport(42, 0, []byte("data2"))}, testapp.Validators[0].ValAddress, testapp.Validators[0].Address)) + res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, []types.RawReport{types.NewRawReport(1, 0, []byte("data1")), types.NewRawReport(42, 0, []byte("data2"))}, testapp.Validators[0].ValAddress)) testapp.CheckErrorf(t, err, types.ErrRawRequestNotFound, "reqID: 42, extID: 42") require.Nil(t, res) // Request already expired k.SetRequestLastExpired(ctx, 42) - res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[0].ValAddress, testapp.Validators[0].Address)) + res, err = oracle.NewHandler(k)(ctx, types.NewMsgReportData(42, reports, testapp.Validators[0].ValAddress)) require.ErrorIs(t, err, types.ErrRequestAlreadyExpired) require.Nil(t, res) } @@ -529,60 +525,3 @@ func TestActivateFail(t *testing.T) { _, err = oracle.NewHandler(k)(ctx, msg) require.NoError(t, err) } - -func TestAddReporterSuccess(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(false) - require.False(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address)) - // Add testapp.Bob to a reporter of testapp.Alice validator. - msg := types.NewMsgAddReporter(testapp.Alice.ValAddress, testapp.Bob.Address) - res, err := oracle.NewHandler(k)(ctx, msg) - require.NoError(t, err) - require.True(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address)) - event := abci.Event{ - Type: types.EventTypeAddReporter, - Attributes: []abci.EventAttribute{ - {Key: []byte(types.AttributeKeyValidator), Value: []byte(testapp.Alice.ValAddress.String())}, - {Key: []byte(types.AttributeKeyReporter), Value: []byte(testapp.Bob.Address.String())}, - }, - } - require.Equal(t, abci.Event(event), res.Events[0]) -} - -func TestAddReporterFail(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(false) - // Should fail when you try to add yourself as your reporter. - msg := types.NewMsgAddReporter(testapp.Alice.ValAddress, testapp.Alice.Address) - res, err := oracle.NewHandler(k)(ctx, msg) - testapp.CheckErrorf(t, err, types.ErrReporterAlreadyExists, "val: %s, addr: %s", testapp.Alice.ValAddress.String(), testapp.Alice.Address.String()) - require.Nil(t, res) -} - -func TestRemoveReporterSuccess(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(false) - // Add testapp.Bob to a reporter of testapp.Alice validator. - err := k.AddReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address) - require.True(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address)) - require.NoError(t, err) - // Now remove testapp.Bob from the set of testapp.Alice's reporters. - msg := types.NewMsgRemoveReporter(testapp.Alice.ValAddress, testapp.Bob.Address) - res, err := oracle.NewHandler(k)(ctx, msg) - require.NoError(t, err) - require.False(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address)) - event := abci.Event{ - Type: types.EventTypeRemoveReporter, - Attributes: []abci.EventAttribute{ - {Key: []byte(types.AttributeKeyValidator), Value: []byte(testapp.Alice.ValAddress.String())}, - {Key: []byte(types.AttributeKeyReporter), Value: []byte(testapp.Bob.Address.String())}, - }, - } - require.Equal(t, abci.Event(event), res.Events[0]) -} - -func TestRemoveReporterFail(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(false) - // Should fail because testapp.Bob isn't testapp.Alice validator's reporter. - msg := types.NewMsgRemoveReporter(testapp.Alice.ValAddress, testapp.Bob.Address) - res, err := oracle.NewHandler(k)(ctx, msg) - testapp.CheckErrorf(t, err, types.ErrReporterNotFound, "val: %s, addr: %s", testapp.Alice.ValAddress.String(), testapp.Bob.Address.String()) - require.Nil(t, res) -} diff --git a/x/oracle/keeper/grpc_query.go b/x/oracle/keeper/grpc_query.go index ec146b7f8..44665d1f0 100644 --- a/x/oracle/keeper/grpc_query.go +++ b/x/oracle/keeper/grpc_query.go @@ -180,17 +180,18 @@ func (k Querier) Reporters(c context.Context, req *types.QueryReportersRequest) if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - ctx := sdk.UnwrapSDKContext(c) - val, err := sdk.ValAddressFromBech32(req.ValidatorAddress) - if err != nil { - return nil, err - } - reps := k.GetReporters(ctx, val) - reporters := make([]string, len(reps)) - for idx, rep := range reps { - reporters[idx] = rep.String() - } - return &types.QueryReportersResponse{Reporter: reporters}, nil + // TODO: Wait of get all grants + // ctx := sdk.UnwrapSDKContext(c) + // val, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + // if err != nil { + // return nil, err + // } + // reps := k.GetReporters(ctx, val) + // reporters := make([]string, len(reps)) + // for idx, rep := range reps { + // reporters[idx] = rep.String() + // } + return &types.QueryReportersResponse{Reporter: []string{}}, nil } // ActiveValidators queries all active oracle validators. @@ -266,16 +267,8 @@ func (k Querier) RequestVerification(c context.Context, req *types.QueryRequestV } // Provided reporter should be authorized by the provided validator - reporters := k.GetReporters(ctx, validator) reporter := sdk.AccAddress(reporterPubKey.Address().Bytes()) - isReporterAuthorizedByValidator := false - for _, existingReporter := range reporters { - if reporter.Equals(existingReporter) { - isReporterAuthorizedByValidator = true - break - } - } - if !isReporterAuthorizedByValidator { + if !k.IsReporter(ctx, validator, reporter) { return nil, status.Error(codes.PermissionDenied, fmt.Sprintf("%s is not an authorized reporter of %s", reporter, req.Validator)) } diff --git a/x/oracle/keeper/grpc_query_test.go b/x/oracle/keeper/grpc_query_test.go index 02a41d090..3ec273928 100644 --- a/x/oracle/keeper/grpc_query_test.go +++ b/x/oracle/keeper/grpc_query_test.go @@ -57,9 +57,8 @@ func (suite *RequestVerificationTestSuite) SetupTest() { suite.reporterAddr = sdk.AccAddress(suite.reporterPrivKey.PubKey().Address()) k.SetRequest(ctx, types.RequestID(1), suite.request) - if err := k.AddReporter(ctx, testapp.Validators[0].ValAddress, suite.reporterAddr); err != nil { - panic(err) - } + err := k.GrantReporter(ctx, testapp.Validators[0].ValAddress, suite.reporterAddr) + suite.assert.NoError(err) } func (suite *RequestVerificationTestSuite) TestSuccess() { @@ -186,7 +185,7 @@ func (suite *RequestVerificationTestSuite) TestFailedEmptySignature() { } func (suite *RequestVerificationTestSuite) TestFailedReporterUnauthorized() { - err := suite.querier.Keeper.RemoveReporter(suite.ctx, testapp.Validators[0].ValAddress, suite.reporterAddr) + err := suite.querier.Keeper.RevokeReporter(suite.ctx, testapp.Validators[0].ValAddress, suite.reporterAddr) suite.assert.NoError(err) pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 99d1be550..6ac1e3ad2 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "encoding/binary" "fmt" + "time" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,8 +33,9 @@ type Keeper struct { authKeeper types.AccountKeeper bankKeeper types.BankKeeper - distrKeeper types.DistrKeeper stakingKeeper types.StakingKeeper + distrKeeper types.DistrKeeper + authzKeeper types.AuthzKeeper channelKeeper types.ChannelKeeper portKeeper types.PortKeeper scopedKeeper capabilitykeeper.ScopedKeeper @@ -50,6 +52,7 @@ func NewKeeper( bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, distrKeeper types.DistrKeeper, + authzKeeper types.AuthzKeeper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, scopeKeeper capabilitykeeper.ScopedKeeper, @@ -67,8 +70,9 @@ func NewKeeper( owasmVM: owasmVM, authKeeper: authKeeper, bankKeeper: bankKeeper, - distrKeeper: distrKeeper, stakingKeeper: stakingKeeper, + distrKeeper: distrKeeper, + authzKeeper: authzKeeper, channelKeeper: channelKeeper, portKeeper: portKeeper, scopedKeeper: scopeKeeper, @@ -203,3 +207,19 @@ func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Cap func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { return k.scopedKeeper.ClaimCapability(ctx, cap, name) } + +// IsReporter checks if the validator granted to the reporter +func (k Keeper) IsReporter(ctx sdk.Context, validator sdk.ValAddress, reporter sdk.AccAddress) bool { + cap, _ := k.authzKeeper.GetCleanAuthorization(ctx, reporter, sdk.AccAddress(validator), sdk.MsgTypeURL(&types.MsgReportData{})) + return cap != nil +} + +// GrantReporter grants the reporter to validator for testing +func (k Keeper) GrantReporter(ctx sdk.Context, validator sdk.ValAddress, reporter sdk.AccAddress) error { + return k.authzKeeper.SaveGrant(ctx, reporter, sdk.AccAddress(validator), types.NewReportAuthorization(), ctx.BlockTime().Add(10*time.Minute)) +} + +// RevokeReporter revokes grant from the reporter for testing +func (k Keeper) RevokeReporter(ctx sdk.Context, validator sdk.ValAddress, reporter sdk.AccAddress) error { + return k.authzKeeper.DeleteGrant(ctx, reporter, sdk.AccAddress(validator), sdk.MsgTypeURL(&types.MsgReportData{})) +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 63cd8ac5e..5c4ba0cd2 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -53,16 +53,6 @@ func (k msgServer) ReportData(goCtx context.Context, msg *types.MsgReportData) ( return nil, err } - reporter, err := sdk.AccAddressFromBech32(msg.Reporter) - if err != nil { - return nil, err - } - - // check this address is a reporter of the validator - if !k.IsReporter(ctx, validator, reporter) { - return nil, types.ErrReporterNotAuthorized - } - // check request must not expire. if msg.RequestID <= k.GetRequestLastExpired(ctx) { return nil, types.ErrRequestAlreadyExpired @@ -87,7 +77,7 @@ func (k msgServer) ReportData(goCtx context.Context, msg *types.MsgReportData) ( ctx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeReport, sdk.NewAttribute(types.AttributeKeyID, fmt.Sprintf("%d", msg.RequestID)), - sdk.NewAttribute(types.AttributeKeyValidator, msg.Validator), + sdk.NewAttribute(types.AttributeKeyValidator, validator.String()), )) return &types.MsgReportDataResponse{}, nil } @@ -284,47 +274,3 @@ func (k msgServer) Activate(goCtx context.Context, msg *types.MsgActivate) (*typ )) return &types.MsgActivateResponse{}, nil } - -func (k msgServer) AddReporter(goCtx context.Context, msg *types.MsgAddReporter) (*types.MsgAddReporterResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - repAddr, err := sdk.AccAddressFromBech32(msg.Reporter) - if err != nil { - return nil, err - } - valAddr, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return nil, err - } - err = k.Keeper.AddReporter(ctx, valAddr, repAddr) - if err != nil { - return nil, err - } - ctx.EventManager().EmitEvent(sdk.NewEvent( - types.EventTypeAddReporter, - sdk.NewAttribute(types.AttributeKeyValidator, msg.Validator), - sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), - )) - return &types.MsgAddReporterResponse{}, nil -} - -func (k msgServer) RemoveReporter(goCtx context.Context, msg *types.MsgRemoveReporter) (*types.MsgRemoveReporterResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - repAddr, err := sdk.AccAddressFromBech32(msg.Reporter) - if err != nil { - return nil, err - } - valAddr, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return nil, err - } - err = k.Keeper.RemoveReporter(ctx, valAddr, repAddr) - if err != nil { - return nil, err - } - ctx.EventManager().EmitEvent(sdk.NewEvent( - types.EventTypeRemoveReporter, - sdk.NewAttribute(types.AttributeKeyValidator, msg.Validator), - sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), - )) - return &types.MsgRemoveReporterResponse{}, nil -} diff --git a/x/oracle/keeper/querier.go b/x/oracle/keeper/querier.go index 35b9f91ae..7ceff5dd1 100644 --- a/x/oracle/keeper/querier.go +++ b/x/oracle/keeper/querier.go @@ -1,6 +1,7 @@ package keeper import ( + "errors" "strconv" "github.com/cosmos/cosmos-sdk/codec" @@ -145,14 +146,16 @@ func queryValidatorStatus(ctx sdk.Context, path []string, _ abci.RequestQuery, k } func queryReporters(ctx sdk.Context, path []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - if len(path) != 1 { - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "validator address not specified") - } - validatorAddress, err := sdk.ValAddressFromBech32(path[0]) - if err != nil { - return types.QueryBadRequest(legacyQuerierCdc, err.Error()) - } - return types.QueryOK(legacyQuerierCdc, k.GetReporters(ctx, validatorAddress)) + // TODO: Query all reporters + // if len(path) != 1 { + // return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "validator address not specified") + // } + // validatorAddress, err := sdk.ValAddressFromBech32(path[0]) + // if err != nil { + // return types.QueryBadRequest(legacyQuerierCdc, err.Error()) + // } + // return types.QueryOK(legacyQuerierCdc, k.GetReporters(ctx, validatorAddress)) + return types.QueryNotFound(legacyQuerierCdc, errors.New("Unimplemented")) } func queryActiveValidators(ctx sdk.Context, path []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { diff --git a/x/oracle/keeper/report.go b/x/oracle/keeper/report.go index 08e302185..d0aba37f8 100644 --- a/x/oracle/keeper/report.go +++ b/x/oracle/keeper/report.go @@ -22,6 +22,14 @@ func (k Keeper) SetReport(ctx sdk.Context, rid types.RequestID, rep types.Report // AddReports performs sanity checks and adds a new batch from one validator to one request // to the store. Note that we expect each validator to report to all raw data requests at once. func (k Keeper) AddReport(ctx sdk.Context, rid types.RequestID, rep types.Report) error { + if err := k.CheckValidReport(ctx, rid, rep); err != nil { + return err + } + k.SetReport(ctx, rid, rep) + return nil +} + +func (k Keeper) CheckValidReport(ctx sdk.Context, rid types.RequestID, rep types.Report) error { req, err := k.GetRequest(ctx, rid) if err != nil { return err @@ -57,7 +65,6 @@ func (k Keeper) AddReport(ctx sdk.Context, rid types.RequestID, rep types.Report types.ErrRawRequestNotFound, "reqID: %d, extID: %d", rid, rep.ExternalID) } } - k.SetReport(ctx, rid, rep) return nil } diff --git a/x/oracle/keeper/reporter.go b/x/oracle/keeper/reporter.go deleted file mode 100644 index 8f3f27923..000000000 --- a/x/oracle/keeper/reporter.go +++ /dev/null @@ -1,73 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/bandprotocol/chain/v2/x/oracle/types" -) - -// IsReporter returns true iff the address is an authorized reporter for the given validator. -func (k Keeper) IsReporter(ctx sdk.Context, val sdk.ValAddress, addr sdk.AccAddress) bool { - if val.Equals(sdk.ValAddress(addr)) { // A validator is always a reporter of himself. - return true - } - return ctx.KVStore(k.storeKey).Has(types.ReporterStoreKey(val, addr)) -} - -// AddReporter adds the reporter address to the list of reporters of the given validator. -func (k Keeper) AddReporter(ctx sdk.Context, val sdk.ValAddress, addr sdk.AccAddress) error { - if k.IsReporter(ctx, val, addr) { - return sdkerrors.Wrapf( - types.ErrReporterAlreadyExists, "val: %s, addr: %s", val.String(), addr.String()) - } - ctx.KVStore(k.storeKey).Set(types.ReporterStoreKey(val, addr), []byte{1}) - return nil -} - -// RemoveReporter removes the reporter address from the list of reporters of the given validator. -func (k Keeper) RemoveReporter(ctx sdk.Context, val sdk.ValAddress, addr sdk.AccAddress) error { - if !k.IsReporter(ctx, val, addr) { - return sdkerrors.Wrapf( - types.ErrReporterNotFound, "val: %s, addr: %s", val.String(), addr.String()) - } - ctx.KVStore(k.storeKey).Delete(types.ReporterStoreKey(val, addr)) - return nil -} - -// GetReporters returns the reporter list of the given validator. -func (k Keeper) GetReporters(ctx sdk.Context, val sdk.ValAddress) (reporters []sdk.AccAddress) { - // Appends self reporter of validator to the list - selfReporter := sdk.AccAddress(val) - reporters = append(reporters, selfReporter) - - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ReportersOfValidatorPrefixKey(val)) - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - key := iterator.Key() - reporterAddress := sdk.AccAddress(key[1+len(val):]) - reporters = append(reporters, reporterAddress) - } - return reporters -} - -func (k Keeper) GetAllReporters(ctx sdk.Context) []types.ReportersPerValidator { - var reporterList []types.ReportersPerValidator - k.stakingKeeper.IterateBondedValidatorsByPower(ctx, func(index int64, validator stakingtypes.ValidatorI) (stop bool) { - valAddress := validator.GetOperator() - reporters := k.GetReporters(ctx, valAddress) - var reportersBech32 []string - for _, reporter := range reporters { - reportersBech32 = append(reportersBech32, reporter.String()) - } - reporterList = append(reporterList, types.ReportersPerValidator{ - Validator: sdk.ValAddress(valAddress).String(), - Reporters: reportersBech32, - }) - return false - }) - - return reporterList -} diff --git a/x/oracle/keeper/reporter_test.go b/x/oracle/keeper/reporter_test.go deleted file mode 100644 index 1029c1b66..000000000 --- a/x/oracle/keeper/reporter_test.go +++ /dev/null @@ -1,106 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/bandprotocol/chain/v2/testing/testapp" -) - -func TestCheckSelfReporter(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(true) - // Owner must always be a reporter of himself. - require.True(t, k.IsReporter(ctx, testapp.Owner.ValAddress, testapp.Owner.Address)) -} - -func TestAddReporter(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(true) - // Before we do anything, Bob and Carol must not be a reporter of Alice. - require.False(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address)) - // Adds Bob as a reporter Alice. IsReporter should return true for Bob, false for Carol. - err := k.AddReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address) - require.Nil(t, err) - require.True(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address)) - require.False(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Carol.Address)) - // We should get an error if we try to add Bob again. - err = k.AddReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address) - require.NotNil(t, err) -} - -func TestRemoveReporter(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(true) - // Removing Bob from Alice's reporter list should error as Bob is not a reporter of Alice. - err := k.RemoveReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address) - require.NotNil(t, err) - // Adds Bob as the reporter of Alice. We now should be able to remove Bob, but not Carol. - err = k.AddReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address) - require.Nil(t, err) - err = k.RemoveReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address) - require.Nil(t, err) - err = k.RemoveReporter(ctx, testapp.Alice.ValAddress, testapp.Carol.Address) - require.NotNil(t, err) - // By the end of everything, no one should be a reporter of Alice. - require.False(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address)) - require.False(t, k.IsReporter(ctx, testapp.Alice.ValAddress, testapp.Carol.Address)) -} - -func TestGetReporters(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(true) - // Initially, only Alice should be the reporter of Alice. - reporters := k.GetReporters(ctx, testapp.Alice.ValAddress) - require.Equal(t, 1, len(reporters)) - require.Contains(t, reporters, testapp.Alice.Address) - // After we add Bob and Carol, they should also appear in GetReporters. - err := k.AddReporter(ctx, testapp.Alice.ValAddress, testapp.Bob.Address) - require.NoError(t, err) - err = k.AddReporter(ctx, testapp.Alice.ValAddress, testapp.Carol.Address) - require.NoError(t, err) - reporters = k.GetReporters(ctx, testapp.Alice.ValAddress) - require.Equal(t, 3, len(reporters)) - require.Contains(t, reporters, testapp.Alice.Address) - require.Contains(t, reporters, testapp.Bob.Address) - require.Contains(t, reporters, testapp.Carol.Address) -} - -func TestGetAllReporters(t *testing.T) { - _, ctx, k := testapp.CreateTestInput(true) - // Initially, only validators should be reporters of themselves - reporters := k.GetAllReporters(ctx) - expectedReporterMap := map[string][]string{ - sdk.ValAddress(testapp.Validators[0].Address).String(): {testapp.Validators[0].Address.String()}, - sdk.ValAddress(testapp.Validators[1].Address).String(): {testapp.Validators[1].Address.String()}, - sdk.ValAddress(testapp.Validators[2].Address).String(): {testapp.Validators[2].Address.String()}, - } - require.Equal(t, len(expectedReporterMap), len(reporters)) - for _, reportersPerValidator := range reporters { - require.Contains(t, expectedReporterMap, reportersPerValidator.Validator) - for _, reporter := range reportersPerValidator.Reporters { - require.Contains(t, expectedReporterMap[reportersPerValidator.Validator], reporter) - } - } - - // After Alice, Bob, and Carol are added, they should be included in result of GetAllReporters - err := k.AddReporter(ctx, testapp.Validators[0].ValAddress, testapp.Alice.Address) - require.NoError(t, err) - err = k.AddReporter(ctx, testapp.Validators[0].ValAddress, testapp.Bob.Address) - require.NoError(t, err) - err = k.AddReporter(ctx, testapp.Validators[2].ValAddress, testapp.Carol.Address) - require.NoError(t, err) - - reporters = k.GetAllReporters(ctx) - expectedReporterMap = map[string][]string{ - sdk.ValAddress(testapp.Validators[0].Address).String(): {testapp.Validators[0].Address.String(), testapp.Bob.Address.String(), testapp.Alice.Address.String()}, - sdk.ValAddress(testapp.Validators[1].Address).String(): {testapp.Validators[1].Address.String()}, - sdk.ValAddress(testapp.Validators[2].Address).String(): {testapp.Validators[2].Address.String(), testapp.Carol.Address.String()}, - } - - require.Equal(t, len(expectedReporterMap), len(reporters)) - for _, reportersPerValidator := range reporters { - require.Contains(t, expectedReporterMap, reportersPerValidator.Validator) - for _, reporter := range reportersPerValidator.Reporters { - require.Contains(t, expectedReporterMap[reportersPerValidator.Validator], reporter) - } - } -} diff --git a/x/oracle/legacy/v039/types.go b/x/oracle/legacy/v039/types.go index 4b3e3c29f..64aa2e280 100644 --- a/x/oracle/legacy/v039/types.go +++ b/x/oracle/legacy/v039/types.go @@ -12,6 +12,11 @@ type DataSource struct { Filename string `json:"filename,omitempty"` } +type ReportersPerValidator struct { + Validator string `json:"validator,omitempty"` + Reporters []string `json:"reporters,omitempty"` +} + // Params represents parameters for oracle module type Params struct { MaxRawRequestCount uint64 `json:"max_raw_request_count,omitempty"` @@ -25,8 +30,8 @@ type Params struct { } type GenesisState struct { - Params Params `json:"params" yaml:"params"` - DataSources []DataSource `json:"data_sources" yaml:"data_sources"` - OracleScripts []types.OracleScript `json:"oracle_scripts" yaml:"oracle_scripts"` - Reporters []types.ReportersPerValidator `json:"reporters" yaml:"reporters"` + Params Params `json:"params" yaml:"params"` + DataSources []DataSource `json:"data_sources" yaml:"data_sources"` + OracleScripts []types.OracleScript `json:"oracle_scripts" yaml:"oracle_scripts"` + Reporters []ReportersPerValidator `json:"reporters" yaml:"reporters"` } diff --git a/x/oracle/types/authz.pb.go b/x/oracle/types/authz.pb.go new file mode 100644 index 000000000..7d8c5606f --- /dev/null +++ b/x/oracle/types/authz.pb.go @@ -0,0 +1,268 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: oracle/v1/authz.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ReportAuthorization defines authorization for report. +type ReportAuthorization struct { +} + +func (m *ReportAuthorization) Reset() { *m = ReportAuthorization{} } +func (m *ReportAuthorization) String() string { return proto.CompactTextString(m) } +func (*ReportAuthorization) ProtoMessage() {} +func (*ReportAuthorization) Descriptor() ([]byte, []int) { + return fileDescriptor_d8b2b741cb7fb568, []int{0} +} +func (m *ReportAuthorization) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ReportAuthorization) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ReportAuthorization.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 *ReportAuthorization) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReportAuthorization.Merge(m, src) +} +func (m *ReportAuthorization) XXX_Size() int { + return m.Size() +} +func (m *ReportAuthorization) XXX_DiscardUnknown() { + xxx_messageInfo_ReportAuthorization.DiscardUnknown(m) +} + +var xxx_messageInfo_ReportAuthorization proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ReportAuthorization)(nil), "oracle.v1.ReportAuthorization") +} + +func init() { proto.RegisterFile("oracle/v1/authz.proto", fileDescriptor_d8b2b741cb7fb568) } + +var fileDescriptor_d8b2b741cb7fb568 = []byte{ + // 183 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0x2f, 0x4a, 0x4c, + 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x2c, 0x2d, 0xc9, 0xa8, 0xd2, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0xe2, 0x84, 0x08, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x45, + 0xf5, 0x41, 0x2c, 0x88, 0x02, 0x29, 0xc9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0xe2, 0x78, 0x88, 0x04, + 0x84, 0x03, 0x91, 0x52, 0xd2, 0xe0, 0x12, 0x0e, 0x4a, 0x2d, 0xc8, 0x2f, 0x2a, 0x71, 0x2c, 0x2d, + 0xc9, 0xc8, 0x2f, 0xca, 0xac, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0xb3, 0x12, 0xbc, 0xb4, 0x45, 0x97, + 0x17, 0x45, 0xc8, 0xc9, 0xed, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, + 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, + 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x93, 0x12, 0xf3, 0x52, 0xc0, + 0x26, 0x27, 0xe7, 0xe7, 0xe8, 0x27, 0x67, 0x24, 0x66, 0xe6, 0xe9, 0x57, 0xe8, 0x43, 0x9d, 0x5d, + 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x96, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xcc, + 0x91, 0x56, 0x6f, 0xcd, 0x00, 0x00, 0x00, +} + +func (m *ReportAuthorization) 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 *ReportAuthorization) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ReportAuthorization) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { + offset -= sovAuthz(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ReportAuthorization) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovAuthz(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAuthz(x uint64) (n int) { + return sovAuthz(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ReportAuthorization) 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 ErrIntOverflowAuthz + } + 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: ReportAuthorization: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ReportAuthorization: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipAuthz(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthz + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAuthz(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuthz + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuthz + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuthz + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAuthz + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAuthz + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAuthz + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAuthz = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAuthz = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAuthz = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go index 20e8194b5..8abf980db 100644 --- a/x/oracle/types/codec.go +++ b/x/oracle/types/codec.go @@ -6,6 +6,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + "github.com/cosmos/cosmos-sdk/x/authz" ) // RegisterLegacyAminoCodec registers the necessary x/oracle interfaces and concrete types @@ -18,10 +19,6 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateOracleScript{}, "oracle/CreateOracleScript", nil) cdc.RegisterConcrete(&MsgEditOracleScript{}, "oracle/EditOracleScript", nil) cdc.RegisterConcrete(&MsgActivate{}, "oracle/Activate", nil) - cdc.RegisterConcrete(&MsgAddReporter{}, "oracle/AddReporter", nil) - cdc.RegisterConcrete(&MsgRemoveReporter{}, "oracle/RemoveReporter", nil) - // cdc.RegisterConcrete(OracleRequestPacketData{}, "oracle/OracleRequestPacketData", nil) - // cdc.RegisterConcrete(OracleResponsePacketData{}, "oracle/OracleResponsePacketData", nil) } // RegisterInterfaces register the oracle module interfaces to protobuf Any. @@ -34,8 +31,11 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgCreateOracleScript{}, &MsgEditOracleScript{}, &MsgActivate{}, - &MsgAddReporter{}, - &MsgRemoveReporter{}, + ) + + registry.RegisterImplementations( + (*authz.Authorization)(nil), + &ReportAuthorization{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go index e61d6489c..fad881c3b 100644 --- a/x/oracle/types/expected_keepers.go +++ b/x/oracle/types/expected_keepers.go @@ -1,8 +1,11 @@ package types import ( + "time" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -49,3 +52,11 @@ type ChannelKeeper interface { type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability } + +// AuthzKeeper defines the expected authz keeper. for query and testing only don't use to create/remove grant on deliver tx +type AuthzKeeper interface { + GetCleanAuthorization(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (cap authz.Authorization, expiration time.Time) + + SaveGrant(ctx sdk.Context, grantee, granter sdk.AccAddress, authorization authz.Authorization, expiration time.Time) error + DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error +} diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 8e4b02801..8ecefb485 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -7,12 +7,11 @@ import ( ) // NewGenesisState creates a new GenesisState instanc e -func NewGenesisState(params Params, dataSources []DataSource, oracleScripts []OracleScript, reporters []ReportersPerValidator) *GenesisState { +func NewGenesisState(params Params, dataSources []DataSource, oracleScripts []OracleScript) *GenesisState { return &GenesisState{ Params: params, DataSources: dataSources, OracleScripts: oracleScripts, - Reporters: reporters, } } @@ -22,7 +21,6 @@ func DefaultGenesisState() *GenesisState { Params: DefaultParams(), DataSources: []DataSource{}, OracleScripts: []OracleScript{}, - Reporters: []ReportersPerValidator{}, } } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index b86565d10..b5971b4d0 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -32,9 +32,6 @@ type GenesisState struct { // OracleScripts are list of oracle scripts to be installed during genesis // phase OracleScripts []OracleScript `protobuf:"bytes,3,rep,name=oracle_scripts,json=oracleScripts,proto3" json:"oracle_scripts"` - // Reporters are mapping between reporter's account address (key) and - // validator's validator address (value) - Reporters []ReportersPerValidator `protobuf:"bytes,4,rep,name=reporters,proto3" json:"reporters"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -91,13 +88,6 @@ func (m *GenesisState) GetOracleScripts() []OracleScript { return nil } -func (m *GenesisState) GetReporters() []ReportersPerValidator { - if m != nil { - return m.Reporters - } - return nil -} - func init() { proto.RegisterType((*GenesisState)(nil), "oracle.v1.GenesisState") } @@ -105,26 +95,24 @@ func init() { func init() { proto.RegisterFile("oracle/v1/genesis.proto", fileDescriptor_14b982a0a6345d1d) } var fileDescriptor_14b982a0a6345d1d = []byte{ - // 300 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0x31, 0x6b, 0xfa, 0x40, - 0x18, 0xc6, 0x13, 0x15, 0xc1, 0xe8, 0xff, 0x0f, 0x0d, 0x6d, 0x0d, 0x0e, 0xd7, 0xd0, 0xc9, 0xa1, - 0xe4, 0xd0, 0xee, 0x1d, 0x44, 0xda, 0xb1, 0x62, 0xa0, 0x43, 0x17, 0x79, 0x73, 0x39, 0x62, 0x20, - 0xe6, 0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 0xe9, 0x3c, 0x9c, 0x3d, 0xee, 0x4b, 0x62, 0x1f, 0x4a, - 0x62, 0xff, 0x94, 0xc4, 0xfe, 0xac, 0x88, 0x75, 0xa8, 0x88, 0xf5, 0x55, 0x11, 0xeb, 0xf5, 0x2e, - 0x49, 0xd5, 0x7a, 0x1b, 0x05, 0x0c, 0x37, 0x34, 0x82, 0x3c, 0xd6, 0xdf, 0x63, 0x98, 0x51, 0xb6, - 0x86, 0x34, 0xa7, 0x6f, 0xe6, 0xab, 0x54, 0xbd, 0x17, 0x5c, 0x46, 0x5d, 0x8d, 0xef, 0x7f, 0x03, - 0x00, 0x00, 0xff, 0xff, 0xa9, 0x21, 0x54, 0x08, 0xb0, 0x01, 0x00, 0x00, + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x2f, 0x4a, 0x4c, + 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0x48, 0xe8, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, + 0x83, 0x45, 0xf5, 0x41, 0x2c, 0x88, 0x02, 0x29, 0x31, 0x84, 0x4e, 0xa8, 0x52, 0xb0, 0xb8, 0xd2, + 0x51, 0x46, 0x2e, 0x1e, 0x77, 0x88, 0x51, 0xc1, 0x25, 0x89, 0x25, 0xa9, 0x42, 0xfa, 0x5c, 0x6c, + 0x05, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x82, 0x7a, 0x70, + 0xa3, 0xf5, 0x02, 0xc0, 0x12, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x95, 0x09, 0xd9, + 0x71, 0xf1, 0xa4, 0x24, 0x96, 0x24, 0xc6, 0x17, 0xe7, 0x97, 0x16, 0x25, 0xa7, 0x16, 0x4b, 0x30, + 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x89, 0x22, 0x69, 0x73, 0x49, 0x2c, 0x49, 0x0c, 0x06, 0xcb, 0x42, + 0xb5, 0x72, 0xa7, 0xc0, 0x45, 0x8a, 0x85, 0x5c, 0xb8, 0xf8, 0x20, 0x4a, 0xe3, 0x8b, 0x93, 0x8b, + 0x32, 0x0b, 0x4a, 0x8a, 0x25, 0x98, 0xc1, 0x26, 0x88, 0x23, 0x99, 0xe0, 0x0f, 0x66, 0x05, 0x83, + 0xe5, 0xa1, 0x66, 0xf0, 0xe6, 0x23, 0x89, 0x15, 0x3b, 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, + 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, + 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, + 0x7e, 0x52, 0x62, 0x5e, 0x0a, 0xd8, 0xdf, 0xc9, 0xf9, 0x39, 0xfa, 0xc9, 0x19, 0x89, 0x99, 0x79, + 0xfa, 0x15, 0xd0, 0xf0, 0xd0, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x4b, 0x1b, 0x03, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x21, 0x1c, 0xeb, 0x6a, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -147,20 +135,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Reporters) > 0 { - for iNdEx := len(m.Reporters) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Reporters[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } if len(m.OracleScripts) > 0 { for iNdEx := len(m.OracleScripts) - 1; iNdEx >= 0; iNdEx-- { { @@ -233,12 +207,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.Reporters) > 0 { - for _, e := range m.Reporters { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -378,40 +346,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reporters", 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.Reporters = append(m.Reporters, ReportersPerValidator{}) - if err := m.Reporters[len(m.Reporters)-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/keys.go b/x/oracle/types/keys.go index dc2a4930d..8b5cbcbd7 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -50,10 +50,8 @@ var ( DataSourceStoreKeyPrefix = []byte{0x03} // OracleScriptStoreKeyPrefix is the prefix for oracle script store. OracleScriptStoreKeyPrefix = []byte{0x04} - // ReporterStoreKeyPrefix is the prefix for reporter store. - ReporterStoreKeyPrefix = []byte{0x05} // ValidatorStatusKeyPrefix is the prefix for validator status store. - ValidatorStatusKeyPrefix = []byte{0x06} + ValidatorStatusKeyPrefix = []byte{0x05} // ResultStoreKeyPrefix is the prefix for request result store. ResultStoreKeyPrefix = []byte{0xff} @@ -81,13 +79,6 @@ func OracleScriptStoreKey(oracleScriptID OracleScriptID) []byte { return append(OracleScriptStoreKeyPrefix, sdk.Uint64ToBigEndian(uint64(oracleScriptID))...) } -// ReporterStoreKey returns the key to check whether an address is a reporter of a validator. -func ReporterStoreKey(validatorAddress sdk.ValAddress, reporterAddress sdk.AccAddress) []byte { - buf := append(ReporterStoreKeyPrefix, []byte(validatorAddress)...) - buf = append(buf, []byte(reporterAddress)...) - return buf -} - // ValidatorStatusStoreKey returns the key to a validator's status. func ValidatorStatusStoreKey(v sdk.ValAddress) []byte { return append(ValidatorStatusKeyPrefix, v.Bytes()...) @@ -104,8 +95,3 @@ func ReportsOfValidatorPrefixKey(reqID RequestID, val sdk.ValAddress) []byte { buf = append(buf, val.Bytes()...) return buf } - -// ReportersOfValidatorPrefixKey returns the prefix key to get all reporters of a validator. -func ReportersOfValidatorPrefixKey(val sdk.ValAddress) []byte { - return append(ReporterStoreKeyPrefix, val.Bytes()...) -} diff --git a/x/oracle/types/keys_test.go b/x/oracle/types/keys_test.go index f31f0d899..8f326cc26 100644 --- a/x/oracle/types/keys_test.go +++ b/x/oracle/types/keys_test.go @@ -28,13 +28,6 @@ func TestOracleScriptStoreKey(t *testing.T) { require.Equal(t, expect, OracleScriptStoreKey(123)) } -func TestReporterStoreKey(t *testing.T) { - val, _ := sdk.ValAddressFromHex("b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") - rep, _ := sdk.AccAddressFromHex("ba11d00c5f74255f56a5e366f4f77f5a186d7f55") - expect, _ := hex.DecodeString("05b80f2a5df7d5710b15622d1a9f1e3830ded5bda8ba11d00c5f74255f56a5e366f4f77f5a186d7f55") - require.Equal(t, expect, ReporterStoreKey(val, rep)) -} - func TestValidatorStatusStoreKey(t *testing.T) { val, _ := sdk.ValAddressFromHex("b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") expect, _ := hex.DecodeString("06b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") @@ -51,9 +44,3 @@ func TestReportsOfValidatorPrefixKey(t *testing.T) { expect, _ := hex.DecodeString("020000000000000014b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") require.Equal(t, expect, ReportsOfValidatorPrefixKey(20, val)) } - -func TestReportersOfValidatorPrefixKey(t *testing.T) { - val, _ := sdk.ValAddressFromHex("b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") - expect, _ := hex.DecodeString("05b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") - require.Equal(t, expect, ReportersOfValidatorPrefixKey(val)) -} diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index ee6c91638..476a9e16a 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -28,8 +28,6 @@ var ( _ sdk.Msg = &MsgCreateOracleScript{} _ sdk.Msg = &MsgEditOracleScript{} _ sdk.Msg = &MsgActivate{} - _ sdk.Msg = &MsgAddReporter{} - _ sdk.Msg = &MsgRemoveReporter{} ) // NewMsgRequestData creates a new MsgRequestData instance. @@ -106,12 +104,11 @@ func (msg MsgRequestData) GetSignBytes() []byte { } // NewMsgReportData creates a new MsgReportData instance -func NewMsgReportData(requestID RequestID, rawReports []RawReport, validator sdk.ValAddress, reporter sdk.AccAddress) *MsgReportData { +func NewMsgReportData(requestID RequestID, rawReports []RawReport, validator sdk.ValAddress) *MsgReportData { return &MsgReportData{ RequestID: requestID, RawReports: rawReports, Validator: validator.String(), - Reporter: reporter.String(), } } @@ -127,16 +124,9 @@ func (msg MsgReportData) ValidateBasic() error { if err != nil { return err } - repAddr, err := sdk.AccAddressFromBech32(msg.Reporter) - if err != nil { - return err - } if err := sdk.VerifyAddressFormat(valAddr); err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "validator: %s", msg.Validator) } - if err := sdk.VerifyAddressFormat(repAddr); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "reporter: %s", msg.Reporter) - } if len(msg.RawReports) == 0 { return ErrEmptyReport } @@ -152,8 +142,8 @@ func (msg MsgReportData) ValidateBasic() error { // GetSigners returns the required signers for the given MsgReportData (sdk.Msg interface). func (msg MsgReportData) GetSigners() []sdk.AccAddress { - reporter, _ := sdk.AccAddressFromBech32(msg.Reporter) - return []sdk.AccAddress{reporter} + validator, _ := sdk.ValAddressFromBech32(msg.Validator) + return []sdk.AccAddress{sdk.AccAddress(validator)} } // GetSignBytes returns raw JSON bytes to be signed by the signers (sdk.Msg interface). @@ -488,97 +478,3 @@ func (msg MsgActivate) GetSigners() []sdk.AccAddress { func (msg MsgActivate) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) } - -// NewMsgAddReporter creates a new MsgAddReporter instance -func NewMsgAddReporter(validator sdk.ValAddress, reporter sdk.AccAddress) *MsgAddReporter { - return &MsgAddReporter{ - Validator: validator.String(), - Reporter: reporter.String(), - } -} - -// Route returns the route of MsgAddReporter - "oracle" (sdk.Msg interface). -func (msg MsgAddReporter) Route() string { return RouterKey } - -// Type returns the message type of MsgAddReporter (sdk.Msg interface). -func (msg MsgAddReporter) Type() string { return TypeMsgAddReporter } - -// ValidateBasic checks whether the given MsgAddReporter instance (sdk.Msg interface). -func (msg MsgAddReporter) ValidateBasic() error { - val, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return err - } - rep, err := sdk.AccAddressFromBech32(msg.Reporter) - if err != nil { - return err - } - if err := sdk.VerifyAddressFormat(val); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "validator: %s", msg.Validator) - } - if err := sdk.VerifyAddressFormat(rep); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "reporter: %s", msg.Reporter) - } - if sdk.ValAddress(rep).Equals(val) { - return ErrSelfReferenceAsReporter - } - return nil -} - -// GetSigners returns the required signers for the given MsgAddReporter (sdk.Msg interface). -func (msg MsgAddReporter) GetSigners() []sdk.AccAddress { - val, _ := sdk.ValAddressFromBech32(msg.Validator) - return []sdk.AccAddress{sdk.AccAddress(val)} -} - -// GetSignBytes returns raw JSON bytes to be signed by the signers (sdk.Msg interface). -func (msg MsgAddReporter) GetSignBytes() []byte { - return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) -} - -// NewMsgRemoveReporter creates a new MsgRemoveReporter instance -func NewMsgRemoveReporter(validator sdk.ValAddress, reporter sdk.AccAddress) *MsgRemoveReporter { - return &MsgRemoveReporter{ - Validator: validator.String(), - Reporter: reporter.String(), - } -} - -// Route returns the route of MsgRemoveReporter - "oracle" (sdk.Msg interface). -func (msg MsgRemoveReporter) Route() string { return RouterKey } - -// Type returns the message type of MsgRemoveReporter (sdk.Msg interface). -func (msg MsgRemoveReporter) Type() string { return TypeMsgRemoveReporter } - -// ValidateBasic checks whether the given MsgRemoveReporter instance (sdk.Msg interface). -func (msg MsgRemoveReporter) ValidateBasic() error { - val, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return err - } - rep, err := sdk.AccAddressFromBech32(msg.Reporter) - if err != nil { - return err - } - if err := sdk.VerifyAddressFormat(val); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "validator: %s", msg.Validator) - } - if err := sdk.VerifyAddressFormat(rep); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "reporter: %s", msg.Reporter) - } - if sdk.ValAddress(rep).Equals(val) { - return ErrSelfReferenceAsReporter - } - return nil -} - -// GetSigners returns the required signers for the given MsgRemoveReporter (sdk.Msg interface). -func (msg MsgRemoveReporter) GetSigners() []sdk.AccAddress { - val, _ := sdk.ValAddressFromBech32(msg.Validator) - return []sdk.AccAddress{sdk.AccAddress(val)} -} - -// GetSignBytes returns raw JSON bytes to be signed by the signers (sdk.Msg interface). -func (msg MsgRemoveReporter) GetSignBytes() []byte { - return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) -} diff --git a/x/oracle/types/msgs_test.go b/x/oracle/types/msgs_test.go index 13c4dde9e..ce0427fa6 100644 --- a/x/oracle/types/msgs_test.go +++ b/x/oracle/types/msgs_test.go @@ -48,8 +48,6 @@ func TestMsgRoute(t *testing.T) { require.Equal(t, "oracle", MsgRequestData{}.Route()) require.Equal(t, "oracle", MsgReportData{}.Route()) require.Equal(t, "oracle", MsgActivate{}.Route()) - require.Equal(t, "oracle", MsgAddReporter{}.Route()) - require.Equal(t, "oracle", MsgRemoveReporter{}.Route()) } func TestMsgType(t *testing.T) { @@ -60,8 +58,6 @@ func TestMsgType(t *testing.T) { require.Equal(t, "request", MsgRequestData{}.Type()) require.Equal(t, "report", MsgReportData{}.Type()) require.Equal(t, "activate", MsgActivate{}.Type()) - require.Equal(t, "add_reporter", MsgAddReporter{}.Type()) - require.Equal(t, "remove_reporter", MsgRemoveReporter{}.Type()) } func TestMsgGetSigners(t *testing.T) { @@ -77,10 +73,8 @@ func TestMsgGetSigners(t *testing.T) { require.Equal(t, signers, NewMsgCreateOracleScript("name", "desc", "schema", "url", []byte("code"), anotherAcc, signerAcc).GetSigners()) require.Equal(t, signers, NewMsgEditOracleScript(1, "name", "desc", "schema", "url", []byte("code"), anotherAcc, signerAcc).GetSigners()) require.Equal(t, signers, NewMsgRequestData(1, []byte("calldata"), 10, 5, "client-id", emptyCoins, 1, 1, signerAcc).GetSigners()) - require.Equal(t, signers, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, anotherVal, signerAcc).GetSigners()) + require.Equal(t, []sdk.AccAddress{anotherAcc}, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, anotherVal).GetSigners()) require.Equal(t, signers, NewMsgActivate(signerVal).GetSigners()) - require.Equal(t, signers, NewMsgAddReporter(signerVal, anotherAcc).GetSigners()) - require.Equal(t, signers, NewMsgRemoveReporter(signerVal, anotherAcc).GetSigners()) } func TestMsgGetSignBytes(t *testing.T) { @@ -108,21 +102,13 @@ func TestMsgGetSignBytes(t *testing.T) { string(NewMsgRequestData(1, []byte("calldata"), 10, 5, "client-id", FeeCoins, 50000, 250000, GoodTestAddr).GetSignBytes()), ) require.Equal(t, - `{"type":"oracle/Report","value":{"raw_reports":[{"data":"ZGF0YTE=","exit_code":1,"external_id":"1"},{"data":"ZGF0YTI=","exit_code":2,"external_id":"2"}],"reporter":"band1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq2vqal4","request_id":"1","validator":"bandvaloper1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx6y767"}}`, - string(NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, GoodTestValAddr, GoodTestAddr).GetSignBytes()), + `{"type":"oracle/Report","value":{"raw_reports":[{"data":"ZGF0YTE=","exit_code":1,"external_id":"1"},{"data":"ZGF0YTI=","exit_code":2,"external_id":"2"}],"request_id":"1","validator":"bandvaloper1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx6y767"}}`, + string(NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, GoodTestValAddr).GetSignBytes()), ) require.Equal(t, `{"type":"oracle/Activate","value":{"validator":"bandvaloper1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx6y767"}}`, string(NewMsgActivate(GoodTestValAddr).GetSignBytes()), ) - require.Equal(t, - `{"type":"oracle/AddReporter","value":{"reporter":"band1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq2vqal4","validator":"bandvaloper1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx6y767"}}`, - string(NewMsgAddReporter(GoodTestValAddr, GoodTestAddr).GetSignBytes()), - ) - require.Equal(t, - `{"type":"oracle/RemoveReporter","value":{"reporter":"band1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq2vqal4","validator":"bandvaloper1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx6y767"}}`, - string(NewMsgRemoveReporter(GoodTestValAddr, GoodTestAddr).GetSignBytes()), - ) } func TestMsgCreateDataSourceValidation(t *testing.T) { @@ -198,11 +184,10 @@ func TestMsgRequestDataValidation(t *testing.T) { func TestMsgReportDataValidation(t *testing.T) { performValidateTests(t, []validateTestCase{ - {true, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, GoodTestValAddr, GoodTestAddr)}, - {false, NewMsgReportData(1, []RawReport{}, GoodTestValAddr, GoodTestAddr)}, - {false, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {1, 1, []byte("data2")}}, GoodTestValAddr, GoodTestAddr)}, - {false, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, EmptyValAddr, GoodTestAddr)}, - {false, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, GoodTestValAddr, EmptyAddr)}, + {true, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, GoodTestValAddr)}, + {false, NewMsgReportData(1, []RawReport{}, GoodTestValAddr)}, + {false, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {1, 1, []byte("data2")}}, GoodTestValAddr)}, + {false, NewMsgReportData(1, []RawReport{{1, 1, []byte("data1")}, {2, 2, []byte("data2")}}, EmptyValAddr)}, }) } @@ -212,21 +197,3 @@ func TestMsgActivateValidation(t *testing.T) { {false, NewMsgActivate(EmptyValAddr)}, }) } - -func TestMsgAddReporterValidation(t *testing.T) { - performValidateTests(t, []validateTestCase{ - {true, NewMsgAddReporter(GoodTestValAddr, GoodTestAddr2)}, - {false, NewMsgAddReporter(EmptyValAddr, GoodTestAddr)}, - {false, NewMsgAddReporter(GoodTestValAddr, EmptyAddr)}, - {false, NewMsgAddReporter(GoodTestValAddr, GoodTestAddr)}, - }) -} - -func TestMsgRemoveReporterValidation(t *testing.T) { - performValidateTests(t, []validateTestCase{ - {true, NewMsgRemoveReporter(GoodTestValAddr, GoodTestAddr2)}, - {false, NewMsgRemoveReporter(EmptyValAddr, GoodTestAddr)}, - {false, NewMsgRemoveReporter(GoodTestValAddr, EmptyAddr)}, - {false, NewMsgRemoveReporter(GoodTestValAddr, GoodTestAddr)}, - }) -} diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index 1853c50ce..cf4a36680 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -1369,63 +1369,6 @@ func (m *IBCChannel) GetChannelId() string { return "" } -// ReportersPerValidator is list of reporters that is associated with a -// validator -type ReportersPerValidator struct { - // Validator a validator address - Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` - // Reporters is a list of reporter account addresses associated with the - // validator - Reporters []string `protobuf:"bytes,2,rep,name=reporters,proto3" json:"reporters,omitempty"` -} - -func (m *ReportersPerValidator) Reset() { *m = ReportersPerValidator{} } -func (m *ReportersPerValidator) String() string { return proto.CompactTextString(m) } -func (*ReportersPerValidator) ProtoMessage() {} -func (*ReportersPerValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_652b57db11528d07, []int{15} -} -func (m *ReportersPerValidator) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ReportersPerValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ReportersPerValidator.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 *ReportersPerValidator) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReportersPerValidator.Merge(m, src) -} -func (m *ReportersPerValidator) XXX_Size() int { - return m.Size() -} -func (m *ReportersPerValidator) XXX_DiscardUnknown() { - xxx_messageInfo_ReportersPerValidator.DiscardUnknown(m) -} - -var xxx_messageInfo_ReportersPerValidator proto.InternalMessageInfo - -func (m *ReportersPerValidator) GetValidator() string { - if m != nil { - return m.Validator - } - return "" -} - -func (m *ReportersPerValidator) GetReporters() []string { - if m != nil { - return m.Reporters - } - return nil -} - // RequestVerification is a message that is constructed and signed by a reporter // to be used as a part of verification of oracle request. type RequestVerification struct { @@ -1443,7 +1386,7 @@ func (m *RequestVerification) Reset() { *m = RequestVerification{} } func (m *RequestVerification) String() string { return proto.CompactTextString(m) } func (*RequestVerification) ProtoMessage() {} func (*RequestVerification) Descriptor() ([]byte, []int) { - return fileDescriptor_652b57db11528d07, []int{16} + return fileDescriptor_652b57db11528d07, []int{15} } func (m *RequestVerification) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1521,7 +1464,7 @@ func (m *PriceResult) Reset() { *m = PriceResult{} } func (m *PriceResult) String() string { return proto.CompactTextString(m) } func (*PriceResult) ProtoMessage() {} func (*PriceResult) Descriptor() ([]byte, []int) { - return fileDescriptor_652b57db11528d07, []int{17} + return fileDescriptor_652b57db11528d07, []int{16} } func (m *PriceResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1602,7 +1545,6 @@ func init() { proto.RegisterType((*Params)(nil), "oracle.v1.Params") proto.RegisterType((*PendingResolveList)(nil), "oracle.v1.PendingResolveList") proto.RegisterType((*IBCChannel)(nil), "oracle.v1.IBCChannel") - proto.RegisterType((*ReportersPerValidator)(nil), "oracle.v1.ReportersPerValidator") proto.RegisterType((*RequestVerification)(nil), "oracle.v1.RequestVerification") proto.RegisterType((*PriceResult)(nil), "oracle.v1.PriceResult") } @@ -1610,118 +1552,116 @@ func init() { func init() { proto.RegisterFile("oracle/v1/oracle.proto", fileDescriptor_652b57db11528d07) } var fileDescriptor_652b57db11528d07 = []byte{ - // 1767 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xcd, 0x6f, 0x23, 0x59, - 0x11, 0x4f, 0xdb, 0x4e, 0x62, 0x97, 0x9d, 0xaf, 0x37, 0x99, 0x8c, 0xc7, 0xbb, 0xd8, 0x21, 0x5a, + // 1740 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xcd, 0x6f, 0x23, 0x49, + 0x15, 0x4f, 0xdb, 0x4e, 0x62, 0x3f, 0x3b, 0x5f, 0x35, 0x99, 0x8c, 0xc7, 0xbb, 0xd8, 0x21, 0x5a, 0xd0, 0x30, 0x5a, 0x6c, 0x32, 0x20, 0xc4, 0xcc, 0xf2, 0xa1, 0xd8, 0x71, 0x16, 0xa3, 0x68, 0xc6, - 0x7a, 0x4e, 0x46, 0x80, 0x84, 0x5a, 0xcf, 0xdd, 0x2f, 0xce, 0x53, 0xfa, 0x8b, 0xf7, 0xda, 0x89, - 0xb3, 0x37, 0x6e, 0x68, 0x4f, 0x7b, 0x41, 0xe2, 0xc0, 0x4a, 0x2b, 0x71, 0xe3, 0x8a, 0xf8, 0x07, - 0x38, 0xcd, 0x8d, 0x3d, 0x21, 0x24, 0x24, 0x2f, 0xf2, 0x5c, 0xe0, 0x0f, 0xe0, 0x02, 0x17, 0xf4, - 0x3e, 0xda, 0x6d, 0x9b, 0x2c, 0x43, 0x86, 0x8f, 0xc3, 0x9e, 0xe2, 0xfa, 0x55, 0x55, 0x77, 0xbd, - 0xaa, 0x5f, 0xd5, 0xab, 0x0e, 0xec, 0x84, 0x9c, 0x38, 0x1e, 0x6d, 0x5c, 0xee, 0x37, 0xf4, 0xaf, - 0x7a, 0xc4, 0xc3, 0x38, 0x44, 0x05, 0x23, 0x5d, 0xee, 0x57, 0xb6, 0x07, 0xe1, 0x20, 0x54, 0x68, - 0x43, 0xfe, 0xd2, 0x06, 0x95, 0xda, 0x20, 0x0c, 0x07, 0x1e, 0x6d, 0x28, 0xa9, 0x3f, 0x3c, 0x6b, - 0xc4, 0xcc, 0xa7, 0x22, 0x26, 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x53, 0x01, 0xff, 0xdf, 0x4e, - 0xbe, 0x03, 0x2b, 0xc2, 0x39, 0xa7, 0x3e, 0x31, 0xe7, 0x36, 0x12, 0x7a, 0x0c, 0x1b, 0x42, 0xd5, - 0xc0, 0x76, 0x42, 0x97, 0xda, 0x43, 0xee, 0x95, 0x57, 0xa4, 0x41, 0x73, 0x6b, 0x32, 0xae, 0xad, - 0xe9, 0xf2, 0xb4, 0x42, 0x97, 0x9e, 0xe2, 0x63, 0xbc, 0x26, 0x52, 0x91, 0x7b, 0xe6, 0x44, 0xbf, - 0xb1, 0x00, 0x30, 0xb9, 0xc2, 0xf4, 0xc7, 0x43, 0x2a, 0x62, 0xf4, 0x2d, 0x28, 0xd2, 0x51, 0x4c, - 0x79, 0x40, 0x3c, 0x9b, 0xb9, 0xea, 0x54, 0xb9, 0xe6, 0x9b, 0x93, 0x71, 0x0d, 0xda, 0x06, 0xee, - 0x1c, 0xfe, 0x6d, 0x4e, 0xc2, 0x90, 0x38, 0x74, 0x5c, 0x74, 0x04, 0xeb, 0x2e, 0x89, 0x89, 0x6d, - 0x62, 0x62, 0xae, 0x4a, 0x41, 0xae, 0xb9, 0x3b, 0x19, 0xd7, 0x4a, 0x29, 0x61, 0xd4, 0x33, 0xe6, - 0x64, 0x5c, 0x72, 0x53, 0xc9, 0x95, 0xa9, 0x70, 0x88, 0xe7, 0x49, 0x4c, 0x65, 0xaa, 0x84, 0xa7, - 0xb2, 0x89, 0xfb, 0x27, 0x16, 0x14, 0x54, 0xdc, 0x51, 0xc8, 0xff, 0xe3, 0xb0, 0xdf, 0x80, 0x02, - 0x1d, 0xb1, 0x58, 0xe5, 0x50, 0x45, 0xbc, 0x86, 0xf3, 0x12, 0x90, 0xa9, 0x92, 0xc5, 0x9c, 0x89, - 0x23, 0x37, 0x13, 0xc3, 0x5f, 0xb2, 0xb0, 0x9a, 0x24, 0xee, 0x29, 0x6c, 0xea, 0x86, 0xb4, 0x75, - 0x41, 0xd3, 0x30, 0xde, 0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0x49, 0xd1, 0x80, 0xf4, 0x3d, 0xea, 0x2a, 0x66, 0xe7, 0x9b, 0x77, 0x27, + 0xe3, 0xda, 0x56, 0xa7, 0xd9, 0x32, 0x39, 0xb5, 0xb5, 0x12, 0x6f, 0xb1, 0xbe, 0x33, 0x0f, 0x3d, + 0xc9, 0xff, 0xec, 0x93, 0xda, 0x92, 0x62, 0xe3, 0x7b, 0x80, 0xba, 0x34, 0x70, 0x59, 0x30, 0x30, + 0x43, 0x74, 0xcc, 0x84, 0x3a, 0xe2, 0xd2, 0x95, 0x20, 0x49, 0x99, 0x95, 0x27, 0xd8, 0x74, 0xee, + 0x93, 0x13, 0xec, 0x7b, 0x30, 0x73, 0x73, 0x42, 0xf7, 0x60, 0x55, 0x31, 0x20, 0x59, 0x8b, 0x78, + 0x45, 0x8a, 0x1d, 0x17, 0x7d, 0x0e, 0xc0, 0x5c, 0xc5, 0x92, 0x05, 0x58, 0xc0, 0x05, 0x83, 0x4c, + 0x8f, 0xa9, 0x3f, 0x58, 0x70, 0xc7, 0x44, 0xf9, 0x9c, 0x72, 0x76, 0xc6, 0x1c, 0x9d, 0xf1, 0x17, + 0x21, 0xef, 0x9c, 0x13, 0x16, 0xa4, 0xdb, 0xb6, 0x38, 0x19, 0xd7, 0x56, 0x5b, 0x12, 0xeb, 0x1c, + 0xe2, 0x55, 0xa5, 0xec, 0xb8, 0xf3, 0x37, 0xaf, 0xcc, 0xe2, 0xcd, 0x6b, 0x7e, 0xc7, 0x65, 0x6f, + 0xb3, 0xe3, 0x16, 0xbe, 0x1f, 0x72, 0xb7, 0xfb, 0x7e, 0x30, 0xd9, 0xfd, 0xca, 0x82, 0x62, 0x97, + 0x33, 0x87, 0x9a, 0x43, 0x44, 0x7e, 0xb3, 0x5d, 0xfb, 0xfd, 0xd0, 0x4b, 0x4a, 0xa5, 0x25, 0x54, + 0x05, 0xf0, 0x87, 0x5e, 0xcc, 0x22, 0x8f, 0x4d, 0x87, 0x7e, 0x06, 0x41, 0x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 0xff, 0xff, 0x91, 0xec, 0x8d, 0x21, 0xae, 0x11, 0x00, 0x00, } func (this *DataSource) Equal(that interface{}) bool { @@ -3158,45 +3098,6 @@ func (m *IBCChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ReportersPerValidator) 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 *ReportersPerValidator) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ReportersPerValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Reporters) > 0 { - for iNdEx := len(m.Reporters) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Reporters[iNdEx]) - copy(dAtA[i:], m.Reporters[iNdEx]) - i = encodeVarintOracle(dAtA, i, uint64(len(m.Reporters[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.Validator) > 0 { - i -= len(m.Validator) - copy(dAtA[i:], m.Validator) - i = encodeVarintOracle(dAtA, i, uint64(len(m.Validator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *RequestVerification) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -3713,25 +3614,6 @@ func (m *IBCChannel) Size() (n int) { return n } -func (m *ReportersPerValidator) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Validator) - if l > 0 { - n += 1 + l + sovOracle(uint64(l)) - } - if len(m.Reporters) > 0 { - for _, s := range m.Reporters { - l = len(s) - n += 1 + l + sovOracle(uint64(l)) - } - } - return n -} - func (m *RequestVerification) Size() (n int) { if m == nil { return 0 @@ -6496,120 +6378,6 @@ func (m *IBCChannel) Unmarshal(dAtA []byte) error { } return nil } -func (m *ReportersPerValidator) 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: ReportersPerValidator: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ReportersPerValidator: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowOracle - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthOracle - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthOracle - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Validator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reporters", 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.Reporters = append(m.Reporters, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipOracle(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthOracle - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *RequestVerification) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/report_authorization.go b/x/oracle/types/report_authorization.go new file mode 100644 index 000000000..8f16cf22a --- /dev/null +++ b/x/oracle/types/report_authorization.go @@ -0,0 +1,30 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" +) + +var ( + _ authz.Authorization = &ReportAuthorization{} +) + +// NewSendAuthorization creates a new SendAuthorization object. +func NewReportAuthorization() *ReportAuthorization { + return &ReportAuthorization{} +} + +// MsgTypeURL implements Authorization.MsgTypeURL. +func (a ReportAuthorization) MsgTypeURL() string { + return sdk.MsgTypeURL(&MsgReportData{}) +} + +// Accept implements Authorization.Accept. +func (a ReportAuthorization) Accept(ctx sdk.Context, _ sdk.Msg) (authz.AcceptResponse, error) { + return authz.AcceptResponse{Accept: true, Delete: false}, nil +} + +// ValidateBasic implements Authorization.ValidateBasic. +func (a ReportAuthorization) ValidateBasic() error { + return nil +} diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index b5e7213f7..919deb9c0 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -199,9 +199,6 @@ type MsgReportData struct { RawReports []RawReport `protobuf:"bytes,2,rep,name=raw_reports,json=rawReports,proto3" json:"raw_reports"` // Validator is the address of the validator that owns this report. Validator string `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,omitempty"` - // Reporter is the message signer who submits this report transaction for the - // validator. - Reporter string `protobuf:"bytes,4,opt,name=reporter,proto3" json:"reporter,omitempty"` } func (m *MsgReportData) Reset() { *m = MsgReportData{} } @@ -258,13 +255,6 @@ func (m *MsgReportData) GetValidator() string { return "" } -func (m *MsgReportData) GetReporter() string { - if m != nil { - return m.Reporter - } - return "" -} - // MsgReportDataResponse is response data for MsgReportData message type MsgReportDataResponse struct { } @@ -969,194 +959,6 @@ func (m *MsgActivateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgActivateResponse proto.InternalMessageInfo -// MsgAddReporter is a message for adding a new reporter for a validator. -type MsgAddReporter struct { - // Validator is the validator address who requested to add a new reporter. - // Note that this is the signer. - Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` - // Reporter is the account address to be added as a reporter to the validator. - Reporter string `protobuf:"bytes,2,opt,name=reporter,proto3" json:"reporter,omitempty"` -} - -func (m *MsgAddReporter) Reset() { *m = MsgAddReporter{} } -func (m *MsgAddReporter) String() string { return proto.CompactTextString(m) } -func (*MsgAddReporter) ProtoMessage() {} -func (*MsgAddReporter) Descriptor() ([]byte, []int) { - return fileDescriptor_31571edce0094a5d, []int{14} -} -func (m *MsgAddReporter) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAddReporter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAddReporter.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 *MsgAddReporter) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddReporter.Merge(m, src) -} -func (m *MsgAddReporter) XXX_Size() int { - return m.Size() -} -func (m *MsgAddReporter) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddReporter.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAddReporter proto.InternalMessageInfo - -func (m *MsgAddReporter) GetValidator() string { - if m != nil { - return m.Validator - } - return "" -} - -func (m *MsgAddReporter) GetReporter() string { - if m != nil { - return m.Reporter - } - return "" -} - -// MsgAddReporterResponse is response data for MsgAddReporter message -type MsgAddReporterResponse struct { -} - -func (m *MsgAddReporterResponse) Reset() { *m = MsgAddReporterResponse{} } -func (m *MsgAddReporterResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddReporterResponse) ProtoMessage() {} -func (*MsgAddReporterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_31571edce0094a5d, []int{15} -} -func (m *MsgAddReporterResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAddReporterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAddReporterResponse.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 *MsgAddReporterResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddReporterResponse.Merge(m, src) -} -func (m *MsgAddReporterResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgAddReporterResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddReporterResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAddReporterResponse proto.InternalMessageInfo - -// MsgAddReporter is a message for removing an existing reporter from a -// validator. -type MsgRemoveReporter struct { - // Validator is the validator address who requested to remove an existing - // reporter. Note that this is the signer. - Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` - // Reporter is the account address to be removed from being the validator's - // reporter. - Reporter string `protobuf:"bytes,2,opt,name=reporter,proto3" json:"reporter,omitempty"` -} - -func (m *MsgRemoveReporter) Reset() { *m = MsgRemoveReporter{} } -func (m *MsgRemoveReporter) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveReporter) ProtoMessage() {} -func (*MsgRemoveReporter) Descriptor() ([]byte, []int) { - return fileDescriptor_31571edce0094a5d, []int{16} -} -func (m *MsgRemoveReporter) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRemoveReporter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRemoveReporter.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 *MsgRemoveReporter) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveReporter.Merge(m, src) -} -func (m *MsgRemoveReporter) XXX_Size() int { - return m.Size() -} -func (m *MsgRemoveReporter) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveReporter.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRemoveReporter proto.InternalMessageInfo - -func (m *MsgRemoveReporter) GetValidator() string { - if m != nil { - return m.Validator - } - return "" -} - -func (m *MsgRemoveReporter) GetReporter() string { - if m != nil { - return m.Reporter - } - return "" -} - -// MsgRemoveReporterResponse is response data for MsgRemoveReporter message -type MsgRemoveReporterResponse struct { -} - -func (m *MsgRemoveReporterResponse) Reset() { *m = MsgRemoveReporterResponse{} } -func (m *MsgRemoveReporterResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveReporterResponse) ProtoMessage() {} -func (*MsgRemoveReporterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_31571edce0094a5d, []int{17} -} -func (m *MsgRemoveReporterResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRemoveReporterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRemoveReporterResponse.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 *MsgRemoveReporterResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveReporterResponse.Merge(m, src) -} -func (m *MsgRemoveReporterResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRemoveReporterResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveReporterResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRemoveReporterResponse proto.InternalMessageInfo - func init() { proto.RegisterType((*MsgRequestData)(nil), "oracle.v1.MsgRequestData") proto.RegisterType((*MsgRequestDataResponse)(nil), "oracle.v1.MsgRequestDataResponse") @@ -1172,85 +974,75 @@ func init() { proto.RegisterType((*MsgEditOracleScriptResponse)(nil), "oracle.v1.MsgEditOracleScriptResponse") proto.RegisterType((*MsgActivate)(nil), "oracle.v1.MsgActivate") proto.RegisterType((*MsgActivateResponse)(nil), "oracle.v1.MsgActivateResponse") - proto.RegisterType((*MsgAddReporter)(nil), "oracle.v1.MsgAddReporter") - proto.RegisterType((*MsgAddReporterResponse)(nil), "oracle.v1.MsgAddReporterResponse") - proto.RegisterType((*MsgRemoveReporter)(nil), "oracle.v1.MsgRemoveReporter") - proto.RegisterType((*MsgRemoveReporterResponse)(nil), "oracle.v1.MsgRemoveReporterResponse") } func init() { proto.RegisterFile("oracle/v1/tx.proto", fileDescriptor_31571edce0094a5d) } var fileDescriptor_31571edce0094a5d = []byte{ - // 1092 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x73, 0xdb, 0xc4, - 0x1b, 0x8e, 0x6c, 0xc7, 0xb1, 0x5e, 0x3b, 0xf9, 0xb5, 0xfa, 0xa5, 0x41, 0x71, 0x5a, 0xc9, 0x64, - 0x3a, 0x1d, 0x33, 0x03, 0x16, 0x29, 0xa7, 0xc2, 0xa9, 0x4e, 0x28, 0x64, 0xda, 0x00, 0xb3, 0x81, - 0x4b, 0x67, 0x18, 0xb3, 0x96, 0x36, 0x8a, 0x26, 0x92, 0xd6, 0x68, 0xe5, 0xfc, 0xf9, 0x16, 0x9c, - 0x39, 0x71, 0x86, 0x3b, 0x5f, 0x81, 0x1e, 0x7b, 0xe4, 0x64, 0x3a, 0xce,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, 0x9e, 0x99, 0xb5, 0xfc, 0x98, 0x59, - 0xbe, 0x6d, 0x94, 0xe7, 0xd3, 0x1e, 0xcf, 0xa1, 0x99, 0x3d, 0x2d, 0x05, 0x2b, 0x65, 0xa0, 0xa2, - 0x95, 0x4a, 0x4e, 0x04, 0x17, 0xa9, 0x78, 0x1c, 0x8a, 0xa6, 0xc9, 0xa2, 0x45, 0x91, 0xca, 0x5d, - 0xdf, 0x7f, 0xf6, 0x6a, 0x6a, 0x28, 0xaf, 0xa7, 0x86, 0xf2, 0x66, 0x6a, 0x28, 0x3f, 0x9d, 0x1b, - 0x0b, 0xaf, 0xcf, 0x8d, 0x85, 0x3f, 0xcf, 0x8d, 0x85, 0x97, 0x1f, 0x66, 0xde, 0xcd, 0x21, 0x0e, - 0x1d, 0xf1, 0xc3, 0xc0, 0xa6, 0xbe, 0x65, 0x1f, 0x62, 0x2f, 0xb4, 0x4e, 0x93, 0x1f, 0x14, 0xf2, - 0x05, 0x1d, 0xd6, 0x05, 0xfc, 0xc9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x0c, 0x97, 0x21, - 0xe2, 0x0c, 0x00, 0x00, + // 1007 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x73, 0xdb, 0x44, + 0x14, 0x8f, 0x62, 0xc7, 0xb1, 0x9e, 0x9d, 0xd0, 0x8a, 0x34, 0x28, 0x4a, 0x2b, 0x99, 0x4c, 0xa7, + 0x63, 0x66, 0xc0, 0x22, 0xe5, 0x54, 0x38, 0x61, 0x87, 0x42, 0x86, 0x1a, 0x66, 0xb6, 0x70, 0xe9, + 0x0c, 0x63, 0xd6, 0xd2, 0x46, 0xd1, 0x44, 0xd6, 0x1a, 0xed, 0x3a, 0x7f, 0xbe, 0x05, 0x67, 0x4e, + 0x9c, 0xe9, 0x9d, 0xcf, 0xd0, 0x63, 0x8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8c, 0xfd, 0xd0, 0x3e, 0x4f, 0xfe, 0xb3, 0xca, 0x0b, 0xbc, 0x5f, 0x11, 0xf0, + 0x17, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x01, 0x49, 0x5e, 0x14, 0x45, 0x0b, 0x00, 0x00, } func (this *MsgRequestData) Equal(that interface{}) bool { @@ -1339,9 +1131,6 @@ func (this *MsgReportData) Equal(that interface{}) bool { if this.Validator != that1.Validator { return false } - if this.Reporter != that1.Reporter { - return false - } return true } func (this *MsgCreateDataSource) Equal(that interface{}) bool { @@ -1552,60 +1341,6 @@ func (this *MsgActivate) Equal(that interface{}) bool { } return true } -func (this *MsgAddReporter) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*MsgAddReporter) - if !ok { - that2, ok := that.(MsgAddReporter) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Validator != that1.Validator { - return false - } - if this.Reporter != that1.Reporter { - return false - } - return true -} -func (this *MsgRemoveReporter) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*MsgRemoveReporter) - if !ok { - that2, ok := that.(MsgRemoveReporter) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Validator != that1.Validator { - return false - } - if this.Reporter != that1.Reporter { - return false - } - return true -} // Reference imports to suppress errors if they are not otherwise used. var _ context.Context @@ -1633,10 +1368,6 @@ type MsgClient interface { EditOracleScript(ctx context.Context, in *MsgEditOracleScript, opts ...grpc.CallOption) (*MsgEditOracleScriptResponse, error) // Activate defines a method for applying to be an oracle validator. Activate(ctx context.Context, in *MsgActivate, opts ...grpc.CallOption) (*MsgActivateResponse, error) - // AddReporter defines a method for adding a new reporter for a validator. - AddReporter(ctx context.Context, in *MsgAddReporter, opts ...grpc.CallOption) (*MsgAddReporterResponse, error) - // RemoveReporter defines a method for removing an reporter from a validator - RemoveReporter(ctx context.Context, in *MsgRemoveReporter, opts ...grpc.CallOption) (*MsgRemoveReporterResponse, error) } type msgClient struct { @@ -1710,24 +1441,6 @@ func (c *msgClient) Activate(ctx context.Context, in *MsgActivate, opts ...grpc. return out, nil } -func (c *msgClient) AddReporter(ctx context.Context, in *MsgAddReporter, opts ...grpc.CallOption) (*MsgAddReporterResponse, error) { - out := new(MsgAddReporterResponse) - err := c.cc.Invoke(ctx, "/oracle.v1.Msg/AddReporter", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) RemoveReporter(ctx context.Context, in *MsgRemoveReporter, opts ...grpc.CallOption) (*MsgRemoveReporterResponse, error) { - out := new(MsgRemoveReporterResponse) - err := c.cc.Invoke(ctx, "/oracle.v1.Msg/RemoveReporter", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. type MsgServer interface { // RequestData defines a method for submitting a new request. @@ -1744,10 +1457,6 @@ type MsgServer interface { EditOracleScript(context.Context, *MsgEditOracleScript) (*MsgEditOracleScriptResponse, error) // Activate defines a method for applying to be an oracle validator. Activate(context.Context, *MsgActivate) (*MsgActivateResponse, error) - // AddReporter defines a method for adding a new reporter for a validator. - AddReporter(context.Context, *MsgAddReporter) (*MsgAddReporterResponse, error) - // RemoveReporter defines a method for removing an reporter from a validator - RemoveReporter(context.Context, *MsgRemoveReporter) (*MsgRemoveReporterResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1775,12 +1484,6 @@ func (*UnimplementedMsgServer) EditOracleScript(ctx context.Context, req *MsgEdi func (*UnimplementedMsgServer) Activate(ctx context.Context, req *MsgActivate) (*MsgActivateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Activate not implemented") } -func (*UnimplementedMsgServer) AddReporter(ctx context.Context, req *MsgAddReporter) (*MsgAddReporterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddReporter not implemented") -} -func (*UnimplementedMsgServer) RemoveReporter(ctx context.Context, req *MsgRemoveReporter) (*MsgRemoveReporterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveReporter not implemented") -} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1912,42 +1615,6 @@ func _Msg_Activate_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Msg_AddReporter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddReporter) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).AddReporter(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/oracle.v1.Msg/AddReporter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddReporter(ctx, req.(*MsgAddReporter)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_RemoveReporter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRemoveReporter) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RemoveReporter(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/oracle.v1.Msg/RemoveReporter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RemoveReporter(ctx, req.(*MsgRemoveReporter)) - } - return interceptor(ctx, in, info, handler) -} - var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "oracle.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -1980,14 +1647,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Activate", Handler: _Msg_Activate_Handler, }, - { - MethodName: "AddReporter", - Handler: _Msg_AddReporter_Handler, - }, - { - MethodName: "RemoveReporter", - Handler: _Msg_RemoveReporter_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "oracle/v1/tx.proto", @@ -2119,13 +1778,6 @@ func (m *MsgReportData) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Reporter) > 0 { - i -= len(m.Reporter) - copy(dAtA[i:], m.Reporter) - i = encodeVarintTx(dAtA, i, uint64(len(m.Reporter))) - i-- - dAtA[i] = 0x22 - } if len(m.Validator) > 0 { i -= len(m.Validator) copy(dAtA[i:], m.Validator) @@ -2635,149 +2287,29 @@ func (m *MsgActivateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgAddReporter) 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 encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil -} - -func (m *MsgAddReporter) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *MsgAddReporter) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *MsgRequestData) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.Reporter) > 0 { - i -= len(m.Reporter) - copy(dAtA[i:], m.Reporter) - i = encodeVarintTx(dAtA, i, uint64(len(m.Reporter))) - i-- - dAtA[i] = 0x12 - } - 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] = 0xa + if m.OracleScriptID != 0 { + n += 1 + sovTx(uint64(m.OracleScriptID)) } - return len(dAtA) - i, nil -} - -func (m *MsgAddReporterResponse) 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 *MsgAddReporterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAddReporterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgRemoveReporter) 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 *MsgRemoveReporter) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveReporter) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Reporter) > 0 { - i -= len(m.Reporter) - copy(dAtA[i:], m.Reporter) - i = encodeVarintTx(dAtA, i, uint64(len(m.Reporter))) - i-- - dAtA[i] = 0x12 - } - 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] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRemoveReporterResponse) 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 *MsgRemoveReporterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveReporterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgRequestData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.OracleScriptID != 0 { - n += 1 + sovTx(uint64(m.OracleScriptID)) - } - l = len(m.Calldata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } if m.AskCount != 0 { n += 1 + sovTx(uint64(m.AskCount)) @@ -2836,10 +2368,6 @@ func (m *MsgReportData) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Reporter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } return n } @@ -3068,58 +2596,6 @@ func (m *MsgActivateResponse) Size() (n int) { return n } -func (m *MsgAddReporter) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Validator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Reporter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgAddReporterResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgRemoveReporter) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Validator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Reporter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRemoveReporterResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3567,38 +3043,6 @@ func (m *MsgReportData) Unmarshal(dAtA []byte) error { } m.Validator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reporter", 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.Reporter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5148,334 +4592,6 @@ func (m *MsgActivateResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddReporter) 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: MsgAddReporter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddReporter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reporter", 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.Reporter = 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 *MsgAddReporterResponse) 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: MsgAddReporterResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddReporterResponse: 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 *MsgRemoveReporter) 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: MsgRemoveReporter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveReporter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reporter", 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.Reporter = 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 *MsgRemoveReporterResponse) 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: MsgRemoveReporterResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveReporterResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/yoda/execute.go b/yoda/execute.go index 64132d5de..1597e6009 100644 --- a/yoda/execute.go +++ b/yoda/execute.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/version" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" ctypes "github.com/tendermint/tendermint/rpc/core/types" band "github.com/bandprotocol/chain/v2/app" @@ -50,7 +51,9 @@ func signAndBroadcast( WithKeybase(kb). WithAccountRetriever(clientCtx.AccountRetriever) - txb, err := tx.BuildUnsignedTx(txf, msgs...) + execMsg := authz.NewMsgExec(key.GetAddress(), msgs) + + txb, err := tx.BuildUnsignedTx(txf, &execMsg) if err != nil { return "", err } diff --git a/yoda/gas.go b/yoda/gas.go index fbcbcb429..42e5cf1e9 100644 --- a/yoda/gas.go +++ b/yoda/gas.go @@ -120,6 +120,7 @@ func estimateAuthAnteHandlerGas(c *Context, msgs []sdk.Msg) uint64 { } func estimateGas(c *Context, l *Logger, msgs []sdk.Msg, feeEstimations []FeeEstimationData) uint64 { + // TODO: Add authz validation / remove check reporter base gas gas := estimateAuthAnteHandlerGas(c, msgs) for i, msg := range msgs { diff --git a/yoda/handler.go b/yoda/handler.go index bfa16ffdd..955487567 100644 --- a/yoda/handler.go +++ b/yoda/handler.go @@ -120,7 +120,7 @@ func handleRequestLog(c *Context, l *Logger, log sdk.ABCIMessageLog) { } c.pendingMsgs <- ReportMsgWithKey{ - msg: types.NewMsgReportData(types.RequestID(id), reports, c.validator, key.GetAddress()), + msg: types.NewMsgReportData(types.RequestID(id), reports, c.validator), execVersion: execVersions, keyIndex: keyIndex, feeEstimationData: FeeEstimationData{ @@ -169,7 +169,7 @@ func handlePendingRequest(c *Context, l *Logger, id types.RequestID) { reports, execVersions := handleRawRequests(c, l, id, rawRequests, key) c.pendingMsgs <- ReportMsgWithKey{ - msg: types.NewMsgReportData(types.RequestID(id), reports, c.validator, key.GetAddress()), + msg: types.NewMsgReportData(types.RequestID(id), reports, c.validator), execVersion: execVersions, keyIndex: keyIndex, feeEstimationData: FeeEstimationData{ From 5bbcb3b153fe8704e7ed48f3bf3d65c0a2e04f88 Mon Sep 17 00:00:00 2001 From: taobun Date: Wed, 18 Aug 2021 21:17:25 +0700 Subject: [PATCH 02/11] Add check grant on keys list --- x/oracle/keeper/grpc_query.go | 28 +- x/oracle/keeper/grpc_query_test.go | 51 +-- x/oracle/types/keys_test.go | 2 +- x/oracle/types/query.pb.go | 668 +++++++++++++++++++++++------ x/oracle/types/query.pb.gw.go | 120 ++++++ yoda/executor/rest.go | 2 +- yoda/handler.go | 2 +- yoda/keys.go | 28 +- 8 files changed, 725 insertions(+), 176 deletions(-) diff --git a/x/oracle/keeper/grpc_query.go b/x/oracle/keeper/grpc_query.go index 44665d1f0..122a2a843 100644 --- a/x/oracle/keeper/grpc_query.go +++ b/x/oracle/keeper/grpc_query.go @@ -2,9 +2,10 @@ package keeper import ( "context" + "encoding/hex" "fmt" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "google.golang.org/grpc/codes" @@ -175,6 +176,20 @@ func (k Querier) Validator(c context.Context, req *types.QueryValidatorRequest) return &types.QueryValidatorResponse{Status: &status}, nil } +// IsReporter queries grant of account on this validator +func (k Querier) IsReporter(c context.Context, req *types.QueryIsReporterRequest) (*types.QueryIsReporterResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + val, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + if err != nil { + return nil, err + } + rep, err := sdk.AccAddressFromBech32(req.ReporterAddress) + if err != nil { + return nil, err + } + return &types.QueryIsReporterResponse{IsReporter: k.Keeper.IsReporter(ctx, val, rep)}, nil +} + // Reporters queries all reporters of a given validator address. func (k Querier) Reporters(c context.Context, req *types.QueryReportersRequest) (*types.QueryReportersResponse, error) { if req == nil { @@ -255,11 +270,12 @@ func (k Querier) RequestVerification(c context.Context, req *types.QueryRequestV return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unable to parse validator address: %s", err.Error())) } - // Provided signature should be valid, which means this query request should be signed by the provided reporter - reporterPubKey, ok := req.Reporter.GetCachedValue().(cryptotypes.PubKey) - if !ok { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unable to get reporter's public key")) + bz, err := hex.DecodeString(req.Reporter) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "unable to get reporter's public key") } + reporterPubKey := secp256k1.PubKey{Key: bz} + requestVerificationContent := types.NewRequestVerification(req.ChainId, validator, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) signByte := requestVerificationContent.GetSignBytes() if !reporterPubKey.VerifySignature(signByte, req.Signature) { @@ -268,7 +284,7 @@ func (k Querier) RequestVerification(c context.Context, req *types.QueryRequestV // Provided reporter should be authorized by the provided validator reporter := sdk.AccAddress(reporterPubKey.Address().Bytes()) - if !k.IsReporter(ctx, validator, reporter) { + if !k.Keeper.IsReporter(ctx, validator, reporter) { return nil, status.Error(codes.PermissionDenied, fmt.Sprintf("%s is not an authorized reporter of %s", reporter, req.Validator)) } diff --git a/x/oracle/keeper/grpc_query_test.go b/x/oracle/keeper/grpc_query_test.go index 3ec273928..c36afc9dd 100644 --- a/x/oracle/keeper/grpc_query_test.go +++ b/x/oracle/keeper/grpc_query_test.go @@ -1,9 +1,9 @@ package keeper_test import ( + "encoding/hex" "testing" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -62,15 +62,12 @@ func (suite *RequestVerificationTestSuite) SetupTest() { } func (suite *RequestVerificationTestSuite) TestSuccess() { - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -99,15 +96,12 @@ func (suite *RequestVerificationTestSuite) TestFailedEmptyRequest() { } func (suite *RequestVerificationTestSuite) TestFailedChainIDNotMatch() { - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: "other-chain-id", Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -122,15 +116,12 @@ func (suite *RequestVerificationTestSuite) TestFailedChainIDNotMatch() { } func (suite *RequestVerificationTestSuite) TestFailedInvalidValidatorAddr() { - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: "someRandomString", RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -145,14 +136,12 @@ func (suite *RequestVerificationTestSuite) TestFailedInvalidValidatorAddr() { } func (suite *RequestVerificationTestSuite) TestFailedInvalidReporterPubKey() { - pk := &codectypes.Any{} - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: "Non-hex", } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -167,15 +156,12 @@ func (suite *RequestVerificationTestSuite) TestFailedInvalidReporterPubKey() { } func (suite *RequestVerificationTestSuite) TestFailedEmptySignature() { - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } res, err := suite.querier.RequestVerification(sdk.WrapSDKContext(suite.ctx), req) @@ -188,15 +174,12 @@ func (suite *RequestVerificationTestSuite) TestFailedReporterUnauthorized() { err := suite.querier.Keeper.RevokeReporter(suite.ctx, testapp.Validators[0].ValAddress, suite.reporterAddr) suite.assert.NoError(err) - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -214,15 +197,12 @@ func (suite *RequestVerificationTestSuite) TestFailedUnselectedValidator() { suite.request.RequestedValidators = []string{testapp.Validators[1].ValAddress.String()} suite.querier.Keeper.SetRequest(suite.ctx, types.RequestID(1), suite.request) - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -240,15 +220,12 @@ func (suite *RequestVerificationTestSuite) TestFailedNoDataSourceFound() { suite.request.RawRequests = []types.RawRequest{} suite.querier.Keeper.SetRequest(suite.ctx, types.RequestID(1), suite.request) - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -270,15 +247,12 @@ func (suite *RequestVerificationTestSuite) TestFailedValidatorAlreadyReported() })) suite.assert.NoError(err) - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } requestVerification := types.NewRequestVerification(req.ChainId, testapp.Validators[0].ValAddress, types.RequestID(req.RequestId), types.ExternalID(req.ExternalId)) @@ -293,15 +267,12 @@ func (suite *RequestVerificationTestSuite) TestFailedValidatorAlreadyReported() } func (suite *RequestVerificationTestSuite) TestFailedRequestAlreadyExpired() { - pk, err := codectypes.NewAnyWithValue(suite.reporterPrivKey.PubKey()) - suite.assert.NoError(err) - req := &types.QueryRequestVerificationRequest{ ChainId: suite.ctx.ChainID(), Validator: testapp.Validators[0].ValAddress.String(), RequestId: 1, ExternalId: 1, - Reporter: pk, + Reporter: hex.EncodeToString(suite.reporterPrivKey.PubKey().Bytes()), } suite.ctx = suite.ctx.WithBlockHeight(1000) diff --git a/x/oracle/types/keys_test.go b/x/oracle/types/keys_test.go index 8f326cc26..bb71bc905 100644 --- a/x/oracle/types/keys_test.go +++ b/x/oracle/types/keys_test.go @@ -30,7 +30,7 @@ func TestOracleScriptStoreKey(t *testing.T) { func TestValidatorStatusStoreKey(t *testing.T) { val, _ := sdk.ValAddressFromHex("b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") - expect, _ := hex.DecodeString("06b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") + expect, _ := hex.DecodeString("05b80f2a5df7d5710b15622d1a9f1e3830ded5bda8") require.Equal(t, expect, ValidatorStatusStoreKey(val)) } diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 75bbecc1d..b0848edda 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -792,6 +792,107 @@ func (m *QueryValidatorResponse) GetStatus() *ValidatorStatus { return nil } +// QueryIsReporterRequest is request type for the Query/Reporter RPC method. +type QueryIsReporterRequest struct { + // ValidatorAddress is a validator address + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // ReporterAddress is a candidate account + ReporterAddress string `protobuf:"bytes,2,opt,name=reporter_address,json=reporterAddress,proto3" json:"reporter_address,omitempty"` +} + +func (m *QueryIsReporterRequest) Reset() { *m = QueryIsReporterRequest{} } +func (m *QueryIsReporterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryIsReporterRequest) ProtoMessage() {} +func (*QueryIsReporterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_34238c8dfdfcd7ec, []int{16} +} +func (m *QueryIsReporterRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIsReporterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIsReporterRequest.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 *QueryIsReporterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIsReporterRequest.Merge(m, src) +} +func (m *QueryIsReporterRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIsReporterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIsReporterRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIsReporterRequest proto.InternalMessageInfo + +func (m *QueryIsReporterRequest) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +func (m *QueryIsReporterRequest) GetReporterAddress() string { + if m != nil { + return m.ReporterAddress + } + return "" +} + +// QueryIsReporterResponse is response type for the Query/Reporter RPC method. +type QueryIsReporterResponse struct { + // IsReporter is true if this account has been granted by validator + IsReporter bool `protobuf:"varint,1,opt,name=is_reporter,json=isReporter,proto3" json:"is_reporter,omitempty"` +} + +func (m *QueryIsReporterResponse) Reset() { *m = QueryIsReporterResponse{} } +func (m *QueryIsReporterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryIsReporterResponse) ProtoMessage() {} +func (*QueryIsReporterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_34238c8dfdfcd7ec, []int{17} +} +func (m *QueryIsReporterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIsReporterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIsReporterResponse.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 *QueryIsReporterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIsReporterResponse.Merge(m, src) +} +func (m *QueryIsReporterResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIsReporterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIsReporterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIsReporterResponse proto.InternalMessageInfo + +func (m *QueryIsReporterResponse) GetIsReporter() bool { + if m != nil { + return m.IsReporter + } + return false +} + // QueryReportersRequest is request type for the Query/Reporters RPC method. type QueryReportersRequest struct { // ValidatorAddress is a validator address @@ -802,7 +903,7 @@ func (m *QueryReportersRequest) Reset() { *m = QueryReportersRequest{} } func (m *QueryReportersRequest) String() string { return proto.CompactTextString(m) } func (*QueryReportersRequest) ProtoMessage() {} func (*QueryReportersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{16} + return fileDescriptor_34238c8dfdfcd7ec, []int{18} } func (m *QueryReportersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -848,7 +949,7 @@ func (m *QueryReportersResponse) Reset() { *m = QueryReportersResponse{} func (m *QueryReportersResponse) String() string { return proto.CompactTextString(m) } func (*QueryReportersResponse) ProtoMessage() {} func (*QueryReportersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{17} + return fileDescriptor_34238c8dfdfcd7ec, []int{19} } func (m *QueryReportersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -893,7 +994,7 @@ func (m *QueryActiveValidatorsRequest) Reset() { *m = QueryActiveValidat func (m *QueryActiveValidatorsRequest) String() string { return proto.CompactTextString(m) } func (*QueryActiveValidatorsRequest) ProtoMessage() {} func (*QueryActiveValidatorsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{18} + return fileDescriptor_34238c8dfdfcd7ec, []int{20} } func (m *QueryActiveValidatorsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -933,7 +1034,7 @@ func (m *QueryActiveValidatorsResponse) Reset() { *m = QueryActiveValida func (m *QueryActiveValidatorsResponse) String() string { return proto.CompactTextString(m) } func (*QueryActiveValidatorsResponse) ProtoMessage() {} func (*QueryActiveValidatorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{19} + return fileDescriptor_34238c8dfdfcd7ec, []int{21} } func (m *QueryActiveValidatorsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -987,7 +1088,7 @@ func (m *QueryRequestSearchRequest) Reset() { *m = QueryRequestSearchReq func (m *QueryRequestSearchRequest) String() string { return proto.CompactTextString(m) } func (*QueryRequestSearchRequest) ProtoMessage() {} func (*QueryRequestSearchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{20} + return fileDescriptor_34238c8dfdfcd7ec, []int{22} } func (m *QueryRequestSearchRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1055,7 +1156,7 @@ func (m *QueryRequestSearchResponse) Reset() { *m = QueryRequestSearchRe func (m *QueryRequestSearchResponse) String() string { return proto.CompactTextString(m) } func (*QueryRequestSearchResponse) ProtoMessage() {} func (*QueryRequestSearchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{21} + return fileDescriptor_34238c8dfdfcd7ec, []int{23} } func (m *QueryRequestSearchResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1106,7 +1207,7 @@ func (m *QueryRequestPriceRequest) Reset() { *m = QueryRequestPriceReque func (m *QueryRequestPriceRequest) String() string { return proto.CompactTextString(m) } func (*QueryRequestPriceRequest) ProtoMessage() {} func (*QueryRequestPriceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{22} + return fileDescriptor_34238c8dfdfcd7ec, []int{24} } func (m *QueryRequestPriceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1167,7 +1268,7 @@ func (m *QueryRequestPriceResponse) Reset() { *m = QueryRequestPriceResp func (m *QueryRequestPriceResponse) String() string { return proto.CompactTextString(m) } func (*QueryRequestPriceResponse) ProtoMessage() {} func (*QueryRequestPriceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{23} + return fileDescriptor_34238c8dfdfcd7ec, []int{25} } func (m *QueryRequestPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1217,7 +1318,7 @@ type QueryRequestVerificationRequest struct { ExternalId uint64 `protobuf:"varint,4,opt,name=external_id,json=externalId,proto3" json:"external_id,omitempty"` // Reporter is an bech32-encoded public key of the reporter authorized by the // validator - Reporter *types.Any `protobuf:"bytes,5,opt,name=reporter,proto3" json:"reporter,omitempty" yaml:"reporter"` + Reporter string `protobuf:"bytes,5,opt,name=reporter,proto3" json:"reporter,omitempty"` // Signature is a signature signed by the reporter using reporter's private // key Signature []byte `protobuf:"bytes,6,opt,name=signature,proto3" json:"signature,omitempty"` @@ -1227,7 +1328,7 @@ func (m *QueryRequestVerificationRequest) Reset() { *m = QueryRequestVer func (m *QueryRequestVerificationRequest) String() string { return proto.CompactTextString(m) } func (*QueryRequestVerificationRequest) ProtoMessage() {} func (*QueryRequestVerificationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{24} + return fileDescriptor_34238c8dfdfcd7ec, []int{26} } func (m *QueryRequestVerificationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1284,11 +1385,11 @@ func (m *QueryRequestVerificationRequest) GetExternalId() uint64 { return 0 } -func (m *QueryRequestVerificationRequest) GetReporter() *types.Any { +func (m *QueryRequestVerificationRequest) GetReporter() string { if m != nil { return m.Reporter } - return nil + return "" } func (m *QueryRequestVerificationRequest) GetSignature() []byte { @@ -1318,7 +1419,7 @@ func (m *QueryRequestVerificationResponse) Reset() { *m = QueryRequestVe func (m *QueryRequestVerificationResponse) String() string { return proto.CompactTextString(m) } func (*QueryRequestVerificationResponse) ProtoMessage() {} func (*QueryRequestVerificationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_34238c8dfdfcd7ec, []int{25} + return fileDescriptor_34238c8dfdfcd7ec, []int{27} } func (m *QueryRequestVerificationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1399,6 +1500,8 @@ func init() { proto.RegisterType((*QueryParamsResponse)(nil), "oracle.v1.QueryParamsResponse") proto.RegisterType((*QueryValidatorRequest)(nil), "oracle.v1.QueryValidatorRequest") proto.RegisterType((*QueryValidatorResponse)(nil), "oracle.v1.QueryValidatorResponse") + proto.RegisterType((*QueryIsReporterRequest)(nil), "oracle.v1.QueryIsReporterRequest") + proto.RegisterType((*QueryIsReporterResponse)(nil), "oracle.v1.QueryIsReporterResponse") proto.RegisterType((*QueryReportersRequest)(nil), "oracle.v1.QueryReportersRequest") proto.RegisterType((*QueryReportersResponse)(nil), "oracle.v1.QueryReportersResponse") proto.RegisterType((*QueryActiveValidatorsRequest)(nil), "oracle.v1.QueryActiveValidatorsRequest") @@ -1414,97 +1517,98 @@ func init() { func init() { proto.RegisterFile("oracle/v1/query.proto", fileDescriptor_34238c8dfdfcd7ec) } var fileDescriptor_34238c8dfdfcd7ec = []byte{ - // 1425 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x8f, 0x93, 0x34, 0xc9, 0xbe, 0x6c, 0xda, 0x64, 0x92, 0xb6, 0x89, 0x93, 0x6c, 0x52, 0x37, - 0xd0, 0x6d, 0x53, 0xd6, 0x24, 0x54, 0x20, 0x0a, 0x42, 0x6a, 0x88, 0x2a, 0x16, 0x90, 0x9a, 0x6e, - 0xa4, 0xf2, 0x4f, 0x68, 0x35, 0x6b, 0xbb, 0xbb, 0x56, 0x77, 0xed, 0xad, 0xc7, 0x1b, 0x75, 0x55, - 0x22, 0xa4, 0x22, 0x4e, 0x1c, 0xa0, 0x42, 0x82, 0x43, 0x6f, 0x7c, 0x06, 0xbe, 0x00, 0xb7, 0x8a, - 0x53, 0x25, 0x2e, 0x9c, 0x2a, 0x94, 0xf0, 0x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x44, 0xc3, 0x8b, 0xac, 0xa7, 0xfd, - 0xa5, 0xd7, 0x08, 0xf5, 0xc2, 0x10, 0x04, 0x72, 0xd9, 0xe2, 0x5c, 0x36, 0xc9, 0x65, 0x89, 0x4b, - 0x3c, 0x14, 0x73, 0x59, 0x3c, 0x52, 0xa0, 0x10, 0xcd, 0xf5, 0x2c, 0x8b, 0xf4, 0xe2, 0x90, 0x65, - 0x91, 0x59, 0x0a, 0x72, 0x1f, 0x6c, 0xd8, 0xdb, 0xf2, 0x49, 0x7c, 0xa7, 0xc0, 0x6c, 0x7a, 0x0d, - 0x20, 0x99, 0x1b, 0x18, 0xb0, 0x48, 0xa8, 0xe5, 0x93, 0x81, 0xc8, 0x6c, 0x83, 0x33, 0x2b, 0x91, - 0x15, 0x89, 0x19, 0xe5, 0xe0, 0x7a, 0x9c, 0xa6, 0xa0, 0x25, 0x89, 0x05, 0x2f, 0xdb, 0x92, 0x12, - 0x9b, 0x63, 0xb6, 0x25, 0x25, 0x57, 0xc8, 0xdc, 0x96, 0x24, 0x96, 0x45, 0xf2, 0x35, 0xcc, 0x24, - 0x86, 0x3f, 0xd9, 0x18, 0xf0, 0xec, 0x13, 0x8b, 0x8b, 0xfa, 0xca, 0x09, 0x28, 0x74, 0x7c, 0x81, - 0x3b, 0x5e, 0x26, 0x4b, 0xd9, 0x12, 0xa9, 0x33, 0xe1, 0xef, 0x2b, 0x28, 0xca, 0x43, 0x3b, 0xdb, - 0x22, 0x72, 0x56, 0x08, 0x75, 0x63, 0x38, 0xe8, 0x05, 0xbc, 0xf3, 0x19, 0xcf, 0xc8, 0x63, 0x05, - 0xe6, 0x73, 0xc6, 0x17, 0xb9, 0x32, 0xc0, 0x41, 0xce, 0xf4, 0x57, 0x37, 0x5f, 0x08, 0x3b, 0x84, - 0xd3, 0x41, 0x00, 0xec, 0x87, 0x45, 0xba, 0x73, 0xf3, 0xe9, 0x51, 0x49, 0x79, 0x76, 0x54, 0x52, - 0xfe, 0x3a, 0x2a, 0x29, 0x3f, 0x1c, 0x97, 0x46, 0x9e, 0x1d, 0x97, 0x46, 0xfe, 0x3c, 0x2e, 0x8d, - 0x7c, 0x7e, 0xb5, 0x69, 0xfb, 0xad, 0x5e, 0xa3, 0x62, 0xb8, 0x1d, 0xbd, 0x41, 0x1d, 0x93, 0xcf, - 0x78, 0xc3, 0x6d, 0xeb, 0x7c, 0xa4, 0xea, 0x0f, 0x42, 0x9b, 0x7e, 0xbf, 0x6b, 0xb1, 0xc6, 0x04, - 0x57, 0xbf, 0xf1, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x41, 0xca, 0xf2, 0x37, 0xe7, 0x10, 0x00, - 0x00, + // 1453 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x4b, 0x6f, 0x1c, 0x45, + 0x10, 0xf6, 0xd8, 0x8e, 0xed, 0x2d, 0xaf, 0x1d, 0xbb, 0x9d, 0x87, 0x3d, 0xb6, 0xd7, 0xce, 0xc4, + 0x90, 0xcd, 0x43, 0x3b, 0xd8, 0x44, 0x20, 0x42, 0x84, 0x14, 0x63, 0x45, 0x18, 0x21, 0x25, 0x59, + 0x4b, 0xe1, 0x75, 0x58, 0xf5, 0xce, 0x4e, 0xd6, 0xa3, 0xac, 0x67, 0x36, 0xd3, 0xb3, 0x56, 0xac, + 0x60, 0x21, 0x05, 0x71, 0xe2, 0x00, 0x08, 0x09, 0x0e, 0xb9, 0x71, 0xe5, 0x57, 0x70, 0xcb, 0x31, + 0x12, 0x1c, 0x38, 0x45, 0xc8, 0xe1, 0x87, 0xa0, 0xe9, 0xae, 0xee, 0xe9, 0x79, 0xec, 0x3a, 0xf8, + 0xc2, 0x6d, 0xa7, 0xea, 0xeb, 0xaa, 0xaf, 0xba, 0xab, 0xab, 0x3f, 0x2d, 0x9c, 0x0d, 0x42, 0xea, + 0x74, 0x5c, 0x7b, 0x7f, 0xdd, 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d, 0xd1, 0xe7, 0x2f, 0x57, 0x86, 0xea, 0x12, 0x47, 0x2e, 0xc3, 0x58, 0xe8, 0xb2, + 0x5e, 0x47, 0xf4, 0x56, 0x76, 0x45, 0xec, 0xa8, 0x23, 0xc0, 0xfa, 0x18, 0x16, 0x39, 0xc7, 0xbb, + 0xae, 0xdf, 0xf2, 0xfc, 0x36, 0x66, 0x97, 0x17, 0x84, 0x5c, 0x85, 0xd9, 0x7d, 0xda, 0xf1, 0x5a, + 0x34, 0x0a, 0xc2, 0x06, 0x6d, 0xb5, 0x42, 0x97, 0x31, 0xec, 0xbd, 0x19, 0xe5, 0xb8, 0x25, 0xec, + 0xd6, 0x1d, 0x58, 0x2a, 0x8e, 0x85, 0x75, 0xdb, 0x30, 0x99, 0xec, 0x57, 0x1c, 0x66, 0xa4, 0x3a, + 0xba, 0x39, 0x7d, 0xf4, 0x72, 0x05, 0x10, 0xba, 0xbd, 0xc5, 0xea, 0xa0, 0x36, 0x90, 0xa9, 0x4b, + 0x7b, 0x97, 0x86, 0x74, 0x4f, 0x5d, 0xda, 0xdb, 0x78, 0x1a, 0xd2, 0xaa, 0xa2, 0x8f, 0x75, 0xb9, + 0x05, 0x37, 0x55, 0x2f, 0x5a, 0x40, 0x71, 0x9b, 0x10, 0x66, 0x6d, 0xc1, 0x59, 0x1e, 0xe7, 0xbe, + 0xac, 0xe3, 0x44, 0x45, 0x7f, 0x82, 0xf7, 0x49, 0x8b, 0x82, 0x84, 0x36, 0x60, 0x8c, 0x45, 0x34, + 0xea, 0x49, 0x42, 0xa6, 0x46, 0x48, 0xa1, 0x77, 0x38, 0xa2, 0x8e, 0x48, 0xab, 0x8b, 0xd1, 0xb6, + 0x99, 0x38, 0x59, 0xf7, 0x44, 0xa4, 0xc8, 0x65, 0x98, 0x09, 0x71, 0xbd, 0xc2, 0x0e, 0x73, 0xec, + 0x69, 0x69, 0x97, 0xfc, 0x6f, 0xe0, 0x7d, 0xd6, 0x33, 0x62, 0x01, 0x2b,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0x55, 0x86, 0xfe, 0x7a, 0x55, 0x19, 0xfa, 0xe2, 0x5a, 0xdb, 0x8b, + 0x76, 0x7b, 0xcd, 0x9a, 0x13, 0xec, 0xd9, 0x4d, 0xea, 0xb7, 0xf8, 0xff, 0x20, 0x4e, 0xd0, 0xb1, + 0xf9, 0x63, 0x6f, 0x3f, 0x96, 0x31, 0xa3, 0x83, 0xae, 0xcb, 0x9a, 0x63, 0xdc, 0xfd, 0xf6, 0xbf, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x98, 0x8c, 0x12, 0x29, 0xec, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1536,6 +1640,8 @@ type QueryClient interface { PendingRequests(ctx context.Context, in *QueryPendingRequestsRequest, opts ...grpc.CallOption) (*QueryPendingRequestsResponse, error) // Validator queries properties of given validator address. Validator(ctx context.Context, in *QueryValidatorRequest, opts ...grpc.CallOption) (*QueryValidatorResponse, error) + // IsReporter queries grant of account on this validator. + IsReporter(ctx context.Context, in *QueryIsReporterRequest, opts ...grpc.CallOption) (*QueryIsReporterResponse, error) // Reporters queries all reporters associated with given validator address. Reporters(ctx context.Context, in *QueryReportersRequest, opts ...grpc.CallOption) (*QueryReportersResponse, error) // ActiveValidators queries all active oracle validators. @@ -1623,6 +1729,15 @@ func (c *queryClient) Validator(ctx context.Context, in *QueryValidatorRequest, return out, nil } +func (c *queryClient) IsReporter(ctx context.Context, in *QueryIsReporterRequest, opts ...grpc.CallOption) (*QueryIsReporterResponse, error) { + out := new(QueryIsReporterResponse) + err := c.cc.Invoke(ctx, "/oracle.v1.Query/IsReporter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) Reporters(ctx context.Context, in *QueryReportersRequest, opts ...grpc.CallOption) (*QueryReportersResponse, error) { out := new(QueryReportersResponse) err := c.cc.Invoke(ctx, "/oracle.v1.Query/Reporters", in, out, opts...) @@ -1696,6 +1811,8 @@ type QueryServer interface { PendingRequests(context.Context, *QueryPendingRequestsRequest) (*QueryPendingRequestsResponse, error) // Validator queries properties of given validator address. Validator(context.Context, *QueryValidatorRequest) (*QueryValidatorResponse, error) + // IsReporter queries grant of account on this validator. + IsReporter(context.Context, *QueryIsReporterRequest) (*QueryIsReporterResponse, error) // Reporters queries all reporters associated with given validator address. Reporters(context.Context, *QueryReportersRequest) (*QueryReportersResponse, error) // ActiveValidators queries all active oracle validators. @@ -1737,6 +1854,9 @@ func (*UnimplementedQueryServer) PendingRequests(ctx context.Context, req *Query func (*UnimplementedQueryServer) Validator(ctx context.Context, req *QueryValidatorRequest) (*QueryValidatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Validator not implemented") } +func (*UnimplementedQueryServer) IsReporter(ctx context.Context, req *QueryIsReporterRequest) (*QueryIsReporterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IsReporter not implemented") +} func (*UnimplementedQueryServer) Reporters(ctx context.Context, req *QueryReportersRequest) (*QueryReportersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Reporters not implemented") } @@ -1886,6 +2006,24 @@ func _Query_Validator_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Query_IsReporter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIsReporterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IsReporter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/oracle.v1.Query/IsReporter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IsReporter(ctx, req.(*QueryIsReporterRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_Reporters_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryReportersRequest) if err := dec(in); err != nil { @@ -2026,6 +2164,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Validator", Handler: _Query_Validator_Handler, }, + { + MethodName: "IsReporter", + Handler: _Query_IsReporter_Handler, + }, { MethodName: "Reporters", Handler: _Query_Reporters_Handler, @@ -2583,6 +2725,76 @@ func (m *QueryValidatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *QueryIsReporterRequest) 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 *QueryIsReporterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIsReporterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ReporterAddress) > 0 { + i -= len(m.ReporterAddress) + copy(dAtA[i:], m.ReporterAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ReporterAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIsReporterResponse) 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 *QueryIsReporterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIsReporterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsReporter { + i-- + if m.IsReporter { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *QueryReportersRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2891,15 +3103,10 @@ func (m *QueryRequestVerificationRequest) MarshalToSizedBuffer(dAtA []byte) (int i-- dAtA[i] = 0x32 } - if m.Reporter != nil { - { - size, err := m.Reporter.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.Reporter) > 0 { + i -= len(m.Reporter) + copy(dAtA[i:], m.Reporter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Reporter))) i-- dAtA[i] = 0x2a } @@ -3206,6 +3413,35 @@ func (m *QueryValidatorResponse) Size() (n int) { return n } +func (m *QueryIsReporterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ReporterAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryIsReporterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IsReporter { + n += 2 + } + return n +} + func (m *QueryReportersRequest) Size() (n int) { if m == nil { return 0 @@ -3349,8 +3585,8 @@ func (m *QueryRequestVerificationRequest) Size() (n int) { if m.ExternalId != 0 { n += 1 + sovQuery(uint64(m.ExternalId)) } - if m.Reporter != nil { - l = m.Reporter.Size() + l = len(m.Reporter) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } l = len(m.Signature) @@ -4759,6 +4995,190 @@ func (m *QueryValidatorResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryIsReporterRequest) 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: QueryIsReporterRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIsReporterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReporterAddress", 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.ReporterAddress = 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 *QueryIsReporterResponse) 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: QueryIsReporterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIsReporterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsReporter", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsReporter = bool(v != 0) + 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 *QueryReportersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -5621,7 +6041,7 @@ func (m *QueryRequestVerificationRequest) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Reporter", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5631,27 +6051,23 @@ func (m *QueryRequestVerificationRequest) 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 m.Reporter == nil { - m.Reporter = &types.Any{} - } - if err := m.Reporter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Reporter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 6: if wireType != 2 { diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index a8320f8cd..110f4e2ab 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -373,6 +373,82 @@ func local_request_Query_Validator_0(ctx context.Context, marshaler runtime.Mars } +func request_Query_IsReporter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIsReporterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + val, ok = pathParams["reporter_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reporter_address") + } + + protoReq.ReporterAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reporter_address", err) + } + + msg, err := client.IsReporter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IsReporter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIsReporterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + val, ok = pathParams["reporter_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reporter_address") + } + + protoReq.ReporterAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reporter_address", err) + } + + msg, err := server.IsReporter(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_Reporters_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryReportersRequest var metadata runtime.ServerMetadata @@ -717,6 +793,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_IsReporter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IsReporter_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IsReporter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Reporters_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1018,6 +1114,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_IsReporter_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_IsReporter_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_IsReporter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Reporters_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1156,6 +1272,8 @@ var ( pattern_Query_Validator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"oracle", "v1", "validators", "validator_address"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_IsReporter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"oracle", "v1", "reporter", "validator_address", "reporter_address"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Reporters_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"oracle", "v1", "reporters", "validator_address"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_ActiveValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"oracle", "v1", "active_validators"}, "", runtime.AssumeColonVerbOpt(true))) @@ -1184,6 +1302,8 @@ var ( forward_Query_Validator_0 = runtime.ForwardResponseMessage + forward_Query_IsReporter_0 = runtime.ForwardResponseMessage + forward_Query_Reporters_0 = runtime.ForwardResponseMessage forward_Query_ActiveValidators_0 = runtime.ForwardResponseMessage diff --git a/yoda/executor/rest.go b/yoda/executor/rest.go index 6cee20a39..5e01bdb1d 100644 --- a/yoda/executor/rest.go +++ b/yoda/executor/rest.go @@ -51,7 +51,7 @@ func (e *RestExec) Exec(code []byte, arg string, env interface{}) (ExecResult, e return ExecResult{Output: []byte{}, Code: 111}, nil } - if resp.Ok != true { + if !resp.Ok { return ExecResult{}, ErrRestNotOk } diff --git a/yoda/handler.go b/yoda/handler.go index 955487567..81173da9c 100644 --- a/yoda/handler.go +++ b/yoda/handler.go @@ -237,7 +237,7 @@ func handleRawRequest(c *Context, l *Logger, req rawRequest, key keyring.Info, i "BAND_VALIDATOR": vmsg.Validator, "BAND_REQUEST_ID": strconv.Itoa(int(vmsg.RequestID)), "BAND_EXTERNAL_ID": strconv.Itoa(int(vmsg.ExternalID)), - "BAND_REPORTER": pubkey, + "BAND_REPORTER": hex.EncodeToString(pubkey.Bytes()), "BAND_SIGNATURE": sig, }) diff --git a/yoda/keys.go b/yoda/keys.go index ae1a88a30..888a398da 100644 --- a/yoda/keys.go +++ b/yoda/keys.go @@ -2,15 +2,20 @@ package yoda import ( "bufio" + "context" "fmt" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/crypto/hd" bip39 "github.com/cosmos/go-bip39" + "github.com/kyokomi/emoji" "github.com/spf13/cobra" "github.com/spf13/viper" band "github.com/bandprotocol/chain/v2/app" + "github.com/bandprotocol/chain/v2/x/oracle/types" ) const ( @@ -136,6 +141,10 @@ func keysListCmd(c *Context) *cobra.Command { Short: "List all the keys in the keychain", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } keys, err := kb.List() if err != nil { return err @@ -145,14 +154,31 @@ func keysListCmd(c *Context) *cobra.Command { if isShowAddr { fmt.Printf("%s ", key.GetAddress().String()) } else { - fmt.Printf("%s => %s\n", key.GetName(), key.GetAddress().String()) + queryClient := types.NewQueryClient(clientCtx) + r, err := queryClient.IsReporter( + context.Background(), + &types.QueryIsReporterRequest{ValidatorAddress: cfg.Validator, ReporterAddress: key.GetAddress().String()}, + ) + s := ":question:" + if err == nil { + if r.IsReporter { + s = ":white_check_mark:" + } else { + s = ":x:" + } + } + emoji.Printf("%s%s => %s\n", s, key.GetName(), key.GetAddress().String()) } } + return nil }, } cmd.Flags().BoolP(flagAddress, "a", false, "Output the address only") viper.BindPFlag(flagAddress, cmd.Flags().Lookup(flagAddress)) + + flags.AddQueryFlagsToCmd(cmd) + return cmd } From ba78b53d7b382b2dcb9fd2355fc187a66c7eb999 Mon Sep 17 00:00:00 2001 From: taobun Date: Thu, 19 Aug 2021 10:30:48 +0700 Subject: [PATCH 03/11] Add IsReporter proto --- proto/oracle/v1/query.proto | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/proto/oracle/v1/query.proto b/proto/oracle/v1/query.proto index 0e484e78b..e2ce2c788 100644 --- a/proto/oracle/v1/query.proto +++ b/proto/oracle/v1/query.proto @@ -54,6 +54,12 @@ service Query { option (google.api.http).get = "/oracle/v1/validators/{validator_address}"; } + // IsReporter queries grant of account on this validator. + rpc IsReporter(QueryIsReporterRequest) returns (QueryIsReporterResponse) { + option (google.api.http).get = + "/oracle/v1/reporter/{validator_address}/{reporter_address}"; + } + // Reporters queries all reporters associated with given validator address. rpc Reporters(QueryReportersRequest) returns (QueryReportersResponse) { option (google.api.http).get = "/oracle/v1/reporters/{validator_address}"; @@ -195,6 +201,20 @@ message QueryValidatorResponse { ValidatorStatus status = 1; } +// QueryIsReporterRequest is request type for the Query/Reporter RPC method. +message QueryIsReporterRequest { + // ValidatorAddress is a validator address + string validator_address = 1; + // ReporterAddress is a candidate account + string reporter_address = 2; +} + +// QueryIsReporterResponse is response type for the Query/Reporter RPC method. +message QueryIsReporterResponse { + // IsReporter is true if this account has been granted by validator + bool is_reporter = 1; +} + // QueryReportersRequest is request type for the Query/Reporters RPC method. message QueryReportersRequest { // ValidatorAddress is a validator address @@ -271,10 +291,7 @@ message QueryRequestVerificationRequest { uint64 external_id = 4; // Reporter is an bech32-encoded public key of the reporter authorized by the // validator - google.protobuf.Any reporter = 5 [ - (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", - (gogoproto.moretags) = "yaml:\"reporter\"" - ]; + string reporter = 5; // Signature is a signature signed by the reporter using reporter's private // key bytes signature = 6; From 68cf7aaf42c9dff39e148923704b482cfceab030 Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 11:17:24 +0700 Subject: [PATCH 04/11] ante test suite --- x/oracle/ante/ante_test.go | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 x/oracle/ante/ante_test.go diff --git a/x/oracle/ante/ante_test.go b/x/oracle/ante/ante_test.go new file mode 100644 index 000000000..3aee6d8c5 --- /dev/null +++ b/x/oracle/ante/ante_test.go @@ -0,0 +1,140 @@ +package ante_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/authz" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" + + "github.com/bandprotocol/chain/v2/testing/testapp" + bandante "github.com/bandprotocol/chain/v2/x/oracle/ante" + "github.com/bandprotocol/chain/v2/x/oracle/keeper" + "github.com/bandprotocol/chain/v2/x/oracle/types" +) + +type MyStubTx struct { + sdk.Tx + Msgs []sdk.Msg +} + +func (mst *MyStubTx) GetMsgs() []sdk.Msg { + return mst.Msgs +} + +type MyMockAnte struct { + mock.Mock +} + +func (m *MyMockAnte) Ante(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + + m.Called(ctx, tx, simulate) + return ctx, nil +} + +type AnteTestSuit struct { + suite.Suite + ctx sdk.Context + oracleKeeper keeper.Keeper + mockAnte *MyMockAnte + gaslessAnte sdk.AnteHandler + requestId types.RequestID +} + +func (suite *AnteTestSuit) SetupTest() { + _, suite.ctx, suite.oracleKeeper = testapp.CreateTestInput(true) + suite.ctx = suite.ctx.WithBlockHeight(999).WithIsCheckTx(true).WithMinGasPrices(sdk.DecCoins{{Denom: "uband", Amount: sdk.NewDec(14000)}}) + + suite.oracleKeeper.GrantReporter(suite.ctx, testapp.Validators[0].ValAddress, testapp.Alice.Address) + + req := types.NewRequest(1, []byte("BASIC_CALLDATA"), []sdk.ValAddress{testapp.Validators[0].ValAddress}, 1, 1, testapp.ParseTime(0), "", nil, nil, 0) + suite.requestId = suite.oracleKeeper.AddRequest(suite.ctx, req) + + suite.mockAnte = new(MyMockAnte) + suite.gaslessAnte = bandante.NewFeelessReportsAnteHandler(suite.mockAnte.Ante, suite.oracleKeeper) +} + +func (suite *AnteTestSuit) TestValidRawReport() { + + msgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} + stubTx := &MyStubTx{Msgs: msgs} + + suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTx, false) + ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) + + suite.mockAnte.AssertExpectations(suite.T()) + suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) + suite.Require().Equal(err, nil) +} + +func (suite *AnteTestSuit) TestNotValidRawReport() { + msgs := []sdk.Msg{types.NewMsgReportData(1, []types.RawReport{}, testapp.Alice.ValAddress)} + stubTx := &MyStubTx{Msgs: msgs} + + ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) + + suite.Require().Equal(ctx, suite.ctx) + suite.Require().Error(err) +} + +func (suite *AnteTestSuit) TestValidReport() { + reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} + autzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) + stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} + + suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTx, false) + ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) + + suite.mockAnte.AssertExpectations(suite.T()) + suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) + suite.Require().Equal(err, nil) +} + +func (suite *AnteTestSuit) TestNoAuthzReport() { + reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} + autzMsg := authz.NewMsgExec(testapp.Bob.Address, reportMsgs) + stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} + + _, err := suite.gaslessAnte(suite.ctx, stubTx, false) + + suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) + suite.Require().EqualError(err, sdkerrors.ErrUnauthorized.Wrap("authorization not found").Error()) +} + +func (suite *AnteTestSuit) TestNotValidReport() { + reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId+1, []types.RawReport{}, testapp.Validators[0].ValAddress)} + autzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) + stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} + + _, err := suite.gaslessAnte(suite.ctx, stubTx, false) + + suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) + suite.Require().Error(err) +} + +func (suite *AnteTestSuit) TestNotReportMsg() { + requetMsg := types.NewMsgRequestData(1, []byte("BASIC_CALLDATA"), 1, 1, "BASIC_CLIENT_ID", testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} + + suite.mockAnte.On("Ante", suite.ctx, stubTx, false) + suite.gaslessAnte(suite.ctx, stubTx, false) + + suite.mockAnte.AssertExpectations(suite.T()) +} + +func (suite *AnteTestSuit) TestNotReportMsgButReportOnlyBlock() { + suite.ctx = suite.ctx.WithBlockHeight(0) + requetMsg := types.NewMsgRequestData(1, []byte("BASIC_CALLDATA"), 1, 1, "BASIC_CLIENT_ID", testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} + + _, err := suite.gaslessAnte(suite.ctx, stubTx, false) + + suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) + suite.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Block reserved for report txs").Error()) +} + +func TestAnteTestSuite(t *testing.T) { + suite.Run(t, new(AnteTestSuit)) +} From 27df1b4493e077bbe9012841bdf7a99e40e0fcbc Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 12:57:35 +0700 Subject: [PATCH 05/11] assert mock ante --- x/oracle/ante/ante_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/x/oracle/ante/ante_test.go b/x/oracle/ante/ante_test.go index 3aee6d8c5..b598f2598 100644 --- a/x/oracle/ante/ante_test.go +++ b/x/oracle/ante/ante_test.go @@ -15,6 +15,11 @@ import ( "github.com/bandprotocol/chain/v2/x/oracle/types" ) +var ( + BasicCalldata = []byte("BASIC_CALLDATA") + BasicClientID = "BASIC_CLIENT_ID" +) + type MyStubTx struct { sdk.Tx Msgs []sdk.Msg @@ -49,7 +54,7 @@ func (suite *AnteTestSuit) SetupTest() { suite.oracleKeeper.GrantReporter(suite.ctx, testapp.Validators[0].ValAddress, testapp.Alice.Address) - req := types.NewRequest(1, []byte("BASIC_CALLDATA"), []sdk.ValAddress{testapp.Validators[0].ValAddress}, 1, 1, testapp.ParseTime(0), "", nil, nil, 0) + req := types.NewRequest(1, BasicCalldata, []sdk.ValAddress{testapp.Validators[0].ValAddress}, 1, 1, testapp.ParseTime(0), "", nil, nil, 0) suite.requestId = suite.oracleKeeper.AddRequest(suite.ctx, req) suite.mockAnte = new(MyMockAnte) @@ -115,18 +120,20 @@ func (suite *AnteTestSuit) TestNotValidReport() { } func (suite *AnteTestSuit) TestNotReportMsg() { - requetMsg := types.NewMsgRequestData(1, []byte("BASIC_CALLDATA"), 1, 1, "BASIC_CLIENT_ID", testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + requetMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} suite.mockAnte.On("Ante", suite.ctx, stubTx, false) - suite.gaslessAnte(suite.ctx, stubTx, false) + ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertExpectations(suite.T()) + suite.Require().Equal(ctx, suite.ctx) + suite.Require().Equal(err, nil) } func (suite *AnteTestSuit) TestNotReportMsgButReportOnlyBlock() { suite.ctx = suite.ctx.WithBlockHeight(0) - requetMsg := types.NewMsgRequestData(1, []byte("BASIC_CALLDATA"), 1, 1, "BASIC_CLIENT_ID", testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + requetMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} _, err := suite.gaslessAnte(suite.ctx, stubTx, false) From a8b5c052bb9b17c2257eb4005d9b2733c551158d Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 13:40:59 +0700 Subject: [PATCH 06/11] rename ante --- x/oracle/ante/ante_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/x/oracle/ante/ante_test.go b/x/oracle/ante/ante_test.go index b598f2598..cb6ec28a2 100644 --- a/x/oracle/ante/ante_test.go +++ b/x/oracle/ante/ante_test.go @@ -44,7 +44,7 @@ type AnteTestSuit struct { ctx sdk.Context oracleKeeper keeper.Keeper mockAnte *MyMockAnte - gaslessAnte sdk.AnteHandler + feelessAnte sdk.AnteHandler requestId types.RequestID } @@ -58,7 +58,7 @@ func (suite *AnteTestSuit) SetupTest() { suite.requestId = suite.oracleKeeper.AddRequest(suite.ctx, req) suite.mockAnte = new(MyMockAnte) - suite.gaslessAnte = bandante.NewFeelessReportsAnteHandler(suite.mockAnte.Ante, suite.oracleKeeper) + suite.feelessAnte = bandante.NewFeelessReportsAnteHandler(suite.mockAnte.Ante, suite.oracleKeeper) } func (suite *AnteTestSuit) TestValidRawReport() { @@ -67,7 +67,7 @@ func (suite *AnteTestSuit) TestValidRawReport() { stubTx := &MyStubTx{Msgs: msgs} suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTx, false) - ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) + ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertExpectations(suite.T()) suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) @@ -78,7 +78,7 @@ func (suite *AnteTestSuit) TestNotValidRawReport() { msgs := []sdk.Msg{types.NewMsgReportData(1, []types.RawReport{}, testapp.Alice.ValAddress)} stubTx := &MyStubTx{Msgs: msgs} - ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) + ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.Require().Equal(ctx, suite.ctx) suite.Require().Error(err) @@ -90,7 +90,7 @@ func (suite *AnteTestSuit) TestValidReport() { stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTx, false) - ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) + ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertExpectations(suite.T()) suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) @@ -102,7 +102,7 @@ func (suite *AnteTestSuit) TestNoAuthzReport() { autzMsg := authz.NewMsgExec(testapp.Bob.Address, reportMsgs) stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} - _, err := suite.gaslessAnte(suite.ctx, stubTx, false) + _, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) suite.Require().EqualError(err, sdkerrors.ErrUnauthorized.Wrap("authorization not found").Error()) @@ -113,7 +113,7 @@ func (suite *AnteTestSuit) TestNotValidReport() { autzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} - _, err := suite.gaslessAnte(suite.ctx, stubTx, false) + _, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) suite.Require().Error(err) @@ -124,7 +124,7 @@ func (suite *AnteTestSuit) TestNotReportMsg() { stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} suite.mockAnte.On("Ante", suite.ctx, stubTx, false) - ctx, err := suite.gaslessAnte(suite.ctx, stubTx, false) + ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertExpectations(suite.T()) suite.Require().Equal(ctx, suite.ctx) @@ -136,7 +136,7 @@ func (suite *AnteTestSuit) TestNotReportMsgButReportOnlyBlock() { requetMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} - _, err := suite.gaslessAnte(suite.ctx, stubTx, false) + _, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) suite.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Block reserved for report txs").Error()) From fa6287745dd5aad9e785082f826e803b88d69823 Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 15:39:02 +0700 Subject: [PATCH 07/11] typo fixed --- x/oracle/ante/ante_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/x/oracle/ante/ante_test.go b/x/oracle/ante/ante_test.go index cb6ec28a2..dc123e37e 100644 --- a/x/oracle/ante/ante_test.go +++ b/x/oracle/ante/ante_test.go @@ -71,7 +71,7 @@ func (suite *AnteTestSuit) TestValidRawReport() { suite.mockAnte.AssertExpectations(suite.T()) suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) - suite.Require().Equal(err, nil) + suite.Require().NoError(err) } func (suite *AnteTestSuit) TestNotValidRawReport() { @@ -86,21 +86,21 @@ func (suite *AnteTestSuit) TestNotValidRawReport() { func (suite *AnteTestSuit) TestValidReport() { reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} - autzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) - stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} + authzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) + stubTx := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTx, false) ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertExpectations(suite.T()) suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) - suite.Require().Equal(err, nil) + suite.Require().NoError(err) } func (suite *AnteTestSuit) TestNoAuthzReport() { reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} - autzMsg := authz.NewMsgExec(testapp.Bob.Address, reportMsgs) - stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} + authzMsg := authz.NewMsgExec(testapp.Bob.Address, reportMsgs) + stubTx := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} _, err := suite.feelessAnte(suite.ctx, stubTx, false) @@ -110,8 +110,8 @@ func (suite *AnteTestSuit) TestNoAuthzReport() { func (suite *AnteTestSuit) TestNotValidReport() { reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId+1, []types.RawReport{}, testapp.Validators[0].ValAddress)} - autzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) - stubTx := &MyStubTx{Msgs: []sdk.Msg{&autzMsg}} + authzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) + stubTx := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} _, err := suite.feelessAnte(suite.ctx, stubTx, false) @@ -120,21 +120,21 @@ func (suite *AnteTestSuit) TestNotValidReport() { } func (suite *AnteTestSuit) TestNotReportMsg() { - requetMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) - stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} + requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + stubTx := &MyStubTx{Msgs: []sdk.Msg{requestMsg}} suite.mockAnte.On("Ante", suite.ctx, stubTx, false) ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) suite.mockAnte.AssertExpectations(suite.T()) suite.Require().Equal(ctx, suite.ctx) - suite.Require().Equal(err, nil) + suite.Require().NoError(err) } func (suite *AnteTestSuit) TestNotReportMsgButReportOnlyBlock() { suite.ctx = suite.ctx.WithBlockHeight(0) - requetMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) - stubTx := &MyStubTx{Msgs: []sdk.Msg{requetMsg}} + requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + stubTx := &MyStubTx{Msgs: []sdk.Msg{requestMsg}} _, err := suite.feelessAnte(suite.ctx, stubTx, false) From 2910f8699bde4b0512087e5269e206d69b005188 Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 16:15:31 +0700 Subject: [PATCH 08/11] TestNotReportMsgOnReportOnlyBlockByCash --- x/oracle/ante/ante_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/x/oracle/ante/ante_test.go b/x/oracle/ante/ante_test.go index dc123e37e..58dd5bf08 100644 --- a/x/oracle/ante/ante_test.go +++ b/x/oracle/ante/ante_test.go @@ -142,6 +142,28 @@ func (suite *AnteTestSuit) TestNotReportMsgButReportOnlyBlock() { suite.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Block reserved for report txs").Error()) } +func (suite *AnteTestSuit) TestNotReportMsgOnReportOnlyBlockByCash() { + reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} + authzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) + stubTxReport := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} + requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + stubTxNotReport := &MyStubTx{Msgs: []sdk.Msg{requestMsg}} + + suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTxReport, false) + suite.feelessAnte(suite.ctx, stubTxReport, false) + + suite.ctx = suite.ctx.WithBlockHeight(suite.ctx.BlockHeight() + 21) + suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTxReport, false) + suite.feelessAnte(suite.ctx, stubTxReport, false) + + suite.ctx = suite.ctx.WithBlockHeight(suite.ctx.BlockHeight() + 1) + _, err := suite.feelessAnte(suite.ctx, stubTxNotReport, false) + + suite.mockAnte.AssertExpectations(suite.T()) + suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 2) + suite.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Block reserved for report txs").Error()) +} + func TestAnteTestSuite(t *testing.T) { suite.Run(t, new(AnteTestSuit)) } From 5ac253c8a0f6f5bddfac4ea434f9f68e216b3c4d Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 16:46:36 +0700 Subject: [PATCH 09/11] added comment --- x/oracle/ante/ante_test.go | 43 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/x/oracle/ante/ante_test.go b/x/oracle/ante/ante_test.go index 58dd5bf08..47489967c 100644 --- a/x/oracle/ante/ante_test.go +++ b/x/oracle/ante/ante_test.go @@ -29,13 +29,14 @@ func (mst *MyStubTx) GetMsgs() []sdk.Msg { return mst.Msgs } +//mock object for tracking behavior of ante function type MyMockAnte struct { mock.Mock } func (m *MyMockAnte) Ante(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { - m.Called(ctx, tx, simulate) + //make the function return the same contex as in argument list and no error for the ease of testing return ctx, nil } @@ -62,14 +63,17 @@ func (suite *AnteTestSuit) SetupTest() { } func (suite *AnteTestSuit) TestValidRawReport() { - msgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} stubTx := &MyStubTx{Msgs: msgs} + //makes an expectation when call function 'Ante' of 'mockAnte' object + //valid report Msg was called by ante function without minGasPrice suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTx, false) ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) + //asserts all everything specificed with 'On' was in fact called as expected of the 'mockAnte' object suite.mockAnte.AssertExpectations(suite.T()) + //the contex's minGasPrice should be the same as before had been validated by ante function suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) suite.Require().NoError(err) } @@ -78,8 +82,11 @@ func (suite *AnteTestSuit) TestNotValidRawReport() { msgs := []sdk.Msg{types.NewMsgReportData(1, []types.RawReport{}, testapp.Alice.ValAddress)} stubTx := &MyStubTx{Msgs: msgs} + //no need to make an expectaion because ante function will not be called by this condition ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) + //make sure that ante function was not called + suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) suite.Require().Equal(ctx, suite.ctx) suite.Require().Error(err) } @@ -89,10 +96,14 @@ func (suite *AnteTestSuit) TestValidReport() { authzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) stubTx := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} + //makes an expectation when call function 'Ante' of 'mockAnte' object + //valid report Msg was called by ante function without minGasPrice suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTx, false) ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) + //asserts all everything specificed with 'On' was in fact called as expected of the 'mockAnte' object suite.mockAnte.AssertExpectations(suite.T()) + //the contex's minGasPrice should be the same as before had been validated by ante function suite.Require().Equal(ctx.MinGasPrices(), suite.ctx.MinGasPrices()) suite.Require().NoError(err) } @@ -102,8 +113,10 @@ func (suite *AnteTestSuit) TestNoAuthzReport() { authzMsg := authz.NewMsgExec(testapp.Bob.Address, reportMsgs) stubTx := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} + //no need to make an expectaion because ante function will not be called by this condition _, err := suite.feelessAnte(suite.ctx, stubTx, false) + //make sure that ante function was not called suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) suite.Require().EqualError(err, sdkerrors.ErrUnauthorized.Wrap("authorization not found").Error()) } @@ -113,8 +126,10 @@ func (suite *AnteTestSuit) TestNotValidReport() { authzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) stubTx := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} + //no need to make an expectaion because ante function will not be called by this condition _, err := suite.feelessAnte(suite.ctx, stubTx, false) + //make sure that ante function was not called suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) suite.Require().Error(err) } @@ -123,25 +138,17 @@ func (suite *AnteTestSuit) TestNotReportMsg() { requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) stubTx := &MyStubTx{Msgs: []sdk.Msg{requestMsg}} + //makes an expectation when call function 'Ante' of 'mockAnte' object + //others type Msg was normally called by ante function suite.mockAnte.On("Ante", suite.ctx, stubTx, false) ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) + //asserts all everything specificed with 'On' was in fact called as expected of the 'mockAnte' object suite.mockAnte.AssertExpectations(suite.T()) suite.Require().Equal(ctx, suite.ctx) suite.Require().NoError(err) } -func (suite *AnteTestSuit) TestNotReportMsgButReportOnlyBlock() { - suite.ctx = suite.ctx.WithBlockHeight(0) - requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) - stubTx := &MyStubTx{Msgs: []sdk.Msg{requestMsg}} - - _, err := suite.feelessAnte(suite.ctx, stubTx, false) - - suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 0) - suite.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Block reserved for report txs").Error()) -} - func (suite *AnteTestSuit) TestNotReportMsgOnReportOnlyBlockByCash() { reportMsgs := []sdk.Msg{types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress)} authzMsg := authz.NewMsgExec(testapp.Alice.Address, reportMsgs) @@ -149,17 +156,27 @@ func (suite *AnteTestSuit) TestNotReportMsgOnReportOnlyBlockByCash() { requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) stubTxNotReport := &MyStubTx{Msgs: []sdk.Msg{requestMsg}} + //makes an expectation when call function 'Ante' of 'mockAnte' object + //valid report Msg was called by ante function without minGasPrice suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTxReport, false) suite.feelessAnte(suite.ctx, stubTxReport, false) + //do the simulating as the proposal block had been passed for 21 blocks suite.ctx = suite.ctx.WithBlockHeight(suite.ctx.BlockHeight() + 21) + //makes an expectation when call function 'Ante' of 'mockAnte' object + //valid report Msg was called by ante function without minGasPrice + //need to make another expectation because blockHeight of 'suite.ctx' have been changed suite.mockAnte.On("Ante", suite.ctx.WithMinGasPrices(sdk.DecCoins{}), stubTxReport, false) suite.feelessAnte(suite.ctx, stubTxReport, false) + //do the simulating as the proposal block had passed for a block suite.ctx = suite.ctx.WithBlockHeight(suite.ctx.BlockHeight() + 1) + //no need to make an expectaion because ante function will not be called by this condition _, err := suite.feelessAnte(suite.ctx, stubTxNotReport, false) + //asserts all everything specificed with 'On' was in fact called as expected of the 'mockAnte' object suite.mockAnte.AssertExpectations(suite.T()) + //the method 'Ante' was called only 2 times because the last 'feelessAnte' execution had been rejected by the block reserved for report txs only reason suite.mockAnte.AssertNumberOfCalls(suite.T(), "Ante", 2) suite.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Block reserved for report txs").Error()) } From c451f918467cdf6b6aba1dbb66bcf3f45ba1c33a Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 18:06:30 +0700 Subject: [PATCH 10/11] remove todo comment --- x/oracle/ante/ante.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/x/oracle/ante/ante.go b/x/oracle/ante/ante.go index 293ff8d3b..96a15c7cb 100644 --- a/x/oracle/ante/ante.go +++ b/x/oracle/ante/ante.go @@ -25,8 +25,6 @@ func init() { } } -// TODO: Add test on this ante before merge - func checkValidReportMsg(ctx sdk.Context, oracleKeeper keeper.Keeper, r *types.MsgReportData) error { validator, err := sdk.ValAddressFromBech32(r.Validator) if err != nil { From 706d838fe7ad95b9691c450d8d21e5d7243b594b Mon Sep 17 00:00:00 2001 From: "kissada147@gmail.com" Date: Mon, 23 Aug 2021 18:43:59 +0700 Subject: [PATCH 11/11] add multi msgs test --- x/oracle/ante/ante_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/x/oracle/ante/ante_test.go b/x/oracle/ante/ante_test.go index 47489967c..3bddee16c 100644 --- a/x/oracle/ante/ante_test.go +++ b/x/oracle/ante/ante_test.go @@ -181,6 +181,40 @@ func (suite *AnteTestSuit) TestNotReportMsgOnReportOnlyBlockByCash() { suite.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Block reserved for report txs").Error()) } +func (suite *AnteTestSuit) TestReportMsgAndOthersTypeMsgInTheSameAuthzMsgs() { + reportMsg := types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress) + requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + msgs := []sdk.Msg{reportMsg, requestMsg} + authzMsg := authz.NewMsgExec(testapp.Alice.Address, msgs) + stubTx := &MyStubTx{Msgs: []sdk.Msg{&authzMsg}} + + //makes an expectation when call function 'Ante' of 'mockAnte' object + //the authzMsgs have others type Msg was normally called by ante function + suite.mockAnte.On("Ante", suite.ctx, stubTx, false) + ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) + + //asserts all everything specificed with 'On' was in fact called as expected of the 'mockAnte' object + suite.mockAnte.AssertExpectations(suite.T()) + suite.Require().Equal(ctx, suite.ctx) + suite.Require().NoError(err) +} + +func (suite *AnteTestSuit) TestReportMsgAndOthersTypeMsgInTheSameTx() { + reportMsg := types.NewMsgReportData(suite.requestId, []types.RawReport{}, testapp.Validators[0].ValAddress) + requestMsg := types.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000uband, testapp.TestDefaultPrepareGas, testapp.TestDefaultExecuteGas, testapp.FeePayer.Address) + stubTx := &MyStubTx{Msgs: []sdk.Msg{reportMsg, requestMsg}} + + //makes an expectation when call function 'Ante' of 'mockAnte' object + //the tx has others type Msg was normally called by ante function + suite.mockAnte.On("Ante", suite.ctx, stubTx, false) + ctx, err := suite.feelessAnte(suite.ctx, stubTx, false) + + //asserts all everything specificed with 'On' was in fact called as expected of the 'mockAnte' object + suite.mockAnte.AssertExpectations(suite.T()) + suite.Require().Equal(ctx, suite.ctx) + suite.Require().NoError(err) +} + func TestAnteTestSuite(t *testing.T) { suite.Run(t, new(AnteTestSuit)) }