From d0ee57128eb6536b1556d58203a5c2e9fd96866b Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Thu, 20 Apr 2023 16:46:31 +0800 Subject: [PATCH] feat: define the turn for submitting attestation --- deployment/localup/localup.sh | 1 + e2e/tests/challenge_test.go | 59 +- proto/greenfield/challenge/params.proto | 6 + proto/greenfield/challenge/query.proto | 33 +- proto/greenfield/challenge/types.proto | 13 + x/challenge/client/cli/query.go | 60 +- .../cli/query_latest_attested_challenge.go | 43 - x/challenge/keeper/bls_signed_msg.go | 10 +- x/challenge/keeper/challenge.go | 90 +- x/challenge/keeper/challenge_test.go | 33 + x/challenge/keeper/grpc_query.go | 40 + .../grpc_query_latest_attested_challenge.go | 25 - x/challenge/keeper/keeper.go | 55 ++ x/challenge/keeper/msg_server_attest.go | 17 +- x/challenge/keeper/params.go | 20 +- x/challenge/types/errors.go | 2 + x/challenge/types/keys.go | 16 +- x/challenge/types/params.go | 64 +- x/challenge/types/params.pb.go | 150 ++- x/challenge/types/query.pb.go | 864 ++++++++++++++++-- x/challenge/types/query.pb.gw.go | 93 +- x/challenge/types/types.pb.go | 355 ++++++- 22 files changed, 1748 insertions(+), 301 deletions(-) delete mode 100644 x/challenge/client/cli/query_latest_attested_challenge.go delete mode 100644 x/challenge/keeper/grpc_query_latest_attested_challenge.go diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index 3a84f72e1..bd58c41a0 100644 --- a/deployment/localup/localup.sh +++ b/deployment/localup/localup.sh @@ -146,6 +146,7 @@ function generate_genesis() { sed -i -e "s/\"challenge_count_per_block\": \"1\"/\"challenge_count_per_block\": \"5\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"challenge_keep_alive_period\": \"300\"/\"challenge_keep_alive_period\": \"50\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"heartbeat_interval\": \"1000\"/\"heartbeat_interval\": \"100\"/g" ${workspace}/.local/validator${i}/config/genesis.json + sed -i -e "s/\"attestation_inturn_interval\": \"120\"/\"attestation_inturn_interval\": \"10\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"time_iota_ms\": \"1000\"/\"time_iota_ms\": \"10\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"discontinue_confirm_period\": \"604800\"/\"discontinue_confirm_period\": \"15\"/g" ${workspace}/.local/validator${i}/config/genesis.json done diff --git a/e2e/tests/challenge_test.go b/e2e/tests/challenge_test.go index 946eea88d..da65eee03 100644 --- a/e2e/tests/challenge_test.go +++ b/e2e/tests/challenge_test.go @@ -178,7 +178,7 @@ func (s *ChallengeTestSuite) TestNormalAttest() { valBitset := s.calculateValidatorBitSet(height, s.ValidatorBLS.PubKey().String()) - msgAttest := challengetypes.NewMsgAttest(user.GetAddr(), event.ChallengeId, event.ObjectId, primarySp.String(), + msgAttest := challengetypes.NewMsgAttest(s.Challenger.GetAddr(), event.ChallengeId, event.ObjectId, primarySp.String(), challengetypes.CHALLENGE_SUCCEED, user.GetAddr().String(), valBitset.Bytes(), nil) toSign := msgAttest.GetBlsSignBytes() @@ -188,12 +188,33 @@ func (s *ChallengeTestSuite) TestNormalAttest() { } msgAttest.VoteAggSignature = voteAggSignature - txRes = s.SendTxBlock(msgAttest, user) + // wait to its turn + for { + queryRes, err := s.Client.ChallengeQueryClient.InturnAttestationSubmitter(context.Background(), &challengetypes.QueryInturnAttestationSubmitterRequest{}) + s.Require().NoError(err) + + s.T().Logf("current submitter %s, interval: %d - %d", queryRes.BlsPubKey, + queryRes.SubmitInterval.Start, queryRes.SubmitInterval.End) + + if queryRes.BlsPubKey == hex.EncodeToString(s.ValidatorBLS.GetPrivKey().PubKey().Bytes()) { + break + } + } + + // submit attest + txRes = s.SendTxBlock(msgAttest, s.Challenger) s.Require().True(txRes.Code == 0) - queryRes, err := s.Client.ChallengeQueryClient.LatestAttestedChallenge(context.Background(), &challengetypes.QueryLatestAttestedChallengeRequest{}) + queryRes, err := s.Client.ChallengeQueryClient.LatestAttestedChallenges(context.Background(), &challengetypes.QueryLatestAttestedChallengesRequest{}) s.Require().NoError(err) - s.Require().True(queryRes.ChallengeId == event.ChallengeId) + found := false + for _, challengeId := range queryRes.ChallengeIds { + if challengeId == event.ChallengeId { + found = true + break + } + } + s.Require().True(found) } func (s *ChallengeTestSuite) TestHeartbeatAttest() { @@ -202,7 +223,6 @@ func (s *ChallengeTestSuite) TestHeartbeatAttest() { } heartbeatInterval := uint64(100) - user := s.GenAndChargeAccounts(1, 1000000)[0] var event challengetypes.EventStartChallenge found := false @@ -236,7 +256,7 @@ func (s *ChallengeTestSuite) TestHeartbeatAttest() { valBitset := s.calculateValidatorBitSet(height, s.ValidatorBLS.PubKey().String()) - msgAttest := challengetypes.NewMsgAttest(user.GetAddr(), event.ChallengeId, event.ObjectId, + msgAttest := challengetypes.NewMsgAttest(s.Challenger.GetAddr(), event.ChallengeId, event.ObjectId, event.SpOperatorAddress, challengetypes.CHALLENGE_FAILED, "", valBitset.Bytes(), nil) toSign := msgAttest.GetBlsSignBytes() @@ -246,12 +266,33 @@ func (s *ChallengeTestSuite) TestHeartbeatAttest() { } msgAttest.VoteAggSignature = voteAggSignature - txRes := s.SendTxBlock(msgAttest, user) + // wait to its turn + for { + queryRes, err := s.Client.ChallengeQueryClient.InturnAttestationSubmitter(context.Background(), &challengetypes.QueryInturnAttestationSubmitterRequest{}) + s.Require().NoError(err) + + s.T().Logf("current submitter %s, interval: %d - %d", queryRes.BlsPubKey, + queryRes.SubmitInterval.Start, queryRes.SubmitInterval.End) + + if queryRes.BlsPubKey == hex.EncodeToString(s.ValidatorBLS.GetPrivKey().PubKey().Bytes()) { + break + } + } + + // submit attest + txRes := s.SendTxBlock(msgAttest, s.Challenger) s.Require().True(txRes.Code == 0) - queryRes, err := s.Client.ChallengeQueryClient.LatestAttestedChallenge(context.Background(), &challengetypes.QueryLatestAttestedChallengeRequest{}) + queryRes, err := s.Client.ChallengeQueryClient.LatestAttestedChallenges(context.Background(), &challengetypes.QueryLatestAttestedChallengesRequest{}) s.Require().NoError(err) - s.Require().True(queryRes.ChallengeId == event.ChallengeId) + found = false + for _, challengeId := range queryRes.ChallengeIds { + if challengeId == event.ChallengeId { + found = true + break + } + } + s.Require().True(found) } func (s *ChallengeTestSuite) TestFailedAttest_ChallengeExpired() { diff --git a/proto/greenfield/challenge/params.proto b/proto/greenfield/challenge/params.proto index 7933eca34..043a33916 100644 --- a/proto/greenfield/challenge/params.proto +++ b/proto/greenfield/challenge/params.proto @@ -63,4 +63,10 @@ message Params { // Heartbeat interval, based on challenge id, defines the frequency of heartbeat attestation. uint64 heartbeat_interval = 10 [(gogoproto.moretags) = "yaml:\"heartbeat_interval\""]; + + // The time duration for each submitter to submit attestations in turn. + uint64 attestation_inturn_interval = 11 [(gogoproto.moretags) = "yaml:\"attestation_inturn_interval\""]; + + // The number of kept attested challenge ids, which can be queried by clients. + uint64 attestation_kept_count = 12 [(gogoproto.moretags) = "yaml:\"attestation_kept_count\""]; } diff --git a/proto/greenfield/challenge/query.proto b/proto/greenfield/challenge/query.proto index ad17e9476..a8d82e115 100644 --- a/proto/greenfield/challenge/query.proto +++ b/proto/greenfield/challenge/query.proto @@ -19,10 +19,14 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/greenfield/challenge/params"; } - // Queries the latest attested challenge id. - rpc LatestAttestedChallenge(QueryLatestAttestedChallengeRequest) returns (QueryLatestAttestedChallengeResponse) { + // Queries the latest attested challenge ids. + rpc LatestAttestedChallenges(QueryLatestAttestedChallengesRequest) returns (QueryLatestAttestedChallengesResponse) { option (google.api.http).get = "/greenfield/challenge/latest_attested_challenge"; } + // Queries the inturn challenger. + rpc InturnAttestationSubmitter(QueryInturnAttestationSubmitterRequest) returns (QueryInturnAttestationSubmitterResponse) { + option (google.api.http).get = "/greenfield/challenge/inturn_attestation_submitter"; + } // this line is used by starport scaffolding # 2 } @@ -36,12 +40,27 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } -// QueryParamsRequest is request type for the Query/LatestAttestedChallenge RPC method. -message QueryLatestAttestedChallengeRequest {} +// QueryLatestAttestedChallengesRequest is request type for the Query/LatestAttestedChallenges RPC method. +message QueryLatestAttestedChallengesRequest {} + +// QueryLatestAttestedChallengesResponse is response type for the Query/LatestAttestedChallenges RPC method. +message QueryLatestAttestedChallengesResponse { + repeated uint64 challengeIds = 1; +} + +// QueryInturnAttestationSubmitterRequest is request type for the Query/InturnAttestationSubmitter RPC method. +message QueryInturnAttestationSubmitterRequest {} + +// QueryInturnAttestationSubmitterResponse is response type for the Query/InturnAttestationSubmitter RPC method. +message QueryInturnAttestationSubmitterResponse { + string bls_pub_key = 1; + SubmitInterval submit_interval = 2; +} -// QueryParamsResponse is response type for the Query/LatestAttestedChallenge RPC method. -message QueryLatestAttestedChallengeResponse { - uint64 challengeId = 1; +// SubmitInterval holds start and end (exclusive) (i.e., [start, end)) time of in turn attestation. +message SubmitInterval { + uint64 start = 1; + uint64 end = 2; } // this line is used by starport scaffolding # 3 diff --git a/proto/greenfield/challenge/types.proto b/proto/greenfield/challenge/types.proto index f73b86883..7f81c8ac0 100644 --- a/proto/greenfield/challenge/types.proto +++ b/proto/greenfield/challenge/types.proto @@ -41,3 +41,16 @@ message Challenge { // The height at which the challenge will be expired. uint64 expired_height = 2; } + +// AttestedChallengeIds stored fixed number of the latest attested challenge ids. +// To use the storage more efficiently, a circular queue will be constructed using these fields. +message AttestedChallengeIds { + // The fixed number of challenge ids to save. + uint64 size = 1; + + // The latest attested challenge ids. + repeated uint64 ids = 2; + + // The cursor to retrieve data from the ids field. + int64 cursor = 3; +} diff --git a/x/challenge/client/cli/query.go b/x/challenge/client/cli/query.go index 941ed88b3..59ea95dde 100644 --- a/x/challenge/client/cli/query.go +++ b/x/challenge/client/cli/query.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" "github.com/bnb-chain/greenfield/x/challenge/types" @@ -21,9 +22,66 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) - cmd.AddCommand(CmdLatestAttestedChallenge()) + cmd.AddCommand(CmdLatestAttestedChallenges()) + cmd.AddCommand(CmdInturnChallenger()) // this line is used by starport scaffolding # 1 return cmd } + +func CmdLatestAttestedChallenges() *cobra.Command { + cmd := &cobra.Command{ + Use: "latest-attested-challenges", + Short: "Query latest attested challenges", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryLatestAttestedChallengesRequest{} + + res, err := queryClient.LatestAttestedChallenges(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdInturnChallenger() *cobra.Command { + cmd := &cobra.Command{ + Use: "inturn-attestation-submitter", + Short: "Query the inturn attestation submitter", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.InturnAttestationSubmitter(cmd.Context(), &types.QueryInturnAttestationSubmitterRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/challenge/client/cli/query_latest_attested_challenge.go b/x/challenge/client/cli/query_latest_attested_challenge.go deleted file mode 100644 index 0ffa3d452..000000000 --- a/x/challenge/client/cli/query_latest_attested_challenge.go +++ /dev/null @@ -1,43 +0,0 @@ -package cli - -import ( - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - - "github.com/bnb-chain/greenfield/x/challenge/types" -) - -var _ = strconv.Itoa(0) - -func CmdLatestAttestedChallenge() *cobra.Command { - cmd := &cobra.Command{ - Use: "latest-attested-challenge", - Short: "Query latest attested challenge", - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { - - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryLatestAttestedChallengeRequest{} - - res, err := queryClient.LatestAttestedChallenge(cmd.Context(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/challenge/keeper/bls_signed_msg.go b/x/challenge/keeper/bls_signed_msg.go index 9fd63e45a..28be92bb2 100644 --- a/x/challenge/keeper/bls_signed_msg.go +++ b/x/challenge/keeper/bls_signed_msg.go @@ -5,7 +5,7 @@ import ( "cosmossdk.io/errors" "github.com/bits-and-blooms/bitset" - sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/bnb-chain/greenfield/x/challenge/types" @@ -24,13 +24,7 @@ type BlsSignedMsg interface { } // verifySignature verifies whether the signature is valid or not. -func (k Keeper) verifySignature(ctx sdk.Context, signedMsg BlsSignedMsg) ([]string, error) { - historicalInfo, ok := k.stakingKeeper.GetHistoricalInfo(ctx, ctx.BlockHeight()) - if !ok { - return nil, errors.Wrap(types.ErrInvalidVoteValidatorSet, "fail to get validators") - } - validators := historicalInfo.Valset - +func (k Keeper) verifySignature(signedMsg BlsSignedMsg, validators []stakingtypes.Validator) ([]string, error) { validatorsBitSet := bitset.From(signedMsg.GetVoteValidatorSet()) if validatorsBitSet.Count() > uint(len(validators)) { return nil, errors.Wrap(types.ErrInvalidVoteValidatorSet, "number of validator set is larger than validators") diff --git a/x/challenge/keeper/challenge.go b/x/challenge/keeper/challenge.go index ec2b89b3c..c2dfe8f17 100644 --- a/x/challenge/keeper/challenge.go +++ b/x/challenge/keeper/challenge.go @@ -70,24 +70,88 @@ func getChallengeKeyBytes(challengeId uint64) []byte { return bz } -// GetAttestChallengeId gets the challenge id of the latest attestation challenge -func (k Keeper) GetAttestChallengeId(ctx sdk.Context) uint64 { - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) - bz := store.Get(types.AttestChallengeIdKey) +func (k Keeper) encodeUint64(data uint64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, data) + return bz +} - if bz == nil { - return 0 +// GetAttestChallengeIds gets the challenge id of the latest attestation challenge +func (k Keeper) GetAttestChallengeIds(ctx sdk.Context) []uint64 { + store := ctx.KVStore(k.storeKey) + sizeBz := store.Get(types.AttestChallengeIdsSizeKey) + + if sizeBz == nil { + return []uint64{} } - return binary.BigEndian.Uint64(bz) + size := binary.BigEndian.Uint64(sizeBz) + cursor := binary.BigEndian.Uint64(store.Get(types.AttestChallengeIdsCursorKey)) + + result := []uint64{} + current := cursor + idsStore := prefix.NewStore(store, types.AttestChallengeIdsPrefix) + for { + current = (current + 1) % size + idBz := idsStore.Get(k.encodeUint64(current)) + if idBz != nil { + result = append(result, binary.BigEndian.Uint64(idBz)) + } + if current == cursor { + break + } + } + return result } -// SetAttestChallengeId sets the new id of challenge to the store -func (k Keeper) SetAttestChallengeId(ctx sdk.Context, challengeId uint64) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) - bz := make([]byte, 8) - binary.BigEndian.PutUint64(bz, challengeId) - store.Set(types.AttestChallengeIdKey, bz) +// AppendAttestChallengeId sets the new id of challenge to the store +func (k Keeper) AppendAttestChallengeId(ctx sdk.Context, challengeId uint64) { + toKeep := k.KeyAttestationKeptCount(ctx) + + store := ctx.KVStore(k.storeKey) + sizeBz := store.Get(types.AttestChallengeIdsSizeKey) + + idsStore := prefix.NewStore(store, types.AttestChallengeIdsPrefix) + if sizeBz == nil { // the first time to append + store.Set(types.AttestChallengeIdsSizeKey, k.encodeUint64(toKeep)) + k.enqueueAttestChallengeId(store, idsStore, challengeId) + return + } + + size := binary.BigEndian.Uint64(sizeBz) + if size != toKeep { // the parameter changes, which is not frequent + currentIds := k.GetAttestChallengeIds(ctx) + + iterator := storetypes.KVStorePrefixIterator(idsStore, []byte{}) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + idsStore.Delete(iterator.Key()) + } + + store.Set(types.AttestChallengeIdsSizeKey, k.encodeUint64(toKeep)) + store.Delete(types.AttestChallengeIdsCursorKey) + + for _, id := range currentIds { + k.enqueueAttestChallengeId(store, idsStore, id) + } + } + k.enqueueAttestChallengeId(store, idsStore, challengeId) +} + +func (k Keeper) enqueueAttestChallengeId(store, idsStore storetypes.KVStore, challengeId uint64) { + size := binary.BigEndian.Uint64(store.Get(types.AttestChallengeIdsSizeKey)) + cursorBz := store.Get(types.AttestChallengeIdsCursorKey) + cursor := uint64(0) + if cursorBz != nil { + cursor = binary.BigEndian.Uint64(cursorBz) + cursor = (cursor + 1) % size + } + + cursorBz = k.encodeUint64(cursor) + store.Set(types.AttestChallengeIdsCursorKey, cursorBz) + + idsStore.Set(cursorBz, k.encodeUint64(challengeId)) } // GetChallengeCountCurrentBlock gets the count of challenges diff --git a/x/challenge/keeper/challenge_test.go b/x/challenge/keeper/challenge_test.go index bec257239..74053db4b 100644 --- a/x/challenge/keeper/challenge_test.go +++ b/x/challenge/keeper/challenge_test.go @@ -21,3 +21,36 @@ func TestGetChallengeId(t *testing.T) { }) require.True(t, keeper.GetChallengeId(ctx) == 100) } + +func TestAttestedChallengeIds(t *testing.T) { + keeper, ctx := keepertest.ChallengeKeeper(t) + params := types.DefaultParams() + params.AttestationKeptCount = 5 + keeper.SetParams(ctx, params) + + keeper.AppendAttestChallengeId(ctx, 1) + keeper.AppendAttestChallengeId(ctx, 2) + keeper.AppendAttestChallengeId(ctx, 3) + require.Equal(t, []uint64{1, 2, 3}, keeper.GetAttestChallengeIds(ctx)) + + keeper.AppendAttestChallengeId(ctx, 4) + keeper.AppendAttestChallengeId(ctx, 5) + keeper.AppendAttestChallengeId(ctx, 6) + require.Equal(t, []uint64{2, 3, 4, 5, 6}, keeper.GetAttestChallengeIds(ctx)) + + params.AttestationKeptCount = 8 + keeper.SetParams(ctx, params) + keeper.AppendAttestChallengeId(ctx, 7) + keeper.AppendAttestChallengeId(ctx, 8) + require.Equal(t, []uint64{2, 3, 4, 5, 6, 7, 8}, keeper.GetAttestChallengeIds(ctx)) + + params.AttestationKeptCount = 3 + keeper.SetParams(ctx, params) + keeper.AppendAttestChallengeId(ctx, 9) + require.Equal(t, []uint64{7, 8, 9}, keeper.GetAttestChallengeIds(ctx)) + + params.AttestationKeptCount = 5 + keeper.SetParams(ctx, params) + keeper.AppendAttestChallengeId(ctx, 10) + require.Equal(t, []uint64{7, 8, 9, 10}, keeper.GetAttestChallengeIds(ctx)) +} diff --git a/x/challenge/keeper/grpc_query.go b/x/challenge/keeper/grpc_query.go index 465ee4dd3..6a964adb1 100644 --- a/x/challenge/keeper/grpc_query.go +++ b/x/challenge/keeper/grpc_query.go @@ -1,7 +1,47 @@ package keeper import ( + "context" + "encoding/hex" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/bnb-chain/greenfield/x/challenge/types" ) var _ types.QueryServer = Keeper{} + +func (k Keeper) LatestAttestedChallenges(goCtx context.Context, req *types.QueryLatestAttestedChallengesRequest) (*types.QueryLatestAttestedChallengesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + challengeId := k.GetAttestChallengeIds(ctx) + + return &types.QueryLatestAttestedChallengesResponse{ + ChallengeIds: challengeId, + }, nil +} + +func (k Keeper) InturnAttestationSubmitter(goCtx context.Context, req *types.QueryInturnAttestationSubmitterRequest) (*types.QueryInturnAttestationSubmitterResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + blsKey, interval, err := k.getInturnSubmitter(ctx, k.AttestationInturnInterval(ctx)) + if err != nil { + return nil, err + } + + return &types.QueryInturnAttestationSubmitterResponse{ + BlsPubKey: hex.EncodeToString(blsKey), + SubmitInterval: interval, + }, nil + +} diff --git a/x/challenge/keeper/grpc_query_latest_attested_challenge.go b/x/challenge/keeper/grpc_query_latest_attested_challenge.go deleted file mode 100644 index 982705c78..000000000 --- a/x/challenge/keeper/grpc_query_latest_attested_challenge.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/bnb-chain/greenfield/x/challenge/types" -) - -func (k Keeper) LatestAttestedChallenge(goCtx context.Context, req *types.QueryLatestAttestedChallengeRequest) (*types.QueryLatestAttestedChallengeResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - challengeId := k.GetAttestChallengeId(ctx) - - return &types.QueryLatestAttestedChallengeResponse{ - ChallengeId: challengeId, - }, nil -} diff --git a/x/challenge/keeper/keeper.go b/x/challenge/keeper/keeper.go index 6ecbdbcdc..c92384c07 100644 --- a/x/challenge/keeper/keeper.go +++ b/x/challenge/keeper/keeper.go @@ -1,13 +1,16 @@ package keeper import ( + "bytes" "fmt" + "cosmossdk.io/errors" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/bnb-chain/greenfield/x/challenge/types" ) @@ -60,3 +63,55 @@ func NewKeeper( func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +// isInturnAttestation returns whether the attestation submitted in turn +func (k Keeper) isInturnAttestation(ctx sdk.Context, submitter sdk.AccAddress, validators []stakingtypes.Validator) (bool, error) { + var validatorIndex int64 = -1 + var vldr stakingtypes.Validator + for index, validator := range validators { + if validator.ChallengerAddress == submitter.String() { + validatorIndex = int64(index) + vldr = validator + break + } + } + + if validatorIndex < 0 { + return false, errors.Wrapf(types.ErrNotChallenger, "sender (%s) is not a attestation submitter", submitter.String()) + } + + inturnBlsKey, _, err := k.getInturnSubmitter(ctx, k.AttestationInturnInterval(ctx)) + if err != nil { + return false, err + } + + return bytes.Equal(inturnBlsKey, vldr.BlsKey), nil +} + +func (k Keeper) getInturnSubmitter(ctx sdk.Context, interval uint64) ([]byte, *types.SubmitInterval, error) { + historicalInfo, ok := k.stakingKeeper.GetHistoricalInfo(ctx, ctx.BlockHeight()) + if !ok { + return nil, nil, errors.Wrap(types.ErrInvalidVoteValidatorSet, "fail to get validators") + } + validators := historicalInfo.Valset + + validatorsSize := len(validators) + + // totalIntervals is sum of intervals from all challengers + totalIntervals := interval * uint64(validatorsSize) + + curTimeStamp := uint64(ctx.BlockTime().Unix()) + + remainder := curTimeStamp % totalIntervals + inTurnIndex := remainder / interval + + start := curTimeStamp - (remainder - inTurnIndex*interval) + end := start + interval + + inturnChallenger := validators[inTurnIndex] + + return inturnChallenger.BlsKey, &types.SubmitInterval{ + Start: start, + End: end, + }, nil +} diff --git a/x/challenge/keeper/msg_server_attest.go b/x/challenge/keeper/msg_server_attest.go index b3063c139..cf4d2f1fc 100644 --- a/x/challenge/keeper/msg_server_attest.go +++ b/x/challenge/keeper/msg_server_attest.go @@ -34,6 +34,19 @@ func (k msgServer) Attest(goCtx context.Context, msg *types.MsgAttest) (*types.M return nil, errors.Wrapf(types.ErrInvalidChallengeId, "challenge %d cannot be found, it could be expired", msg.ChallengeId) } + historicalInfo, ok := k.stakingKeeper.GetHistoricalInfo(ctx, ctx.BlockHeight()) + if !ok { + return nil, errors.Wrap(types.ErrInvalidVoteValidatorSet, "fail to get validators") + } + allValidators := historicalInfo.Valset + inTurn, err := k.isInturnAttestation(ctx, submitter, allValidators) + if err != nil { + return nil, err + } + if !inTurn { + return nil, types.ErrNotInturnChallenger + } + //check object, and get object info objectInfo, found := k.StorageKeeper.GetObjectInfoById(ctx, msg.ObjectId) if !found { // be noted: even the object info is not in service now, we will continue slash the storage provider @@ -41,7 +54,7 @@ func (k msgServer) Attest(goCtx context.Context, msg *types.MsgAttest) (*types.M } // check attest validators and signatures - validators, err := k.verifySignature(ctx, msg) + validators, err := k.verifySignature(msg, allValidators) if err != nil { return nil, err } @@ -78,7 +91,7 @@ func (k msgServer) Attest(goCtx context.Context, msg *types.MsgAttest) (*types.M return nil, err } } - k.SetAttestChallengeId(ctx, msg.ChallengeId) + k.AppendAttestChallengeId(ctx, msg.ChallengeId) return &types.MsgAttestResponse{}, nil } diff --git a/x/challenge/keeper/params.go b/x/challenge/keeper/params.go index 9ba0f8308..e73a7c8dc 100644 --- a/x/challenge/keeper/params.go +++ b/x/challenge/keeper/params.go @@ -20,6 +20,8 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { k.RewardSubmitterRatio(ctx), k.RewardSubmitterThreshold(ctx), k.HeartbeatInterval(ctx), + k.AttestationInturnInterval(ctx), + k.KeyAttestationKeptCount(ctx), ) } @@ -76,14 +78,26 @@ func (k Keeper) RewardSubmitterRatio(ctx sdk.Context) (res sdk.Dec) { return } +// RewardSubmitterThreshold returns the RewardSubmitterThreshold param +func (k Keeper) RewardSubmitterThreshold(ctx sdk.Context) (res math.Int) { + k.paramstore.Get(ctx, types.KeyRewardSubmitterThreshold, &res) + return +} + // HeartbeatInterval returns the HeartbeatInterval param func (k Keeper) HeartbeatInterval(ctx sdk.Context) (res uint64) { k.paramstore.Get(ctx, types.KeyHeartbeatInterval, &res) return } -// RewardSubmitterThreshold returns the RewardSubmitterThreshold param -func (k Keeper) RewardSubmitterThreshold(ctx sdk.Context) (res math.Int) { - k.paramstore.Get(ctx, types.KeyRewardSubmitterThreshold, &res) +// AttestationInturnInterval returns the AttestationInturnInterval param +func (k Keeper) AttestationInturnInterval(ctx sdk.Context) (res uint64) { + k.paramstore.Get(ctx, types.KeyAttestationInturnInterval, &res) + return +} + +// KeyAttestationKeptCount returns the KeyAttestationKeptCount param +func (k Keeper) KeyAttestationKeptCount(ctx sdk.Context) (res uint64) { + k.paramstore.Get(ctx, types.KeyAttestationKeptCount, &res) return } diff --git a/x/challenge/types/errors.go b/x/challenge/types/errors.go index e8be33207..5d6d0cf30 100644 --- a/x/challenge/types/errors.go +++ b/x/challenge/types/errors.go @@ -20,4 +20,6 @@ var ( ErrDuplicatedSlash = errors.Register(ModuleName, 12, "duplicated slash in cooling-off period") ErrInvalidBlsPubKey = errors.Register(ModuleName, 13, "invalid bls public key") ErrNotEnoughVotes = errors.Register(ModuleName, 14, "attest votes are not enough") + ErrNotChallenger = errors.Register(ModuleName, 15, "not a valid challenger") + ErrNotInturnChallenger = errors.Register(ModuleName, 16, "challenger is not in turn") ) diff --git a/x/challenge/types/keys.go b/x/challenge/types/keys.go index 3179e4aa2..5bf182cd4 100644 --- a/x/challenge/types/keys.go +++ b/x/challenge/types/keys.go @@ -28,13 +28,19 @@ var ( // ChallengeKeyPrefix is the prefix to retrieve Challenge. ChallengeKeyPrefix = []byte{0x12} - // AttestChallengeIdKey is the key to record the latest attest challenge id. - AttestChallengeIdKey = []byte{0x13} - // SlashKeyPrefix is the prefix to retrieve Slash. - SlashKeyPrefix = []byte{0x14} + SlashKeyPrefix = []byte{0x13} // CurrentBlockChallengeCountKey is key to track the count of challenges in the current block. // The data is stored in transient store. - CurrentBlockChallengeCountKey = []byte{0x15} + CurrentBlockChallengeCountKey = []byte{0x14} + + // AttestChallengeIdsPrefix is the prefix to record the latest attested challenge ids. + AttestChallengeIdsPrefix = []byte{0x15} + + // AttestChallengeIdsSizeKey is the key to record the size of latest attested challenge ids. + AttestChallengeIdsSizeKey = []byte{0x16} + + // AttestChallengeIdsCursorKey is the key to retrieve the latest attested challenge ids. + AttestChallengeIdsCursorKey = []byte{0x17} ) diff --git a/x/challenge/types/params.go b/x/challenge/types/params.go index e80eb0f91..590cf40e3 100644 --- a/x/challenge/types/params.go +++ b/x/challenge/types/params.go @@ -63,6 +63,16 @@ var ( DefaultHeartbeatInterval uint64 = 1000 ) +var ( + KeyAttestationInturnInterval = []byte("AttestationInturnInterval") + DefaultAttestationInturnInterval uint64 = 120 // in seconds +) + +var ( + KeyAttestationKeptCount = []byte("AttestationKeptCount") + DefaultAttestationKeptCount uint64 = 300 +) + // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -80,18 +90,22 @@ func NewParams( rewardSubmitterRatio sdk.Dec, rewardSubmitterThreshold math.Int, heartbeatInterval uint64, + attestationInturnInterval uint64, + attestationKeptCount uint64, ) Params { return Params{ - ChallengeCountPerBlock: challengeCountPerBlock, - ChallengeKeepAlivePeriod: challengeKeepAlivePeriod, - SlashCoolingOffPeriod: slashCoolingOffPeriod, - SlashAmountSizeRate: slashAmountSizeRate, - SlashAmountMin: slashAmountMin, - SlashAmountMax: slashAmountMax, - RewardValidatorRatio: rewardValidatorRatio, - RewardSubmitterRatio: rewardSubmitterRatio, - RewardSubmitterThreshold: rewardSubmitterThreshold, - HeartbeatInterval: heartbeatInterval, + ChallengeCountPerBlock: challengeCountPerBlock, + ChallengeKeepAlivePeriod: challengeKeepAlivePeriod, + SlashCoolingOffPeriod: slashCoolingOffPeriod, + SlashAmountSizeRate: slashAmountSizeRate, + SlashAmountMin: slashAmountMin, + SlashAmountMax: slashAmountMax, + RewardValidatorRatio: rewardValidatorRatio, + RewardSubmitterRatio: rewardSubmitterRatio, + RewardSubmitterThreshold: rewardSubmitterThreshold, + HeartbeatInterval: heartbeatInterval, + AttestationInturnInterval: attestationInturnInterval, + AttestationKeptCount: attestationKeptCount, } } @@ -108,6 +122,8 @@ func DefaultParams() Params { DefaultRewardSubmitterRatio, DefaultRewardSubmitterThreshold, DefaultHeartbeatInterval, + DefaultAttestationInturnInterval, + DefaultAttestationKeptCount, ) } @@ -124,6 +140,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyRewardSubmitterRatio, &p.RewardSubmitterRatio, validateRewardSubmitterRatio), paramtypes.NewParamSetPair(KeyRewardSubmitterThreshold, &p.RewardSubmitterThreshold, validateRewardSubmitterThreshold), paramtypes.NewParamSetPair(KeyHeartbeatInterval, &p.HeartbeatInterval, validateHeartbeatInterval), + paramtypes.NewParamSetPair(KeyAttestationInturnInterval, &p.AttestationInturnInterval, validateAttestationInturnInterval), + paramtypes.NewParamSetPair(KeyAttestationKeptCount, &p.AttestationKeptCount, validateAttestationKeptCount), } } @@ -316,3 +334,29 @@ func validateHeartbeatInterval(v interface{}) error { return nil } + +// validateAttestationInturnInterval validates the AttestationInturnInterval param +func validateAttestationInturnInterval(v interface{}) error { + inturnInterval, ok := v.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + if inturnInterval == 0 { + return errors.New("attestation inturn interval cannot be zero") + } + + return nil +} + +// validateAttestationKeptCount validates the AttestationKeptCount param +func validateAttestationKeptCount(v interface{}) error { + count, ok := v.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + if count == 0 { + return errors.New("attestation kept count cannot be zero") + } + + return nil +} diff --git a/x/challenge/types/params.pb.go b/x/challenge/types/params.pb.go index 1bbe22641..f14c72121 100644 --- a/x/challenge/types/params.pb.go +++ b/x/challenge/types/params.pb.go @@ -47,6 +47,10 @@ type Params struct { RewardSubmitterThreshold github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=reward_submitter_threshold,json=rewardSubmitterThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"reward_submitter_threshold"` // Heartbeat interval, based on challenge id, defines the frequency of heartbeat attestation. HeartbeatInterval uint64 `protobuf:"varint,10,opt,name=heartbeat_interval,json=heartbeatInterval,proto3" json:"heartbeat_interval,omitempty" yaml:"heartbeat_interval"` + // The time duration for each submitter to submit attestations in turn. + AttestationInturnInterval uint64 `protobuf:"varint,11,opt,name=attestation_inturn_interval,json=attestationInturnInterval,proto3" json:"attestation_inturn_interval,omitempty" yaml:"attestation_inturn_interval"` + // The number of kept attested challenge ids, which can be queried by clients. + AttestationKeptCount uint64 `protobuf:"varint,12,opt,name=attestation_kept_count,json=attestationKeptCount,proto3" json:"attestation_kept_count,omitempty" yaml:"attestation_kept_count"` } func (m *Params) Reset() { *m = Params{} } @@ -109,6 +113,20 @@ func (m *Params) GetHeartbeatInterval() uint64 { return 0 } +func (m *Params) GetAttestationInturnInterval() uint64 { + if m != nil { + return m.AttestationInturnInterval + } + return 0 +} + +func (m *Params) GetAttestationKeptCount() uint64 { + if m != nil { + return m.AttestationKeptCount + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "greenfield.challenge.Params") } @@ -116,43 +134,47 @@ func init() { func init() { proto.RegisterFile("greenfield/challenge/params.proto", fileDescriptor_2396367ee53edf57) } var fileDescriptor_2396367ee53edf57 = []byte{ - // 575 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x31, 0x6f, 0xd3, 0x5c, - 0x14, 0x8d, 0xbf, 0xaf, 0x84, 0xf6, 0x0d, 0x08, 0x4c, 0x88, 0x9c, 0xa0, 0xda, 0xc1, 0xa0, 0xaa, - 0x4b, 0x12, 0x21, 0xb6, 0x8a, 0xa5, 0x29, 0x4b, 0x54, 0x50, 0x23, 0x17, 0x31, 0x20, 0x24, 0xeb, - 0xd9, 0xbe, 0xb6, 0x9f, 0x62, 0xfb, 0x59, 0xcf, 0x2f, 0x21, 0xcd, 0x0c, 0xcc, 0x8c, 0x8c, 0xfc, - 0x08, 0x7e, 0x44, 0xc7, 0x8a, 0x09, 0x31, 0x58, 0x28, 0x91, 0xf8, 0x01, 0xf9, 0x05, 0xc8, 0xcf, - 0x89, 0x93, 0x26, 0x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0x61, 0x97, 0x07, 0x19, 0xa3, 0xfa, 0x46, 0x0e, 0xee, 0x33, 0x48, 0x7c, 0x1a, 0x38, 0xca, - 0xce, 0x0d, 0x1c, 0x81, 0xb2, 0xe6, 0xfb, 0x7a, 0xd1, 0x5d, 0x7e, 0x89, 0x64, 0x1f, 0x30, 0xe3, - 0x16, 0x60, 0x6e, 0x92, 0x88, 0x03, 0x1b, 0xe2, 0x40, 0x41, 0xe2, 0xdb, 0xd9, 0x9d, 0xa5, 0x5a, - 0x2d, 0x9f, 0x68, 0x53, 0xa3, 0x1b, 0xf7, 0x0a, 0xb0, 0x3b, 0xc7, 0x0e, 0xb6, 0xbe, 0x7c, 0xd5, - 0x4a, 0x9d, 0xe3, 0xf3, 0x89, 0x2a, 0x5d, 0x4c, 0x54, 0xe9, 0xd7, 0x44, 0x95, 0x3e, 0x4f, 0xd5, - 0xd2, 0xc5, 0x54, 0x2d, 0xfd, 0x98, 0xaa, 0xa5, 0xb7, 0x4f, 0x57, 0xd2, 0x5b, 0x91, 0xd5, 0xb4, - 0x7d, 0x4c, 0xa2, 0xf6, 0xca, 0x06, 0x1c, 0xad, 0xec, 0x40, 0x31, 0x8c, 0x55, 0x16, 0xcb, 0xeb, - 0xd9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x08, 0xc3, 0x1a, 0x28, 0x05, 0x00, 0x00, + // 634 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xc1, 0x6e, 0xd3, 0x4a, + 0x14, 0x8d, 0xdf, 0x2b, 0x85, 0x0e, 0x08, 0x81, 0x09, 0xd1, 0xa4, 0x55, 0xed, 0xd6, 0xa0, 0xaa, + 0x9b, 0x26, 0x42, 0xec, 0x2a, 0x36, 0x4d, 0xd9, 0x44, 0x05, 0x35, 0x72, 0x11, 0x48, 0x08, 0xc9, + 0x1a, 0x3b, 0xd7, 0xf1, 0x28, 0xf6, 0x8c, 0x35, 0x9e, 0x94, 0xb6, 0x6b, 0x60, 0xcd, 0x92, 0x25, + 0x3b, 0x7e, 0x80, 0x8f, 0xe8, 0xb2, 0x62, 0x85, 0x58, 0x58, 0xa8, 0xfd, 0x83, 0x7c, 0x01, 0xf2, + 0x38, 0x71, 0xdc, 0xa4, 0x45, 0xaa, 0xe8, 0x2a, 0xf1, 0x3d, 0xe7, 0x9e, 0x73, 0xae, 0x67, 0x7c, + 0xd1, 0x6a, 0x4f, 0x00, 0x30, 0x9f, 0x42, 0xd8, 0x6d, 0x7a, 0x01, 0x09, 0x43, 0x60, 0x3d, 0x68, + 0xc6, 0x44, 0x90, 0x28, 0x69, 0xc4, 0x82, 0x4b, 0xae, 0x57, 0x27, 0x94, 0x46, 0x41, 0x59, 0xac, + 0x7b, 0x3c, 0x89, 0x78, 0xe2, 0x28, 0x4e, 0x33, 0x7f, 0xc8, 0x1b, 0x16, 0xab, 0x3d, 0xde, 0xe3, + 0x79, 0x3d, 0xfb, 0x97, 0x57, 0xad, 0x6f, 0x08, 0xcd, 0x77, 0x94, 0xae, 0xee, 0xa0, 0x7a, 0x21, + 0xe4, 0x78, 0x7c, 0xc0, 0xa4, 0x13, 0x83, 0x70, 0xdc, 0x90, 0x7b, 0x7d, 0xac, 0xad, 0x68, 0xeb, + 0x73, 0xad, 0xc7, 0xc3, 0xd4, 0x5c, 0x39, 0x24, 0x51, 0xb8, 0x69, 0x5d, 0x4a, 0xb5, 0xec, 0x5a, + 0x81, 0x6d, 0x67, 0x50, 0x07, 0x44, 0x2b, 0x03, 0x74, 0x40, 0x4b, 0x93, 0xae, 0x3e, 0x40, 0xec, + 0x90, 0x90, 0xee, 0x43, 0xd6, 0x4a, 0x79, 0x17, 0xff, 0xa7, 0x2c, 0xd6, 0x86, 0xa9, 0x69, 0x4d, + 0x5b, 0xcc, 0x90, 0x2d, 0x1b, 0x17, 0xe8, 0x0e, 0x40, 0xbc, 0x95, 0x61, 0x1d, 0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 0xbf, 0xcb, 0xdc, 0x0d, 0x2f, 0x20, 0x94, 0x35, 0x4b, + 0x2b, 0xfc, 0xa0, 0xb4, 0xc4, 0xd5, 0x69, 0xb8, 0xf3, 0x6a, 0xfb, 0x3e, 0xfd, 0x13, 0x00, 0x00, + 0xff, 0xff, 0xbf, 0x94, 0xb9, 0x14, 0xe9, 0x05, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -175,6 +197,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.AttestationKeptCount != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.AttestationKeptCount)) + i-- + dAtA[i] = 0x60 + } + if m.AttestationInturnInterval != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.AttestationInturnInterval)) + i-- + dAtA[i] = 0x58 + } if m.HeartbeatInterval != 0 { i = encodeVarintParams(dAtA, i, uint64(m.HeartbeatInterval)) i-- @@ -299,6 +331,12 @@ func (m *Params) Size() (n int) { if m.HeartbeatInterval != 0 { n += 1 + sovParams(uint64(m.HeartbeatInterval)) } + if m.AttestationInturnInterval != 0 { + n += 1 + sovParams(uint64(m.AttestationInturnInterval)) + } + if m.AttestationKeptCount != 0 { + n += 1 + sovParams(uint64(m.AttestationKeptCount)) + } return n } @@ -617,6 +655,44 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AttestationInturnInterval", wireType) + } + m.AttestationInturnInterval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AttestationInturnInterval |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AttestationKeptCount", wireType) + } + m.AttestationKeptCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AttestationKeptCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/challenge/types/query.pb.go b/x/challenge/types/query.pb.go index 944932644..1d43cd2a0 100644 --- a/x/challenge/types/query.pb.go +++ b/x/challenge/types/query.pb.go @@ -114,22 +114,22 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -// QueryParamsRequest is request type for the Query/LatestAttestedChallenge RPC method. -type QueryLatestAttestedChallengeRequest struct { +// QueryLatestAttestedChallengesRequest is request type for the Query/LatestAttestedChallenges RPC method. +type QueryLatestAttestedChallengesRequest struct { } -func (m *QueryLatestAttestedChallengeRequest) Reset() { *m = QueryLatestAttestedChallengeRequest{} } -func (m *QueryLatestAttestedChallengeRequest) String() string { return proto.CompactTextString(m) } -func (*QueryLatestAttestedChallengeRequest) ProtoMessage() {} -func (*QueryLatestAttestedChallengeRequest) Descriptor() ([]byte, []int) { +func (m *QueryLatestAttestedChallengesRequest) Reset() { *m = QueryLatestAttestedChallengesRequest{} } +func (m *QueryLatestAttestedChallengesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryLatestAttestedChallengesRequest) ProtoMessage() {} +func (*QueryLatestAttestedChallengesRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f6f1807fa0a2b619, []int{2} } -func (m *QueryLatestAttestedChallengeRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryLatestAttestedChallengesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryLatestAttestedChallengeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryLatestAttestedChallengesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryLatestAttestedChallengeRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryLatestAttestedChallengesRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -139,35 +139,35 @@ func (m *QueryLatestAttestedChallengeRequest) XXX_Marshal(b []byte, deterministi return b[:n], nil } } -func (m *QueryLatestAttestedChallengeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLatestAttestedChallengeRequest.Merge(m, src) +func (m *QueryLatestAttestedChallengesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestAttestedChallengesRequest.Merge(m, src) } -func (m *QueryLatestAttestedChallengeRequest) XXX_Size() int { +func (m *QueryLatestAttestedChallengesRequest) XXX_Size() int { return m.Size() } -func (m *QueryLatestAttestedChallengeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLatestAttestedChallengeRequest.DiscardUnknown(m) +func (m *QueryLatestAttestedChallengesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestAttestedChallengesRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryLatestAttestedChallengeRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryLatestAttestedChallengesRequest proto.InternalMessageInfo -// QueryParamsResponse is response type for the Query/LatestAttestedChallenge RPC method. -type QueryLatestAttestedChallengeResponse struct { - ChallengeId uint64 `protobuf:"varint,1,opt,name=challengeId,proto3" json:"challengeId,omitempty"` +// QueryLatestAttestedChallengesResponse is response type for the Query/LatestAttestedChallenges RPC method. +type QueryLatestAttestedChallengesResponse struct { + ChallengeIds []uint64 `protobuf:"varint,1,rep,packed,name=challengeIds,proto3" json:"challengeIds,omitempty"` } -func (m *QueryLatestAttestedChallengeResponse) Reset() { *m = QueryLatestAttestedChallengeResponse{} } -func (m *QueryLatestAttestedChallengeResponse) String() string { return proto.CompactTextString(m) } -func (*QueryLatestAttestedChallengeResponse) ProtoMessage() {} -func (*QueryLatestAttestedChallengeResponse) Descriptor() ([]byte, []int) { +func (m *QueryLatestAttestedChallengesResponse) Reset() { *m = QueryLatestAttestedChallengesResponse{} } +func (m *QueryLatestAttestedChallengesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryLatestAttestedChallengesResponse) ProtoMessage() {} +func (*QueryLatestAttestedChallengesResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f6f1807fa0a2b619, []int{3} } -func (m *QueryLatestAttestedChallengeResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryLatestAttestedChallengesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryLatestAttestedChallengeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryLatestAttestedChallengesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryLatestAttestedChallengeResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryLatestAttestedChallengesResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -177,21 +177,168 @@ func (m *QueryLatestAttestedChallengeResponse) XXX_Marshal(b []byte, determinist return b[:n], nil } } -func (m *QueryLatestAttestedChallengeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLatestAttestedChallengeResponse.Merge(m, src) +func (m *QueryLatestAttestedChallengesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestAttestedChallengesResponse.Merge(m, src) } -func (m *QueryLatestAttestedChallengeResponse) XXX_Size() int { +func (m *QueryLatestAttestedChallengesResponse) XXX_Size() int { return m.Size() } -func (m *QueryLatestAttestedChallengeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLatestAttestedChallengeResponse.DiscardUnknown(m) +func (m *QueryLatestAttestedChallengesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestAttestedChallengesResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryLatestAttestedChallengeResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryLatestAttestedChallengesResponse proto.InternalMessageInfo -func (m *QueryLatestAttestedChallengeResponse) GetChallengeId() uint64 { +func (m *QueryLatestAttestedChallengesResponse) GetChallengeIds() []uint64 { if m != nil { - return m.ChallengeId + return m.ChallengeIds + } + return nil +} + +// QueryInturnAttestationSubmitterRequest is request type for the Query/InturnAttestationSubmitter RPC method. +type QueryInturnAttestationSubmitterRequest struct { +} + +func (m *QueryInturnAttestationSubmitterRequest) Reset() { + *m = QueryInturnAttestationSubmitterRequest{} +} +func (m *QueryInturnAttestationSubmitterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryInturnAttestationSubmitterRequest) ProtoMessage() {} +func (*QueryInturnAttestationSubmitterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f6f1807fa0a2b619, []int{4} +} +func (m *QueryInturnAttestationSubmitterRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInturnAttestationSubmitterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInturnAttestationSubmitterRequest.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 *QueryInturnAttestationSubmitterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInturnAttestationSubmitterRequest.Merge(m, src) +} +func (m *QueryInturnAttestationSubmitterRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryInturnAttestationSubmitterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInturnAttestationSubmitterRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInturnAttestationSubmitterRequest proto.InternalMessageInfo + +// QueryInturnAttestationSubmitterResponse is response type for the Query/InturnAttestationSubmitter RPC method. +type QueryInturnAttestationSubmitterResponse struct { + BlsPubKey string `protobuf:"bytes,1,opt,name=bls_pub_key,json=blsPubKey,proto3" json:"bls_pub_key,omitempty"` + SubmitInterval *SubmitInterval `protobuf:"bytes,2,opt,name=submit_interval,json=submitInterval,proto3" json:"submit_interval,omitempty"` +} + +func (m *QueryInturnAttestationSubmitterResponse) Reset() { + *m = QueryInturnAttestationSubmitterResponse{} +} +func (m *QueryInturnAttestationSubmitterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryInturnAttestationSubmitterResponse) ProtoMessage() {} +func (*QueryInturnAttestationSubmitterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f6f1807fa0a2b619, []int{5} +} +func (m *QueryInturnAttestationSubmitterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInturnAttestationSubmitterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInturnAttestationSubmitterResponse.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 *QueryInturnAttestationSubmitterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInturnAttestationSubmitterResponse.Merge(m, src) +} +func (m *QueryInturnAttestationSubmitterResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryInturnAttestationSubmitterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInturnAttestationSubmitterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInturnAttestationSubmitterResponse proto.InternalMessageInfo + +func (m *QueryInturnAttestationSubmitterResponse) GetBlsPubKey() string { + if m != nil { + return m.BlsPubKey + } + return "" +} + +func (m *QueryInturnAttestationSubmitterResponse) GetSubmitInterval() *SubmitInterval { + if m != nil { + return m.SubmitInterval + } + return nil +} + +// SubmitInterval holds start and end (exclusive) (i.e., [start, end)) time of in turn attestation. +type SubmitInterval struct { + Start uint64 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"` + End uint64 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` +} + +func (m *SubmitInterval) Reset() { *m = SubmitInterval{} } +func (m *SubmitInterval) String() string { return proto.CompactTextString(m) } +func (*SubmitInterval) ProtoMessage() {} +func (*SubmitInterval) Descriptor() ([]byte, []int) { + return fileDescriptor_f6f1807fa0a2b619, []int{6} +} +func (m *SubmitInterval) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SubmitInterval) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SubmitInterval.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 *SubmitInterval) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubmitInterval.Merge(m, src) +} +func (m *SubmitInterval) XXX_Size() int { + return m.Size() +} +func (m *SubmitInterval) XXX_DiscardUnknown() { + xxx_messageInfo_SubmitInterval.DiscardUnknown(m) +} + +var xxx_messageInfo_SubmitInterval proto.InternalMessageInfo + +func (m *SubmitInterval) GetStart() uint64 { + if m != nil { + return m.Start + } + return 0 +} + +func (m *SubmitInterval) GetEnd() uint64 { + if m != nil { + return m.End } return 0 } @@ -199,40 +346,52 @@ func (m *QueryLatestAttestedChallengeResponse) GetChallengeId() uint64 { func init() { proto.RegisterType((*QueryParamsRequest)(nil), "greenfield.challenge.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "greenfield.challenge.QueryParamsResponse") - proto.RegisterType((*QueryLatestAttestedChallengeRequest)(nil), "greenfield.challenge.QueryLatestAttestedChallengeRequest") - proto.RegisterType((*QueryLatestAttestedChallengeResponse)(nil), "greenfield.challenge.QueryLatestAttestedChallengeResponse") + proto.RegisterType((*QueryLatestAttestedChallengesRequest)(nil), "greenfield.challenge.QueryLatestAttestedChallengesRequest") + proto.RegisterType((*QueryLatestAttestedChallengesResponse)(nil), "greenfield.challenge.QueryLatestAttestedChallengesResponse") + proto.RegisterType((*QueryInturnAttestationSubmitterRequest)(nil), "greenfield.challenge.QueryInturnAttestationSubmitterRequest") + proto.RegisterType((*QueryInturnAttestationSubmitterResponse)(nil), "greenfield.challenge.QueryInturnAttestationSubmitterResponse") + proto.RegisterType((*SubmitInterval)(nil), "greenfield.challenge.SubmitInterval") } func init() { proto.RegisterFile("greenfield/challenge/query.proto", fileDescriptor_f6f1807fa0a2b619) } var fileDescriptor_f6f1807fa0a2b619 = []byte{ - // 406 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x41, 0x6f, 0xda, 0x30, - 0x18, 0x86, 0x13, 0xc4, 0x38, 0x98, 0x9b, 0x87, 0xb4, 0x2d, 0x42, 0x19, 0xcb, 0x98, 0xc4, 0x26, - 0x2d, 0x56, 0xd8, 0x61, 0x1a, 0xb7, 0xb1, 0xcb, 0xaa, 0xf6, 0x50, 0x38, 0xf6, 0x82, 0x9c, 0xe0, - 0x9a, 0x48, 0xc1, 0x0e, 0x89, 0xa9, 0xca, 0xb5, 0xfd, 0x03, 0x95, 0xfa, 0xa7, 0xe8, 0x0d, 0xa9, - 0x97, 0xf6, 0x52, 0x55, 0xd0, 0x1f, 0x52, 0x61, 0x3b, 0x94, 0xb6, 0x69, 0x54, 0xf5, 0x12, 0xc5, - 0x9f, 0xdf, 0xf7, 0xfd, 0x1e, 0x7f, 0x36, 0x68, 0xd0, 0x84, 0x10, 0x76, 0x18, 0x92, 0x68, 0x88, - 0x82, 0x11, 0x8e, 0x22, 0xc2, 0x28, 0x41, 0x93, 0x29, 0x49, 0x66, 0x6e, 0x9c, 0x70, 0xc1, 0x61, - 0xed, 0x41, 0xe1, 0x6e, 0x14, 0xd6, 0x8f, 0x80, 0xa7, 0x63, 0x9e, 0x22, 0x1f, 0xa7, 0x5a, 0x8e, - 0x8e, 0x3c, 0x9f, 0x08, 0xec, 0xa1, 0x18, 0xd3, 0x90, 0x61, 0x11, 0x72, 0xa6, 0x12, 0xac, 0x4f, - 0x4a, 0x3b, 0x90, 0x2b, 0xa4, 0x16, 0x7a, 0xab, 0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x0f, 0x1e, 0x49, - 0xfb, 0x00, 0x6b, 0xff, 0x60, 0xb3, 0xd3, 0xdd, 0x9d, 0x2f, 0x6d, 0x73, 0xb1, 0xb4, 0xcd, 0xdb, - 0xa5, 0x6d, 0x9e, 0xad, 0x6c, 0x63, 0xb1, 0xb2, 0x8d, 0xab, 0x95, 0x6d, 0x1c, 0x78, 0x34, 0x14, - 0xa3, 0xa9, 0xef, 0x06, 0x7c, 0x8c, 0x7c, 0xe6, 0xff, 0x0c, 0x46, 0x38, 0x64, 0xdb, 0xf1, 0xc7, - 0x4f, 0x1f, 0xa2, 0x5f, 0x91, 0x2f, 0xf1, 0xd7, 0x7d, 0x00, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x5f, - 0xe3, 0x99, 0x83, 0x03, 0x00, 0x00, + // 560 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4f, 0x8b, 0xd3, 0x4c, + 0x18, 0x6f, 0x76, 0xbb, 0x85, 0x9d, 0x7d, 0xd9, 0x57, 0xc6, 0x1e, 0x6a, 0x28, 0x71, 0x0d, 0x75, + 0xad, 0x82, 0x19, 0x5a, 0x05, 0xa5, 0xea, 0xc1, 0xf5, 0x54, 0xaa, 0xb0, 0x1b, 0x6f, 0x5e, 0xc2, + 0x4c, 0x3b, 0xa6, 0xc1, 0x74, 0x26, 0x9b, 0x99, 0x2c, 0xf6, 0xaa, 0x5f, 0x40, 0xf0, 0xe2, 0x07, + 0xf1, 0x43, 0xec, 0xc1, 0xc3, 0x82, 0x08, 0x9e, 0x44, 0x5a, 0x3f, 0x88, 0x64, 0x66, 0x52, 0xad, + 0x66, 0x5b, 0xd9, 0x4b, 0xc8, 0x3c, 0xf9, 0xfd, 0x7b, 0x9e, 0x3c, 0x0c, 0xd8, 0x0b, 0x53, 0x4a, + 0xd9, 0xcb, 0x88, 0xc6, 0x23, 0x34, 0x1c, 0xe3,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 0x11, 0x6a, 0xed, 0x42, 0xda, 0x8f, 0x2e, 0xc8, 0x36, 0x4d, 0xf5, 0x54, + 0x53, 0x77, 0x61, 0xb7, 0xbc, 0xa9, 0x48, 0x29, 0x98, 0xa6, 0x94, 0x44, 0x20, 0x0a, 0x8d, 0x83, + 0xc1, 0xe9, 0xcc, 0xb1, 0xce, 0x66, 0x8e, 0xf5, 0x7d, 0xe6, 0x58, 0xef, 0xe6, 0x4e, 0xe5, 0x6c, + 0xee, 0x54, 0xbe, 0xce, 0x9d, 0xca, 0x8b, 0x4e, 0x18, 0xc9, 0x71, 0x46, 0xbc, 0x21, 0x9f, 0x20, + 0xc2, 0xc8, 0xed, 0xe1, 0x18, 0x47, 0xec, 0x77, 0x87, 0xd7, 0x7f, 0x5e, 0x33, 0xa4, 0xa6, 0xee, + 0x99, 0x3b, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x57, 0x79, 0xbb, 0xeb, 0x61, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -249,8 +408,10 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // Queries the latest attested challenge id. - LatestAttestedChallenge(ctx context.Context, in *QueryLatestAttestedChallengeRequest, opts ...grpc.CallOption) (*QueryLatestAttestedChallengeResponse, error) + // Queries the latest attested challenge ids. + LatestAttestedChallenges(ctx context.Context, in *QueryLatestAttestedChallengesRequest, opts ...grpc.CallOption) (*QueryLatestAttestedChallengesResponse, error) + // Queries the inturn challenger. + InturnAttestationSubmitter(ctx context.Context, in *QueryInturnAttestationSubmitterRequest, opts ...grpc.CallOption) (*QueryInturnAttestationSubmitterResponse, error) } type queryClient struct { @@ -270,9 +431,18 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } -func (c *queryClient) LatestAttestedChallenge(ctx context.Context, in *QueryLatestAttestedChallengeRequest, opts ...grpc.CallOption) (*QueryLatestAttestedChallengeResponse, error) { - out := new(QueryLatestAttestedChallengeResponse) - err := c.cc.Invoke(ctx, "/greenfield.challenge.Query/LatestAttestedChallenge", in, out, opts...) +func (c *queryClient) LatestAttestedChallenges(ctx context.Context, in *QueryLatestAttestedChallengesRequest, opts ...grpc.CallOption) (*QueryLatestAttestedChallengesResponse, error) { + out := new(QueryLatestAttestedChallengesResponse) + err := c.cc.Invoke(ctx, "/greenfield.challenge.Query/LatestAttestedChallenges", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) InturnAttestationSubmitter(ctx context.Context, in *QueryInturnAttestationSubmitterRequest, opts ...grpc.CallOption) (*QueryInturnAttestationSubmitterResponse, error) { + out := new(QueryInturnAttestationSubmitterResponse) + err := c.cc.Invoke(ctx, "/greenfield.challenge.Query/InturnAttestationSubmitter", in, out, opts...) if err != nil { return nil, err } @@ -283,8 +453,10 @@ func (c *queryClient) LatestAttestedChallenge(ctx context.Context, in *QueryLate type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // Queries the latest attested challenge id. - LatestAttestedChallenge(context.Context, *QueryLatestAttestedChallengeRequest) (*QueryLatestAttestedChallengeResponse, error) + // Queries the latest attested challenge ids. + LatestAttestedChallenges(context.Context, *QueryLatestAttestedChallengesRequest) (*QueryLatestAttestedChallengesResponse, error) + // Queries the inturn challenger. + InturnAttestationSubmitter(context.Context, *QueryInturnAttestationSubmitterRequest) (*QueryInturnAttestationSubmitterResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -294,8 +466,11 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (*UnimplementedQueryServer) LatestAttestedChallenge(ctx context.Context, req *QueryLatestAttestedChallengeRequest) (*QueryLatestAttestedChallengeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LatestAttestedChallenge not implemented") +func (*UnimplementedQueryServer) LatestAttestedChallenges(ctx context.Context, req *QueryLatestAttestedChallengesRequest) (*QueryLatestAttestedChallengesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LatestAttestedChallenges not implemented") +} +func (*UnimplementedQueryServer) InturnAttestationSubmitter(ctx context.Context, req *QueryInturnAttestationSubmitterRequest) (*QueryInturnAttestationSubmitterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InturnAttestationSubmitter not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -320,20 +495,38 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_LatestAttestedChallenge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryLatestAttestedChallengeRequest) +func _Query_LatestAttestedChallenges_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryLatestAttestedChallengesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).LatestAttestedChallenge(ctx, in) + return srv.(QueryServer).LatestAttestedChallenges(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/greenfield.challenge.Query/LatestAttestedChallenge", + FullMethod: "/greenfield.challenge.Query/LatestAttestedChallenges", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).LatestAttestedChallenge(ctx, req.(*QueryLatestAttestedChallengeRequest)) + return srv.(QueryServer).LatestAttestedChallenges(ctx, req.(*QueryLatestAttestedChallengesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_InturnAttestationSubmitter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryInturnAttestationSubmitterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).InturnAttestationSubmitter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.challenge.Query/InturnAttestationSubmitter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).InturnAttestationSubmitter(ctx, req.(*QueryInturnAttestationSubmitterRequest)) } return interceptor(ctx, in, info, handler) } @@ -347,8 +540,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_Params_Handler, }, { - MethodName: "LatestAttestedChallenge", - Handler: _Query_LatestAttestedChallenge_Handler, + MethodName: "LatestAttestedChallenges", + Handler: _Query_LatestAttestedChallenges_Handler, + }, + { + MethodName: "InturnAttestationSubmitter", + Handler: _Query_InturnAttestationSubmitter_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -411,7 +608,7 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryLatestAttestedChallengeRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryLatestAttestedChallengesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -421,12 +618,12 @@ func (m *QueryLatestAttestedChallengeRequest) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryLatestAttestedChallengeRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryLatestAttestedChallengesRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryLatestAttestedChallengeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryLatestAttestedChallengesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -434,7 +631,7 @@ func (m *QueryLatestAttestedChallengeRequest) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *QueryLatestAttestedChallengeResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryLatestAttestedChallengesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -444,18 +641,129 @@ func (m *QueryLatestAttestedChallengeResponse) Marshal() (dAtA []byte, err error return dAtA[:n], nil } -func (m *QueryLatestAttestedChallengeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryLatestAttestedChallengesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryLatestAttestedChallengeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryLatestAttestedChallengesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.ChallengeId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ChallengeId)) + if len(m.ChallengeIds) > 0 { + dAtA3 := make([]byte, len(m.ChallengeIds)*10) + var j2 int + for _, num := range m.ChallengeIds { + for num >= 1<<7 { + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j2++ + } + dAtA3[j2] = uint8(num) + j2++ + } + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintQuery(dAtA, i, uint64(j2)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryInturnAttestationSubmitterRequest) 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 *QueryInturnAttestationSubmitterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInturnAttestationSubmitterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryInturnAttestationSubmitterResponse) 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 *QueryInturnAttestationSubmitterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInturnAttestationSubmitterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SubmitInterval != nil { + { + size, err := m.SubmitInterval.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.BlsPubKey) > 0 { + i -= len(m.BlsPubKey) + copy(dAtA[i:], m.BlsPubKey) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BlsPubKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SubmitInterval) 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 *SubmitInterval) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SubmitInterval) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.End != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.End)) + i-- + dAtA[i] = 0x10 + } + if m.Start != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Start)) i-- dAtA[i] = 0x8 } @@ -493,7 +801,32 @@ func (m *QueryParamsResponse) Size() (n int) { return n } -func (m *QueryLatestAttestedChallengeRequest) Size() (n int) { +func (m *QueryLatestAttestedChallengesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryLatestAttestedChallengesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ChallengeIds) > 0 { + l = 0 + for _, e := range m.ChallengeIds { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *QueryInturnAttestationSubmitterRequest) Size() (n int) { if m == nil { return 0 } @@ -502,14 +835,34 @@ func (m *QueryLatestAttestedChallengeRequest) Size() (n int) { return n } -func (m *QueryLatestAttestedChallengeResponse) Size() (n int) { +func (m *QueryInturnAttestationSubmitterResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.ChallengeId != 0 { - n += 1 + sovQuery(uint64(m.ChallengeId)) + l = len(m.BlsPubKey) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.SubmitInterval != nil { + l = m.SubmitInterval.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *SubmitInterval) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Start != 0 { + n += 1 + sovQuery(uint64(m.Start)) + } + if m.End != 0 { + n += 1 + sovQuery(uint64(m.End)) } return n } @@ -653,7 +1006,57 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryLatestAttestedChallengeRequest) Unmarshal(dAtA []byte) error { +func (m *QueryLatestAttestedChallengesRequest) 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: QueryLatestAttestedChallengesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLatestAttestedChallengesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLatestAttestedChallengesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -676,12 +1079,88 @@ func (m *QueryLatestAttestedChallengeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryLatestAttestedChallengeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryLatestAttestedChallengesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLatestAttestedChallengeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryLatestAttestedChallengesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChallengeIds = append(m.ChallengeIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ChallengeIds) == 0 { + m.ChallengeIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChallengeIds = append(m.ChallengeIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ChallengeIds", wireType) + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -703,7 +1182,7 @@ func (m *QueryLatestAttestedChallengeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryLatestAttestedChallengeResponse) Unmarshal(dAtA []byte) error { +func (m *QueryInturnAttestationSubmitterRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -726,17 +1205,204 @@ func (m *QueryLatestAttestedChallengeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryLatestAttestedChallengeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryInturnAttestationSubmitterRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLatestAttestedChallengeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryInturnAttestationSubmitterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryInturnAttestationSubmitterResponse) 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: QueryInturnAttestationSubmitterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInturnAttestationSubmitterResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsPubKey", 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.BlsPubKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubmitInterval", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SubmitInterval == nil { + m.SubmitInterval = &SubmitInterval{} + } + if err := m.SubmitInterval.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SubmitInterval) 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: SubmitInterval: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubmitInterval: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Start", wireType) + } + m.Start = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Start |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ChallengeId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field End", wireType) } - m.ChallengeId = 0 + m.End = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -746,7 +1412,7 @@ func (m *QueryLatestAttestedChallengeResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ChallengeId |= uint64(b&0x7F) << shift + m.End |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/challenge/types/query.pb.gw.go b/x/challenge/types/query.pb.gw.go index c6080412d..3682f1117 100644 --- a/x/challenge/types/query.pb.gw.go +++ b/x/challenge/types/query.pb.gw.go @@ -51,20 +51,38 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } -func request_Query_LatestAttestedChallenge_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLatestAttestedChallengeRequest +func request_Query_LatestAttestedChallenges_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestAttestedChallengesRequest var metadata runtime.ServerMetadata - msg, err := client.LatestAttestedChallenge(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.LatestAttestedChallenges(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_LatestAttestedChallenge_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLatestAttestedChallengeRequest +func local_request_Query_LatestAttestedChallenges_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestAttestedChallengesRequest var metadata runtime.ServerMetadata - msg, err := server.LatestAttestedChallenge(ctx, &protoReq) + msg, err := server.LatestAttestedChallenges(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_InturnAttestationSubmitter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInturnAttestationSubmitterRequest + var metadata runtime.ServerMetadata + + msg, err := client.InturnAttestationSubmitter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_InturnAttestationSubmitter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInturnAttestationSubmitterRequest + var metadata runtime.ServerMetadata + + msg, err := server.InturnAttestationSubmitter(ctx, &protoReq) return msg, metadata, err } @@ -98,7 +116,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_LatestAttestedChallenge_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_LatestAttestedChallenges_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -109,7 +127,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_LatestAttestedChallenge_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_LatestAttestedChallenges_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -117,7 +135,30 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_LatestAttestedChallenge_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_LatestAttestedChallenges_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_InturnAttestationSubmitter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_InturnAttestationSubmitter_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_InturnAttestationSubmitter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -182,7 +223,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_LatestAttestedChallenge_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_LatestAttestedChallenges_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) @@ -191,14 +232,34 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_LatestAttestedChallenge_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_LatestAttestedChallenges_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_LatestAttestedChallenge_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_LatestAttestedChallenges_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_InturnAttestationSubmitter_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_InturnAttestationSubmitter_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_InturnAttestationSubmitter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -208,11 +269,15 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "challenge", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_LatestAttestedChallenge_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "challenge", "latest_attested_challenge"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_LatestAttestedChallenges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "challenge", "latest_attested_challenge"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_InturnAttestationSubmitter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "challenge", "inturn_attestation_submitter"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage - forward_Query_LatestAttestedChallenge_0 = runtime.ForwardResponseMessage + forward_Query_LatestAttestedChallenges_0 = runtime.ForwardResponseMessage + + forward_Query_InturnAttestationSubmitter_0 = runtime.ForwardResponseMessage ) diff --git a/x/challenge/types/types.pb.go b/x/challenge/types/types.pb.go index fc238abe8..adfd67347 100644 --- a/x/challenge/types/types.pb.go +++ b/x/challenge/types/types.pb.go @@ -164,40 +164,108 @@ func (m *Challenge) GetExpiredHeight() uint64 { return 0 } +// AttestedChallengeIds stored fixed number of the latest attested challenge ids. +// To use the storage more efficiently, a circular queue will be constructed using these fields. +type AttestedChallengeIds struct { + // The fixed number of challenge ids to save. + Size_ uint64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` + // The latest attested challenge ids. + Ids []uint64 `protobuf:"varint,2,rep,packed,name=ids,proto3" json:"ids,omitempty"` + // The cursor to retrieve data from the ids field. + Cursor int64 `protobuf:"varint,3,opt,name=cursor,proto3" json:"cursor,omitempty"` +} + +func (m *AttestedChallengeIds) Reset() { *m = AttestedChallengeIds{} } +func (m *AttestedChallengeIds) String() string { return proto.CompactTextString(m) } +func (*AttestedChallengeIds) ProtoMessage() {} +func (*AttestedChallengeIds) Descriptor() ([]byte, []int) { + return fileDescriptor_9c297f0764c47d40, []int{2} +} +func (m *AttestedChallengeIds) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AttestedChallengeIds) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AttestedChallengeIds.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 *AttestedChallengeIds) XXX_Merge(src proto.Message) { + xxx_messageInfo_AttestedChallengeIds.Merge(m, src) +} +func (m *AttestedChallengeIds) XXX_Size() int { + return m.Size() +} +func (m *AttestedChallengeIds) XXX_DiscardUnknown() { + xxx_messageInfo_AttestedChallengeIds.DiscardUnknown(m) +} + +var xxx_messageInfo_AttestedChallengeIds proto.InternalMessageInfo + +func (m *AttestedChallengeIds) GetSize_() uint64 { + if m != nil { + return m.Size_ + } + return 0 +} + +func (m *AttestedChallengeIds) GetIds() []uint64 { + if m != nil { + return m.Ids + } + return nil +} + +func (m *AttestedChallengeIds) GetCursor() int64 { + if m != nil { + return m.Cursor + } + return 0 +} + func init() { proto.RegisterEnum("greenfield.challenge.VoteResult", VoteResult_name, VoteResult_value) proto.RegisterType((*Slash)(nil), "greenfield.challenge.Slash") proto.RegisterType((*Challenge)(nil), "greenfield.challenge.Challenge") + proto.RegisterType((*AttestedChallengeIds)(nil), "greenfield.challenge.AttestedChallengeIds") } func init() { proto.RegisterFile("greenfield/challenge/types.proto", fileDescriptor_9c297f0764c47d40) } var fileDescriptor_9c297f0764c47d40 = []byte{ - // 369 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x2f, 0x4a, 0x4d, - 0xcd, 0x4b, 0xcb, 0x4c, 0xcd, 0x49, 0xd1, 0x4f, 0xce, 0x48, 0xcc, 0xc9, 0x49, 0xcd, 0x4b, 0x4f, - 0xd5, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, - 0xd0, 0x83, 0xab, 0x90, 0x92, 0x4c, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x8e, 0x07, 0xab, 0xd1, 0x87, - 0x70, 0x20, 0x1a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0x21, 0xe2, 0x20, 0x16, 0x44, 0x54, 0xa9, - 0x93, 0x91, 0x8b, 0x35, 0x38, 0x27, 0xb1, 0x38, 0x43, 0x48, 0x8f, 0x4b, 0xb8, 0xb8, 0x20, 0x3e, - 0xbf, 0x20, 0xb5, 0x28, 0xb1, 0x24, 0xbf, 0x28, 0x3e, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x58, - 0x82, 0x51, 0x81, 0x51, 0x83, 0x27, 0x48, 0xb0, 0xb8, 0xc0, 0x1f, 0x2a, 0xe3, 0x08, 0x91, 0x10, - 0xb2, 0xe0, 0xe2, 0xcc, 0x4f, 0xca, 0x4a, 0x4d, 0x2e, 0x89, 0xcf, 0x4c, 0x91, 0x60, 0x52, 0x60, - 0xd4, 0xe0, 0x74, 0x92, 0x3e, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x96, 0xd0, 0xcc, 0xbc, - 0x92, 0x4b, 0x5b, 0x74, 0xb9, 0xa1, 0x0e, 0x00, 0x71, 0x83, 0x38, 0x20, 0xaa, 0x3d, 0x53, 0x84, - 0xc4, 0xb8, 0xd8, 0x32, 0x52, 0x33, 0xd3, 0x33, 0x4a, 0x24, 0x98, 0x15, 0x18, 0x35, 0x58, 0x82, - 0xa0, 0x3c, 0x25, 0x27, 0x2e, 0x4e, 0x67, 0x98, 0x4f, 0x84, 0xf8, 0xb8, 0x98, 0x32, 0x53, 0xc0, - 0xb6, 0xb3, 0x04, 0x31, 0x65, 0xa6, 0x08, 0xa9, 0x72, 0xf1, 0xa5, 0x56, 0x14, 0x64, 0x16, 0xa5, - 0xa6, 0xc4, 0x43, 0x35, 0x33, 0x81, 0xe5, 0x78, 0xa1, 0xa2, 0x1e, 0x60, 0x41, 0x2d, 0x7b, 0x2e, - 0xae, 0xb0, 0xfc, 0x92, 0xd4, 0xa0, 0xd4, 0xe2, 0xd2, 0x9c, 0x12, 0x21, 0x11, 0x2e, 0x01, 0x67, - 0x0f, 0x47, 0x1f, 0x1f, 0x57, 0x3f, 0x77, 0xd7, 0x78, 0x37, 0x47, 0x4f, 0x1f, 0x57, 0x17, 0x01, - 0x06, 0x21, 0x51, 0x2e, 0x41, 0x84, 0x68, 0x70, 0xa8, 0xb3, 0xb3, 0xab, 0xab, 0x8b, 0x00, 0xa3, - 0x14, 0x4b, 0xc7, 0x62, 0x39, 0x06, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, - 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, - 0x63, 0x88, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xca, - 0x4b, 0xd2, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x47, 0x8a, 0xa8, 0x0a, 0xf4, 0xa8, 0x4a, 0x62, - 0x03, 0x07, 0xb2, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x0d, 0x66, 0x7b, 0xc7, 0xcf, 0x01, 0x00, - 0x00, + // 416 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0xcf, 0x6a, 0xd4, 0x40, + 0x18, 0xcf, 0x64, 0x63, 0x71, 0x47, 0x2d, 0xe9, 0x18, 0x25, 0xae, 0x90, 0x86, 0x82, 0x10, 0x84, + 0x26, 0x88, 0x17, 0x6f, 0x92, 0x4d, 0xa3, 0x5d, 0x5c, 0x14, 0x52, 0xeb, 0xc1, 0x4b, 0x48, 0x32, + 0x9f, 0xc9, 0x48, 0x9a, 0x09, 0x33, 0xb3, 0x50, 0x7d, 0x02, 0xbd, 0xf9, 0x0e, 0xbe, 0x82, 0x0f, + 0xd1, 0x63, 0xf1, 0x24, 0x1e, 0x8a, 0xec, 0xbe, 0x88, 0xe4, 0x8f, 0xad, 0xf4, 0xf6, 0xfd, 0xfe, + 0x7c, 0xbf, 0xfc, 0xc2, 0x37, 0xd8, 0x2d, 0x05, 0x40, 0xf3, 0x81, 0x41, 0x4d, 0x83,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x18, 0x03, 0xfb, 0x99, 0x98, 0x78, 0xc2, 0xa8, 0xb4, 0x75, 0x77, + 0xe2, 0x19, 0x49, 0x37, 0x76, 0xcd, 0x8a, 0x95, 0x90, 0x5c, 0xf4, 0xcd, 0x26, 0xc9, 0x88, 0x1e, + 0x3f, 0xc7, 0xf8, 0x1d, 0x57, 0x90, 0x80, 0x5c, 0xd5, 0x8a, 0x58, 0xd8, 0x8c, 0x0e, 0xc3, 0xe5, + 0x32, 0x7e, 0xfd, 0x32, 0x4e, 0x5f, 0x84, 0x8b, 0x65, 0x7c, 0x60, 0x6a, 0xe4, 0x1e, 0xde, 0xb9, + 0x62, 0x8f, 0x8e, 0xa3, 0x28, 0x8e, 0x0f, 0x4c, 0x34, 0x33, 0xbe, 0x7c, 0x77, 0xb4, 0xf9, 0xab, + 0xb3, 0xb5, 0x83, 0xce, 0xd7, 0x0e, 0xfa, 0xb3, 0x76, 0xd0, 0xb7, 0x8d, 0xa3, 0x9d, 0x6f, 0x1c, + 0xed, 0xd7, 0xc6, 0xd1, 0xde, 0x3f, 0x29, 0x99, 0xaa, 0x56, 0xb9, 0x5f, 0xf0, 0x93, 0x20, 0x6f, + 0xf2, 0xfd, 0xa2, 0xca, 0x58, 0x13, 0xfc, 0x77, 0xfe, 0xd3, 0xeb, 0x0f, 0x20, 0xdf, 0xea, 0x4f, + 0xf7, 0xf4, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0x65, 0x6e, 0xca, 0x25, 0x02, 0x00, 0x00, } func (m *Slash) Marshal() (dAtA []byte, err error) { @@ -278,6 +346,57 @@ func (m *Challenge) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AttestedChallengeIds) 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 *AttestedChallengeIds) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AttestedChallengeIds) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Cursor != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Cursor)) + i-- + dAtA[i] = 0x18 + } + if len(m.Ids) > 0 { + dAtA2 := make([]byte, len(m.Ids)*10) + var j1 int + for _, num := range m.Ids { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintTypes(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x12 + } + if m.Size_ != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Size_)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -322,6 +441,28 @@ func (m *Challenge) Size() (n int) { return n } +func (m *AttestedChallengeIds) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Size_ != 0 { + n += 1 + sovTypes(uint64(m.Size_)) + } + if len(m.Ids) > 0 { + l = 0 + for _, e := range m.Ids { + l += sovTypes(uint64(e)) + } + n += 1 + sovTypes(uint64(l)) + l + } + if m.Cursor != 0 { + n += 1 + sovTypes(uint64(m.Cursor)) + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -553,6 +694,170 @@ func (m *Challenge) Unmarshal(dAtA []byte) error { } return nil } +func (m *AttestedChallengeIds) 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 ErrIntOverflowTypes + } + 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: AttestedChallengeIds: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AttestedChallengeIds: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) + } + m.Size_ = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size_ |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Ids) == 0 { + m.Ids = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Cursor", wireType) + } + m.Cursor = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Cursor |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0