diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index e5a1b87f8..b54f6057f 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -54,3 +54,24 @@ jobs: - name: run e2e test run: | make e2e_test + - name: stop e2e local chain + run: | + make e2e_stop_localchain + - name: make coverage report + id: coverage-report + if: github.event_name == 'pull_request' + continue-on-error: true + run: | + echo '## E2E Test Coverage Report' >> coverage-report.txt + echo 'commit-id: ${{ github.event.pull_request.head.sha }}' >> coverage-report.txt + echo 'generated by https://github.com/vladopajic/go-test-coverage' >> coverage-report.txt + echo >> coverage-report.txt + echo '
Additional details and impacted files' >> coverage-report.txt + echo >> coverage-report.txt + echo '```' >> coverage-report.txt + make check-e2e-coverage >> coverage-report.txt + echo '```' >> coverage-report.txt + echo >> coverage-report.txt + echo '
' >> coverage-report.txt + + cat coverage-report.txt >> $GITHUB_STEP_SUMMARY diff --git a/.testcoverage.yml b/.testcoverage.yml new file mode 100644 index 000000000..8415c3bba --- /dev/null +++ b/.testcoverage.yml @@ -0,0 +1,42 @@ +# (mandatory) +# Path to coverprofile file (output of `go test -coverprofile` command) +profile: coverage.out + +# (optional) +# When specified reported file paths will not contain local prefix in the output +local-prefix: "github.com/bnb-chain/greenfield" + +# Holds coverage thresholds percentages, values should be in range [0-100] +threshold: + # (optional; default 0) + # The minimum coverage that each file should have + file: 80 + + # (optional; default 0) + # The minimum coverage that each package should have + package: 80 + + # (optional; default 0) + # The minimum total coverage project should have + total: 80 + +# Holds regexp rules which will override thresholds for matched files or packages +override: + # Increase coverage threshold to 100% for `foo` package (default is 80, as configured above) + # - threshold: 100 + # path: ^pkg/lib/foo$ + +# Holds regexp rules which will exclude matched files or packages from coverage statistics +exclude: + # Exclude files or packages matching their paths + paths: + - \.pb\.go$ # excludes all protobuf generated files + - \.pb\.gw\.go$ # excludes all protobuf generated files + - .*_mocks.go$ # excludes all protobuf generated files + - testutil/.* + - e2e/.* + - internal/sequence/.* + +# NOTES: +# - symbol `/` in all path regexps will be replaced by +# current OS file path separator to properly work on Windows \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 36fa24b32..e4e0a1eef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 0.2.3-alpha.7 +This release includes 2 features and 3 bugfixes. + +Features: +* [#366](https://github.com/bnb-chain/greenfield/pull/366) feat: add strategy for event emit +* [#368](https://github.com/bnb-chain/greenfield/pull/368) feat: limit sp slash amount and add query api + +Bugfixes: +* [#369](https://github.com/bnb-chain/greenfield/pull/369) fix: parse failed when object name contains / +* [#370](https://github.com/bnb-chain/greenfield/pull/370) fix: fix the precision issue of storage bill +* [#371](https://github.com/bnb-chain/greenfield/pull/371) fix: add src dst sp check when migrate bucket + +Chores: +* [#365](https://github.com/bnb-chain/greenfield/pull/365) ci: add e2e test coverage report + ## 0.2.3-alpha.6 This release includes 6 features and 5 bugfixes. diff --git a/Makefile b/Makefile index 55c929621..f015a6109 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ .PHONY: build build-linux build-macos build-windows .PHONY: tools proto-gen proto-format test e2e_test ci lint +.PHONY: install-go-test-coverage check-coverage VERSION=$(shell git describe --tags --always) GIT_COMMIT=$(shell git rev-parse HEAD) @@ -8,6 +9,8 @@ REPO=github.com/bnb-chain/greenfield IMAGE_NAME=ghcr.io/bnb-chain/greenfield REPO=github.com/bnb-chain/greenfield +GOBIN ?= $$(go env GOPATH)/bin + ldflags = -X $(REPO)/version.AppVersion=$(VERSION) \ -X $(REPO)/version.GitCommit=$(GIT_COMMIT) \ -X $(REPO)/version.GitCommitDate=$(GIT_COMMIT_DATE) @@ -51,8 +54,17 @@ test: e2e_start_localchain: bash ./deployment/localup/localup.sh all 1 7 +e2e_stop_localchain: + bash ./deployment/localup/localup.sh stop + e2e_test: - go test -p 1 -failfast -v ./e2e/... -timeout 99999s + go test -p 1 -failfast -v ./e2e/... -coverpkg=./... -covermode=atomic -coverprofile=./coverage.out -timeout 99999s + +install-go-test-coverage: + @go install github.com/vladopajic/go-test-coverage/v2@latest + +check-e2e-coverage: install-go-test-coverage + @go-test-coverage --config=./.testcoverage.yml || true lint: golangci-lint run --fix diff --git a/cmd/gnfd/cmd/root.go b/cmd/gnfd/cmd/root.go index bd190aa00..8d7b6ba04 100644 --- a/cmd/gnfd/cmd/root.go +++ b/cmd/gnfd/cmd/root.go @@ -357,6 +357,7 @@ func (a appCreator) newApp( &app.AppConfig{Config: *serverConfig, CrossChain: appConfig.CrossChain}, appOpts, baseapp.SetPruning(pruningOpts), + baseapp.SetEventing(cast.ToString(appOpts.Get(server.FlagEventing))), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))), baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), diff --git a/e2e/core/basesuite.go b/e2e/core/basesuite.go index 3214fb6be..e2197e6e6 100644 --- a/e2e/core/basesuite.go +++ b/e2e/core/basesuite.go @@ -130,12 +130,12 @@ func (s *BaseSuite) RefreshGVGFamilies() { } gvgsResp, err3 := s.Client.GlobalVirtualGroupByFamilyID(context.Background(), &virtualgroupmoduletypes.QueryGlobalVirtualGroupByFamilyIDRequest{ - StorageProviderId: sp.Info.Id, GlobalVirtualGroupFamilyId: gvgFamily.Id, }) s.Require().NoError(err3) sp.GlobalVirtualGroupFamilies[gvgFamily.Id] = gvgsResp.GlobalVirtualGroups s.StorageProviders[gvgFamily.PrimarySpId] = sp + s.T().Logf("resp: %s", gvgsResp.String()) } } diff --git a/e2e/tests/challenge_test.go b/e2e/tests/challenge_test.go index 795bf04b6..31d73bd82 100644 --- a/e2e/tests/challenge_test.go +++ b/e2e/tests/challenge_test.go @@ -19,7 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/stretchr/testify/suite" @@ -32,10 +32,12 @@ import ( type ChallengeTestSuite struct { core.BaseSuite + defaultParams challengetypes.Params } func (s *ChallengeTestSuite) SetupSuite() { s.BaseSuite.SetupSuite() + s.defaultParams = s.queryParams() } func (s *ChallengeTestSuite) SetupTest() { @@ -45,9 +47,8 @@ func TestChallengeTestSuite(t *testing.T) { suite.Run(t, new(ChallengeTestSuite)) } -func (s *ChallengeTestSuite) createObject() (string, string, *core.StorageProvider) { +func (s *ChallengeTestSuite) createObject(sp *core.StorageProvider) (string, string, *core.StorageProvider) { var err error - sp := s.BaseSuite.PickStorageProvider() gvg, found := sp.GetFirstGlobalVirtualGroup() s.Require().True(found) @@ -141,8 +142,9 @@ func (s *ChallengeTestSuite) createObject() (string, string, *core.StorageProvid func (s *ChallengeTestSuite) TestSubmit() { user := s.GenAndChargeAccounts(1, 1000000)[0] + sp := s.PickStorageProvider() - bucketName, objectName, primarySp := s.createObject() + bucketName, objectName, primarySp := s.createObject(sp) msgSubmit := challengetypes.NewMsgSubmit(user.GetAddr(), primarySp.OperatorKey.GetAddr(), bucketName, objectName, true, 1000) txRes := s.SendTxBlock(user, msgSubmit) event := filterChallengeEventFromTx(txRes) // secondary sps are faked with primary sp, redundancy check is meaningless here @@ -150,7 +152,7 @@ func (s *ChallengeTestSuite) TestSubmit() { s.Require().NotEqual(event.SegmentIndex, uint32(100)) s.Require().Equal(event.SpOperatorAddress, primarySp.OperatorKey.GetAddr().String()) - bucketName, objectName, _ = s.createObject() + bucketName, objectName, _ = s.createObject(sp) msgSubmit = challengetypes.NewMsgSubmit(user.GetAddr(), primarySp.OperatorKey.GetAddr(), bucketName, objectName, false, 0) txRes = s.SendTxBlock(user, msgSubmit) @@ -180,8 +182,9 @@ func (s *ChallengeTestSuite) calculateValidatorBitSet(height int64, blsKey strin func (s *ChallengeTestSuite) TestNormalAttest() { user := s.GenAndChargeAccounts(1, 1000000)[0] + sp := s.PickStorageProvider() - bucketName, objectName, primarySp := s.createObject() + bucketName, objectName, primarySp := s.createObject(sp) msgSubmit := challengetypes.NewMsgSubmit(user.GetAddr(), primarySp.OperatorKey.GetAddr(), bucketName, objectName, true, 1000) txRes := s.SendTxBlock(user, msgSubmit) event := filterChallengeEventFromTx(txRes) @@ -219,24 +222,31 @@ func (s *ChallengeTestSuite) TestNormalAttest() { txRes = s.SendTxBlock(s.Challenger, msgAttest) s.Require().True(txRes.Code == 0) - queryRes, err := s.Client.ChallengeQueryClient.LatestAttestedChallenges(context.Background(), &challengetypes.QueryLatestAttestedChallengesRequest{}) + queryAllRes, err := s.Client.ChallengeQueryClient.LatestAttestedChallenges(context.Background(), &challengetypes.QueryLatestAttestedChallengesRequest{}) s.Require().NoError(err) found := false + challengeId := uint64(0) result := challengetypes.CHALLENGE_FAILED - for _, challenge := range queryRes.Challenges { + for _, challenge := range queryAllRes.Challenges { if challenge.Id == event.ChallengeId { found = true + challengeId = challenge.Id result = challenge.Result break } } s.Require().True(found) s.Require().True(result == challengetypes.CHALLENGE_SUCCEED) + + queryOneRes, err := s.Client.ChallengeQueryClient.AttestedChallenge(context.Background(), &challengetypes.QueryAttestedChallengeRequest{ChallengeId: challengeId}) + s.Require().NoError(err) + s.Require().True(queryOneRes.Challenge.Result == challengetypes.CHALLENGE_SUCCEED) } func (s *ChallengeTestSuite) TestHeartbeatAttest() { + sp := s.PickStorageProvider() for i := 0; i < 3; i++ { - s.createObject() + s.createObject(sp) } heartbeatInterval := uint64(100) @@ -317,8 +327,9 @@ func (s *ChallengeTestSuite) TestHeartbeatAttest() { func (s *ChallengeTestSuite) TestFailedAttest_ChallengeExpired() { user := s.GenAndChargeAccounts(1, 1000000)[0] + sp := s.PickStorageProvider() - bucketName, objectName, primarySp := s.createObject() + bucketName, objectName, primarySp := s.createObject(sp) msgSubmit := challengetypes.NewMsgSubmit(user.GetAddr(), primarySp.OperatorKey.GetAddr(), bucketName, objectName, true, 1000) txRes := s.SendTxBlock(user, msgSubmit) event := filterChallengeEventFromTx(txRes) @@ -356,9 +367,96 @@ func (s *ChallengeTestSuite) TestFailedAttest_ChallengeExpired() { s.SendTxBlockWithExpectErrorString(msgAttest, user, challengetypes.ErrInvalidChallengeId.Error()) } +func (s *ChallengeTestSuite) TestFailedAttest_ExceedMaxSlashAmount() { + defer s.revertParams() + params := s.queryParams() + params.SpSlashMaxAmount = sdkmath.NewInt(1) // extreme small + s.updateParams(params) + + user := s.GenAndChargeAccounts(1, 1000000)[0] + sp := s.PickStorageProvider() + + // first one is allowed to slash + bucketName, objectName, primarySp := s.createObject(sp) + msgSubmit := challengetypes.NewMsgSubmit(user.GetAddr(), primarySp.OperatorKey.GetAddr(), bucketName, objectName, true, 1000) + txRes := s.SendTxBlock(user, msgSubmit) + event := filterChallengeEventFromTx(txRes) + + statusRes, err := s.TmClient.TmClient.Status(context.Background()) + s.Require().NoError(err) + height := statusRes.SyncInfo.LatestBlockHeight + + valBitset := s.calculateValidatorBitSet(height, s.ValidatorBLS.PubKey().String()) + + msgAttest := challengetypes.NewMsgAttest(s.Challenger.GetAddr(), event.ChallengeId, event.ObjectId, primarySp.OperatorKey.GetAddr().String(), + challengetypes.CHALLENGE_SUCCEED, user.GetAddr().String(), valBitset.Bytes(), nil) + toSign := msgAttest.GetBlsSignBytes(s.Config.ChainId) + + voteAggSignature, err := s.ValidatorBLS.Sign(toSign[:]) + if err != nil { + panic(err) + } + msgAttest.VoteAggSignature = voteAggSignature + + // 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.PubKey().Bytes()) { + break + } + } + + // submit attest + txRes = s.SendTxBlock(s.Challenger, msgAttest) + s.Require().True(txRes.Code == 0) + + // second one will be not allowed + bucketName, objectName, primarySp = s.createObject(sp) + msgSubmit = challengetypes.NewMsgSubmit(user.GetAddr(), primarySp.OperatorKey.GetAddr(), bucketName, objectName, true, 1000) + txRes = s.SendTxBlock(user, msgSubmit) + event = filterChallengeEventFromTx(txRes) + + statusRes, err = s.TmClient.TmClient.Status(context.Background()) + s.Require().NoError(err) + height = statusRes.SyncInfo.LatestBlockHeight + + valBitset = s.calculateValidatorBitSet(height, s.ValidatorBLS.PubKey().String()) + + msgAttest = challengetypes.NewMsgAttest(s.Challenger.GetAddr(), event.ChallengeId, event.ObjectId, primarySp.OperatorKey.GetAddr().String(), + challengetypes.CHALLENGE_SUCCEED, user.GetAddr().String(), valBitset.Bytes(), nil) + toSign = msgAttest.GetBlsSignBytes(s.Config.ChainId) + + voteAggSignature, err = s.ValidatorBLS.Sign(toSign[:]) + if err != nil { + panic(err) + } + msgAttest.VoteAggSignature = voteAggSignature + + // 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.PubKey().Bytes()) { + break + } + } + + s.SendTxBlock(s.Challenger, msgAttest) // no error +} + func (s *ChallengeTestSuite) TestEndBlock() { + sp := s.PickStorageProvider() for i := 0; i < 3; i++ { - s.createObject() + s.createObject(sp) } statusRes, err := s.TmClient.TmClient.Status(context.Background()) @@ -456,7 +554,7 @@ func (s *ChallengeTestSuite) TestUpdateChallengerParams() { Params: updatedParams, } - proposal, err := v1.NewMsgSubmitProposal([]sdk.Msg{msgUpdateParams}, sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(1000000000000000000))), + proposal, err := govtypesv1.NewMsgSubmitProposal([]sdk.Msg{msgUpdateParams}, sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(1000000000000000000))), s.Validator.GetAddr().String(), "", "update Challenger params", "Test update Challenger params") s.Require().NoError(err) txBroadCastResp, err := s.SendTxBlockWithoutCheck(proposal, s.Validator) @@ -488,7 +586,7 @@ func (s *ChallengeTestSuite) TestUpdateChallengerParams() { Memo: "", FeeAmount: sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(1000000000000000000))), } - voteBroadCastResp, err := s.SendTxBlockWithoutCheckWithTxOpt(v1.NewMsgVote(s.Validator.GetAddr(), uint64(proposalID), v1.OptionYes, ""), + voteBroadCastResp, err := s.SendTxBlockWithoutCheckWithTxOpt(govtypesv1.NewMsgVote(s.Validator.GetAddr(), uint64(proposalID), govtypesv1.OptionYes, ""), s.Validator, txOpt) s.Require().NoError(err) voteResp, err := s.WaitForTx(voteBroadCastResp.TxResponse.TxHash) @@ -502,20 +600,20 @@ func (s *ChallengeTestSuite) TestUpdateChallengerParams() { // 3. query proposal until it is end voting period CheckProposalStatus: for { - queryProposalResp, err := s.Client.Proposal(context.Background(), &v1.QueryProposalRequest{ProposalId: uint64(proposalID)}) + queryProposalResp, err := s.Client.Proposal(context.Background(), &govtypesv1.QueryProposalRequest{ProposalId: uint64(proposalID)}) s.Require().NoError(err) - if queryProposalResp.Proposal.Status != v1.StatusVotingPeriod { + if queryProposalResp.Proposal.Status != govtypesv1.StatusVotingPeriod { switch queryProposalResp.Proposal.Status { - case v1.StatusDepositPeriod: + case govtypesv1.StatusDepositPeriod: s.T().Errorf("proposal deposit period") return - case v1.StatusRejected: + case govtypesv1.StatusRejected: s.T().Errorf("proposal rejected") return - case v1.StatusPassed: + case govtypesv1.StatusPassed: s.T().Logf("proposal passed") break CheckProposalStatus - case v1.StatusFailed: + case govtypesv1.StatusFailed: s.T().Errorf("proposal failed, reason %s", queryProposalResp.Proposal.FailedReason) return } @@ -535,3 +633,85 @@ CheckProposalStatus: s.T().Errorf("update params failed") } } + +func (s *ChallengeTestSuite) revertParams() { + s.updateParams(s.defaultParams) +} + +func (s *ChallengeTestSuite) queryParams() challengetypes.Params { + queryParamsRequest := challengetypes.QueryParamsRequest{} + queryParamsResponse, err := s.Client.ChallengeQueryClient.Params(context.Background(), &queryParamsRequest) + s.Require().NoError(err) + s.T().Log("params", core.YamlString(queryParamsResponse.Params)) + return queryParamsResponse.Params +} + +func (s *ChallengeTestSuite) updateParams(params challengetypes.Params) { + var err error + validator := s.Validator.GetAddr() + + ctx := context.Background() + + queryParamsRequest := &challengetypes.QueryParamsRequest{} + queryParamsResponse, err := s.Client.ChallengeQueryClient.Params(ctx, queryParamsRequest) + s.Require().NoError(err) + s.T().Log("params before", core.YamlString(queryParamsResponse.Params)) + + msgUpdateParams := &challengetypes.MsgUpdateParams{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Params: params, + } + + msgProposal, err := govtypesv1.NewMsgSubmitProposal( + []sdk.Msg{msgUpdateParams}, + sdk.Coins{sdk.NewCoin(s.BaseSuite.Config.Denom, types.NewIntFromInt64WithDecimal(100, types.DecimalBNB))}, + validator.String(), + "test", "test", "test", + ) + s.Require().NoError(err) + + txRes := s.SendTxBlock(s.Validator, msgProposal) + s.Require().Equal(txRes.Code, uint32(0)) + + // 3. query proposal and get proposal ID + var proposalId uint64 + for _, event := range txRes.Logs[0].Events { + if event.Type == "submit_proposal" { + for _, attr := range event.Attributes { + if attr.Key == "proposal_id" { + proposalId, err = strconv.ParseUint(attr.Value, 10, 0) + s.Require().NoError(err) + break + } + } + break + } + } + s.Require().True(proposalId != 0) + + queryProposal := &govtypesv1.QueryProposalRequest{ProposalId: proposalId} + _, err = s.Client.GovQueryClientV1.Proposal(ctx, queryProposal) + s.Require().NoError(err) + + // 4. submit MsgVote and wait the proposal exec + msgVote := govtypesv1.NewMsgVote(validator, proposalId, govtypesv1.OptionYes, "test") + txRes = s.SendTxBlock(s.Validator, msgVote) + s.Require().Equal(txRes.Code, uint32(0)) + + queryVoteParamsReq := govtypesv1.QueryParamsRequest{ParamsType: "voting"} + queryVoteParamsResp, err := s.Client.GovQueryClientV1.Params(ctx, &queryVoteParamsReq) + s.Require().NoError(err) + + // 5. wait a voting period and confirm that the proposal success. + s.T().Logf("voting period %s", *queryVoteParamsResp.Params.VotingPeriod) + time.Sleep(*queryVoteParamsResp.Params.VotingPeriod) + time.Sleep(1 * time.Second) + proposalRes, err := s.Client.GovQueryClientV1.Proposal(ctx, queryProposal) + s.Require().NoError(err) + s.Require().Equal(proposalRes.Proposal.Status, govtypesv1.ProposalStatus_PROPOSAL_STATUS_PASSED) + + queryParamsRequest = &challengetypes.QueryParamsRequest{} + queryParamsResponse, err = s.Client.ChallengeQueryClient.Params(ctx, queryParamsRequest) + s.Require().NoError(err) + s.T().Log("params after", core.YamlString(queryParamsResponse.Params)) +} diff --git a/e2e/tests/payment_test.go b/e2e/tests/payment_test.go index 9d6e9fd61..b3fb6fc18 100644 --- a/e2e/tests/payment_test.go +++ b/e2e/tests/payment_test.go @@ -2085,12 +2085,7 @@ func (s *PaymentTestSuite) TestStorageBill_SealObject_WithPriceChangeValidatorTa // assertions streamRecordsAfter = s.getStreamRecords(streamAddresses) gvgFamilyRateReadAfter, taxRateReadAfter, userTotalRateReadAfter = s.calculateReadRatesCurrentTimestamp(sp, bucketName) - gvgFamilyRateStore, gvgRateStore, taxRateStore, userTotalRateStore = s.calculateStorageRatesCurrentTimestamp(sp, bucketName, objectName, payloadSize) - - gvgFamilyRateStore = gvgFamilyRateStore.MulRaw(2) - gvgRateStore = gvgRateStore.MulRaw(2) - taxRateStore = taxRateStore.MulRaw(2) - userTotalRateStore = userTotalRateStore.MulRaw(2) + gvgFamilyRateStore, gvgRateStore, taxRateStore, userTotalRateStore = s.calculateStorageRatesCurrentTimestamp(sp, bucketName, objectName, payloadSize*2) s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index b4cd6c34a..df5ccf718 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1429,3 +1429,77 @@ func (s *StorageTestSuite) TestUpdateGroupExtraWithPermission() { s.Require().Error(err) } + +func (s *StorageTestSuite) TestPutPolicy_ObjectWithSlash() { + var err error + user := s.GenAndChargeAccounts(2, 1000000) + + sp := s.BaseSuite.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + // CreateBucket + bucketName := storageutil.GenRandomBucketName() + msgCreateBucket := storagetypes.NewMsgCreateBucket( + user[0].GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PUBLIC_READ, sp.OperatorKey.GetAddr(), + nil, math.MaxUint, nil, 0) + msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId + msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxBlock(user[0], msgCreateBucket) + + // HeadBucket + ctx := context.Background() + queryHeadBucketRequest := storagetypes.QueryHeadBucketRequest{ + BucketName: bucketName, + } + queryHeadBucketResponse, err := s.Client.HeadBucket(ctx, &queryHeadBucketRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.BucketName, bucketName) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.Owner, user[0].GetAddr().String()) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.GlobalVirtualGroupFamilyId, gvg.FamilyId) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.PaymentAddress, user[0].GetAddr().String()) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.Visibility, storagetypes.VISIBILITY_TYPE_PUBLIC_READ) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.SourceType, storagetypes.SOURCE_TYPE_ORIGIN) + + // CreateObject + objectName := "test/" + storageutil.GenRandomObjectName() + // create test buffer + var buffer bytes.Buffer + line := `1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,123` + // Create 1MiB content where each line contains 1024 characters. + for i := 0; i < 1024; i++ { + buffer.WriteString(fmt.Sprintf("[%05d] %s\n", i, line)) + } + payloadSize := buffer.Len() + checksum := sdk.Keccak256(buffer.Bytes()) + expectChecksum := [][]byte{checksum, checksum, checksum, checksum, checksum, checksum, checksum} + contextType := "text/event-stream" + msgCreateObject := storagetypes.NewMsgCreateObject(user[0].GetAddr(), bucketName, objectName, uint64(payloadSize), storagetypes.VISIBILITY_TYPE_PUBLIC_READ, expectChecksum, contextType, storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil) + msgCreateObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateObject.GetApprovalBytes()) + s.Require().NoError(err) + s.T().Logf("Message: %s", msgCreateObject.String()) + + time.Sleep(3 * time.Second) + s.SendTxBlock(user[0], msgCreateObject) + + time.Sleep(3 * time.Second) + // Put object policy + statement := &types.Statement{ + Actions: []types.ActionType{types.ACTION_GET_OBJECT}, + Effect: types.EFFECT_ALLOW, + } + principal := types.NewPrincipalWithAccount(user[1].GetAddr()) + msgPutPolicy := storagetypes.NewMsgPutPolicy(user[0].GetAddr(), types2.NewObjectGRN(bucketName, objectName).String(), + principal, []*types.Statement{statement}, nil) + s.SendTxBlock(user[0], msgPutPolicy) + +} diff --git a/e2e/tests/storage_bill_test.go b/e2e/tests/storage_bill_test.go index 4f063ebb3..0c73fe4d2 100644 --- a/e2e/tests/storage_bill_test.go +++ b/e2e/tests/storage_bill_test.go @@ -33,10 +33,10 @@ func (s *PaymentTestSuite) TestStorageBill_CopyObject_WithoutPriceChange() { }) s.Require().NoError(err) family := queryFamilyResponse.GlobalVirtualGroupFamily - user0 := s.GenAndChargeAccounts(1, 1000000)[0] + user := s.GenAndChargeAccounts(1, 1000000)[0] streamAddresses := []string{ - user0.GetAddr().String(), + user.GetAddr().String(), family.VirtualPaymentAddress, gvg.VirtualPaymentAddress, paymenttypes.ValidatorTaxPoolAddress.String(), @@ -46,11 +46,11 @@ func (s *PaymentTestSuite) TestStorageBill_CopyObject_WithoutPriceChange() { s.T().Logf("paymentParams %s, err: %v", paymentParams, err) s.Require().NoError(err) - bucketName := s.createBucket(sp, user0, 0) + bucketName := s.createBucket(sp, user, 0) // create object with none zero payload size streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, objectName, objectId, checksums, payloadSize := s.createObject(user0, bucketName, false) + _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) // assertions streamRecordsAfter := s.getStreamRecords(streamAddresses) @@ -78,7 +78,7 @@ func (s *PaymentTestSuite) TestStorageBill_CopyObject_WithoutPriceChange() { distBucketName := bucketName distObjectName := storagetestutils.GenRandomObjectName() - objectIfo, err := s.copyObject(user0, sp, bucketName, objectName, distBucketName, distObjectName) + objectIfo, err := s.copyObject(user, sp, bucketName, objectName, distBucketName, distObjectName) s.Require().NoError(err) s.sealObject(sp, gvg, distBucketName, distObjectName, objectIfo.Id, objectIfo.Checksums) // assertions @@ -104,10 +104,10 @@ func (s *PaymentTestSuite) TestStorageBill_CopyObject_WithPriceChange() { }) s.Require().NoError(err) family := queryFamilyResponse.GlobalVirtualGroupFamily - user0 := s.GenAndChargeAccounts(1, 1000000)[0] + user := s.GenAndChargeAccounts(1, 1000000)[0] streamAddresses := []string{ - user0.GetAddr().String(), + user.GetAddr().String(), family.VirtualPaymentAddress, gvg.VirtualPaymentAddress, paymenttypes.ValidatorTaxPoolAddress.String(), @@ -117,11 +117,11 @@ func (s *PaymentTestSuite) TestStorageBill_CopyObject_WithPriceChange() { s.T().Logf("paymentParams %s, err: %v", paymentParams, err) s.Require().NoError(err) - bucketName := s.createBucket(sp, user0, 0) + bucketName := s.createBucket(sp, user, 0) // create object with none zero payload size streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, objectName, objectId, checksums, payloadSize := s.createObject(user0, bucketName, false) + _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) // assertions streamRecordsAfter := s.getStreamRecords(streamAddresses) @@ -160,9 +160,9 @@ func (s *PaymentTestSuite) TestStorageBill_CopyObject_WithPriceChange() { } s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) - distBucketName := s.createBucket(sp, user0, 0) + distBucketName := s.createBucket(sp, user, 0) distObjectName := storagetestutils.GenRandomObjectName() - objectIfo, err := s.copyObject(user0, sp, bucketName, objectName, distBucketName, distObjectName) + objectIfo, err := s.copyObject(user, sp, bucketName, objectName, distBucketName, distObjectName) s.Require().NoError(err) s.sealObject(sp, gvg, distBucketName, distObjectName, objectIfo.Id, objectIfo.Checksums) // assertions @@ -182,6 +182,7 @@ func (s *PaymentTestSuite) TestStorageBill_UpdateBucketQuota() { var err error ctx := context.Background() sp := s.PickStorageProvider() + user := s.GenAndChargeAccounts(1, 10)[0] // recover price defer s.SetSPPrice(sp, "12.34", "0") gvg, found := sp.GetFirstGlobalVirtualGroup() @@ -191,7 +192,6 @@ func (s *PaymentTestSuite) TestStorageBill_UpdateBucketQuota() { }) s.Require().NoError(err) family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 10)[0] streamAddresses := []string{ user.GetAddr().String(), @@ -320,7 +320,7 @@ func (s *PaymentTestSuite) TestStorageBill_UpdateBucketQuota() { chargedReadQuota := readQuota * 1024 * 1024 msgUpdateBucketInfo := storagetypes.NewMsgUpdateBucketInfo( user.GetAddr(), bucketName, &chargedReadQuota, user.GetAddr(), storagetypes.VISIBILITY_TYPE_PRIVATE) - + s.reduceBNBBalance(user, s.Validator, sdkmath.NewIntWithDecimal(1, 16)) s.SendTxBlockWithExpectErrorString(msgUpdateBucketInfo, user, "apply user flows list failed") } @@ -495,10 +495,10 @@ func (s *PaymentTestSuite) TestStorageBill_MigrationBucket() { }) s.Require().NoError(err) family := queryFamilyResponse.GlobalVirtualGroupFamily - user0 := s.GenAndChargeAccounts(1, 10)[0] + user := s.GenAndChargeAccounts(1, 10)[0] streamAddresses := []string{ - user0.GetAddr().String(), + user.GetAddr().String(), family.VirtualPaymentAddress, gvg.VirtualPaymentAddress, paymenttypes.ValidatorTaxPoolAddress.String(), @@ -509,7 +509,7 @@ func (s *PaymentTestSuite) TestStorageBill_MigrationBucket() { s.T().Logf("paymentParams %s, err: %v", paymentParams, err) s.Require().NoError(err) - bucketName := s.createBucket(primarySP, user0, 0) + bucketName := s.createBucket(primarySP, user, 0) bucketInfo, err := s.Client.HeadBucket(context.Background(), &storagetypes.QueryHeadBucketRequest{ BucketName: bucketName, }) @@ -517,7 +517,7 @@ func (s *PaymentTestSuite) TestStorageBill_MigrationBucket() { // create object with none zero payload size streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, objectName, objectId, checksums, payloadSize := s.createObject(user0, bucketName, false) + _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) // assertions streamRecordsAfter := s.getStreamRecords(streamAddresses) @@ -561,7 +561,7 @@ func (s *PaymentTestSuite) TestStorageBill_MigrationBucket() { s.Require().NoError(err) family = queryFamilyResponse.GlobalVirtualGroupFamily streamAddresses = []string{ - user0.GetAddr().String(), + user.GetAddr().String(), family.VirtualPaymentAddress, dstGVG.VirtualPaymentAddress, paymenttypes.ValidatorTaxPoolAddress.String(), @@ -574,8 +574,8 @@ func (s *PaymentTestSuite) TestStorageBill_MigrationBucket() { s.Require().NoError(err) // MigrationBucket - msgMigrationBucket, msgCompleteMigrationBucket := s.NewMigrateBucket(primarySP, dstPrimarySP, user0, bucketName, gvg.FamilyId, dstGVG.FamilyId, bucketInfo.BucketInfo.Id) - s.SendTxBlock(user0, msgMigrationBucket) + msgMigrationBucket, msgCompleteMigrationBucket := s.NewMigrateBucket(primarySP, dstPrimarySP, user, bucketName, gvg.FamilyId, dstGVG.FamilyId, bucketInfo.BucketInfo.Id) + s.SendTxBlock(user, msgMigrationBucket) s.Require().NoError(err) // complete MigrationBucket @@ -604,11 +604,11 @@ func (s *PaymentTestSuite) TestStorageBill_MigrationBucket() { s.Require().NoError(err) streamRecordsBefore = s.getStreamRecords(streamAddresses0) // send msgMigrationBucket - msgMigrationBucket, msgCompleteMigrationBucket = s.NewMigrateBucket(dstPrimarySP, primarySP, user0, bucketName, dstGVG.FamilyId, gvg.FamilyId, bucketInfo.BucketInfo.Id) + msgMigrationBucket, msgCompleteMigrationBucket = s.NewMigrateBucket(dstPrimarySP, primarySP, user, bucketName, dstGVG.FamilyId, gvg.FamilyId, bucketInfo.BucketInfo.Id) - s.SendTxBlock(user0, msgMigrationBucket) + s.SendTxBlock(user, msgMigrationBucket) s.Require().NoError(err) - s.reduceBNBBalance(user0, s.Validator, sdkmath.NewIntWithDecimal(1, 1)) + s.reduceBNBBalance(user, s.Validator, sdkmath.NewIntWithDecimal(1, 1)) s.SendTxBlockWithExpectErrorString(msgCompleteMigrationBucket, primarySP.OperatorKey, "apply stream record changes for user failed") @@ -616,7 +616,7 @@ func (s *PaymentTestSuite) TestStorageBill_MigrationBucket() { readPrice, primaryPrice, secondaryPrice := s.getPrices(primarySP, time.Now().Unix()) s.T().Logf("readPrice: %v, primaryPrice: %v,secondaryPrice: %v", readPrice, primaryPrice, secondaryPrice) - s.transferBNB(s.Validator, user0, sdkmath.NewIntWithDecimal(10000, 18)) + s.transferBNB(s.Validator, user, sdkmath.NewIntWithDecimal(10000, 18)) s.SendTxBlock(primarySP.OperatorKey, msgCompleteMigrationBucket) streamRecordsAfter = s.getStreamRecords(streamAddresses0) diff --git a/e2e/tests/virtualgroup_test.go b/e2e/tests/virtualgroup_test.go index 91afee122..a39d39e00 100644 --- a/e2e/tests/virtualgroup_test.go +++ b/e2e/tests/virtualgroup_test.go @@ -52,11 +52,11 @@ func (s *VirtualGroupTestSuite) queryGlobalVirtualGroup(gvgID uint32) *virtualgr return resp.GlobalVirtualGroup } -func (s *VirtualGroupTestSuite) queryGlobalVirtualGroupByFamily(spID, familyID uint32) []*virtualgroupmoduletypes.GlobalVirtualGroup { +func (s *VirtualGroupTestSuite) queryGlobalVirtualGroupByFamily(familyID uint32) []*virtualgroupmoduletypes.GlobalVirtualGroup { + s.T().Logf("familyID: %d", familyID) resp, err := s.Client.GlobalVirtualGroupByFamilyID( context.Background(), &virtualgroupmoduletypes.QueryGlobalVirtualGroupByFamilyIDRequest{ - StorageProviderId: spID, GlobalVirtualGroupFamilyId: familyID, }) s.Require().NoError(err) @@ -82,7 +82,7 @@ func (s *VirtualGroupTestSuite) TestBasic() { gvg = g } - srcGVGs := s.queryGlobalVirtualGroupByFamily(primarySP.Info.Id, gvg.FamilyId) + srcGVGs := s.queryGlobalVirtualGroupByFamily(gvg.FamilyId) var secondarySPIDs []uint32 for _, ssp := range s.StorageProviders { @@ -92,7 +92,7 @@ func (s *VirtualGroupTestSuite) TestBasic() { } s.BaseSuite.CreateGlobalVirtualGroup(primarySP, gvg.FamilyId, secondarySPIDs, 1) - gvgs = s.queryGlobalVirtualGroupByFamily(primarySP.Info.Id, gvg.FamilyId) + gvgs = s.queryGlobalVirtualGroupByFamily(gvg.FamilyId) s.Require().Equal(len(gvgs), len(srcGVGs)+1) oldGVGIDs := make(map[uint32]bool) @@ -146,7 +146,7 @@ func (s *VirtualGroupTestSuite) TestBasic() { } s.SendTxBlock(primarySP.OperatorKey, &msgDeleteGVG) - newGVGs := s.queryGlobalVirtualGroupByFamily(primarySP.Info.Id, newGVG.FamilyId) + newGVGs := s.queryGlobalVirtualGroupByFamily(newGVG.FamilyId) for _, gvg := range newGVGs { if gvg.Id == newGVG.Id { diff --git a/go.mod b/go.mod index c74e06b2a..a0fccf520 100644 --- a/go.mod +++ b/go.mod @@ -176,7 +176,7 @@ replace ( github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2 github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.4 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.5 github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) diff --git a/go.sum b/go.sum index 7a0a07453..14d29202e 100644 --- a/go.sum +++ b/go.sum @@ -163,8 +163,8 @@ github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2 h1:ys9kmgtRx04wcCextE6Cr github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2/go.mod h1:EBmwmUdaNbGPyGjf1cMuoN3pAeM2tQu7Lfg95813EAw= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.4 h1:Q5EzT1r3jKv0BZgVJkYFVvqn+7Ghj6RU7mUM0VkUZ4U= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.4/go.mod h1:EghjYxFg4NRNMfTJ6g9rVhjImhXQm+tuboknHqeGmJA= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.5 h1:VZKjhnM/GvdG6iTXj63SrBgDQLtXG4piDDG2fTMTiV4= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.5/go.mod h1:EghjYxFg4NRNMfTJ6g9rVhjImhXQm+tuboknHqeGmJA= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 h1:6fLpmmI0EZvDTfPvI0zy5dBaaTUboHnEkoC5/p/w8TQ= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:rbc4o84RSEvhf09o2+4Qiazsv0snRJLiEZdk17HeIDw= github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 h1:1ZdK+iR1Up02bOa2YTZCml7PBpP//kcdamOcK6aWO/s= diff --git a/proto/greenfield/challenge/params.proto b/proto/greenfield/challenge/params.proto index 043a33916..a9f16a416 100644 --- a/proto/greenfield/challenge/params.proto +++ b/proto/greenfield/challenge/params.proto @@ -69,4 +69,14 @@ message Params { // The number of kept attested challenge ids, which can be queried by clients. uint64 attestation_kept_count = 12 [(gogoproto.moretags) = "yaml:\"attestation_kept_count\""]; + + // The max slash amount for a sp in a counting window. + string sp_slash_max_amount = 13 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // The number of blocks to count how much a sp had been slashed. + uint64 sp_slash_counting_window = 14 [(gogoproto.moretags) = "yaml:\"sp_slash_counting_window\""]; } diff --git a/proto/greenfield/challenge/query.proto b/proto/greenfield/challenge/query.proto index 3a3b00a24..45c93c2e0 100644 --- a/proto/greenfield/challenge/query.proto +++ b/proto/greenfield/challenge/query.proto @@ -19,6 +19,10 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/greenfield/challenge/params"; } + // Queries the attested challenge by challenge id. + rpc AttestedChallenge(QueryAttestedChallengeRequest) returns (QueryAttestedChallengeResponse) { + option (google.api.http).get = "/greenfield/challenge/attested_challenge"; + } // Queries the latest attested challenges. rpc LatestAttestedChallenges(QueryLatestAttestedChallengesRequest) returns (QueryLatestAttestedChallengesResponse) { option (google.api.http).get = "/greenfield/challenge/latest_attested_challenges"; @@ -40,6 +44,17 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } +// QueryAttestedChallengeRequest is request type for the Query/AttestedChallenge RPC method. +message QueryAttestedChallengeRequest { + // The id of the challenge. + uint64 challenge_id = 1; +} + +// QueryAttestedChallengeResponse is response type for the Query/AttestedChallenge RPC method. +message QueryAttestedChallengeResponse { + AttestedChallenge challenge = 1; +} + // QueryLatestAttestedChallengesRequest is request type for the Query/LatestAttestedChallenges RPC method. message QueryLatestAttestedChallengesRequest {} diff --git a/proto/greenfield/challenge/tx.proto b/proto/greenfield/challenge/tx.proto index a910c3fe1..8de2e95ae 100644 --- a/proto/greenfield/challenge/tx.proto +++ b/proto/greenfield/challenge/tx.proto @@ -48,7 +48,10 @@ message MsgSubmit { } // MsgSubmitResponse defines the response of MsgSubmit. -message MsgSubmitResponse {} +message MsgSubmitResponse { + // The id of the challenge. + uint64 challenge_id = 1; +} // MsgSubmit defines the message for attesting challenges. message MsgAttest { diff --git a/proto/greenfield/virtualgroup/query.proto b/proto/greenfield/virtualgroup/query.proto index 649326401..b4856916d 100644 --- a/proto/greenfield/virtualgroup/query.proto +++ b/proto/greenfield/virtualgroup/query.proto @@ -65,8 +65,7 @@ message QueryGlobalVirtualGroupResponse { } message QueryGlobalVirtualGroupByFamilyIDRequest { - uint32 storage_provider_id = 1; - uint32 global_virtual_group_family_id = 2; + uint32 global_virtual_group_family_id = 1; } message QueryGlobalVirtualGroupByFamilyIDResponse { diff --git a/swagger/static/swagger.yaml b/swagger/static/swagger.yaml index 6d4161cfd..9b3a4b440 100644 --- a/swagger/static/swagger.yaml +++ b/swagger/static/swagger.yaml @@ -53,6 +53,65 @@ paths: format: byte tags: - Query + /greenfield/challenge/attested_challenge: + get: + summary: Queries the attested challenge by challenge id. + operationId: AttestedChallenge + responses: + '200': + description: A successful response. + schema: + type: object + properties: + challenge: + type: object + properties: + id: + type: string + format: uint64 + description: The id of the challenge. + result: + description: The attestation result of the challenge. + type: string + enum: + - CHALLENGE_FAILED + - CHALLENGE_SUCCEED + default: CHALLENGE_FAILED + description: AttestedChallenge records the challenge which are attested. + description: >- + QueryAttestedChallengeResponse is response type for the + Query/AttestedChallenge RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: challenge_id + description: The id of the challenge. + in: query + required: false + type: string + format: uint64 + tags: + - Query /greenfield/challenge/inturn_attestation_submitter: get: summary: Queries the inturn challenger. @@ -234,6 +293,15 @@ paths: description: >- The number of kept attested challenge ids, which can be queried by clients. + sp_slash_max_amount: + type: string + description: The max slash amount for a sp in a counting window. + sp_slash_counting_window: + type: string + format: uint64 + description: >- + The number of blocks to count how much a sp had been + slashed. description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -5221,11 +5289,6 @@ paths: type: string format: byte parameters: - - name: storage_provider_id - in: query - required: false - type: integer - format: int64 - name: global_virtual_group_family_id in: query required: false @@ -31359,7 +31422,35 @@ definitions: description: >- The number of kept attested challenge ids, which can be queried by clients. + sp_slash_max_amount: + type: string + description: The max slash amount for a sp in a counting window. + sp_slash_counting_window: + type: string + format: uint64 + description: The number of blocks to count how much a sp had been slashed. description: Params defines the parameters for the module. + greenfield.challenge.QueryAttestedChallengeResponse: + type: object + properties: + challenge: + type: object + properties: + id: + type: string + format: uint64 + description: The id of the challenge. + result: + description: The attestation result of the challenge. + type: string + enum: + - CHALLENGE_FAILED + - CHALLENGE_SUCCEED + default: CHALLENGE_FAILED + description: AttestedChallenge records the challenge which are attested. + description: >- + QueryAttestedChallengeResponse is response type for the + Query/AttestedChallenge RPC method. greenfield.challenge.QueryInturnAttestationSubmitterResponse: type: object properties: @@ -31466,6 +31557,13 @@ definitions: description: >- The number of kept attested challenge ids, which can be queried by clients. + sp_slash_max_amount: + type: string + description: The max slash amount for a sp in a counting window. + sp_slash_counting_window: + type: string + format: uint64 + description: The number of blocks to count how much a sp had been slashed. description: QueryParamsResponse is response type for the Query/Params RPC method. greenfield.challenge.SubmitInterval: type: object diff --git a/types/grn.go b/types/grn.go index 73d43c380..dec35ad7c 100644 --- a/types/grn.go +++ b/types/grn.go @@ -192,16 +192,21 @@ func (r *GRN) ParseFromString(res string, wildcards bool) error { func (r *GRN) parseBucketAndObjectName(name string) (string, string, error) { nameArr := strings.Split(name, "/") - if len(nameArr) != 2 { + if len(nameArr) < 2 { return "", "", gnfderrors.ErrInvalidGRN.Wrapf("expect bucketName/object, actual %s", r.name) } - err := s3util.CheckValidBucketName(nameArr[0]) + bucketName := nameArr[0] + objectName, found := strings.CutPrefix(name, bucketName+"/") + if !found { + return "", "", gnfderrors.ErrInvalidGRN.Wrapf("object name not found, grn: %s", name) + } + err := s3util.CheckValidBucketName(bucketName) if err != nil { return "", "", gnfderrors.ErrInvalidGRN.Wrapf("invalid bucketName, err: %s", err) } - err = s3util.CheckValidObjectName(nameArr[1]) + err = s3util.CheckValidObjectName(objectName) if err != nil { return "", "", gnfderrors.ErrInvalidGRN.Wrapf("invalid objectName, err: %s", err) } - return nameArr[0], nameArr[1], nil + return bucketName, objectName, nil } diff --git a/types/grn_test.go b/types/grn_test.go index 9ff5a319d..f85fd1e9d 100644 --- a/types/grn_test.go +++ b/types/grn_test.go @@ -91,3 +91,14 @@ func TestGRNBasicNew(t *testing.T) { groupGRNString := "grn:g:" + ownerAcc.String() + ":testgroup" require.Equal(t, groupGRNString, types3.NewGroupGRN(ownerAcc, "testgroup").String()) } + +func TestGRNWithSlash(t *testing.T) { + var grn types3.GRN + + err := grn.ParseFromString("grn:o::"+"testbucket"+"/"+"test/object", false) + require.NoError(t, err) + require.Equal(t, grn.ResourceType(), resource.RESOURCE_TYPE_OBJECT) + bucketName, objectName := grn.MustGetBucketAndObjectName() + require.Equal(t, bucketName, "testbucket") + require.Equal(t, objectName, "test/object") +} diff --git a/x/challenge/abci.go b/x/challenge/abci.go index 7b94fd83e..0334c4121 100644 --- a/x/challenge/abci.go +++ b/x/challenge/abci.go @@ -17,14 +17,18 @@ func BeginBlocker(ctx sdk.Context, keeper k.Keeper) { // delete expired challenges at this height keeper.RemoveChallengeUntil(ctx, blockHeight) + params := keeper.GetParams(ctx) // delete too old slashes at this height - coolingOffPeriod := keeper.GetParams(ctx).SlashCoolingOffPeriod - if blockHeight <= coolingOffPeriod { - return + coolingOffPeriod := params.SlashCoolingOffPeriod + if blockHeight > coolingOffPeriod { + height := blockHeight - coolingOffPeriod + keeper.RemoveSlashUntil(ctx, height) } - height := blockHeight - coolingOffPeriod - keeper.RemoveSlashUntil(ctx, height) + // delete storage provider slash amount records + if blockHeight > 0 && blockHeight%params.SpSlashCountingWindow == 0 { + keeper.ClearSpSlashAmount(ctx) + } } func EndBlocker(ctx sdk.Context, keeper k.Keeper) { diff --git a/x/challenge/keeper/grpc_query.go b/x/challenge/keeper/grpc_query.go index 04f4ac566..b2f5e434c 100644 --- a/x/challenge/keeper/grpc_query.go +++ b/x/challenge/keeper/grpc_query.go @@ -22,6 +22,31 @@ func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil } +func (k Keeper) AttestedChallenge(goCtx context.Context, req *types.QueryAttestedChallengeRequest) (*types.QueryAttestedChallengeResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + challenges := k.GetAttestedChallenges(ctx) + var challenge *types.AttestedChallenge + for _, c := range challenges { + if c.Id == req.ChallengeId { + challenge = c + break + } + } + + if challenge == nil { + return nil, status.Error(codes.InvalidArgument, "challenge id not found") + } + + return &types.QueryAttestedChallengeResponse{ + Challenge: challenge, + }, nil +} + func (k Keeper) LatestAttestedChallenges(goCtx context.Context, req *types.QueryLatestAttestedChallengesRequest) (*types.QueryLatestAttestedChallengesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/challenge/keeper/msg_server_attest.go b/x/challenge/keeper/msg_server_attest.go index 74b52918d..27f284211 100644 --- a/x/challenge/keeper/msg_server_attest.go +++ b/x/challenge/keeper/msg_server_attest.go @@ -93,9 +93,22 @@ func (k msgServer) Attest(goCtx context.Context, msg *types.MsgAttest) (*types.M return nil, types.ErrDuplicatedSlash } - // do slash & reward + // check slash amount objectSize := objectInfo.PayloadSize - err = k.doSlashAndRewards(ctx, msg.ChallengeId, msg.VoteResult, objectSize, sp.Id, submitter, challenger, validators) + toSlashAmount := k.calculateSlashAmount(ctx, objectSize) + + slashedAmount := k.GetSpSlashAmount(ctx, sp.Id) + if !slashedAmount.IsZero() { // if it is the first time to slash, do not check the amount + maxSlashAmount := k.GetParams(ctx).SpSlashMaxAmount + if (slashedAmount.Add(toSlashAmount)).GT(maxSlashAmount) { + ctx.Logger().Info("slash amount exceed the max allow amount", + "toSlashAmount", toSlashAmount, "slashedAmount", slashedAmount) + toSlashAmount = sdk.ZeroInt() + } + } + + // do slash & reward + err = k.doSlashAndRewards(ctx, msg.ChallengeId, msg.VoteResult, toSlashAmount, sp.Id, submitter, challenger, validators) if err != nil { return nil, err } @@ -106,6 +119,7 @@ func (k msgServer) Attest(goCtx context.Context, msg *types.MsgAttest) (*types.M Height: uint64(ctx.BlockHeight()), } k.SaveSlash(ctx, slash) + k.SetSpSlashAmount(ctx, sp.Id, slashedAmount.Add(toSlashAmount)) } else { // check whether it is a heartbeat attest heartbeatInterval := k.GetParams(ctx).HeartbeatInterval @@ -178,10 +192,9 @@ func (k msgServer) calculateSlashRewards(ctx sdk.Context, total sdkmath.Int, cha } // doSlashAndRewards will execute the slash, transfer the rewards and emit events. -func (k msgServer) doSlashAndRewards(ctx sdk.Context, challengeId uint64, voteResult types.VoteResult, objectSize uint64, +func (k msgServer) doSlashAndRewards(ctx sdk.Context, challengeId uint64, voteResult types.VoteResult, slashAmount sdkmath.Int, spID uint32, submitter, challenger sdk.AccAddress, validators []string) error { - slashAmount := k.calculateSlashAmount(ctx, objectSize) challengerReward, eachValidatorReward, submitterReward := k.calculateSlashRewards(ctx, slashAmount, challenger, int64(len(validators))) @@ -212,9 +225,11 @@ func (k msgServer) doSlashAndRewards(ctx sdk.Context, challengeId uint64, voteRe Amount: submitterReward, }}) - err := k.SpKeeper.Slash(ctx, spID, rewards) - if err != nil { - return err + if challengerReward.IsPositive() || eachValidatorReward.IsPositive() || submitterReward.IsPositive() { + err := k.SpKeeper.Slash(ctx, spID, rewards) + if err != nil { + return err + } } event := types.EventAttestChallenge{ diff --git a/x/challenge/keeper/msg_server_submit.go b/x/challenge/keeper/msg_server_submit.go index d8b845e1b..49f92c669 100644 --- a/x/challenge/keeper/msg_server_submit.go +++ b/x/challenge/keeper/msg_server_submit.go @@ -104,5 +104,5 @@ func (k msgServer) Submit(goCtx context.Context, msg *types.MsgSubmit) (*types.M return nil, err } - return &types.MsgSubmitResponse{}, nil + return &types.MsgSubmitResponse{ChallengeId: challengeId}, nil } diff --git a/x/challenge/keeper/slash.go b/x/challenge/keeper/slash.go index c11a9ddf7..c4b4af255 100644 --- a/x/challenge/keeper/slash.go +++ b/x/challenge/keeper/slash.go @@ -49,3 +49,42 @@ func getSlashKeyBytes(spId uint32, objectId sdkmath.Uint) []byte { allBytes := append(idBytes, objectId.Bytes()...) return sdk.Keccak256(allBytes) } + +func (k Keeper) SetSpSlashAmount(ctx sdk.Context, spId uint32, amount sdkmath.Int) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SlashAmountKeyPrefix) + idBz := make([]byte, 4) + binary.BigEndian.PutUint32(idBz, spId) + amountBz, err := amount.Marshal() + if err != nil { + panic("cannot marshal amount") + } + store.Set(idBz, amountBz) +} + +func (k Keeper) GetSpSlashAmount(ctx sdk.Context, spId uint32) sdkmath.Int { + amount := sdkmath.ZeroInt() + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SlashAmountKeyPrefix) + idBz := make([]byte, 4) + binary.BigEndian.PutUint32(idBz, spId) + amountBz := store.Get(idBz) + if amountBz == nil { + return amount + } + err := amount.Unmarshal(amountBz) + if err != nil { + panic("cannot unmarshal amount") + } + return amount +} + +func (k Keeper) ClearSpSlashAmount(ctx sdk.Context) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SlashAmountKeyPrefix) + + iterator := storetypes.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + store.Delete(iterator.Key()) + } +} diff --git a/x/challenge/types/keys.go b/x/challenge/types/keys.go index 1cddc4a8d..42b028e6e 100644 --- a/x/challenge/types/keys.go +++ b/x/challenge/types/keys.go @@ -45,4 +45,7 @@ var ( // AttestedChallengesCursorKey is the key to retrieve the latest attested challenges. AttestedChallengesCursorKey = []byte{0x17} + + // SlashAmountKeyPrefix is the prefix to count the amount of Slash for a sp. + SlashAmountKeyPrefix = []byte{0x18} ) diff --git a/x/challenge/types/params.go b/x/challenge/types/params.go index 163a99fa3..b23d1ee99 100644 --- a/x/challenge/types/params.go +++ b/x/challenge/types/params.go @@ -73,6 +73,16 @@ var ( DefaultAttestationKeptCount uint64 = 300 ) +var ( + KeySpSlashMaxAmount = []byte("SpSlashMaxAmount") + DefaultSpSlashMaxAmount = math.NewIntFromBigInt(big.NewInt(5e18)) // 5 bnb +) + +var ( + KeySpSlashCountingWindow = []byte("SpSlashMaxAmount") + DefaultSpSlashCountingWindow = uint64(43200) // about one day +) + // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -92,6 +102,8 @@ func NewParams( heartbeatInterval uint64, attestationInturnInterval uint64, attestationKeptCount uint64, + spSlashMaxAmount math.Int, + spSlashCountingWindow uint64, ) Params { return Params{ ChallengeCountPerBlock: challengeCountPerBlock, @@ -106,6 +118,8 @@ func NewParams( HeartbeatInterval: heartbeatInterval, AttestationInturnInterval: attestationInturnInterval, AttestationKeptCount: attestationKeptCount, + SpSlashMaxAmount: spSlashMaxAmount, + SpSlashCountingWindow: spSlashCountingWindow, } } @@ -124,6 +138,8 @@ func DefaultParams() Params { DefaultHeartbeatInterval, DefaultAttestationInturnInterval, DefaultAttestationKeptCount, + DefaultSpSlashMaxAmount, + DefaultSpSlashCountingWindow, ) } @@ -142,6 +158,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyHeartbeatInterval, &p.HeartbeatInterval, validateHeartbeatInterval), paramtypes.NewParamSetPair(KeyAttestationInturnInterval, &p.AttestationInturnInterval, validateAttestationInturnInterval), paramtypes.NewParamSetPair(KeyAttestationKeptCount, &p.AttestationKeptCount, validateAttestationKeptCount), + paramtypes.NewParamSetPair(KeySpSlashMaxAmount, &p.SpSlashMaxAmount, validateSpSlashMaxAmount), + paramtypes.NewParamSetPair(KeySpSlashCountingWindow, &p.SpSlashCountingWindow, validateSpSlashCountingWindow), } } @@ -203,6 +221,14 @@ func (p Params) Validate() error { return err } + if err := validateSpSlashMaxAmount(p.SpSlashMaxAmount); err != nil { + return err + } + + if err := validateSpSlashCountingWindow(p.SpSlashCountingWindow); err != nil { + return err + } + return nil } @@ -368,3 +394,31 @@ func validateAttestationKeptCount(v interface{}) error { return nil } + +// validateSpSlashMaxAmount validates the SpSlashMaxAmount param +func validateSpSlashMaxAmount(v interface{}) error { + spSlashMaxAmount, ok := v.(math.Int) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + if spSlashMaxAmount.LT(sdk.ZeroInt()) { + return errors.New("storage provider slash amount cannot be lower than zero") + } + + return nil +} + +// validateSpSlashCountingWindow validates the SpSlashCountingWindow param +func validateSpSlashCountingWindow(v interface{}) error { + spSlashCountingWindow, ok := v.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + if spSlashCountingWindow == 0 { + return errors.New("storage provider slash counting window cannot be zero") + } + + return nil +} diff --git a/x/challenge/types/params.pb.go b/x/challenge/types/params.pb.go index f14c72121..870ef971c 100644 --- a/x/challenge/types/params.pb.go +++ b/x/challenge/types/params.pb.go @@ -51,6 +51,10 @@ type Params struct { 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"` + // The max slash amount for a sp in a counting window. + SpSlashMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,13,opt,name=sp_slash_max_amount,json=spSlashMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"sp_slash_max_amount"` + // The number of blocks to count how much a sp had been slashed. + SpSlashCountingWindow uint64 `protobuf:"varint,14,opt,name=sp_slash_counting_window,json=spSlashCountingWindow,proto3" json:"sp_slash_counting_window,omitempty" yaml:"sp_slash_counting_window"` } func (m *Params) Reset() { *m = Params{} } @@ -127,6 +131,13 @@ func (m *Params) GetAttestationKeptCount() uint64 { return 0 } +func (m *Params) GetSpSlashCountingWindow() uint64 { + if m != nil { + return m.SpSlashCountingWindow + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "greenfield.challenge.Params") } @@ -134,47 +145,51 @@ func init() { func init() { proto.RegisterFile("greenfield/challenge/params.proto", fileDescriptor_2396367ee53edf57) } var fileDescriptor_2396367ee53edf57 = []byte{ - // 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,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, 0x67, 0xff, - 0x17, 0xb2, 0x65, 0xd7, 0x4b, 0x68, 0x5b, 0x81, 0x85, 0xcf, 0x1b, 0x54, 0x2b, 0xb7, 0xf6, 0x21, - 0x96, 0xf9, 0x6e, 0xc2, 0x77, 0x94, 0xc5, 0xea, 0xe4, 0x4e, 0x5c, 0xcc, 0xb3, 0xec, 0x6a, 0x09, - 0xd8, 0x81, 0x58, 0xaa, 0xfd, 0xb5, 0x39, 0xf7, 0xe5, 0xab, 0x59, 0x69, 0xed, 0x1c, 0x9f, 0x1a, - 0xda, 0xc9, 0xa9, 0xa1, 0xfd, 0x3e, 0x35, 0xb4, 0xcf, 0x67, 0x46, 0xe5, 0xe4, 0xcc, 0xa8, 0xfc, - 0x3c, 0x33, 0x2a, 0x6f, 0x9f, 0x94, 0x5e, 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, + // 692 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xc1, 0x4e, 0xdb, 0x4a, + 0x14, 0x8d, 0xdf, 0xe3, 0xf1, 0xca, 0xd0, 0x22, 0x6a, 0xd2, 0x68, 0x02, 0x22, 0x06, 0xb7, 0x42, + 0x6c, 0x48, 0x54, 0x75, 0x87, 0xba, 0x21, 0x74, 0x13, 0x51, 0x44, 0x64, 0xaa, 0x22, 0x55, 0x95, + 0xac, 0x89, 0x73, 0x13, 0x8f, 0x62, 0xcf, 0x58, 0xf6, 0x04, 0x02, 0xeb, 0xb6, 0xeb, 0x2e, 0xbb, + 0xec, 0x47, 0xf4, 0x23, 0x58, 0xa2, 0xae, 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, 0x60, 0xe4, 0xe3, 0x81, 0xf4, 0xd1, 0xbc, 0xb3, 0x8f, 0xca, 0x35, 0x1f, 0xd9, 0xb5, + 0x9d, 0x34, 0x72, 0x38, 0x92, 0x53, 0x46, 0xce, 0xd0, 0xf2, 0x94, 0x0f, 0xe1, 0x86, 0x10, 0xb9, + 0xdc, 0x6b, 0xe3, 0xb9, 0x7b, 0x38, 0x02, 0x3c, 0xa1, 0xfb, 0x66, 0x54, 0x5d, 0x7f, 0x8d, 0x74, + 0x17, 0x48, 0x28, 0x5a, 0x40, 0x84, 0x4d, 0x99, 0x80, 0xf0, 0x98, 0x78, 0x18, 0xc9, 0xd9, 0x59, + 0x1d, 0xc6, 0x46, 0x59, 0x75, 0x34, 0xcd, 0x31, 0xad, 0xc7, 0x59, 0xb0, 0x91, 0xc6, 0xf4, 0x0e, + 0x5a, 0x21, 0x42, 0x40, 0x24, 0x92, 0xbe, 0x58, 0xc2, 0xed, 0x87, 0x6c, 0x5c, 0x76, 0x7e, 0x72, + 0xec, 0xff, 0x40, 0x36, 0xad, 0x72, 0x0e, 0x6d, 0x48, 0x30, 0xd3, 0x39, 0x42, 0xa5, 0x7c, 0x6a, + 0x0f, 0x02, 0xa1, 0x76, 0x13, 0x7e, 0x28, 0x25, 0xd6, 0xc7, 0x77, 0xe2, 0x66, 0x9e, 0x69, 0x15, + 0x73, 0xc0, 0x1e, 0x04, 0x42, 0xee, 0x2f, 0xbd, 0x87, 0x96, 0xa2, 0xc0, 0x56, 0x63, 0xe0, 0x93, + 0x41, 0x3a, 0x0a, 0xf8, 0xd1, 0x3d, 0x9c, 0xc1, 0x62, 0x14, 0x1c, 0x26, 0x75, 0xf7, 0xc9, 0x40, + 0xcd, 0x82, 0xdc, 0x5e, 0x23, 0x31, 0xe9, 0x2a, 0xd9, 0x4b, 0x27, 0x94, 0xb5, 0xf9, 0x09, 0x5e, + 0x98, 0xda, 0x5e, 0xb7, 0x30, 0x93, 0xed, 0xa5, 0x0a, 0xef, 0xa6, 0xc0, 0x91, 0x8c, 0x6f, 0xcf, + 0x7c, 0xf9, 0x6a, 0x14, 0xea, 0x7b, 0xe7, 0x97, 0x15, 0xed, 0xe2, 0xb2, 0xa2, 0xfd, 0xba, 0xac, + 0x68, 0x9f, 0xaf, 0x2a, 0x85, 0x8b, 0xab, 0x4a, 0xe1, 0xc7, 0x55, 0xa5, 0xf0, 0xee, 0x79, 0xae, + 0x8b, 0x16, 0x6b, 0x6d, 0x39, 0x2e, 0xa1, 0xac, 0x96, 0x7b, 0x8d, 0x06, 0xb9, 0xf7, 0x48, 0x36, + 0xd5, 0x9a, 0x95, 0x0f, 0xc9, 0x8b, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x14, 0x44, 0x79, 0xdf, + 0xb4, 0x06, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -197,6 +212,21 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.SpSlashCountingWindow != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.SpSlashCountingWindow)) + i-- + dAtA[i] = 0x70 + } + { + size := m.SpSlashMaxAmount.Size() + i -= size + if _, err := m.SpSlashMaxAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a if m.AttestationKeptCount != 0 { i = encodeVarintParams(dAtA, i, uint64(m.AttestationKeptCount)) i-- @@ -337,6 +367,11 @@ func (m *Params) Size() (n int) { if m.AttestationKeptCount != 0 { n += 1 + sovParams(uint64(m.AttestationKeptCount)) } + l = m.SpSlashMaxAmount.Size() + n += 1 + l + sovParams(uint64(l)) + if m.SpSlashCountingWindow != 0 { + n += 1 + sovParams(uint64(m.SpSlashCountingWindow)) + } return n } @@ -693,6 +728,59 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpSlashMaxAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SpSlashMaxAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SpSlashCountingWindow", wireType) + } + m.SpSlashCountingWindow = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SpSlashCountingWindow |= 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 620f129c0..f0cdcc05a 100644 --- a/x/challenge/types/query.pb.go +++ b/x/challenge/types/query.pb.go @@ -114,6 +114,97 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryAttestedChallengeRequest is request type for the Query/AttestedChallenge RPC method. +type QueryAttestedChallengeRequest struct { + // The id of the challenge. + ChallengeId uint64 `protobuf:"varint,1,opt,name=challenge_id,json=challengeId,proto3" json:"challenge_id,omitempty"` +} + +func (m *QueryAttestedChallengeRequest) Reset() { *m = QueryAttestedChallengeRequest{} } +func (m *QueryAttestedChallengeRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAttestedChallengeRequest) ProtoMessage() {} +func (*QueryAttestedChallengeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f6f1807fa0a2b619, []int{2} +} +func (m *QueryAttestedChallengeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAttestedChallengeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAttestedChallengeRequest.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 *QueryAttestedChallengeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAttestedChallengeRequest.Merge(m, src) +} +func (m *QueryAttestedChallengeRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAttestedChallengeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAttestedChallengeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAttestedChallengeRequest proto.InternalMessageInfo + +func (m *QueryAttestedChallengeRequest) GetChallengeId() uint64 { + if m != nil { + return m.ChallengeId + } + return 0 +} + +// QueryAttestedChallengeResponse is response type for the Query/AttestedChallenge RPC method. +type QueryAttestedChallengeResponse struct { + Challenge *AttestedChallenge `protobuf:"bytes,1,opt,name=challenge,proto3" json:"challenge,omitempty"` +} + +func (m *QueryAttestedChallengeResponse) Reset() { *m = QueryAttestedChallengeResponse{} } +func (m *QueryAttestedChallengeResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAttestedChallengeResponse) ProtoMessage() {} +func (*QueryAttestedChallengeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f6f1807fa0a2b619, []int{3} +} +func (m *QueryAttestedChallengeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAttestedChallengeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAttestedChallengeResponse.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 *QueryAttestedChallengeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAttestedChallengeResponse.Merge(m, src) +} +func (m *QueryAttestedChallengeResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAttestedChallengeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAttestedChallengeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAttestedChallengeResponse proto.InternalMessageInfo + +func (m *QueryAttestedChallengeResponse) GetChallenge() *AttestedChallenge { + if m != nil { + return m.Challenge + } + return nil +} + // QueryLatestAttestedChallengesRequest is request type for the Query/LatestAttestedChallenges RPC method. type QueryLatestAttestedChallengesRequest struct { } @@ -122,7 +213,7 @@ func (m *QueryLatestAttestedChallengesRequest) Reset() { *m = QueryLates func (m *QueryLatestAttestedChallengesRequest) String() string { return proto.CompactTextString(m) } func (*QueryLatestAttestedChallengesRequest) ProtoMessage() {} func (*QueryLatestAttestedChallengesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f6f1807fa0a2b619, []int{2} + return fileDescriptor_f6f1807fa0a2b619, []int{4} } func (m *QueryLatestAttestedChallengesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -160,7 +251,7 @@ func (m *QueryLatestAttestedChallengesResponse) Reset() { *m = QueryLate func (m *QueryLatestAttestedChallengesResponse) String() string { return proto.CompactTextString(m) } func (*QueryLatestAttestedChallengesResponse) ProtoMessage() {} func (*QueryLatestAttestedChallengesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f6f1807fa0a2b619, []int{3} + return fileDescriptor_f6f1807fa0a2b619, []int{5} } func (m *QueryLatestAttestedChallengesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -206,7 +297,7 @@ func (m *QueryInturnAttestationSubmitterRequest) Reset() { func (m *QueryInturnAttestationSubmitterRequest) String() string { return proto.CompactTextString(m) } func (*QueryInturnAttestationSubmitterRequest) ProtoMessage() {} func (*QueryInturnAttestationSubmitterRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f6f1807fa0a2b619, []int{4} + return fileDescriptor_f6f1807fa0a2b619, []int{6} } func (m *QueryInturnAttestationSubmitterRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -247,7 +338,7 @@ func (m *QueryInturnAttestationSubmitterResponse) Reset() { func (m *QueryInturnAttestationSubmitterResponse) String() string { return proto.CompactTextString(m) } func (*QueryInturnAttestationSubmitterResponse) ProtoMessage() {} func (*QueryInturnAttestationSubmitterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f6f1807fa0a2b619, []int{5} + return fileDescriptor_f6f1807fa0a2b619, []int{7} } func (m *QueryInturnAttestationSubmitterResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -300,7 +391,7 @@ 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} + return fileDescriptor_f6f1807fa0a2b619, []int{8} } func (m *SubmitInterval) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -346,6 +437,8 @@ func (m *SubmitInterval) GetEnd() uint64 { func init() { proto.RegisterType((*QueryParamsRequest)(nil), "greenfield.challenge.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "greenfield.challenge.QueryParamsResponse") + proto.RegisterType((*QueryAttestedChallengeRequest)(nil), "greenfield.challenge.QueryAttestedChallengeRequest") + proto.RegisterType((*QueryAttestedChallengeResponse)(nil), "greenfield.challenge.QueryAttestedChallengeResponse") proto.RegisterType((*QueryLatestAttestedChallengesRequest)(nil), "greenfield.challenge.QueryLatestAttestedChallengesRequest") proto.RegisterType((*QueryLatestAttestedChallengesResponse)(nil), "greenfield.challenge.QueryLatestAttestedChallengesResponse") proto.RegisterType((*QueryInturnAttestationSubmitterRequest)(nil), "greenfield.challenge.QueryInturnAttestationSubmitterRequest") @@ -356,43 +449,47 @@ func init() { func init() { proto.RegisterFile("greenfield/challenge/query.proto", fileDescriptor_f6f1807fa0a2b619) } var fileDescriptor_f6f1807fa0a2b619 = []byte{ - // 564 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcf, 0x6a, 0x13, 0x41, - 0x18, 0xcf, 0xb6, 0x69, 0xa0, 0x13, 0xa8, 0x32, 0xe6, 0x10, 0x97, 0xb0, 0xd6, 0x25, 0xb6, 0x51, - 0x30, 0x63, 0xa2, 0x87, 0x12, 0xf5, 0x60, 0x3d, 0x48, 0xa9, 0x42, 0xbb, 0xde, 0xbc, 0x2c, 0x33, - 0xc9, 0xb8, 0x59, 0xdc, 0xcc, 0x6c, 0x77, 0x66, 0x8b, 0xb9, 0xea, 0x0b, 0x08, 0x5e, 0x7c, 0x11, - 0xdf, 0xa1, 0x17, 0xa1, 0x20, 0x82, 0x27, 0x91, 0xc4, 0x07, 0x91, 0x9d, 0x99, 0x4d, 0x1b, 0xbb, - 0x4d, 0xa4, 0x97, 0xb0, 0xdf, 0xe4, 0xf7, 0xef, 0xfb, 0xe6, 0x63, 0xc0, 0x66, 0x90, 0x50, 0xca, - 0xde, 0x86, 0x34, 0x1a, 0xa0, 0xfe, 0x10, 0x47, 0x11, 0x65, 0x01, 0x45, 0x47, 0x29, 0x4d, 0xc6, - 0xed, 0x38, 0xe1, 0x92, 0xc3, 0xda, 0x19, 0xa2, 0x3d, 0x43, 0xd8, 0xf7, 0xfa, 0x5c, 0x8c, 0xb8, - 0x40, 0x04, 0x0b, 0x03, 0x47, 0xc7, 0x1d, 0x42, 0x25, 0xee, 0xa0, 0x18, 0x07, 0x21, 0xc3, 0x32, - 0xe4, 0x4c, 0x2b, 0xd8, 0x37, 0x35, 0xd6, 0x57, 0x15, 0xd2, 0x85, 0xf9, 0xab, 0x16, 0xf0, 0x80, - 0xeb, 0xf3, 0xec, 0xcb, 0x9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3, 0x11, 0x22, 0x8c, 0xdc, 0xef, 0x0f, 0x71, 0xc8, 0xce, 0x3b, 0xbc, 0xff, 0xf7, - 0x31, 0x22, 0x15, 0xf5, 0x1a, 0x3d, 0xfc, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x29, 0x58, 0x43, 0xdf, - 0x87, 0x05, 0x00, 0x00, + // 635 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0x8d, 0xfb, 0x25, 0x75, 0x8a, 0x0a, 0x2c, 0x39, 0x14, 0x2b, 0x98, 0xd6, 0x0a, 0x6d, 0xa8, + 0x44, 0xdc, 0xa4, 0x3d, 0x54, 0x01, 0x0e, 0x04, 0x21, 0x14, 0x15, 0xa4, 0xd6, 0xdc, 0xb8, 0x58, + 0xeb, 0x64, 0x71, 0x2c, 0x9c, 0x5d, 0xd7, 0xbb, 0xae, 0xc8, 0x15, 0xfe, 0x00, 0x12, 0x17, 0x7e, + 0x06, 0x3f, 0xa3, 0x17, 0xa4, 0x4a, 0x08, 0x89, 0x13, 0x42, 0x09, 0x07, 0x7e, 0x06, 0xca, 0x7a, + 0xe3, 0x36, 0xc4, 0x49, 0x68, 0x6f, 0xde, 0xf1, 0x7b, 0x6f, 0xde, 0x1b, 0xcf, 0x1a, 0xd6, 0xbd, + 0x88, 0x10, 0xfa, 0xc6, 0x27, 0x41, 0xcb, 0x6a, 0xb6, 0x71, 0x10, 0x10, 0xea, 0x11, 0xeb, 0x38, + 0x26, 0x51, 0xb7, 0x1c, 0x46, 0x4c, 0x30, 0x94, 0x3f, 0x47, 0x94, 0x53, 0x84, 0xbe, 0xdd, 0x64, + 0xbc, 0xc3, 0xb8, 0xe5, 0x62, 0xae, 0xe0, 0xd6, 0x49, 0xc5, 0x25, 0x02, 0x57, 0xac, 0x10, 0x7b, + 0x3e, 0xc5, 0xc2, 0x67, 0x34, 0x51, 0xd0, 0x6f, 0x27, 0x58, 0x47, 0x9e, 0xac, 0xe4, 0xa0, 0x5e, + 0xe5, 0x3d, 0xe6, 0xb1, 0xa4, 0x3e, 0x78, 0x52, 0xd5, 0x82, 0xc7, 0x98, 0x17, 0x10, 0x0b, 0x87, + 0xbe, 0x85, 0x29, 0x65, 0x42, 0xaa, 0x0d, 0x39, 0x1b, 0x99, 0x96, 0x43, 0x1c, 0xe1, 0xce, 0x10, + 0x92, 0x9d, 0x4a, 0x74, 0x43, 0xa2, 0x10, 0x66, 0x1e, 0xd0, 0xd1, 0xc0, 0xf5, 0xa1, 0xa4, 0xd9, + 0xe4, 0x38, 0x26, 0x5c, 0x98, 0x47, 0x70, 0x6b, 0xa4, 0xca, 0x43, 0x46, 0x39, 0x41, 0x35, 0x58, + 0x4a, 0xe4, 0xd7, 0xb4, 0x75, 0xad, 0xb4, 0x52, 0x2d, 0x94, 0xb3, 0x66, 0x52, 0x4e, 0x58, 0xf5, + 0x85, 0xd3, 0x9f, 0x77, 0x73, 0xb6, 0x62, 0x98, 0x75, 0xb8, 0x23, 0x25, 0x9f, 0x08, 0x41, 0xb8, + 0x20, 0xad, 0xa7, 0x43, 0xb8, 0xea, 0x89, 0x36, 0xe0, 0x5a, 0x2a, 0xe1, 0xf8, 0x2d, 0xd9, 0x62, + 0xc1, 0x5e, 0x49, 0x6b, 0x8d, 0x96, 0xe9, 0x81, 0x31, 0x49, 0x43, 0x39, 0x7c, 0x06, 0xcb, 0x29, + 0x41, 0x99, 0xdc, 0xca, 0x36, 0x39, 0xae, 0x71, 0xce, 0x34, 0x37, 0xa1, 0x28, 0x1b, 0xbd, 0xc0, + 0x03, 0xd0, 0x18, 0x34, 0x9d, 0x53, 0x08, 0xf7, 0x66, 0xe0, 0x94, 0xaf, 0xe7, 0x00, 0xa9, 0xfa, + 0x60, 0x7a, 0xf3, 0x97, 0x31, 0x76, 0x81, 0x6a, 0x96, 0x60, 0x53, 0x76, 0x6c, 0x50, 0x11, 0x47, + 0x34, 0xc1, 0xca, 0xad, 0x78, 0x15, 0xbb, 0x1d, 0x5f, 0x08, 0x12, 0x0d, 0xbd, 0x7d, 0xd6, 0x60, + 0x6b, 0x26, 0x54, 0xd9, 0x33, 0x60, 0xc5, 0x0d, 0xb8, 0x13, 0xc6, 0xae, 0xf3, 0x96, 0x74, 0xe5, + 0xe0, 0x96, 0xed, 0x65, 0x37, 0xe0, 0x87, 0xb1, 0x7b, 0x40, 0xba, 0xe8, 0x25, 0x5c, 0xe7, 0x92, + 0xe4, 0xf8, 0x54, 0x90, 0xe8, 0x04, 0x07, 0x6b, 0x73, 0x72, 0xb8, 0xc5, 0xec, 0x0c, 0x49, 0x87, + 0x86, 0xc2, 0xda, 0xab, 0x7c, 0xe4, 0x6c, 0xee, 0xc3, 0xea, 0x28, 0x02, 0xe5, 0x61, 0x91, 0x0b, + 0x1c, 0x09, 0xf5, 0xd5, 0x93, 0x03, 0xba, 0x01, 0xf3, 0x84, 0xb6, 0x64, 0xab, 0x05, 0x7b, 0xf0, + 0x58, 0xfd, 0xb3, 0x08, 0x8b, 0x32, 0x14, 0xfa, 0xa0, 0xc1, 0x52, 0xb2, 0x68, 0xa8, 0x94, 0x6d, + 0x62, 0x7c, 0xaf, 0xf5, 0xfb, 0xff, 0x81, 0x4c, 0x46, 0x62, 0x16, 0xdf, 0x7f, 0xfb, 0xfd, 0x69, + 0xce, 0x40, 0x05, 0x6b, 0xca, 0x35, 0x43, 0x5f, 0x34, 0xb8, 0x39, 0xf6, 0xc1, 0xd0, 0xee, 0x94, + 0x36, 0x93, 0xf6, 0x5f, 0xdf, 0xbb, 0x1c, 0x49, 0xd9, 0xdc, 0x91, 0x36, 0xb7, 0x51, 0x29, 0xdb, + 0x26, 0x56, 0x44, 0x27, 0x2d, 0xa1, 0xaf, 0x1a, 0xac, 0x4d, 0xda, 0x57, 0x54, 0x9b, 0x62, 0x62, + 0xc6, 0x65, 0xd0, 0x1f, 0x5e, 0x89, 0xab, 0x72, 0xec, 0xcb, 0x1c, 0x55, 0xb4, 0x93, 0x9d, 0x23, + 0x90, 0x7c, 0x67, 0x3c, 0x0e, 0x47, 0xdf, 0x35, 0xd0, 0x27, 0xaf, 0x38, 0x7a, 0x34, 0xc5, 0xd5, + 0xcc, 0x4b, 0xa4, 0x3f, 0xbe, 0x22, 0x5b, 0xa5, 0xaa, 0xc9, 0x54, 0x7b, 0xa8, 0x9a, 0x9d, 0xca, + 0x97, 0x0a, 0x2a, 0x95, 0x94, 0x70, 0xf8, 0x50, 0xa3, 0x7e, 0x70, 0xda, 0x33, 0xb4, 0xb3, 0x9e, + 0xa1, 0xfd, 0xea, 0x19, 0xda, 0xc7, 0xbe, 0x91, 0x3b, 0xeb, 0x1b, 0xb9, 0x1f, 0x7d, 0x23, 0xf7, + 0xba, 0xe2, 0xf9, 0xa2, 0x1d, 0xbb, 0xe5, 0x26, 0xeb, 0x58, 0x2e, 0x75, 0x1f, 0x34, 0xdb, 0xd8, + 0xa7, 0x17, 0x3b, 0xbc, 0xfb, 0xf7, 0x67, 0xef, 0x2e, 0xc9, 0xbf, 0xfd, 0xee, 0xdf, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x0f, 0x4b, 0xb6, 0x01, 0xe7, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -409,6 +506,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries the attested challenge by challenge id. + AttestedChallenge(ctx context.Context, in *QueryAttestedChallengeRequest, opts ...grpc.CallOption) (*QueryAttestedChallengeResponse, error) // Queries the latest attested challenges. LatestAttestedChallenges(ctx context.Context, in *QueryLatestAttestedChallengesRequest, opts ...grpc.CallOption) (*QueryLatestAttestedChallengesResponse, error) // Queries the inturn challenger. @@ -432,6 +531,15 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) AttestedChallenge(ctx context.Context, in *QueryAttestedChallengeRequest, opts ...grpc.CallOption) (*QueryAttestedChallengeResponse, error) { + out := new(QueryAttestedChallengeResponse) + err := c.cc.Invoke(ctx, "/greenfield.challenge.Query/AttestedChallenge", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + 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...) @@ -454,6 +562,8 @@ func (c *queryClient) InturnAttestationSubmitter(ctx context.Context, in *QueryI type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries the attested challenge by challenge id. + AttestedChallenge(context.Context, *QueryAttestedChallengeRequest) (*QueryAttestedChallengeResponse, error) // Queries the latest attested challenges. LatestAttestedChallenges(context.Context, *QueryLatestAttestedChallengesRequest) (*QueryLatestAttestedChallengesResponse, error) // Queries the inturn challenger. @@ -467,6 +577,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) AttestedChallenge(ctx context.Context, req *QueryAttestedChallengeRequest) (*QueryAttestedChallengeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AttestedChallenge not implemented") +} func (*UnimplementedQueryServer) LatestAttestedChallenges(ctx context.Context, req *QueryLatestAttestedChallengesRequest) (*QueryLatestAttestedChallengesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method LatestAttestedChallenges not implemented") } @@ -496,6 +609,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_AttestedChallenge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAttestedChallengeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AttestedChallenge(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.challenge.Query/AttestedChallenge", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AttestedChallenge(ctx, req.(*QueryAttestedChallengeRequest)) + } + return interceptor(ctx, in, info, handler) +} + 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 { @@ -540,6 +671,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "AttestedChallenge", + Handler: _Query_AttestedChallenge_Handler, + }, { MethodName: "LatestAttestedChallenges", Handler: _Query_LatestAttestedChallenges_Handler, @@ -609,6 +744,69 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryAttestedChallengeRequest) 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 *QueryAttestedChallengeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAttestedChallengeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChallengeId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ChallengeId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryAttestedChallengeResponse) 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 *QueryAttestedChallengeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAttestedChallengeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Challenge != nil { + { + size, err := m.Challenge.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *QueryLatestAttestedChallengesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -798,6 +996,31 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryAttestedChallengeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChallengeId != 0 { + n += 1 + sovQuery(uint64(m.ChallengeId)) + } + return n +} + +func (m *QueryAttestedChallengeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Challenge != nil { + l = m.Challenge.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryLatestAttestedChallengesRequest) Size() (n int) { if m == nil { return 0 @@ -1002,6 +1225,161 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryAttestedChallengeRequest) 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: QueryAttestedChallengeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAttestedChallengeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChallengeId", wireType) + } + m.ChallengeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChallengeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryAttestedChallengeResponse) 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: QueryAttestedChallengeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAttestedChallengeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Challenge", 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.Challenge == nil { + m.Challenge = &AttestedChallenge{} + } + if err := m.Challenge.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 *QueryLatestAttestedChallengesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/challenge/types/query.pb.gw.go b/x/challenge/types/query.pb.gw.go index 0cbff06e7..b61550c22 100644 --- a/x/challenge/types/query.pb.gw.go +++ b/x/challenge/types/query.pb.gw.go @@ -51,6 +51,42 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_Query_AttestedChallenge_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_AttestedChallenge_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAttestedChallengeRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AttestedChallenge_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AttestedChallenge(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AttestedChallenge_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAttestedChallengeRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AttestedChallenge_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AttestedChallenge(ctx, &protoReq) + return msg, metadata, err + +} + 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 @@ -116,6 +152,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_AttestedChallenge_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_AttestedChallenge_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_AttestedChallenge_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + 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() @@ -223,6 +282,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_AttestedChallenge_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_AttestedChallenge_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_AttestedChallenge_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + 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() @@ -269,6 +348,8 @@ 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_AttestedChallenge_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "challenge", "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_challenges"}, "", 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))) @@ -277,6 +358,8 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_AttestedChallenge_0 = runtime.ForwardResponseMessage + forward_Query_LatestAttestedChallenges_0 = runtime.ForwardResponseMessage forward_Query_InturnAttestationSubmitter_0 = runtime.ForwardResponseMessage diff --git a/x/challenge/types/tx.pb.go b/x/challenge/types/tx.pb.go index 68419f632..65caa37e0 100644 --- a/x/challenge/types/tx.pb.go +++ b/x/challenge/types/tx.pb.go @@ -124,6 +124,8 @@ func (m *MsgSubmit) GetRandomIndex() bool { // MsgSubmitResponse defines the response of MsgSubmit. type MsgSubmitResponse struct { + // The id of the challenge. + ChallengeId uint64 `protobuf:"varint,1,opt,name=challenge_id,json=challengeId,proto3" json:"challenge_id,omitempty"` } func (m *MsgSubmitResponse) Reset() { *m = MsgSubmitResponse{} } @@ -159,6 +161,13 @@ func (m *MsgSubmitResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitResponse proto.InternalMessageInfo +func (m *MsgSubmitResponse) GetChallengeId() uint64 { + if m != nil { + return m.ChallengeId + } + return 0 +} + // MsgSubmit defines the message for attesting challenges. type MsgAttest struct { // The submitter address. @@ -403,50 +412,51 @@ func init() { func init() { proto.RegisterFile("greenfield/challenge/tx.proto", fileDescriptor_516ed0ec90010e48) } var fileDescriptor_516ed0ec90010e48 = []byte{ - // 684 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x41, 0x6f, 0xd3, 0x3c, - 0x18, 0xc7, 0x9b, 0xb5, 0x6f, 0xdf, 0xd5, 0xed, 0x36, 0xe6, 0x4d, 0x5a, 0x56, 0xa0, 0xcd, 0x8a, - 0x10, 0x15, 0xa2, 0x8d, 0x36, 0x24, 0x34, 0xed, 0xd6, 0x9e, 0x98, 0xd0,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6, 0x3a, 0xd0, 0x37, - 0xd7, 0x94, 0xc0, 0x3f, 0x6a, 0x5e, 0x95, 0x18, 0xba, 0xa0, 0x76, 0x45, 0xde, 0xc7, 0x37, 0x6e, - 0x9c, 0xc5, 0xea, 0x9d, 0x3b, 0x61, 0x69, 0x97, 0xfe, 0xab, 0x93, 0x8b, 0x86, 0x76, 0x7a, 0xd1, - 0xd0, 0x7e, 0x5f, 0x34, 0xb4, 0xcf, 0x97, 0x8d, 0xc2, 0xe9, 0x65, 0xa3, 0xf0, 0xf3, 0xb2, 0x51, - 0x78, 0xb7, 0x49, 0x3c, 0x3e, 0x8a, 0x9d, 0xee, 0x90, 0xfa, 0xa6, 0x13, 0x38, 0x9d, 0xe1, 0x08, - 0x79, 0x81, 0x39, 0xf3, 0x42, 0x1e, 0x5e, 0x7f, 0x23, 0x9d, 0xb2, 0x78, 0x24, 0x9f, 0xff, 0x0d, - 0x00, 0x00, 0xff, 0xff, 0xfb, 0xa0, 0x8e, 0x5e, 0xea, 0x05, 0x00, 0x00, + // 694 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x41, 0x4f, 0xdb, 0x3c, + 0x18, 0xc7, 0x9b, 0xb6, 0x6f, 0x5f, 0xea, 0x16, 0x78, 0x31, 0x48, 0x84, 0xbe, 0x5b, 0x1b, 0x3a, + 0x4d, 0xab, 0xa6, 0xb5, 0x11, 0x4c, 0x42, 0x88, 0x5b, 0x7b, 0x1a, 0x9a, 0xd8, 0xa6, 0x54, 0x70, + 0xd8, 0x25, 0x72, 0x1a, 0xcf, 0xcd, 0xd6, 0xc4, 0x51, 0xec, 0x56, 0x70, 0xdd, 0x27, 0x98, 0x34, + 0xed, 0x4b, 0xec, 0x30, 0xed, 0xc0, 0x87, 0xe0, 0x88, 0x38, 0x4d, 0x3b, 0xa0, 0x09, 0x0e, 0xfb, + 0x1a, 0x53, 0x6c, 0x27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0xda, 0xe9, 0x45, 0x5d, 0xfb, 0x75, 0x51, 0xd7, 0x3e, 0x5d, + 0xd6, 0x73, 0xa7, 0x97, 0xf5, 0xdc, 0x8f, 0xcb, 0x7a, 0xee, 0xed, 0x06, 0xf1, 0xf8, 0x70, 0xec, + 0x74, 0x06, 0xd4, 0x37, 0x9d, 0xc0, 0x69, 0x0f, 0x86, 0xc8, 0x0b, 0xcc, 0x99, 0x47, 0xf4, 0xf0, + 0xfa, 0x33, 0xea, 0x94, 0xc4, 0x3b, 0xfa, 0xfc, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x08, 0x8b, + 0xeb, 0x8a, 0x0d, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -695,6 +705,11 @@ func (m *MsgSubmitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ChallengeId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ChallengeId)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -912,6 +927,9 @@ func (m *MsgSubmitResponse) Size() (n int) { } var l int _ = l + if m.ChallengeId != 0 { + n += 1 + sovTx(uint64(m.ChallengeId)) + } return n } @@ -1236,6 +1254,25 @@ func (m *MsgSubmitResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgSubmitResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChallengeId", wireType) + } + m.ChallengeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChallengeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 76430a572..438d3f6d7 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1787,6 +1787,10 @@ func (k Keeper) MigrateBucket(ctx sdk.Context, operator sdk.AccAddress, bucketNa return sptypes.ErrStorageProviderNotFound.Wrapf("dst sp not found") } + if srcSP.Id == dstSP.Id { + return types.ErrMigrationBucketFailed.Wrapf("The dest sp must not be the origin sp.") + } + if !srcSP.IsInService() || !dstSP.IsInService() { return sptypes.ErrStorageProviderNotInService.Wrapf( "origin SP status: %s, dst SP status: %s", srcSP.Status.String(), dstSP.Status.String()) diff --git a/x/storage/keeper/payment.go b/x/storage/keeper/payment.go index 7d324b9d9..ff047bbc6 100644 --- a/x/storage/keeper/payment.go +++ b/x/storage/keeper/payment.go @@ -9,6 +9,7 @@ import ( "github.com/bnb-chain/greenfield/x/payment/types" storagetypes "github.com/bnb-chain/greenfield/x/storage/types" + vgtypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" ) func (k Keeper) ChargeBucketReadFee(ctx sdk.Context, bucketInfo *storagetypes.BucketInfo, @@ -390,51 +391,30 @@ func (k Keeper) ChargeViaObjectChange(ctx sdk.Context, bucketInfo *storagetypes. } } - // primary sp - primaryRate := price.PrimaryStorePrice.MulInt(sdkmath.NewIntFromUint64(chargeSize)).TruncateInt() - if primaryRate.IsPositive() { - userFlows.Flows = append(userFlows.Flows, types.OutFlow{ - ToAddress: gvgFamily.VirtualPaymentAddress, - Rate: primaryRate, - }) - } - - //secondary sp gvg, found := k.virtualGroupKeeper.GetGVG(ctx, lvg.GlobalVirtualGroupId) if !found { return fmt.Errorf("get GVG failed: %d, %s", lvg.GlobalVirtualGroupId, lvg.String()) } - secondaryRate := price.SecondaryStorePrice.MulInt(sdkmath.NewIntFromUint64(chargeSize)).TruncateInt() - secondaryRate = secondaryRate.MulRaw(int64(len(gvg.SecondarySpIds))) - if secondaryRate.IsPositive() { - userFlows.Flows = append(userFlows.Flows, types.OutFlow{ - ToAddress: gvg.VirtualPaymentAddress, - Rate: secondaryRate, - }) - } - versionedParams, err := k.paymentKeeper.GetVersionedParamsWithTs(ctx, internalBucketInfo.PriceTime) if err != nil { return fmt.Errorf("failed to get validator tax rate: %w, time: %d", err, internalBucketInfo.PriceTime) } - validatorTaxRate := versionedParams.ValidatorTaxRate.MulInt(primaryRate.Add(secondaryRate)).TruncateInt() - if validatorTaxRate.IsPositive() { - userFlows.Flows = append(userFlows.Flows, types.OutFlow{ - ToAddress: types.ValidatorTaxPoolAddress.String(), - Rate: validatorTaxRate, - }) - } - if !delete { + preOutFlows := k.calculateLVGStoreBill(ctx, price, versionedParams, gvgFamily, gvg, lvg) + var newOutFlows []types.OutFlow + if !delete { // seal object internalBucketInfo.TotalChargeSize = internalBucketInfo.TotalChargeSize + chargeSize lvg.TotalChargeSize = lvg.TotalChargeSize + chargeSize - } else { + newOutFlows = k.calculateLVGStoreBill(ctx, price, versionedParams, gvgFamily, gvg, lvg) + } else { // delete object internalBucketInfo.TotalChargeSize = internalBucketInfo.TotalChargeSize - chargeSize lvg.TotalChargeSize = lvg.TotalChargeSize - chargeSize - - userFlows.Flows = getNegFlows(userFlows.Flows) + newOutFlows = k.calculateLVGStoreBill(ctx, price, versionedParams, gvgFamily, gvg, lvg) } + + userFlows.Flows = append(userFlows.Flows, getNegFlows(preOutFlows)...) + userFlows.Flows = append(userFlows.Flows, newOutFlows...) err = k.paymentKeeper.ApplyUserFlowsList(ctx, []types.UserFlows{userFlows}) if err != nil { ctx.Logger().Error("charge object store fee failed", "err", err.Error()) @@ -444,18 +424,55 @@ func (k Keeper) ChargeViaObjectChange(ctx sdk.Context, bucketInfo *storagetypes. return nil } +func (k Keeper) calculateLVGStoreBill(ctx sdk.Context, price types.StoragePrice, params types.VersionedParams, + gvgFamily *vgtypes.GlobalVirtualGroupFamily, gvg *vgtypes.GlobalVirtualGroup, lvg *storagetypes.LocalVirtualGroup) []types.OutFlow { + outFlows := make([]types.OutFlow, 0) + + // primary sp + primaryStoreFlowRate := price.PrimaryStorePrice.MulInt(sdkmath.NewIntFromUint64(lvg.TotalChargeSize)).TruncateInt() + if primaryStoreFlowRate.IsPositive() { + outFlows = append(outFlows, types.OutFlow{ + ToAddress: gvgFamily.VirtualPaymentAddress, + Rate: primaryStoreFlowRate, + }) + } + + //secondary sp + secondaryStoreFlowRate := price.SecondaryStorePrice.MulInt(sdkmath.NewIntFromUint64(lvg.TotalChargeSize)).TruncateInt() + secondaryStoreFlowRate = secondaryStoreFlowRate.MulRaw(int64(len(gvg.SecondarySpIds))) + if secondaryStoreFlowRate.IsPositive() { + outFlows = append(outFlows, types.OutFlow{ + ToAddress: gvg.VirtualPaymentAddress, + Rate: secondaryStoreFlowRate, + }) + } + + validatorTaxStoreFlowRate := params.ValidatorTaxRate.MulInt(primaryStoreFlowRate.Add(secondaryStoreFlowRate)).TruncateInt() + if validatorTaxStoreFlowRate.IsPositive() { + outFlows = append(outFlows, types.OutFlow{ + ToAddress: types.ValidatorTaxPoolAddress.String(), + Rate: validatorTaxStoreFlowRate, + }) + } + + return outFlows +} + func (k Keeper) GetBucketReadStoreBill(ctx sdk.Context, bucketInfo *storagetypes.BucketInfo, internalBucketInfo *storagetypes.InternalBucketInfo) (userFlows types.UserFlows, err error) { userFlows.From = sdk.MustAccAddressFromHex(bucketInfo.PaymentAddress) + if internalBucketInfo.TotalChargeSize == 0 && bucketInfo.ChargedReadQuota == 0 { + return userFlows, nil + } + + // calculate read fee & store fee separately, for precision + // calculate read fee gvgFamily, found := k.virtualGroupKeeper.GetGVGFamily(ctx, bucketInfo.GlobalVirtualGroupFamilyId) if !found { return userFlows, fmt.Errorf("get GVG family failed: %d", bucketInfo.GlobalVirtualGroupFamilyId) } - if internalBucketInfo.TotalChargeSize == 0 && bucketInfo.ChargedReadQuota == 0 { - return userFlows, nil - } price, err := k.paymentKeeper.GetStoragePrice(ctx, types.StoragePriceParams{ PrimarySp: gvgFamily.PrimarySpId, PriceTime: internalBucketInfo.PriceTime, @@ -464,40 +481,11 @@ func (k Keeper) GetBucketReadStoreBill(ctx sdk.Context, bucketInfo *storagetypes return userFlows, fmt.Errorf("get storage price failed: %w", err) } - // primary sp total rate - primaryTotalFlowRate := price.ReadPrice.MulInt(sdkmath.NewIntFromUint64(bucketInfo.ChargedReadQuota)).TruncateInt() - - // secondary sp total rate - secondaryTotalFlowRate := sdk.ZeroInt() - - for _, lvg := range internalBucketInfo.LocalVirtualGroups { - // primary sp - primaryRate := price.PrimaryStorePrice.MulInt(sdkmath.NewIntFromUint64(lvg.TotalChargeSize)).TruncateInt() - if primaryRate.IsPositive() { - primaryTotalFlowRate = primaryTotalFlowRate.Add(primaryRate) - } - - //secondary sp - gvg, found := k.virtualGroupKeeper.GetGVG(ctx, lvg.GlobalVirtualGroupId) - if !found { - return userFlows, fmt.Errorf("get GVG failed: %d, %s", lvg.GlobalVirtualGroupId, lvg.String()) - } - - secondaryRate := price.SecondaryStorePrice.MulInt(sdkmath.NewIntFromUint64(lvg.TotalChargeSize)).TruncateInt() - secondaryRate = secondaryRate.MulRaw(int64(len(gvg.SecondarySpIds))) - if secondaryRate.IsPositive() { - userFlows.Flows = append(userFlows.Flows, types.OutFlow{ - ToAddress: gvg.VirtualPaymentAddress, - Rate: secondaryRate, - }) - secondaryTotalFlowRate = secondaryTotalFlowRate.Add(secondaryRate) - } - } - - if primaryTotalFlowRate.IsPositive() { + primaryReadFlowRate := price.ReadPrice.MulInt(sdkmath.NewIntFromUint64(bucketInfo.ChargedReadQuota)).TruncateInt() + if primaryReadFlowRate.IsPositive() { userFlows.Flows = append(userFlows.Flows, types.OutFlow{ ToAddress: gvgFamily.VirtualPaymentAddress, - Rate: primaryTotalFlowRate, + Rate: primaryReadFlowRate, }) } @@ -505,14 +493,26 @@ func (k Keeper) GetBucketReadStoreBill(ctx sdk.Context, bucketInfo *storagetypes if err != nil { return userFlows, fmt.Errorf("failed to get validator tax rate: %w, time: %d", err, internalBucketInfo.PriceTime) } - validatorTaxRate := versionedParams.ValidatorTaxRate.MulInt(primaryTotalFlowRate.Add(secondaryTotalFlowRate)).TruncateInt() - if validatorTaxRate.IsPositive() { + validatorTaxReadFlowRate := versionedParams.ValidatorTaxRate.MulInt(primaryReadFlowRate).TruncateInt() + if validatorTaxReadFlowRate.IsPositive() { userFlows.Flows = append(userFlows.Flows, types.OutFlow{ ToAddress: types.ValidatorTaxPoolAddress.String(), - Rate: validatorTaxRate, + Rate: validatorTaxReadFlowRate, }) } + // calculate store fee + // be noted, here we split the fee calculation for each lvg, to make sure each lvg's calculation is precise + for _, lvg := range internalBucketInfo.LocalVirtualGroups { + //secondary sp + gvg, found := k.virtualGroupKeeper.GetGVG(ctx, lvg.GlobalVirtualGroupId) + if !found { + return userFlows, fmt.Errorf("get GVG failed: %d, %s", lvg.GlobalVirtualGroupId, lvg.String()) + } + outFlows := k.calculateLVGStoreBill(ctx, price, versionedParams, gvgFamily, gvg, lvg) + userFlows.Flows = append(userFlows.Flows, outFlows...) + } + return userFlows, nil } diff --git a/x/storage/keeper/payment_test.go b/x/storage/keeper/payment_test.go index 1d3d087e1..5a9614572 100644 --- a/x/storage/keeper/payment_test.go +++ b/x/storage/keeper/payment_test.go @@ -226,18 +226,20 @@ func (s *TestSuite) TestGetBucketReadStoreBill() { ChargedReadQuota: 100, } + lvg1 := &types.LocalVirtualGroup{ + Id: 1, + TotalChargeSize: 100, + GlobalVirtualGroupId: 1, + } + lvg2 := &types.LocalVirtualGroup{ + Id: 2, + TotalChargeSize: 200, + GlobalVirtualGroupId: 2, + } internalBucketInfo := &types.InternalBucketInfo{ TotalChargeSize: 300, LocalVirtualGroups: []*types.LocalVirtualGroup{ - { - Id: 1, - TotalChargeSize: 100, - GlobalVirtualGroupId: 1, - }, { - Id: 2, - TotalChargeSize: 200, - GlobalVirtualGroupId: 2, - }, + lvg1, lvg2, }, } @@ -261,23 +263,47 @@ func (s *TestSuite) TestGetBucketReadStoreBill() { flows, err := s.storageKeeper.GetBucketReadStoreBill(s.ctx, bucketInfo, internalBucketInfo) s.Require().NoError(err) - gvg1StoreSize := internalBucketInfo.LocalVirtualGroups[0].TotalChargeSize * uint64(len(gvg1.SecondarySpIds)) - gvg1StoreRate := price.SecondaryStorePrice.MulInt64(int64(gvg1StoreSize)).TruncateInt() - s.Require().Equal(flows.Flows[0].ToAddress, gvg1.VirtualPaymentAddress) - s.Require().Equal(flows.Flows[0].Rate, gvg1StoreRate) + // read rate to gvg family + s.Require().Equal(flows.Flows[0].ToAddress, gvgFamily.VirtualPaymentAddress) + readRate := price.ReadPrice.MulInt64(int64(bucketInfo.ChargedReadQuota)).TruncateInt() + s.Require().Equal(flows.Flows[0].Rate, readRate) - gvg2StoreSize := internalBucketInfo.LocalVirtualGroups[1].TotalChargeSize * uint64(len(gvg2.SecondarySpIds)) - gvg2StoreRate := price.SecondaryStorePrice.MulInt64(int64(gvg2StoreSize)).TruncateInt() - s.Require().Equal(flows.Flows[1].ToAddress, gvg2.VirtualPaymentAddress) - s.Require().Equal(flows.Flows[1].Rate, gvg2StoreRate) + // read rate to validator tax pool + s.Require().Equal(flows.Flows[1].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String()) + taxPoolRate := params.VersionedParams.ValidatorTaxRate.MulInt(readRate).TruncateInt() + s.Require().Equal(flows.Flows[1].Rate, taxPoolRate) - readRate := price.ReadPrice.MulInt64(int64(bucketInfo.ChargedReadQuota)).TruncateInt() - primaryStoreRate := price.PrimaryStorePrice.MulInt64(int64(internalBucketInfo.TotalChargeSize)).TruncateInt() + // first gvg + // store rate to gvg family s.Require().Equal(flows.Flows[2].ToAddress, gvgFamily.VirtualPaymentAddress) - s.Require().Equal(flows.Flows[2].Rate, readRate.Add(primaryStoreRate)) + primaryStoreRate := price.PrimaryStorePrice.MulInt64(int64(lvg1.TotalChargeSize)).TruncateInt() + s.Require().Equal(flows.Flows[2].Rate, primaryStoreRate) + + // store rate to gvg + gvg1StoreSize := lvg1.TotalChargeSize * uint64(len(gvg1.SecondarySpIds)) + gvg1StoreRate := price.SecondaryStorePrice.MulInt64(int64(gvg1StoreSize)).TruncateInt() + s.Require().Equal(flows.Flows[3].ToAddress, gvg1.VirtualPaymentAddress) + s.Require().Equal(flows.Flows[3].Rate, gvg1StoreRate) + + // store rate to validator tax pool + s.Require().Equal(flows.Flows[4].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String()) + taxPoolRate = params.VersionedParams.ValidatorTaxRate.MulInt(primaryStoreRate.Add(gvg1StoreRate)).TruncateInt() + s.Require().Equal(flows.Flows[4].Rate, taxPoolRate) + + // secondary gvg + // store rate to gvg family + s.Require().Equal(flows.Flows[5].ToAddress, gvgFamily.VirtualPaymentAddress) + primaryStoreRate = price.PrimaryStorePrice.MulInt64(int64(lvg2.TotalChargeSize)).TruncateInt() + s.Require().Equal(flows.Flows[5].Rate, primaryStoreRate) + + // store rate to gvg + gvg2StoreSize := lvg2.TotalChargeSize * uint64(len(gvg2.SecondarySpIds)) + gvg2StoreRate := price.SecondaryStorePrice.MulInt64(int64(gvg2StoreSize)).TruncateInt() + s.Require().Equal(flows.Flows[6].ToAddress, gvg2.VirtualPaymentAddress) + s.Require().Equal(flows.Flows[6].Rate, gvg2StoreRate) - totalRate := readRate.Add(primaryStoreRate).Add(gvg1StoreRate).Add(gvg2StoreRate) - taxPoolRate := params.VersionedParams.ValidatorTaxRate.MulInt(totalRate).TruncateInt() - s.Require().Equal(flows.Flows[3].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String()) - s.Require().Equal(flows.Flows[3].Rate, taxPoolRate) + // store rate to validator tax pool + s.Require().Equal(flows.Flows[7].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String()) + taxPoolRate = params.VersionedParams.ValidatorTaxRate.MulInt(primaryStoreRate.Add(gvg2StoreRate)).TruncateInt() + s.Require().Equal(flows.Flows[7].Rate, taxPoolRate) } diff --git a/x/virtualgroup/client/cli/query_global_virtual_group_by_family_id.go b/x/virtualgroup/client/cli/query_global_virtual_group_by_family_id.go index 628a1ff51..8fbc62947 100644 --- a/x/virtualgroup/client/cli/query_global_virtual_group_by_family_id.go +++ b/x/virtualgroup/client/cli/query_global_virtual_group_by_family_id.go @@ -15,17 +15,12 @@ var _ = strconv.Itoa(0) func CmdGlobalVirtualGroupByFamilyID() *cobra.Command { cmd := &cobra.Command{ - Use: "global-virtual-group-by-family-id [sp-id] [family-id]", + Use: "global-virtual-group-by-family-id [family-id]", Short: "query virtual group by family id", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { - spID, err := strconv.ParseInt(args[0], 10, 32) - if err != nil || spID <= 0 { - return fmt.Errorf("invalid GVG id %s", args[1]) - } - - familyID, err := strconv.ParseInt(args[1], 10, 32) + familyID, err := strconv.ParseInt(args[0], 10, 32) if err != nil || familyID <= 0 { return fmt.Errorf("invalid GVG id %s", args[1]) } @@ -38,7 +33,6 @@ func CmdGlobalVirtualGroupByFamilyID() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) params := &types.QueryGlobalVirtualGroupByFamilyIDRequest{ - StorageProviderId: uint32(spID), GlobalVirtualGroupFamilyId: uint32(familyID), } diff --git a/x/virtualgroup/keeper/grpc_query.go b/x/virtualgroup/keeper/grpc_query.go index 568f8614f..b31405cfb 100644 --- a/x/virtualgroup/keeper/grpc_query.go +++ b/x/virtualgroup/keeper/grpc_query.go @@ -47,10 +47,6 @@ func (k Keeper) GlobalVirtualGroupByFamilyID(goCtx context.Context, req *types.Q ctx := sdk.UnwrapSDKContext(goCtx) - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - gvgFamily, found := k.GetGVGFamily(ctx, req.GlobalVirtualGroupFamilyId) if !found { return nil, types.ErrGVGFamilyNotExist diff --git a/x/virtualgroup/keeper/keeper.go b/x/virtualgroup/keeper/keeper.go index d60353b2f..6cded1b3b 100644 --- a/x/virtualgroup/keeper/keeper.go +++ b/x/virtualgroup/keeper/keeper.go @@ -157,7 +157,7 @@ func (k Keeper) DeleteGVG(ctx sdk.Context, primarySp *sptypes.StorageProvider, g return err } - if k.paymentKeeper.IsEmptyNetFlow(ctx, sdk.MustAccAddressFromHex(gvgFamily.VirtualPaymentAddress)) { + if len(gvgFamily.GlobalVirtualGroupIds) == 0 && k.paymentKeeper.IsEmptyNetFlow(ctx, sdk.MustAccAddressFromHex(gvgFamily.VirtualPaymentAddress)) { store.Delete(types.GetGVGFamilyKey(gvg.FamilyId)) if err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteGlobalVirtualGroupFamily{ Id: gvgFamily.Id, diff --git a/x/virtualgroup/types/keys.go b/x/virtualgroup/types/keys.go index a0e92f211..a20f1d9c4 100644 --- a/x/virtualgroup/types/keys.go +++ b/x/virtualgroup/types/keys.go @@ -55,11 +55,6 @@ func GetGVGFamilyKey(familyID uint32) []byte { return append(GVGFamilyKey, uint32Seq.EncodeSequence(familyID)...) } -func GetGVGFamilyPrefixKey(spID uint32) []byte { - var uint32Seq sequence.Sequence[uint32] - return append(GVGFamilyKey, uint32Seq.EncodeSequence(spID)...) -} - func GetGVGStatisticsWithinSPKey(spID uint32) []byte { var uint32Seq sequence.Sequence[uint32] return append(GVGStatisticsWithinSPKey, uint32Seq.EncodeSequence(spID)...) diff --git a/x/virtualgroup/types/query.pb.go b/x/virtualgroup/types/query.pb.go index 336ea65d8..36fdca30c 100644 --- a/x/virtualgroup/types/query.pb.go +++ b/x/virtualgroup/types/query.pb.go @@ -202,8 +202,7 @@ func (m *QueryGlobalVirtualGroupResponse) GetGlobalVirtualGroup() *GlobalVirtual } type QueryGlobalVirtualGroupByFamilyIDRequest struct { - StorageProviderId uint32 `protobuf:"varint,1,opt,name=storage_provider_id,json=storageProviderId,proto3" json:"storage_provider_id,omitempty"` - GlobalVirtualGroupFamilyId uint32 `protobuf:"varint,2,opt,name=global_virtual_group_family_id,json=globalVirtualGroupFamilyId,proto3" json:"global_virtual_group_family_id,omitempty"` + GlobalVirtualGroupFamilyId uint32 `protobuf:"varint,1,opt,name=global_virtual_group_family_id,json=globalVirtualGroupFamilyId,proto3" json:"global_virtual_group_family_id,omitempty"` } func (m *QueryGlobalVirtualGroupByFamilyIDRequest) Reset() { @@ -241,13 +240,6 @@ func (m *QueryGlobalVirtualGroupByFamilyIDRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGlobalVirtualGroupByFamilyIDRequest proto.InternalMessageInfo -func (m *QueryGlobalVirtualGroupByFamilyIDRequest) GetStorageProviderId() uint32 { - if m != nil { - return m.StorageProviderId - } - return 0 -} - func (m *QueryGlobalVirtualGroupByFamilyIDRequest) GetGlobalVirtualGroupFamilyId() uint32 { if m != nil { return m.GlobalVirtualGroupFamilyId @@ -608,57 +600,55 @@ func init() { } var fileDescriptor_83cd53fc415e00e7 = []byte{ - // 800 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x4f, 0xdb, 0x48, - 0x18, 0xc6, 0x33, 0xec, 0x2e, 0x5a, 0x5e, 0x96, 0xc3, 0x0e, 0x59, 0x81, 0x0c, 0x72, 0x76, 0x0d, - 0x0b, 0x14, 0x8a, 0x2d, 0x28, 0x50, 0x54, 0x01, 0x85, 0x80, 0xa0, 0x5c, 0x2a, 0x1a, 0xa1, 0x56, - 0xaa, 0x54, 0x45, 0x63, 0x32, 0x0c, 0x96, 0x1c, 0x8f, 0xb1, 0x9d, 0xa8, 0xb9, 0x55, 0x3d, 0x73, - 0xa8, 0xd4, 0x53, 0x2f, 0xfd, 0x28, 0x3d, 0x73, 0x44, 0xea, 0xa1, 0x3d, 0xb5, 0x15, 0xf4, 0xd2, - 0xaf, 0x50, 0xf5, 0x50, 0x65, 0x3c, 0x56, 0x88, 0x92, 0xc9, 0x3f, 0x7a, 0x8b, 0x3c, 0xf3, 0x3e, - 0xef, 0xf3, 0x7b, 0xc7, 0xf3, 0xc4, 0x30, 0xc1, 0x02, 0x4a, 0xbd, 0x63, 0x87, 0xba, 0x05, 0xab, - 0xec, 0x04, 0x51, 0x89, 0xb8,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x96, 0x4b, 0xbe, 0x35, 0xc1, 0xb7, 0x82, 0x97, 0xba, 0xe3, - 0x8b, 0xe1, 0xf0, 0x67, 0x04, 0x9a, 0xfa, 0x32, 0xe2, 0xfb, 0x3d, 0x99, 0xab, 0x45, 0x87, 0xb6, - 0xd9, 0xbb, 0x80, 0xe4, 0xdb, 0x10, 0x7c, 0xab, 0x78, 0xa5, 0x07, 0xbe, 0x2a, 0xc2, 0x77, 0x04, - 0x13, 0x1d, 0xe4, 0x0e, 0xde, 0x56, 0x3a, 0xed, 0x3c, 0x29, 0xb5, 0x9d, 0x9b, 0x89, 0x48, 0xe4, - 0x07, 0x02, 0x39, 0x8b, 0x37, 0x95, 0xc8, 0x24, 0x51, 0xcb, 0xb7, 0x84, 0xcf, 0x3e, 0x3c, 0xbf, - 0xd4, 0xd1, 0xc5, 0xa5, 0x8e, 0xbe, 0x5c, 0xea, 0xe8, 0xd5, 0x95, 0x9e, 0xba, 0xb8, 0xd2, 0x53, - 0x1f, 0xaf, 0xf4, 0xd4, 0xd3, 0x25, 0xe6, 0x44, 0x27, 0x25, 0xdb, 0x3c, 0xe2, 0x45, 0xcb, 0xf6, - 0xec, 0xf9, 0xa3, 0x13, 0xe2, 0x78, 0xd7, 0xfb, 0x3d, 0x6f, 0xf2, 0x4d, 0x6b, 0xf7, 0x8b, 0x8f, - 0xda, 0x3b, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xba, 0xb0, 0xee, 0x41, 0xbf, 0x0b, 0x00, 0x00, + // 762 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x4f, 0x13, 0x41, + 0x14, 0xc7, 0x3b, 0xa8, 0x44, 0x1e, 0x72, 0x19, 0x6a, 0x20, 0x0b, 0xd9, 0xea, 0x82, 0x80, 0x20, + 0xbb, 0x01, 0x01, 0x89, 0x01, 0x84, 0x42, 0x40, 0x2e, 0x06, 0x1b, 0xa2, 0x89, 0x89, 0x69, 0x66, + 0xe9, 0x30, 0x6c, 0xb2, 0xdd, 0x5d, 0xba, 0xdb, 0xc6, 0xde, 0x8c, 0x67, 0x0e, 0x26, 0x9e, 0xfc, + 0x67, 0x3c, 0x73, 0x24, 0xf1, 0xa0, 0x27, 0x35, 0xe0, 0xc5, 0x7f, 0xc1, 0x78, 0x30, 0x9d, 0x99, + 0x4d, 0xa9, 0xed, 0xf4, 0x17, 0xde, 0x9a, 0xdd, 0xf7, 0xbe, 0xef, 0xfb, 0x79, 0xc3, 0x7c, 0x59, + 0x18, 0x63, 0x05, 0x4a, 0xbd, 0x43, 0x87, 0xba, 0x39, 0xab, 0xe4, 0x14, 0xa2, 0x22, 0x71, 0x59, + 0xc1, 0x2f, 0x06, 0xd6, 0x71, 0x91, 0x16, 0xca, 0x66, 0x50, 0xf0, 0x23, 0x1f, 0x0f, 0x55, 0x8b, + 0xcc, 0xcb, 0x45, 0xda, 0xf4, 0x81, 0x1f, 0xe6, 0xfd, 0xd0, 0xb2, 0x49, 0x48, 0x45, 0x87, 0x55, + 0x9a, 0xb3, 0x69, 0x44, 0xe6, 0xac, 0x80, 0x30, 0xc7, 0x23, 0x91, 0xe3, 0x7b, 0x42, 0x44, 0x4b, + 0x32, 0x9f, 0xf9, 0xfc, 0xa7, 0x55, 0xf9, 0x25, 0x9f, 0x8e, 0x32, 0xdf, 0x67, 0x2e, 0xb5, 0x48, + 0xe0, 0x58, 0xc4, 0xf3, 0xfc, 0x88, 0xb7, 0x84, 0xf2, 0xed, 0xb8, 0xca, 0x5d, 0x40, 0x0a, 0x24, + 0x1f, 0x57, 0x29, 0x19, 0xa2, 0x72, 0x40, 0x65, 0x91, 0x91, 0x04, 0xfc, 0xbc, 0x62, 0x70, 0x8f, + 0x77, 0x66, 0xe8, 0x71, 0x91, 0x86, 0x91, 0xb1, 0x0f, 0x83, 0x35, 0x4f, 0xc3, 0xc0, 0xf7, 0x42, + 0x8a, 0x57, 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0xd2, + 0x57, 0x91, 0x90, 0x78, 0x69, 0x8e, 0xb7, 0x82, 0x1f, 0x77, 0x84, 0x97, 0xb5, 0xcb, 0xd5, 0xbf, + 0x34, 0xfc, 0x05, 0xc1, 0xb0, 0xea, 0x86, 0xe2, 0xd5, 0x4e, 0x4d, 0xd6, 0x04, 0xb0, 0xb6, 0xd6, + 0x6d, 0xbb, 0xe4, 0x5b, 0xe1, 0x7c, 0x4b, 0x78, 0xa1, 0x33, 0x3e, 0x01, 0x87, 0xbf, 0x23, 0xd0, + 0xd4, 0x97, 0x11, 0x3f, 0xe9, 0xca, 0x5c, 0x35, 0x3a, 0xb4, 0xf5, 0xee, 0x05, 0x24, 0xdf, 0x1a, + 0xe7, 0x5b, 0xc6, 0x4b, 0x5d, 0xf0, 0x55, 0x10, 0x7e, 0x23, 0x18, 0x6b, 0x23, 0x77, 0xf0, 0xa6, + 0xd2, 0x69, 0xfb, 0x49, 0xa9, 0x6d, 0x5d, 0x4d, 0x44, 0x22, 0x3f, 0xe5, 0xc8, 0x69, 0xbc, 0xae, + 0x44, 0x26, 0xb1, 0x5a, 0xb6, 0x29, 0x7c, 0xfa, 0xd9, 0xe9, 0xb9, 0x8e, 0xce, 0xce, 0x75, 0xf4, + 0xe3, 0x5c, 0x47, 0xef, 0x2f, 0xf4, 0xc4, 0xd9, 0x85, 0x9e, 0xf8, 0x7a, 0xa1, 0x27, 0x5e, 0x2d, + 0x30, 0x27, 0x3a, 0x2a, 0xda, 0xe6, 0x81, 0x9f, 0xb7, 0x6c, 0xcf, 0x9e, 0x3d, 0x38, 0x22, 0x8e, + 0x77, 0x79, 0xde, 0x9b, 0x06, 0x9f, 0xa8, 0x76, 0x2f, 0xff, 0x46, 0x7d, 0xf8, 0x37, 0x00, 0x00, + 0xff, 0xff, 0x7c, 0x68, 0xc4, 0x2a, 0x8e, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1075,11 +1065,6 @@ func (m *QueryGlobalVirtualGroupByFamilyIDRequest) MarshalToSizedBuffer(dAtA []b if m.GlobalVirtualGroupFamilyId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.GlobalVirtualGroupFamilyId)) i-- - dAtA[i] = 0x10 - } - if m.StorageProviderId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StorageProviderId)) - i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil @@ -1413,9 +1398,6 @@ func (m *QueryGlobalVirtualGroupByFamilyIDRequest) Size() (n int) { } var l int _ = l - if m.StorageProviderId != 0 { - n += 1 + sovQuery(uint64(m.StorageProviderId)) - } if m.GlobalVirtualGroupFamilyId != 0 { n += 1 + sovQuery(uint64(m.GlobalVirtualGroupFamilyId)) } @@ -1850,25 +1832,6 @@ func (m *QueryGlobalVirtualGroupByFamilyIDRequest) Unmarshal(dAtA []byte) error } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StorageProviderId", wireType) - } - m.StorageProviderId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StorageProviderId |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GlobalVirtualGroupFamilyId", wireType) }