From 94011056b785952246db371b3149973e2ca5eb17 Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:46:24 +0800 Subject: [PATCH 01/24] fix defining err (#375) --- x/storage/types/errors.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x/storage/types/errors.go b/x/storage/types/errors.go index efe59093c..9fb387674 100644 --- a/x/storage/types/errors.go +++ b/x/storage/types/errors.go @@ -2,8 +2,6 @@ package types import ( "cosmossdk.io/errors" - - "github.com/bnb-chain/greenfield/x/virtualgroup/types" ) // x/storage module sentinel errors @@ -49,5 +47,5 @@ var ( ErrInvalidResource = errors.Register(ModuleName, 3201, "invalid resource type") ErrMigrationBucketFailed = errors.Register(ModuleName, 3202, "migrate bucket failed.") ErrVirtualGroupOperateFailed = errors.Register(ModuleName, 3203, "operate virtual group failed.") - ErrInvalidBlsPubKey = errors.Register(types.ModuleName, 1122, "invalid bls public key") + ErrInvalidBlsPubKey = errors.Register(ModuleName, 3204, "invalid bls public key") ) From 9cd5a4c6828f3af2a86c1d150f2d312e8c50eeef Mon Sep 17 00:00:00 2001 From: dylanhuang Date: Wed, 26 Jul 2023 16:26:13 +0800 Subject: [PATCH 02/24] fix: improve e2e tests to include more coverage from server side (#377) * fix: start e2e test chain in same process to include more coverage from server side * chore: fix ci job --- .github/workflows/e2e-test.yml | 10 ----- Makefile | 14 +++---- e2e/core/basesuite.go | 72 ++++++++++++++++++++++++++++++++++ e2e/core/config.go | 14 +++++++ 4 files changed, 92 insertions(+), 18 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index b54f6057f..00dabebfe 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -44,19 +44,9 @@ jobs: ${{ runner.os }}-go- - name: Setup GitHub Token run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/ - - name: Build - run: | - make build - - name: start e2e local chain - run: | - make e2e_start_localchain - sleep 5 - 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' diff --git a/Makefile b/Makefile index f015a6109..b1c725ad7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: build build-linux build-macos build-windows -.PHONY: tools proto-gen proto-format test e2e_test ci lint +.PHONY: tools proto-gen proto-format test e2e_init_localchain e2e_test ci lint .PHONY: install-go-test-coverage check-coverage VERSION=$(shell git describe --tags --always) @@ -51,13 +51,11 @@ docker-image: test: go test -failfast $$(go list ./... | grep -v e2e | grep -v sdk) -e2e_start_localchain: - bash ./deployment/localup/localup.sh all 1 7 +e2e_init_localchain: build + bash ./deployment/localup/localup.sh init 1 7 + bash ./deployment/localup/localup.sh generate 1 7 -e2e_stop_localchain: - bash ./deployment/localup/localup.sh stop - -e2e_test: +e2e_test: e2e_init_localchain go test -p 1 -failfast -v ./e2e/... -coverpkg=./... -covermode=atomic -coverprofile=./coverage.out -timeout 99999s install-go-test-coverage: @@ -73,5 +71,5 @@ lint: proto-gen-check: proto-gen git diff --exit-code -ci: proto-format-check build test e2e_start_localchain e2e_test lint proto-gen-check +ci: proto-format-check build test e2e_init_localchain e2e_test lint proto-gen-check echo "ci passed" diff --git a/e2e/core/basesuite.go b/e2e/core/basesuite.go index e2197e6e6..1bfcfd88e 100644 --- a/e2e/core/basesuite.go +++ b/e2e/core/basesuite.go @@ -9,10 +9,14 @@ import ( "math" "strconv" "strings" + "sync" "time" sdkmath "cosmossdk.io/math" "github.com/cometbft/cometbft/crypto/tmhash" + tmlog "github.com/cometbft/cometbft/libs/log" + sdkClient "github.com/cosmos/cosmos-sdk/client" + sdkServer "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/tx" @@ -22,8 +26,10 @@ import ( gov "github.com/cosmos/cosmos-sdk/x/gov/types" govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/prysmaticlabs/prysm/crypto/bls" + "github.com/spf13/cobra" "github.com/stretchr/testify/suite" + "github.com/bnb-chain/greenfield/cmd/gnfd/cmd" "github.com/bnb-chain/greenfield/sdk/client" "github.com/bnb-chain/greenfield/sdk/keys" "github.com/bnb-chain/greenfield/sdk/types" @@ -43,6 +49,8 @@ type StorageProvider struct { GlobalVirtualGroupFamilies map[uint32][]*virtualgroupmoduletypes.GlobalVirtualGroup } +var initValidatorOnce sync.Once + type BaseSuite struct { suite.Suite Config *Config @@ -55,8 +63,72 @@ type BaseSuite struct { StorageProviders map[uint32]*StorageProvider } +func findCommand(cmd *cobra.Command, name string) *cobra.Command { + if len(cmd.Commands()) == 0 { + return nil + } + for _, subCmd := range cmd.Commands() { + if subCmd.Name() == name { + return subCmd + } + if found := findCommand(subCmd, name); found != nil { + return found + } + } + + return nil +} + +func (s *BaseSuite) InitChain() { + s.T().Log("Initializing chain") + rootCmd, _ := cmd.NewRootCmd() + // Initialize and start chain + ctx := context.Background() + srvCtx := sdkServer.NewDefaultContext() + ctx = context.WithValue(ctx, sdkClient.ClientContextKey, &sdkClient.Context{}) + ctx = context.WithValue(ctx, sdkServer.ServerContextKey, srvCtx) + + // if you want to debug with chain logs, please discard this + startCmd := findCommand(rootCmd, "start") + startCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error { + err := rootCmd.PersistentPreRunE(cmd, args) + if err != nil { + return err + } + ctx := cmd.Context() + serverCtx := sdkServer.GetServerContextFromCmd(cmd) + serverCtx.Logger = tmlog.NewNopLogger() + ctx = context.WithValue(ctx, sdkServer.ServerContextKey, serverCtx) + cmd.SetContext(ctx) + return nil + } + rootCmd.SetArgs([]string{ + "start", + "--home", s.Config.ValidatorHomeDir, + "--rpc.laddr", s.Config.ValidatorTmRPCAddr, + }) + + errChan := make(chan error) + go func() { + errChan <- rootCmd.ExecuteContext(ctx) + }() + + select { + case err := <-errChan: + s.Require().NoError(err) + case <-time.After(15 * time.Second): + // wait 15 seconds for the server to start if no errors + } + + s.T().Log("Chain started") +} + func (s *BaseSuite) SetupSuite() { s.Config = InitConfig() + initValidatorOnce.Do(func() { + s.InitChain() + }) + s.Client, _ = client.NewGreenfieldClient(s.Config.TendermintAddr, s.Config.ChainId) tmClient := client.NewTendermintClient(s.Config.TendermintAddr) s.TmClient = &tmClient diff --git a/e2e/core/config.go b/e2e/core/config.go index f2e59bbe3..4efae3fbd 100644 --- a/e2e/core/config.go +++ b/e2e/core/config.go @@ -26,6 +26,8 @@ type Config struct { SPMnemonics []SPMnemonics `yaml:"SPMnemonics"` SPBLSMnemonic []string `yaml:"SPBLSMnemonic"` Denom string `yaml:"Denom"` + ValidatorHomeDir string `yaml:"ValidatorHomeDir"` + ValidatorTmRPCAddr string `yaml:"ValidatorTmRPCAddr"` } func InitConfig() *Config { @@ -43,6 +45,8 @@ func InitE2eConfig() *Config { ValidatorBlsMnemonic: ParseValidatorBlsMnemonic(0), RelayerMnemonic: ParseRelayerMnemonic(0), ChallengerMnemonic: ParseChallengerMnemonic(0), + ValidatorHomeDir: ParseValidatorHomeDir(0), + ValidatorTmRPCAddr: ParseValidatorTmRPCAddrDir(0), } for i := 0; i < 7; i++ { config.SPMnemonics = append(config.SPMnemonics, ParseSPMnemonics(i)) @@ -105,3 +109,13 @@ func ParseMnemonicFromFile(fileName string) string { } return line } + +// ParseValidatorHomeDir returns the home dir of the validator +func ParseValidatorHomeDir(i int) string { + return fmt.Sprintf("../../deployment/localup/.local/validator%d", i) +} + +// ParseValidatorTmRPCAddrDir returns the home dir of the validator +func ParseValidatorTmRPCAddrDir(i int) string { + return fmt.Sprintf("tcp://0.0.0.0:%d", 26750+i) +} From ed9668c1838738e284192bbdc1b1f1d4b07a0812 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Thu, 27 Jul 2023 16:02:17 +0800 Subject: [PATCH 03/24] chore: add unit test cases for challenge module (#378) --- x/challenge/abci_test.go | 226 +++++++++++++++++++ x/challenge/keeper/grpc_query_test.go | 27 +++ x/challenge/keeper/msg_server_attest_test.go | 95 ++++++-- x/challenge/keeper/msg_server_submit_test.go | 74 +++++- x/challenge/keeper/slash_test.go | 11 +- 5 files changed, 408 insertions(+), 25 deletions(-) create mode 100644 x/challenge/abci_test.go diff --git a/x/challenge/abci_test.go b/x/challenge/abci_test.go new file mode 100644 index 000000000..6c812de12 --- /dev/null +++ b/x/challenge/abci_test.go @@ -0,0 +1,226 @@ +package challenge_test + +import ( + "testing" + + sptypes "github.com/bnb-chain/greenfield/x/sp/types" + virtualgrouptypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" + + "cosmossdk.io/math" + storagetypes "github.com/bnb-chain/greenfield/x/storage/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/x/challenge" + "github.com/bnb-chain/greenfield/x/challenge/keeper" + "github.com/bnb-chain/greenfield/x/challenge/types" +) + +type TestSuite struct { + suite.Suite + + cdc codec.Codec + challengeKeeper *keeper.Keeper + + bankKeeper *types.MockBankKeeper + storageKeeper *types.MockStorageKeeper + spKeeper *types.MockSpKeeper + stakingKeeper *types.MockStakingKeeper + paymentKeeper *types.MockPaymentKeeper + + ctx sdk.Context + queryClient types.QueryClient + msgServer types.MsgServer +} + +func (s *TestSuite) SetupTest() { + encCfg := moduletestutil.MakeTestEncodingConfig(challenge.AppModuleBasic{}) + key := storetypes.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) + + // set mock randao mix + randaoMix := sdk.Keccak256([]byte{1}) + randaoMix = append(randaoMix, sdk.Keccak256([]byte{2})...) + header := testCtx.Ctx.BlockHeader() + header.RandaoMix = randaoMix + testCtx = testutil.TestContext{ + Ctx: sdk.NewContext(testCtx.CMS, header, false, nil, testCtx.Ctx.Logger()), + DB: testCtx.DB, + CMS: testCtx.CMS, + } + + s.ctx = testCtx.Ctx + + ctrl := gomock.NewController(s.T()) + + bankKeeper := types.NewMockBankKeeper(ctrl) + storageKeeper := types.NewMockStorageKeeper(ctrl) + spKeeper := types.NewMockSpKeeper(ctrl) + stakingKeeper := types.NewMockStakingKeeper(ctrl) + paymentKeeper := types.NewMockPaymentKeeper(ctrl) + + s.challengeKeeper = keeper.NewKeeper( + encCfg.Codec, + key, + key, + bankKeeper, + storageKeeper, + spKeeper, + stakingKeeper, + paymentKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + s.cdc = encCfg.Codec + s.bankKeeper = bankKeeper + s.storageKeeper = storageKeeper + s.spKeeper = spKeeper + s.stakingKeeper = stakingKeeper + s.paymentKeeper = paymentKeeper + + err := s.challengeKeeper.SetParams(s.ctx, types.DefaultParams()) + s.Require().NoError(err) + + queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, encCfg.InterfaceRegistry) + types.RegisterQueryServer(queryHelper, s.challengeKeeper) + + s.queryClient = types.NewQueryClient(queryHelper) + s.msgServer = keeper.NewMsgServerImpl(*s.challengeKeeper) +} + +func TestTestSuite(t *testing.T) { + suite.Run(t, new(TestSuite)) +} + +func (s *TestSuite) TestBeginBlocker_RemoveExpiredChallenge() { + s.challengeKeeper.SaveChallenge(s.ctx, types.Challenge{ + Id: 100, + ExpiredHeight: 100, + }) + s.challengeKeeper.SaveChallenge(s.ctx, types.Challenge{ + Id: 200, + ExpiredHeight: 300, + }) + + s.ctx = s.ctx.WithBlockHeight(101) + challenge.BeginBlocker(s.ctx, *s.challengeKeeper) + s.Require().False(s.challengeKeeper.ExistsChallenge(s.ctx, 100)) + s.Require().True(s.challengeKeeper.ExistsChallenge(s.ctx, 200)) +} + +func (s *TestSuite) TestBeginBlocker_RemoveSlash() { + s.challengeKeeper.SaveSlash(s.ctx, types.Slash{ + SpId: 100, + ObjectId: sdk.NewUint(100), + Height: 100, + }) + s.challengeKeeper.SaveSlash(s.ctx, types.Slash{ + SpId: 200, + ObjectId: sdk.NewUint(200), + Height: 200, + }) + + params := s.challengeKeeper.GetParams(s.ctx) + params.SlashCoolingOffPeriod = 10 + _ = s.challengeKeeper.SetParams(s.ctx, params) + + s.ctx = s.ctx.WithBlockHeight(101) + challenge.BeginBlocker(s.ctx, *s.challengeKeeper) + s.Require().True(s.challengeKeeper.ExistsSlash(s.ctx, 100, sdk.NewUint(100))) + s.Require().True(s.challengeKeeper.ExistsSlash(s.ctx, 200, sdk.NewUint(200))) + + s.ctx = s.ctx.WithBlockHeight(111) + challenge.BeginBlocker(s.ctx, *s.challengeKeeper) + s.Require().False(s.challengeKeeper.ExistsSlash(s.ctx, 100, sdk.NewUint(100))) + s.Require().True(s.challengeKeeper.ExistsSlash(s.ctx, 200, sdk.NewUint(200))) + + s.ctx = s.ctx.WithBlockHeight(211) + challenge.BeginBlocker(s.ctx, *s.challengeKeeper) + s.Require().False(s.challengeKeeper.ExistsSlash(s.ctx, 100, sdk.NewUint(100))) + s.Require().False(s.challengeKeeper.ExistsSlash(s.ctx, 200, sdk.NewUint(200))) +} + +func (s *TestSuite) TestBeginBlocker_RemoveSpSlashAmount() { + s.challengeKeeper.SetSpSlashAmount(s.ctx, 100, sdk.NewInt(100)) + s.challengeKeeper.SetSpSlashAmount(s.ctx, 200, sdk.NewInt(200)) + + params := s.challengeKeeper.GetParams(s.ctx) + params.SpSlashCountingWindow = 10 + _ = s.challengeKeeper.SetParams(s.ctx, params) + + s.ctx = s.ctx.WithBlockHeight(101) + challenge.BeginBlocker(s.ctx, *s.challengeKeeper) + s.Require().True(s.challengeKeeper.GetSpSlashAmount(s.ctx, 100).Int64() == 100) + s.Require().True(s.challengeKeeper.GetSpSlashAmount(s.ctx, 200).Int64() == 200) + + s.ctx = s.ctx.WithBlockHeight(100) + challenge.BeginBlocker(s.ctx, *s.challengeKeeper) + s.Require().False(s.challengeKeeper.GetSpSlashAmount(s.ctx, 100).Int64() == 100) + s.Require().False(s.challengeKeeper.GetSpSlashAmount(s.ctx, 200).Int64() == 200) +} + +func (s *TestSuite) TestEndBlocker_NoRandomChallenge() { + preChallengeId := s.challengeKeeper.GetChallengeId(s.ctx) + + params := s.challengeKeeper.GetParams(s.ctx) + params.ChallengeCountPerBlock = 0 + _ = s.challengeKeeper.SetParams(s.ctx, params) + + challenge.EndBlocker(s.ctx, *s.challengeKeeper) + afterChallengeId := s.challengeKeeper.GetChallengeId(s.ctx) + s.Require().True(preChallengeId == afterChallengeId) +} + +func (s *TestSuite) TestEndBlocker_ObjectNotExists() { + s.storageKeeper.EXPECT().GetObjectInfoCount(gomock.Any()).Return(sdk.NewUint(0)) + + preChallengeId := s.challengeKeeper.GetChallengeId(s.ctx) + challenge.EndBlocker(s.ctx, *s.challengeKeeper) + afterChallengeId := s.challengeKeeper.GetChallengeId(s.ctx) + s.Require().True(preChallengeId == afterChallengeId) +} + +func (s *TestSuite) TestEndBlocker_SuccessRandomChallenge() { + s.storageKeeper.EXPECT().GetObjectInfoCount(gomock.Any()).Return(sdk.NewUint(100)) + s.storageKeeper.EXPECT().MaxSegmentSize(gomock.Any()).Return(uint64(10000)).AnyTimes() + + existObject := &storagetypes.ObjectInfo{ + Id: math.NewUint(64), + BucketName: "bucketname", + ObjectName: "objectname", + ObjectStatus: storagetypes.OBJECT_STATUS_SEALED, + PayloadSize: 500} + s.storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Eq(existObject.Id)). + Return(existObject, true).AnyTimes() + + existBucket := &storagetypes.BucketInfo{ + BucketName: existObject.BucketName, + Id: math.NewUint(10), + } + s.storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Eq(existBucket.BucketName)). + Return(existBucket, true).AnyTimes() + + gvg := &virtualgrouptypes.GlobalVirtualGroup{PrimarySpId: 100, SecondarySpIds: []uint32{ + 1, + }} + s.storageKeeper.EXPECT().GetObjectGVG(gomock.Any(), gomock.Any(), gomock.Any()). + Return(gvg, true).AnyTimes() + + sp := &sptypes.StorageProvider{Id: 1, Status: sptypes.STATUS_IN_SERVICE} + s.spKeeper.EXPECT().GetStorageProvider(gomock.Any(), gomock.Any()). + Return(sp, true).AnyTimes() + + preChallengeId := s.challengeKeeper.GetChallengeId(s.ctx) + challenge.EndBlocker(s.ctx, *s.challengeKeeper) + afterChallengeId := s.challengeKeeper.GetChallengeId(s.ctx) + s.Require().True(preChallengeId == afterChallengeId-1) +} diff --git a/x/challenge/keeper/grpc_query_test.go b/x/challenge/keeper/grpc_query_test.go index a5cc307fd..03b6aa0db 100644 --- a/x/challenge/keeper/grpc_query_test.go +++ b/x/challenge/keeper/grpc_query_test.go @@ -29,6 +29,33 @@ func TestParamsQuery(t *testing.T) { require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } +func TestAttestedChallengeQuery(t *testing.T) { + keeper, ctx := makeKeeper(t) + err := keeper.SetParams(ctx, types.DefaultParams()) + require.NoError(t, err) + c100 := &types.AttestedChallenge{Id: 100, Result: types.CHALLENGE_SUCCEED} + c200 := &types.AttestedChallenge{Id: 200, Result: types.CHALLENGE_FAILED} + keeper.AppendAttestedChallenge(ctx, c100) + keeper.AppendAttestedChallenge(ctx, c200) + + response, err := keeper.AttestedChallenge(ctx, &types.QueryAttestedChallengeRequest{ + ChallengeId: 100, + }) + require.NoError(t, err) + require.Equal(t, &types.QueryAttestedChallengeResponse{Challenge: c100}, response) + + response, err = keeper.AttestedChallenge(ctx, &types.QueryAttestedChallengeRequest{ + ChallengeId: 200, + }) + require.NoError(t, err) + require.Equal(t, &types.QueryAttestedChallengeResponse{Challenge: c200}, response) + + _, err = keeper.AttestedChallenge(ctx, &types.QueryAttestedChallengeRequest{ + ChallengeId: 300, + }) + require.Error(t, err) +} + func TestLatestAttestedChallengesQuery(t *testing.T) { keeper, ctx := makeKeeper(t) err := keeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/challenge/keeper/msg_server_attest_test.go b/x/challenge/keeper/msg_server_attest_test.go index 176c140dc..3d9f2831e 100644 --- a/x/challenge/keeper/msg_server_attest_test.go +++ b/x/challenge/keeper/msg_server_attest_test.go @@ -195,9 +195,13 @@ func (s *TestSuite) TestAttest_Heartbeat() { func (s *TestSuite) TestAttest_Normal() { // prepare challenge - challengeId := uint64(99) + challenge1Id := uint64(99) s.challengeKeeper.SaveChallenge(s.ctx, types.Challenge{ - Id: challengeId, + Id: challenge1Id, + }) + challenge2Id := uint64(100) + s.challengeKeeper.SaveChallenge(s.ctx, types.Challenge{ + Id: challenge2Id, }) validSubmitter := sample.RandAccAddress() @@ -220,14 +224,23 @@ func (s *TestSuite) TestAttest_Normal() { s.storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Eq(existBucket.BucketName)). Return(existBucket, true).AnyTimes() - existObject := &storagetypes.ObjectInfo{ + existObject1 := &storagetypes.ObjectInfo{ Id: math.NewUint(10), - ObjectName: "existobject", + ObjectName: "existobject1", BucketName: existBucket.BucketName, ObjectStatus: storagetypes.OBJECT_STATUS_SEALED, PayloadSize: 500} s.storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Eq(math.NewUint(10))). - Return(existObject, true).AnyTimes() + Return(existObject1, true).AnyTimes() + + existObject2 := &storagetypes.ObjectInfo{ + Id: math.NewUint(100), + ObjectName: "existobject2", + BucketName: existBucket.BucketName, + ObjectStatus: storagetypes.OBJECT_STATUS_SEALED, + PayloadSize: 500} + s.storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Eq(math.NewUint(100))). + Return(existObject2, true).AnyTimes() spOperatorAcc := sample.RandAccAddress() sp := &sptypes.StorageProvider{Id: 1, OperatorAddress: spOperatorAcc.String()} @@ -238,30 +251,78 @@ func (s *TestSuite) TestAttest_Normal() { s.spKeeper.EXPECT().GetStorageProviderByOperatorAddr(gomock.Any(), gomock.Any()). Return(sp, true).AnyTimes() s.storageKeeper.EXPECT().MustGetPrimarySPForBucket(gomock.Any(), gomock.Any()).Return(sp).AnyTimes() - attestMsg := &types.MsgAttest{ + + // success attestation + attestMsg1 := &types.MsgAttest{ Submitter: validSubmitter.String(), - ChallengeId: challengeId, + ChallengeId: challenge1Id, ObjectId: math.NewUint(10), SpOperatorAddress: spOperatorAcc.String(), VoteResult: types.CHALLENGE_SUCCEED, ChallengerAddress: "", VoteValidatorSet: []uint64{1}, } - toSign := attestMsg.GetBlsSignBytes(s.ctx.ChainID()) + toSign1 := attestMsg1.GetBlsSignBytes(s.ctx.ChainID()) + voteAggSignature1 := blsKey.Sign(toSign1[:]) + attestMsg1.VoteAggSignature = voteAggSignature1.Marshal() + _, err := s.msgServer.Attest(s.ctx, attestMsg1) + require.NoError(s.T(), err) - voteAggSignature := blsKey.Sign(toSign[:]) - attestMsg.VoteAggSignature = voteAggSignature.Marshal() + attestedChallenges := s.challengeKeeper.GetAttestedChallenges(s.ctx) + attest1Found := false + for _, c := range attestedChallenges { + if c.Id == challenge1Id { + attest1Found = true + } + } + s.Require().True(attest1Found) + s.Require().True(s.challengeKeeper.ExistsSlash(s.ctx, sp.Id, attestMsg1.ObjectId)) - _, err := s.msgServer.Attest(s.ctx, attestMsg) + // success attestation even exceed the max slash amount + params := s.challengeKeeper.GetParams(s.ctx) + params.SpSlashMaxAmount = math.NewInt(1) + _ = s.challengeKeeper.SetParams(s.ctx, params) + + attestMsg2 := &types.MsgAttest{ + Submitter: validSubmitter.String(), + ChallengeId: challenge2Id, + ObjectId: math.NewUint(100), + SpOperatorAddress: spOperatorAcc.String(), + VoteResult: types.CHALLENGE_SUCCEED, + ChallengerAddress: sample.RandAccAddress().String(), + VoteValidatorSet: []uint64{1}, + } + toSign2 := attestMsg2.GetBlsSignBytes(s.ctx.ChainID()) + voteAggSignature2 := blsKey.Sign(toSign2[:]) + attestMsg2.VoteAggSignature = voteAggSignature2.Marshal() + _, err = s.msgServer.Attest(s.ctx, attestMsg2) require.NoError(s.T(), err) - attestedChallenges := s.challengeKeeper.GetAttestedChallenges(s.ctx) - found := false + attestedChallenges = s.challengeKeeper.GetAttestedChallenges(s.ctx) + attest2Found := false for _, c := range attestedChallenges { - if c.Id == challengeId { - found = true + if c.Id == challenge1Id { + attest2Found = true } } - s.Require().True(found) - s.Require().True(s.challengeKeeper.ExistsSlash(s.ctx, sp.Id, attestMsg.ObjectId)) + s.Require().True(attest1Found) + s.Require().True(s.challengeKeeper.ExistsSlash(s.ctx, sp.Id, attestMsg1.ObjectId)) + s.Require().True(attest2Found) + s.Require().True(s.challengeKeeper.ExistsSlash(s.ctx, sp.Id, attestMsg2.ObjectId)) + + // the sp and the object had been slashed + attestMsg3 := &types.MsgAttest{ + Submitter: validSubmitter.String(), + ChallengeId: challenge2Id, + ObjectId: math.NewUint(100), + SpOperatorAddress: spOperatorAcc.String(), + VoteResult: types.CHALLENGE_SUCCEED, + ChallengerAddress: sample.RandAccAddress().String(), + VoteValidatorSet: []uint64{1}, + } + toSign3 := attestMsg3.GetBlsSignBytes(s.ctx.ChainID()) + voteAggSignature3 := blsKey.Sign(toSign3[:]) + attestMsg3.VoteAggSignature = voteAggSignature3.Marshal() + _, err = s.msgServer.Attest(s.ctx, attestMsg3) + require.Error(s.T(), err) } diff --git a/x/challenge/keeper/msg_server_submit_test.go b/x/challenge/keeper/msg_server_submit_test.go index 6b9bebaa9..8bbf1a0fa 100644 --- a/x/challenge/keeper/msg_server_submit_test.go +++ b/x/challenge/keeper/msg_server_submit_test.go @@ -19,7 +19,11 @@ func (s *TestSuite) TestSubmit() { existSp := &sptypes.StorageProvider{Status: sptypes.STATUS_IN_SERVICE, Id: 100, OperatorAddress: existSpAddr.String()} s.spKeeper.EXPECT().GetStorageProvider(gomock.Any(), gomock.Eq(existSp.Id)). Return(existSp, true).AnyTimes() - s.storageKeeper.EXPECT().MustGetPrimarySPForBucket(gomock.Any(), gomock.Any()).Return(existSp).AnyTimes() + + jailedSpAddr := sample.RandAccAddress() + jailedSp := &sptypes.StorageProvider{Status: sptypes.STATUS_IN_JAILED, Id: 200, OperatorAddress: jailedSpAddr.String()} + s.spKeeper.EXPECT().GetStorageProvider(gomock.Any(), gomock.Eq(jailedSp.Id)). + Return(jailedSp, true).AnyTimes() existBucketName, existObjectName := "existbucket", "existobject" existObject := &storagetypes.ObjectInfo{ @@ -30,28 +34,64 @@ func (s *TestSuite) TestSubmit() { PayloadSize: 500} s.storageKeeper.EXPECT().GetObjectInfo(gomock.Any(), gomock.Eq(existBucketName), gomock.Eq(existObjectName)). Return(existObject, true).AnyTimes() - s.storageKeeper.EXPECT().GetObjectInfo(gomock.Any(), gomock.Any(), gomock.Any()). - Return(nil, false).AnyTimes() existBucket := &storagetypes.BucketInfo{ BucketName: existBucketName, } s.storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Eq(existBucketName)). Return(existBucket, true).AnyTimes() + s.storageKeeper.EXPECT().MustGetPrimarySPForBucket(gomock.Any(), gomock.Eq(existBucket)).Return(existSp).AnyTimes() + + jailedBucketName, jailedObjectName := "jailedbucket", "jailedobject" + jailedObject := &storagetypes.ObjectInfo{ + Id: math.NewUint(10), + BucketName: jailedBucketName, + ObjectName: jailedObjectName, + ObjectStatus: storagetypes.OBJECT_STATUS_SEALED, + PayloadSize: 500} + s.storageKeeper.EXPECT().GetObjectInfo(gomock.Any(), gomock.Eq(jailedBucketName), gomock.Eq(jailedObjectName)). + Return(jailedObject, true).AnyTimes() + + jailedBucket := &storagetypes.BucketInfo{ + BucketName: jailedBucketName, + } + s.storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Eq(jailedBucketName)). + Return(jailedBucket, true).AnyTimes() + s.storageKeeper.EXPECT().MustGetPrimarySPForBucket(gomock.Any(), gomock.Eq(jailedBucket)).Return(jailedSp).AnyTimes() + + s.storageKeeper.EXPECT().GetObjectInfo(gomock.Any(), gomock.Any(), gomock.Any()). + Return(nil, false).AnyTimes() s.storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Any()). Return(nil, false).AnyTimes() s.storageKeeper.EXPECT().MaxSegmentSize(gomock.Any()).Return(uint64(10000)).AnyTimes() - gvg := &virtualgrouptypes.GlobalVirtualGroup{PrimarySpId: 100} + gvg := &virtualgrouptypes.GlobalVirtualGroup{PrimarySpId: 100, SecondarySpIds: []uint32{ + 1, + }} s.storageKeeper.EXPECT().GetObjectGVG(gomock.Any(), gomock.Any(), gomock.Any()). Return(gvg, true).AnyTimes() + secondarySpAddr := sample.RandAccAddress() + secondarySp := &sptypes.StorageProvider{Status: sptypes.STATUS_IN_SERVICE, Id: 1, OperatorAddress: secondarySpAddr.String()} + s.spKeeper.EXPECT().GetStorageProvider(gomock.Any(), gomock.Eq(secondarySp.Id)). + Return(secondarySp, true).AnyTimes() + tests := []struct { name string msg types.MsgSubmit err error }{ + { + name: "incorrect sp status", + msg: types.MsgSubmit{ + Challenger: sample.AccAddress(), + SpOperatorAddress: sample.AccAddress(), + BucketName: jailedBucketName, + ObjectName: jailedObjectName, + }, + err: types.ErrInvalidSpStatus, + }, { name: "not store on the sp", msg: types.MsgSubmit{ @@ -61,7 +101,18 @@ func (s *TestSuite) TestSubmit() { ObjectName: existObjectName, }, err: types.ErrNotStoredOnSp, - }, { + }, + { + name: "unknown bucket", + msg: types.MsgSubmit{ + Challenger: sample.AccAddress(), + SpOperatorAddress: existSpAddr.String(), + BucketName: "unknownbucket", + ObjectName: "nonexistobject", + }, + err: types.ErrUnknownBucketObject, + }, + { name: "unknown object", msg: types.MsgSubmit{ Challenger: sample.AccAddress(), @@ -100,6 +151,15 @@ func (s *TestSuite) TestSubmit() { ObjectName: existObjectName, RandomIndex: true, }, + }, { + name: "success with secondary sp", + msg: types.MsgSubmit{ + Challenger: sample.AccAddress(), + SpOperatorAddress: secondarySpAddr.String(), + BucketName: existBucketName, + ObjectName: existObjectName, + RandomIndex: true, + }, }, } for _, tt := range tests { @@ -114,8 +174,8 @@ func (s *TestSuite) TestSubmit() { } // verify storage - s.Require().Equal(uint64(2), s.challengeKeeper.GetChallengeCountCurrentBlock(s.ctx)) - s.Require().Equal(uint64(2), s.challengeKeeper.GetChallengeId(s.ctx)) + s.Require().Equal(uint64(3), s.challengeKeeper.GetChallengeCountCurrentBlock(s.ctx)) + s.Require().Equal(uint64(3), s.challengeKeeper.GetChallengeId(s.ctx)) // create slash s.challengeKeeper.SaveSlash(s.ctx, types.Slash{ diff --git a/x/challenge/keeper/slash_test.go b/x/challenge/keeper/slash_test.go index 036a26338..b9fe882b1 100644 --- a/x/challenge/keeper/slash_test.go +++ b/x/challenge/keeper/slash_test.go @@ -22,7 +22,7 @@ func createSlash(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Slash { return items } -func TestRecentSlashRemove(t *testing.T) { +func TestRemoveRecentSlash(t *testing.T) { keeper, ctx := makeKeeper(t) items := createSlash(keeper, ctx, 10) for _, item := range items { @@ -31,3 +31,12 @@ func TestRecentSlashRemove(t *testing.T) { require.False(t, found) } } + +func TestRemoveSpSlashAmount(t *testing.T) { + keeper, ctx := makeKeeper(t) + keeper.SetSpSlashAmount(ctx, 1, sdk.NewInt(100)) + keeper.SetSpSlashAmount(ctx, 2, sdk.NewInt(200)) + keeper.ClearSpSlashAmount(ctx) + require.True(t, keeper.GetSpSlashAmount(ctx, 1).Int64() == 0) + require.True(t, keeper.GetSpSlashAmount(ctx, 2).Int64() == 0) +} From 13d2c5d2613f6dae94dd1e97bf7976ded477573d Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 27 Jul 2023 19:49:27 +0800 Subject: [PATCH 04/24] fix: error member name in transferInRefundPackageType (#379) * fix: error member name in transferInRefundPackage * fix: encode test --- x/bridge/keeper/cross_app_test.go | 14 ++++++++++++++ x/bridge/types/types.go | 2 +- x/challenge/abci_test.go | 8 +++----- x/virtualgroup/keeper/grpc_query.go | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/x/bridge/keeper/cross_app_test.go b/x/bridge/keeper/cross_app_test.go index beee21139..00289c465 100644 --- a/x/bridge/keeper/cross_app_test.go +++ b/x/bridge/keeper/cross_app_test.go @@ -8,7 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/bnb-chain/greenfield/x/bridge/keeper" @@ -183,3 +185,15 @@ func (s *TestSuite) TestTransferInSyn() { result := transferInApp.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) s.Require().Nil(err, result.Err, "error should be nil") } + +func (s *TestSuite) TestTransferInRefund() { + transferInRefundPackage := types.TransferInRefundPackage{ + RefundAmount: big.NewInt(1), + RefundAddress: sdk.AccAddress{123, 123, 123}, + RefundReason: 123, + } + + packageBytes, err := transferInRefundPackage.Serialize() + assert.Equal(s.T(), packageBytes, hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000007b7b7b000000000000000000000000000000000000000000000000000000000000007b")) + s.Require().Nil(err, "encode refund package error") +} diff --git a/x/bridge/types/types.go b/x/bridge/types/types.go index 97046a951..af1fe1ced 100644 --- a/x/bridge/types/types.go +++ b/x/bridge/types/types.go @@ -197,7 +197,7 @@ type TransferInRefundPackageStruct struct { var ( transferInRefundPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ {Name: "RefundAmount", Type: "uint256"}, - {Name: "RefundAddr", Type: "address"}, + {Name: "RefundAddress", Type: "address"}, {Name: "RefundReason", Type: "uint32"}, }) diff --git a/x/challenge/abci_test.go b/x/challenge/abci_test.go index 6c812de12..4d1386dfa 100644 --- a/x/challenge/abci_test.go +++ b/x/challenge/abci_test.go @@ -3,12 +3,7 @@ package challenge_test import ( "testing" - sptypes "github.com/bnb-chain/greenfield/x/sp/types" - virtualgrouptypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" - "cosmossdk.io/math" - storagetypes "github.com/bnb-chain/greenfield/x/storage/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -23,6 +18,9 @@ import ( "github.com/bnb-chain/greenfield/x/challenge" "github.com/bnb-chain/greenfield/x/challenge/keeper" "github.com/bnb-chain/greenfield/x/challenge/types" + sptypes "github.com/bnb-chain/greenfield/x/sp/types" + storagetypes "github.com/bnb-chain/greenfield/x/storage/types" + virtualgrouptypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" ) type TestSuite struct { diff --git a/x/virtualgroup/keeper/grpc_query.go b/x/virtualgroup/keeper/grpc_query.go index b31405cfb..2172429a0 100644 --- a/x/virtualgroup/keeper/grpc_query.go +++ b/x/virtualgroup/keeper/grpc_query.go @@ -4,12 +4,13 @@ import ( "context" "math" - "github.com/bnb-chain/greenfield/x/virtualgroup/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/bnb-chain/greenfield/x/virtualgroup/types" ) func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { From 0e46c586dfa7c37aff8da60f29921f6df076fb00 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Thu, 27 Jul 2023 20:28:06 +0800 Subject: [PATCH 05/24] fix: fix lock balance not updated for frozen payment account (#383) Co-authored-by: randyahx <62416962+randyahx@users.noreply.github.com> Co-authored-by: zjubfd <296179868@qq.com> Co-authored-by: KeefeL <90749943+KeefeL@users.noreply.github.com> --- e2e/tests/payment_test.go | 5 ++++ x/payment/keeper/storage_fee_charge.go | 2 +- x/payment/keeper/stream_record.go | 20 +++++++++----- x/payment/keeper/stream_record_test.go | 37 ++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/e2e/tests/payment_test.go b/e2e/tests/payment_test.go index b3fb6fc18..7ceaa3bda 100644 --- a/e2e/tests/payment_test.go +++ b/e2e/tests/payment_test.go @@ -3009,6 +3009,8 @@ func (s *PaymentTestSuite) TestDiscontinue_InBlocks_WithPriceChangeReserveTimeCh s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_CREATED) time.Sleep(200 * time.Millisecond) } + userStreamRecord := s.getStreamRecord(user.GetAddr().String()) + s.Require().True(userStreamRecord.LockBalance.IsPositive()) // update new price msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ @@ -3107,6 +3109,9 @@ func (s *PaymentTestSuite) TestDiscontinue_InBlocks_WithPriceChangeReserveTimeCh s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) s.Require().True(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64() <= int64(0)) // there are other auto settling + s.Require().True(streamRecordsAfter.User.LockBalance.IsZero()) + s.Require().True(streamRecordsAfter.User.StaticBalance.Int64() == userStreamRecord.LockBalance.Int64()) + // revert price msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ SpAddress: sp.OperatorKey.GetAddr().String(), diff --git a/x/payment/keeper/storage_fee_charge.go b/x/payment/keeper/storage_fee_charge.go index c5d3239df..6518e82d9 100644 --- a/x/payment/keeper/storage_fee_charge.go +++ b/x/payment/keeper/storage_fee_charge.go @@ -139,7 +139,7 @@ func (k Keeper) applyFrozenUserFlows(ctx sdk.Context, userFlows types.UserFlows, } streamRecordChange := types.NewDefaultStreamRecordChangeWithAddr(from). WithRateChange(totalActiveRate.Neg()).WithFrozenRateChange(totalFrozenRate.Neg()) - err := k.UpdateFrozenStreamRecord(ctx, streamRecord, streamRecordChange) + err := k.UpdateStreamRecord(ctx, streamRecord, streamRecordChange) if err != nil { return fmt.Errorf("apply stream record changes for user failed: %w", err) } diff --git a/x/payment/keeper/stream_record.go b/x/payment/keeper/stream_record.go index a965f44e9..798016b06 100644 --- a/x/payment/keeper/stream_record.go +++ b/x/payment/keeper/stream_record.go @@ -114,6 +114,10 @@ func (k Keeper) GetAllStreamRecord(ctx sdk.Context) (list []types.StreamRecord) // it only handles the lock balance change and ignore the other changes(since the streams are already changed and the // accumulated OutFlows are changed outside this function) func (k Keeper) UpdateFrozenStreamRecord(ctx sdk.Context, streamRecord *types.StreamRecord, change *types.StreamRecordChange) error { + forced, _ := ctx.Value(types.ForceUpdateStreamRecordKey).(bool) + if !forced { + return fmt.Errorf("stream record %s is frozen", streamRecord.Account) + } // update lock balance if !change.LockBalanceChange.IsZero() { streamRecord.LockBalance = streamRecord.LockBalance.Add(change.LockBalanceChange) @@ -132,6 +136,10 @@ func (k Keeper) UpdateFrozenStreamRecord(ctx sdk.Context, streamRecord *types.St } func (k Keeper) UpdateStreamRecord(ctx sdk.Context, streamRecord *types.StreamRecord, change *types.StreamRecordChange) error { + if streamRecord.Status == types.STREAM_ACCOUNT_STATUS_FROZEN { + return k.UpdateFrozenStreamRecord(ctx, streamRecord, change) + } + forced, _ := ctx.Value(types.ForceUpdateStreamRecordKey).(bool) // force update in end block isPay := change.StaticBalanceChange.IsNegative() || change.RateChange.IsNegative() currentTimestamp := ctx.BlockTime().Unix() @@ -217,13 +225,11 @@ func (k Keeper) UpdateStreamRecordByAddr(ctx sdk.Context, change *types.StreamRe func (k Keeper) ForceSettle(ctx sdk.Context, streamRecord *types.StreamRecord) error { totalBalance := streamRecord.StaticBalance.Add(streamRecord.BufferBalance) - if totalBalance.IsPositive() { - change := types.NewDefaultStreamRecordChangeWithAddr(types.GovernanceAddress).WithStaticBalanceChange(totalBalance) - _, err := k.UpdateStreamRecordByAddr(ctx, change) - if err != nil { - telemetry.IncrCounter(1, types.GovernanceAddressLackBalanceLabel) - return fmt.Errorf("update governance stream record failed: %w", err) - } + change := types.NewDefaultStreamRecordChangeWithAddr(types.GovernanceAddress).WithStaticBalanceChange(totalBalance) + _, err := k.UpdateStreamRecordByAddr(ctx, change) + if err != nil { + telemetry.IncrCounter(1, types.GovernanceAddressLackBalanceLabel) + return fmt.Errorf("update governance stream record failed: %w", err) } // force settle streamRecord.StaticBalance = sdkmath.ZeroInt() diff --git a/x/payment/keeper/stream_record_test.go b/x/payment/keeper/stream_record_test.go index a726888d4..4c6f57327 100644 --- a/x/payment/keeper/stream_record_test.go +++ b/x/payment/keeper/stream_record_test.go @@ -752,3 +752,40 @@ func TestAutoSettle_SettleInMultipleBlocks_AutoResumeExists(t *testing.T) { require.Equal(t, gvg3StreamRecord.NetflowRate, sdk.NewInt(150)) require.Equal(t, gvg3StreamRecord.FrozenNetflowRate, sdkmath.ZeroInt()) } + +func TestUpdateStreamRecord_FrozenAccountLockBalance(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + ctx = ctx.WithBlockTime(time.Now()) + + user := sample.RandAccAddress() + streamRecord := &types.StreamRecord{ + StaticBalance: sdkmath.ZeroInt(), + BufferBalance: sdkmath.ZeroInt(), + LockBalance: sdkmath.NewInt(1000), + Account: user.String(), + Status: types.STREAM_ACCOUNT_STATUS_FROZEN, + NetflowRate: sdkmath.NewInt(0), + FrozenNetflowRate: sdkmath.NewInt(100).Neg(), + OutFlowCount: 1, + } + keeper.SetStreamRecord(ctx, streamRecord) + + // update fail when no force flag + change := types.NewDefaultStreamRecordChangeWithAddr(user). + WithLockBalanceChange(streamRecord.LockBalance.Neg()) + _, err := keeper.UpdateStreamRecordByAddr(ctx, change) + require.ErrorContains(t, err, "is frozen") + + // update success when there is force flag + ctx = ctx.WithValue(types.ForceUpdateStreamRecordKey, true) + change = types.NewDefaultStreamRecordChangeWithAddr(user). + WithLockBalanceChange(streamRecord.LockBalance.Neg()) + _, err = keeper.UpdateStreamRecordByAddr(ctx, change) + require.NoError(t, err) + + streamRecord, _ = keeper.GetStreamRecord(ctx, user) + require.True(t, streamRecord.Status == types.STREAM_ACCOUNT_STATUS_FROZEN) + require.True(t, streamRecord.LockBalance.IsZero()) + require.True(t, streamRecord.StaticBalance.Int64() == 1000) + +} From 795cfd7ed2c1a58693053589d85c138f04e07489 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Thu, 27 Jul 2023 20:35:22 +0800 Subject: [PATCH 06/24] chore: add unit tests for the storage module (#376) * feat: add unit tests for storage module * fix test case * add unit test for create object * add unit tests for virtual group * add more test cases for virtual group * remove unused code * add test cases for params check * recover key_manager.go * refactor cross chain apps --- e2e/tests/virtualgroup_test.go | 13 + testutil/sample/sample.go | 11 + x/storage/keeper/cross_app_bucket.go | 11 +- x/storage/keeper/cross_app_bucket_test.go | 57 ++ x/storage/keeper/cross_app_group.go | 10 +- x/storage/keeper/cross_app_object.go | 6 +- x/storage/keeper/keeper.go | 59 +- x/storage/keeper/keeper_object_test.go | 220 +++++++ x/storage/keeper/msg_server.go | 22 +- x/storage/types/crosschain.go | 14 +- x/storage/types/expected_keepers.go | 24 + x/storage/types/expected_keepers_mocks.go | 214 ++++++- x/storage/types/message.go | 2 +- x/storage/types/message_object_test.go | 567 ++++++++++++++++++ x/storage/types/message_test.go | 290 --------- x/storage/{keeper => types}/options.go | 37 +- x/virtualgroup/keeper/grpc_query.go | 8 - x/virtualgroup/types/message.go | 18 +- .../types/message_cancel_swap_out_test.go | 25 +- ...age_complete_storage_provider_exit_test.go | 4 +- .../types/message_complete_swap_out_test.go | 25 +- .../message_storage_provider_exit_test.go | 4 +- x/virtualgroup/types/message_test.go | 381 ++++++++++++ x/virtualgroup/types/params.go | 2 +- x/virtualgroup/types/params_test.go | 154 +++++ 25 files changed, 1801 insertions(+), 377 deletions(-) create mode 100644 x/storage/keeper/cross_app_bucket_test.go create mode 100644 x/storage/keeper/keeper_object_test.go create mode 100644 x/storage/types/message_object_test.go rename x/storage/{keeper => types}/options.go (59%) create mode 100644 x/virtualgroup/types/message_test.go create mode 100644 x/virtualgroup/types/params_test.go diff --git a/e2e/tests/virtualgroup_test.go b/e2e/tests/virtualgroup_test.go index a39d39e00..ee8e20535 100644 --- a/e2e/tests/virtualgroup_test.go +++ b/e2e/tests/virtualgroup_test.go @@ -65,6 +65,16 @@ func (s *VirtualGroupTestSuite) queryGlobalVirtualGroupByFamily(familyID uint32) return resp.GlobalVirtualGroups } +func (s *VirtualGroupTestSuite) queryAvailableGlobalVirtualGroupFamilies(familyIds []uint32) []uint32 { + resp, err := s.Client.AvailableGlobalVirtualGroupFamilies( + context.Background(), + &virtualgroupmoduletypes.AvailableGlobalVirtualGroupFamiliesRequest{ + GlobalVirtualGroupFamilyIds: familyIds, + }) + s.Require().NoError(err) + return resp.GlobalVirtualGroupFamilyIds +} + func (s *VirtualGroupTestSuite) TestBasic() { primarySP := s.BaseSuite.PickStorageProvider() @@ -82,6 +92,9 @@ func (s *VirtualGroupTestSuite) TestBasic() { gvg = g } + availableGvgFamilyIds := s.queryAvailableGlobalVirtualGroupFamilies([]uint32{gvg.FamilyId}) + s.Require().Equal(availableGvgFamilyIds[0], gvg.FamilyId) + srcGVGs := s.queryGlobalVirtualGroupByFamily(gvg.FamilyId) var secondarySPIDs []uint32 diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 96aaf945c..1c3561189 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -6,6 +6,7 @@ import ( "github.com/cometbft/cometbft/crypto/tmhash" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/prysmaticlabs/prysm/crypto/bls" ) @@ -17,6 +18,16 @@ func AccAddress() string { return sdk.AccAddress(addr).String() } +func RandSignBytes() (addr sdk.AccAddress, signBytes []byte, sig []byte) { + signBytes = RandStr(256) + privKey, _ := ethsecp256k1.GenPrivKey() + + sig, _ = privKey.Sign(sdk.Keccak256(signBytes)) + pk := privKey.PubKey() + addr = sdk.AccAddress(pk.Address()) + return addr, signBytes, sig +} + func RandAccAddress() sdk.AccAddress { pk := ed25519.GenPrivKey().PubKey() addr := pk.Address() diff --git a/x/storage/keeper/cross_app_bucket.go b/x/storage/keeper/cross_app_bucket.go index a3d85a08d..6b6fe84de 100644 --- a/x/storage/keeper/cross_app_bucket.go +++ b/x/storage/keeper/cross_app_bucket.go @@ -13,10 +13,10 @@ import ( var _ sdk.CrossChainApplication = &BucketApp{} type BucketApp struct { - storageKeeper Keeper + storageKeeper types.StorageKeeper } -func NewBucketApp(keeper Keeper) *BucketApp { +func NewBucketApp(keeper types.StorageKeeper) *BucketApp { return &BucketApp{ storageKeeper: keeper, } @@ -216,7 +216,7 @@ func (app *BucketApp) handleCreateBucketSynPackage(ctx sdk.Context, appCtx *sdk. createBucketPackage.Creator, createBucketPackage.BucketName, createBucketPackage.PrimarySpAddress, - &CreateBucketOptions{ + &types.CreateBucketOptions{ Visibility: types.VisibilityType(createBucketPackage.Visibility), SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, ChargedReadQuota: createBucketPackage.ChargedReadQuota, @@ -267,6 +267,7 @@ func (app *BucketApp) handleDeleteBucketSynPackage(ctx sdk.Context, header *sdk. return sdk.ExecuteResult{ Payload: types.DeleteBucketAckPackage{ Status: types.StatusFail, + Id: deleteBucketPackage.Id, ExtraData: deleteBucketPackage.ExtraData, }.MustSerialize(), Err: err, @@ -281,6 +282,7 @@ func (app *BucketApp) handleDeleteBucketSynPackage(ctx sdk.Context, header *sdk. return sdk.ExecuteResult{ Payload: types.DeleteBucketAckPackage{ Status: types.StatusFail, + Id: deleteBucketPackage.Id, ExtraData: deleteBucketPackage.ExtraData, }.MustSerialize(), Err: types.ErrNoSuchBucket, @@ -290,7 +292,7 @@ func (app *BucketApp) handleDeleteBucketSynPackage(ctx sdk.Context, header *sdk. err = app.storageKeeper.DeleteBucket(ctx, deleteBucketPackage.Operator, bucketInfo.BucketName, - DeleteBucketOptions{ + types.DeleteBucketOptions{ SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, }, ) @@ -298,6 +300,7 @@ func (app *BucketApp) handleDeleteBucketSynPackage(ctx sdk.Context, header *sdk. return sdk.ExecuteResult{ Payload: types.DeleteBucketAckPackage{ Status: types.StatusFail, + Id: deleteBucketPackage.Id, ExtraData: deleteBucketPackage.ExtraData, }.MustSerialize(), Err: err, diff --git a/x/storage/keeper/cross_app_bucket_test.go b/x/storage/keeper/cross_app_bucket_test.go new file mode 100644 index 000000000..c4e9f35df --- /dev/null +++ b/x/storage/keeper/cross_app_bucket_test.go @@ -0,0 +1,57 @@ +package keeper_test + +import ( + "fmt" + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" +) + +func (s *TestSuite) TestSynDeleteBucket() { + pack := types.DeleteBucketAckPackage{ + Status: 1, + Id: big.NewInt(10), + ExtraData: []byte("x"), + } + pack.MustSerialize() + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + deleteSynPackage := types.DeleteBucketSynPackage{ + Operator: sample.RandAccAddress(), + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedSynPackage := deleteSynPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationDeleteBucket}, serializedSynPackage...) + + // case 1: bucket not found + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchBucket) + + // case 2: delete bucket error + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&types.BucketInfo{ + BucketName: "bucket", + }, true) + storageKeeper.EXPECT().DeleteBucket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("delete error")) + res = app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().ErrorContains(res.Err, "delete error") + + // case 3: delete bucket success + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&types.BucketInfo{ + BucketName: "bucket", + Id: sdk.NewUint(10), + }, true) + storageKeeper.EXPECT().DeleteBucket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + res = app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().NoError(res.Err) +} diff --git a/x/storage/keeper/cross_app_group.go b/x/storage/keeper/cross_app_group.go index 0f09fcceb..665f74cf6 100644 --- a/x/storage/keeper/cross_app_group.go +++ b/x/storage/keeper/cross_app_group.go @@ -12,10 +12,10 @@ import ( var _ sdk.CrossChainApplication = &GroupApp{} type GroupApp struct { - storageKeeper Keeper + storageKeeper types.StorageKeeper } -func NewGroupApp(keeper Keeper) *GroupApp { +func NewGroupApp(keeper types.StorageKeeper) *GroupApp { return &GroupApp{ storageKeeper: keeper, } @@ -174,7 +174,7 @@ func (app *GroupApp) handleDeleteGroupSynPackage(ctx sdk.Context, header *sdk.Cr err = app.storageKeeper.DeleteGroup(ctx, deleteGroupPackage.Operator, groupInfo.GroupName, - DeleteGroupOptions{ + types.DeleteGroupOptions{ SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, }, ) @@ -226,7 +226,7 @@ func (app *GroupApp) handleCreateGroupSynPackage(ctx sdk.Context, header *sdk.Cr groupId, err := app.storageKeeper.CreateGroup(ctx, createGroupPackage.Creator, createGroupPackage.GroupName, - CreateGroupOptions{ + types.CreateGroupOptions{ SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, }, ) @@ -336,7 +336,7 @@ func (app *GroupApp) handleUpdateGroupMemberSynPackage(ctx sdk.Context, header * } } - options := UpdateGroupMemberOptions{ + options := types.UpdateGroupMemberOptions{ SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, } if updateGroupPackage.OperationType == types.OperationAddGroupMember { diff --git a/x/storage/keeper/cross_app_object.go b/x/storage/keeper/cross_app_object.go index 43b540e34..9acc60fe7 100644 --- a/x/storage/keeper/cross_app_object.go +++ b/x/storage/keeper/cross_app_object.go @@ -12,10 +12,10 @@ import ( var _ sdk.CrossChainApplication = &ObjectApp{} type ObjectApp struct { - storageKeeper Keeper + storageKeeper types.StorageKeeper } -func NewObjectApp(keeper Keeper) *ObjectApp { +func NewObjectApp(keeper types.StorageKeeper) *ObjectApp { return &ObjectApp{ storageKeeper: keeper, } @@ -211,7 +211,7 @@ func (app *ObjectApp) handleDeleteObjectSynPackage(ctx sdk.Context, header *sdk. deleteObjectPackage.Operator, objectInfo.BucketName, objectInfo.ObjectName, - DeleteObjectOptions{ + types.DeleteObjectOptions{ SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, }, ) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 438d3f6d7..b6a350e03 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -86,7 +86,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) CreateBucket( ctx sdk.Context, ownerAcc sdk.AccAddress, bucketName string, - primarySpAcc sdk.AccAddress, opts *CreateBucketOptions) (sdkmath.Uint, error) { + primarySpAcc sdk.AccAddress, opts *types.CreateBucketOptions) (sdkmath.Uint, error) { store := ctx.KVStore(k.storeKey) // check if the bucket exist @@ -170,7 +170,17 @@ func (k Keeper) CreateBucket( return bucketInfo.Id, nil } -func (k Keeper) DeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketName string, opts DeleteBucketOptions) error { +// StoreBucketInfo will store the bucket info +// It's designed to be used by the test cases to create a bucket. +func (k Keeper) StoreBucketInfo(ctx sdk.Context, bucketInfo *types.BucketInfo) { + store := ctx.KVStore(k.storeKey) + bucketKey := types.GetBucketKey(bucketInfo.BucketName) + bz := k.cdc.MustMarshal(bucketInfo) + store.Set(bucketKey, k.bucketSeq.EncodeSequence(bucketInfo.Id)) + store.Set(types.GetBucketByIDKey(bucketInfo.Id), bz) +} + +func (k Keeper) DeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketName string, opts types.DeleteBucketOptions) error { bucketInfo, found := k.GetBucketInfo(ctx, bucketName) if !found { return types.ErrNoSuchBucket @@ -334,7 +344,7 @@ func (k Keeper) ForceDeleteBucket(ctx sdk.Context, bucketId sdkmath.Uint, cap ui return bucketDeleted, deleted, nil } -func (k Keeper) UpdateBucketInfo(ctx sdk.Context, operator sdk.AccAddress, bucketName string, opts UpdateBucketOptions) error { +func (k Keeper) UpdateBucketInfo(ctx sdk.Context, operator sdk.AccAddress, bucketName string, opts types.UpdateBucketOptions) error { bucketInfo, found := k.GetBucketInfo(ctx, bucketName) if !found { return types.ErrNoSuchBucket @@ -499,7 +509,7 @@ func (k Keeper) GetBucketInfoById(ctx sdk.Context, bucketId sdkmath.Uint) (*type func (k Keeper) CreateObject( ctx sdk.Context, operator sdk.AccAddress, bucketName, objectName string, - payloadSize uint64, opts CreateObjectOptions) (sdkmath.Uint, error) { + payloadSize uint64, opts types.CreateObjectOptions) (sdkmath.Uint, error) { store := ctx.KVStore(k.storeKey) // check payload size @@ -619,6 +629,29 @@ func (k Keeper) CreateObject( return objectInfo.Id, nil } +// StoreObjectInfo stores object related keys to KVStore, +// it's designed to be used in tests +func (k Keeper) StoreObjectInfo(ctx sdk.Context, objectInfo *types.ObjectInfo) { + store := ctx.KVStore(k.storeKey) + + objectKey := types.GetObjectKey(objectInfo.BucketName, objectInfo.ObjectName) + + obz := k.cdc.MustMarshal(objectInfo) + store.Set(objectKey, k.objectSeq.EncodeSequence(objectInfo.Id)) + store.Set(types.GetObjectByIDKey(objectInfo.Id), obz) +} + +// DeleteObjectInfo deletes object related keys from KVStore, +// it's designed to be used in tests +func (k Keeper) DeleteObjectInfo(ctx sdk.Context, objectInfo *types.ObjectInfo) { + store := ctx.KVStore(k.storeKey) + + objectKey := types.GetObjectKey(objectInfo.BucketName, objectInfo.ObjectName) + + store.Delete(objectKey) + store.Delete(types.GetObjectByIDKey(objectInfo.Id)) +} + func (k Keeper) SetObjectInfo(ctx sdk.Context, objectInfo *types.ObjectInfo) { store := ctx.KVStore(k.storeKey) @@ -742,7 +775,7 @@ func (k Keeper) SealObject( func (k Keeper) CancelCreateObject( ctx sdk.Context, operator sdk.AccAddress, - bucketName, objectName string, opts CancelCreateObjectOptions) error { + bucketName, objectName string, opts types.CancelCreateObjectOptions) error { store := ctx.KVStore(k.storeKey) bucketInfo, found := k.GetBucketInfo(ctx, bucketName) if !found { @@ -796,7 +829,7 @@ func (k Keeper) CancelCreateObject( } func (k Keeper) DeleteObject( - ctx sdk.Context, operator sdk.AccAddress, bucketName, objectName string, opts DeleteObjectOptions) error { + ctx sdk.Context, operator sdk.AccAddress, bucketName, objectName string, opts types.DeleteObjectOptions) error { bucketInfo, found := k.GetBucketInfo(ctx, bucketName) if !found { @@ -917,7 +950,7 @@ func (k Keeper) ForceDeleteObject(ctx sdk.Context, objectId sdkmath.Uint) error func (k Keeper) CopyObject( ctx sdk.Context, operator sdk.AccAddress, srcBucketName, srcObjectName, dstBucketName, dstObjectName string, - opts CopyObjectOptions) (sdkmath.Uint, error) { + opts types.CopyObjectOptions) (sdkmath.Uint, error) { store := ctx.KVStore(k.storeKey) @@ -1178,7 +1211,7 @@ func (k Keeper) UpdateObjectInfo(ctx sdk.Context, operator sdk.AccAddress, bucke func (k Keeper) CreateGroup( ctx sdk.Context, owner sdk.AccAddress, - groupName string, opts CreateGroupOptions) (sdkmath.Uint, error) { + groupName string, opts types.CreateGroupOptions) (sdkmath.Uint, error) { store := ctx.KVStore(k.storeKey) groupInfo := types.GroupInfo{ @@ -1255,11 +1288,7 @@ func (k Keeper) GetGroupInfoById(ctx sdk.Context, groupId sdkmath.Uint) (*types. return &groupInfo, true } -type DeleteGroupOptions struct { - SourceType types.SourceType -} - -func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName string, opts DeleteGroupOptions) error { +func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName string, opts types.DeleteGroupOptions) error { store := ctx.KVStore(k.storeKey) groupInfo, found := k.GetGroupInfo(ctx, operator, groupName) @@ -1296,7 +1325,7 @@ func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName func (k Keeper) LeaveGroup( ctx sdk.Context, member sdk.AccAddress, owner sdk.AccAddress, - groupName string, opts LeaveGroupOptions) error { + groupName string, opts types.LeaveGroupOptions) error { groupInfo, found := k.GetGroupInfo(ctx, owner, groupName) if !found { @@ -1322,7 +1351,7 @@ func (k Keeper) LeaveGroup( return nil } -func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, opts UpdateGroupMemberOptions) error { +func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, opts types.UpdateGroupMemberOptions) error { if groupInfo.SourceType != opts.SourceType { return types.ErrSourceTypeMismatch } diff --git a/x/storage/keeper/keeper_object_test.go b/x/storage/keeper/keeper_object_test.go new file mode 100644 index 000000000..ba79025ba --- /dev/null +++ b/x/storage/keeper/keeper_object_test.go @@ -0,0 +1,220 @@ +package keeper_test + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/types/common" + types4 "github.com/bnb-chain/greenfield/x/payment/types" + types3 "github.com/bnb-chain/greenfield/x/sp/types" + "github.com/bnb-chain/greenfield/x/storage/types" + types2 "github.com/bnb-chain/greenfield/x/virtualgroup/types" +) + +func (s *TestSuite) TestCreateObject() { + operatorAddress := sample.RandAccAddress() + objectName := "objectName" + + bucketInfo := &types.BucketInfo{ + Owner: operatorAddress.String(), + BucketName: "bucketname", + Id: sdk.NewUint(1), + PaymentAddress: sample.RandAccAddress().String(), + ChargedReadQuota: 100, + BucketStatus: types.BUCKET_STATUS_CREATED, + } + + // case 1: bucket does not exist + _, err := s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: nil, + ApprovalMsgBytes: nil, + }) + s.Require().ErrorContains(err, "No such bucket") + + // case 2: bucket is migrating + bucketInfo.BucketStatus = types.BUCKET_STATUS_MIGRATING + s.storageKeeper.StoreBucketInfo(s.ctx, bucketInfo) + _, err = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: nil, + ApprovalMsgBytes: nil, + }) + s.Require().ErrorContains(err, "the bucket is migrating") + + // case 3: bucket is discontinued + bucketInfo.BucketStatus = types.BUCKET_STATUS_DISCONTINUED + s.storageKeeper.StoreBucketInfo(s.ctx, bucketInfo) + _, err = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: nil, + ApprovalMsgBytes: nil, + }) + s.Require().ErrorContains(err, "the bucket is discontinued") + + // case 4: invalid payload size + _, err = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, types.DefaultParams().MaxPayloadSize+1, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: nil, + ApprovalMsgBytes: nil, + }) + s.Require().ErrorContains(err, "Object payload size is too large") + + // case 4: gvg family does not exist + bucketInfo.BucketStatus = types.BUCKET_STATUS_CREATED + s.storageKeeper.StoreBucketInfo(s.ctx, bucketInfo) + s.virtualGroupKeeper.EXPECT().GetGVGFamily(gomock.Any(), gomock.Any()).Return(nil, false) + s.Require().Panics(func() { + _, _ = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: nil, + ApprovalMsgBytes: nil, + }) + }) + + // case 5: approval expired + s.virtualGroupKeeper.EXPECT().GetGVGFamily(gomock.Any(), gomock.Any()).Return(&types2.GlobalVirtualGroupFamily{ + Id: 0, + PrimarySpId: 0, + GlobalVirtualGroupIds: nil, + VirtualPaymentAddress: "", + }, true).AnyTimes() + + spAddress, signBytes, sig := sample.RandSignBytes() + s.spKeeper.EXPECT().MustGetStorageProvider(gomock.Any(), gomock.Any()).Return(&types3.StorageProvider{ + Id: 0, + OperatorAddress: spAddress.String(), + FundingAddress: "", + SealAddress: "", + ApprovalAddress: spAddress.String(), + GcAddress: "", + TotalDeposit: math.Int{}, + Status: 0, + Endpoint: "", + Description: types3.Description{}, + BlsKey: nil, + }).AnyTimes() + s.ctx = s.ctx.WithBlockHeight(100) + _, err = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: &common.Approval{ + ExpiredHeight: uint64(s.ctx.BlockHeight() - 1), + Sig: sig, + }, + ApprovalMsgBytes: signBytes, + }) + + s.Require().ErrorContains(err, "The approval of sp is expired") + + // case 6: invalid approval sig + _, err = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: &common.Approval{ + ExpiredHeight: uint64(s.ctx.BlockHeight() + 1), + Sig: []byte("invalid sig"), + }, + ApprovalMsgBytes: signBytes, + }) + s.Require().ErrorContains(err, "verify signature error") + + // case 7: object exist + s.storageKeeper.StoreObjectInfo(s.ctx, &types.ObjectInfo{ + Id: sdk.NewUint(1), + BucketName: bucketInfo.BucketName, + ObjectName: objectName, + }) + _, err = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: &common.Approval{ + ExpiredHeight: uint64(s.ctx.BlockHeight() + 1), + Sig: sig, + }, + ApprovalMsgBytes: signBytes, + }) + s.Require().ErrorContains(err, "Object already exists") + + // case 8: valid case + s.storageKeeper.DeleteObjectInfo(s.ctx, &types.ObjectInfo{ + Id: sdk.NewUint(1), + BucketName: bucketInfo.BucketName, + ObjectName: objectName, + }) + s.paymentKeeper.EXPECT().GetStoragePrice(gomock.Any(), gomock.Any()).Return(types4.StoragePrice{ + ReadPrice: sdk.NewDec(1), + PrimaryStorePrice: sdk.NewDec(2), + SecondaryStorePrice: sdk.NewDec(1), + }, nil).AnyTimes() + s.paymentKeeper.EXPECT().GetVersionedParamsWithTs(gomock.Any(), gomock.Any()).Return(types4.VersionedParams{ + ReserveTime: 10000, + ValidatorTaxRate: sdk.NewDec(1), + }, nil).AnyTimes() + s.paymentKeeper.EXPECT().UpdateStreamRecordByAddr(gomock.Any(), gomock.Any()).Return(&types4.StreamRecord{ + Account: "", + CrudTimestamp: 0, + NetflowRate: math.Int{}, + StaticBalance: sdk.NewInt(100), + BufferBalance: math.Int{}, + LockBalance: math.Int{}, + Status: 0, + SettleTimestamp: 0, + OutFlowCount: 0, + FrozenNetflowRate: math.Int{}, + }, nil).AnyTimes() + _, err = s.storageKeeper.CreateObject(s.ctx, operatorAddress, bucketInfo.BucketName, + objectName, 100, types.CreateObjectOptions{ + Visibility: 0, + ContentType: "", + SourceType: 0, + RedundancyType: 0, + Checksums: nil, + PrimarySpApproval: &common.Approval{ + ExpiredHeight: uint64(s.ctx.BlockHeight() + 1), + Sig: sig, + }, + ApprovalMsgBytes: signBytes, + }) + + s.Require().NoError(err) +} diff --git a/x/storage/keeper/msg_server.go b/x/storage/keeper/msg_server.go index f2da636d3..cd7277471 100644 --- a/x/storage/keeper/msg_server.go +++ b/x/storage/keeper/msg_server.go @@ -36,7 +36,7 @@ func (k msgServer) CreateBucket(goCtx context.Context, msg *types.MsgCreateBucke primarySPAcc := sdk.MustAccAddressFromHex(msg.PrimarySpAddress) - id, err := k.Keeper.CreateBucket(ctx, ownerAcc, msg.BucketName, primarySPAcc, &CreateBucketOptions{ + id, err := k.Keeper.CreateBucket(ctx, ownerAcc, msg.BucketName, primarySPAcc, &storagetypes.CreateBucketOptions{ PaymentAddress: msg.PaymentAddress, Visibility: msg.Visibility, ChargedReadQuota: msg.ChargedReadQuota, @@ -58,7 +58,7 @@ func (k msgServer) DeleteBucket(goCtx context.Context, msg *types.MsgDeleteBucke operatorAcc := sdk.MustAccAddressFromHex(msg.Operator) - err := k.Keeper.DeleteBucket(ctx, operatorAcc, msg.BucketName, DeleteBucketOptions{ + err := k.Keeper.DeleteBucket(ctx, operatorAcc, msg.BucketName, storagetypes.DeleteBucketOptions{ SourceType: types.SOURCE_TYPE_ORIGIN, }) if err != nil { @@ -76,7 +76,7 @@ func (k msgServer) UpdateBucketInfo(goCtx context.Context, msg *types.MsgUpdateB if msg.ChargedReadQuota != nil { chargedReadQuota = &msg.ChargedReadQuota.Value } - err := k.Keeper.UpdateBucketInfo(ctx, operatorAcc, msg.BucketName, UpdateBucketOptions{ + err := k.Keeper.UpdateBucketInfo(ctx, operatorAcc, msg.BucketName, storagetypes.UpdateBucketOptions{ SourceType: types.SOURCE_TYPE_ORIGIN, PaymentAddress: msg.PaymentAddress, Visibility: msg.Visibility, @@ -111,7 +111,7 @@ func (k msgServer) CreateObject(goCtx context.Context, msg *types.MsgCreateObjec len(msg.ExpectChecksums)) } - id, err := k.Keeper.CreateObject(ctx, ownerAcc, msg.BucketName, msg.ObjectName, msg.PayloadSize, CreateObjectOptions{ + id, err := k.Keeper.CreateObject(ctx, ownerAcc, msg.BucketName, msg.ObjectName, msg.PayloadSize, storagetypes.CreateObjectOptions{ SourceType: types.SOURCE_TYPE_ORIGIN, Visibility: msg.Visibility, ContentType: msg.ContentType, @@ -134,7 +134,7 @@ func (k msgServer) CancelCreateObject(goCtx context.Context, msg *types.MsgCance operatorAcc := sdk.MustAccAddressFromHex(msg.Operator) - err := k.Keeper.CancelCreateObject(ctx, operatorAcc, msg.BucketName, msg.ObjectName, CancelCreateObjectOptions{SourceType: types.SOURCE_TYPE_ORIGIN}) + err := k.Keeper.CancelCreateObject(ctx, operatorAcc, msg.BucketName, msg.ObjectName, storagetypes.CancelCreateObjectOptions{SourceType: types.SOURCE_TYPE_ORIGIN}) if err != nil { return nil, err } @@ -164,7 +164,7 @@ func (k msgServer) CopyObject(goCtx context.Context, msg *types.MsgCopyObject) ( ownerAcc := sdk.MustAccAddressFromHex(msg.Operator) - id, err := k.Keeper.CopyObject(ctx, ownerAcc, msg.SrcBucketName, msg.SrcObjectName, msg.DstBucketName, msg.DstObjectName, CopyObjectOptions{ + id, err := k.Keeper.CopyObject(ctx, ownerAcc, msg.SrcBucketName, msg.SrcObjectName, msg.DstBucketName, msg.DstObjectName, storagetypes.CopyObjectOptions{ SourceType: types.SOURCE_TYPE_ORIGIN, Visibility: storagetypes.VISIBILITY_TYPE_PRIVATE, PrimarySpApproval: msg.DstPrimarySpApproval, @@ -184,7 +184,7 @@ func (k msgServer) DeleteObject(goCtx context.Context, msg *types.MsgDeleteObjec operatorAcc := sdk.MustAccAddressFromHex(msg.Operator) - err := k.Keeper.DeleteObject(ctx, operatorAcc, msg.BucketName, msg.ObjectName, DeleteObjectOptions{ + err := k.Keeper.DeleteObject(ctx, operatorAcc, msg.BucketName, msg.ObjectName, storagetypes.DeleteObjectOptions{ SourceType: types.SOURCE_TYPE_ORIGIN, }) @@ -232,7 +232,7 @@ func (k msgServer) CreateGroup(goCtx context.Context, msg *types.MsgCreateGroup) ownerAcc := sdk.MustAccAddressFromHex(msg.Creator) - id, err := k.Keeper.CreateGroup(ctx, ownerAcc, msg.GroupName, CreateGroupOptions{Members: msg.Members, Extra: msg.Extra}) + id, err := k.Keeper.CreateGroup(ctx, ownerAcc, msg.GroupName, storagetypes.CreateGroupOptions{Members: msg.Members, Extra: msg.Extra}) if err != nil { return nil, err } @@ -246,7 +246,7 @@ func (k msgServer) DeleteGroup(goCtx context.Context, msg *types.MsgDeleteGroup) ctx := sdk.UnwrapSDKContext(goCtx) operatorAcc := sdk.MustAccAddressFromHex(msg.Operator) - err := k.Keeper.DeleteGroup(ctx, operatorAcc, msg.GroupName, DeleteGroupOptions{SourceType: types.SOURCE_TYPE_ORIGIN}) + err := k.Keeper.DeleteGroup(ctx, operatorAcc, msg.GroupName, storagetypes.DeleteGroupOptions{SourceType: types.SOURCE_TYPE_ORIGIN}) if err != nil { return nil, err } @@ -261,7 +261,7 @@ func (k msgServer) LeaveGroup(goCtx context.Context, msg *types.MsgLeaveGroup) ( ownerAcc := sdk.MustAccAddressFromHex(msg.GroupOwner) - err := k.Keeper.LeaveGroup(ctx, memberAcc, ownerAcc, msg.GroupName, LeaveGroupOptions{SourceType: types.SOURCE_TYPE_ORIGIN}) + err := k.Keeper.LeaveGroup(ctx, memberAcc, ownerAcc, msg.GroupName, storagetypes.LeaveGroupOptions{SourceType: types.SOURCE_TYPE_ORIGIN}) if err != nil { return nil, err } @@ -280,7 +280,7 @@ func (k msgServer) UpdateGroupMember(goCtx context.Context, msg *types.MsgUpdate if !found { return nil, types.ErrNoSuchGroup } - err := k.Keeper.UpdateGroupMember(ctx, operator, groupInfo, UpdateGroupMemberOptions{ + err := k.Keeper.UpdateGroupMember(ctx, operator, groupInfo, storagetypes.UpdateGroupMemberOptions{ SourceType: types.SOURCE_TYPE_ORIGIN, MembersToAdd: msg.MembersToAdd, MembersToDelete: msg.MembersToDelete, diff --git a/x/storage/types/crosschain.go b/x/storage/types/crosschain.go index a09c1ae2c..36938efd8 100644 --- a/x/storage/types/crosschain.go +++ b/x/storage/types/crosschain.go @@ -525,6 +525,18 @@ var ( } ) +func (p DeleteBucketSynPackage) MustSerialize() []byte { + encodedBytes, err := generalDeleteSynPackageArgs.Pack(&GeneralDeleteSynPackageStruct{ + Operator: common.BytesToAddress(p.Operator), + Id: SafeBigInt(p.Id), + ExtraData: p.ExtraData, + }) + if err != nil { + panic("encode delete bucket sync package error") + } + return encodedBytes +} + func (p DeleteBucketSynPackage) ValidateBasic() error { if p.Operator.Empty() { return sdkerrors.ErrInvalidAddress @@ -574,7 +586,7 @@ var ( ) func (p DeleteBucketAckPackage) MustSerialize() []byte { - encodedBytes, err := generalCreateAckPackageArgs.Pack(&DeleteBucketAckPackage{ + encodedBytes, err := generalDeleteAckPackageArgs.Pack(&DeleteBucketAckPackage{ p.Status, SafeBigInt(p.Id), p.ExtraData, diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 5bc76a07f..85b43af1f 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -4,6 +4,8 @@ import ( "math/big" "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" + "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -90,3 +92,25 @@ type VirtualGroupKeeper interface { GetAndCheckGVGFamilyAvailableForNewBucket(ctx sdk.Context, familyID uint32) (*types.GlobalVirtualGroupFamily, error) GetGlobalVirtualGroupIfAvailable(ctx sdk.Context, gvgID uint32, expectedStoreSize uint64) (*types.GlobalVirtualGroup, error) } + +// StorageKeeper used by the cross-chain applications +type StorageKeeper interface { + Logger(ctx sdk.Context) log.Logger + GetBucketInfoById(ctx sdk.Context, bucketId sdkmath.Uint) (*BucketInfo, bool) + SetBucketInfo(ctx sdk.Context, bucketInfo *BucketInfo) + CreateBucket( + ctx sdk.Context, ownerAcc sdk.AccAddress, bucketName string, + primarySpAcc sdk.AccAddress, opts *CreateBucketOptions) (sdkmath.Uint, error) + DeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketName string, opts DeleteBucketOptions) error + GetGroupInfoById(ctx sdk.Context, groupId sdkmath.Uint) (*GroupInfo, bool) + DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName string, opts DeleteGroupOptions) error + CreateGroup( + ctx sdk.Context, owner sdk.AccAddress, + groupName string, opts CreateGroupOptions) (sdkmath.Uint, error) + SetGroupInfo(ctx sdk.Context, groupInfo *GroupInfo) + UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *GroupInfo, opts UpdateGroupMemberOptions) error + GetObjectInfoById(ctx sdk.Context, objectId sdkmath.Uint) (*ObjectInfo, bool) + SetObjectInfo(ctx sdk.Context, objectInfo *ObjectInfo) + DeleteObject( + ctx sdk.Context, operator sdk.AccAddress, bucketName, objectName string, opts DeleteObjectOptions) error +} diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 64ce48f30..12d9f9a5f 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: x/storage/types/expected_keepers.go +// Source: expected_keepers.go // Package types is a generated GoMock package. package types @@ -9,14 +9,16 @@ import ( reflect "reflect" math "cosmossdk.io/math" + log "github.com/cometbft/cometbft/libs/log" + types3 "github.com/cosmos/cosmos-sdk/types" + types4 "github.com/cosmos/cosmos-sdk/x/auth/types" + gomock "github.com/golang/mock/gomock" + resource "github.com/bnb-chain/greenfield/types/resource" types "github.com/bnb-chain/greenfield/x/payment/types" types0 "github.com/bnb-chain/greenfield/x/permission/types" types1 "github.com/bnb-chain/greenfield/x/sp/types" types2 "github.com/bnb-chain/greenfield/x/virtualgroup/types" - types3 "github.com/cosmos/cosmos-sdk/types" - types4 "github.com/cosmos/cosmos-sdk/x/auth/types" - gomock "github.com/golang/mock/gomock" ) // MockAccountKeeper is a mock of AccountKeeper interface. @@ -846,3 +848,207 @@ func (mr *MockVirtualGroupKeeperMockRecorder) SettleAndDistributeGVGFamily(ctx, mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SettleAndDistributeGVGFamily", reflect.TypeOf((*MockVirtualGroupKeeper)(nil).SettleAndDistributeGVGFamily), ctx, sp, family) } + +// MockStorageKeeper is a mock of StorageKeeper interface. +type MockStorageKeeper struct { + ctrl *gomock.Controller + recorder *MockStorageKeeperMockRecorder +} + +// MockStorageKeeperMockRecorder is the mock recorder for MockStorageKeeper. +type MockStorageKeeperMockRecorder struct { + mock *MockStorageKeeper +} + +// NewMockStorageKeeper creates a new mock instance. +func NewMockStorageKeeper(ctrl *gomock.Controller) *MockStorageKeeper { + mock := &MockStorageKeeper{ctrl: ctrl} + mock.recorder = &MockStorageKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStorageKeeper) EXPECT() *MockStorageKeeperMockRecorder { + return m.recorder +} + +// CreateBucket mocks base method. +func (m *MockStorageKeeper) CreateBucket(ctx types3.Context, ownerAcc types3.AccAddress, bucketName string, primarySpAcc types3.AccAddress, opts *CreateBucketOptions) (math.Uint, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateBucket", ctx, ownerAcc, bucketName, primarySpAcc, opts) + ret0, _ := ret[0].(math.Uint) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateBucket indicates an expected call of CreateBucket. +func (mr *MockStorageKeeperMockRecorder) CreateBucket(ctx, ownerAcc, bucketName, primarySpAcc, opts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBucket", reflect.TypeOf((*MockStorageKeeper)(nil).CreateBucket), ctx, ownerAcc, bucketName, primarySpAcc, opts) +} + +// CreateGroup mocks base method. +func (m *MockStorageKeeper) CreateGroup(ctx types3.Context, owner types3.AccAddress, groupName string, opts CreateGroupOptions) (math.Uint, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateGroup", ctx, owner, groupName, opts) + ret0, _ := ret[0].(math.Uint) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateGroup indicates an expected call of CreateGroup. +func (mr *MockStorageKeeperMockRecorder) CreateGroup(ctx, owner, groupName, opts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGroup", reflect.TypeOf((*MockStorageKeeper)(nil).CreateGroup), ctx, owner, groupName, opts) +} + +// DeleteBucket mocks base method. +func (m *MockStorageKeeper) DeleteBucket(ctx types3.Context, operator types3.AccAddress, bucketName string, opts DeleteBucketOptions) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteBucket", ctx, operator, bucketName, opts) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteBucket indicates an expected call of DeleteBucket. +func (mr *MockStorageKeeperMockRecorder) DeleteBucket(ctx, operator, bucketName, opts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBucket", reflect.TypeOf((*MockStorageKeeper)(nil).DeleteBucket), ctx, operator, bucketName, opts) +} + +// DeleteGroup mocks base method. +func (m *MockStorageKeeper) DeleteGroup(ctx types3.Context, operator types3.AccAddress, groupName string, opts DeleteGroupOptions) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteGroup", ctx, operator, groupName, opts) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteGroup indicates an expected call of DeleteGroup. +func (mr *MockStorageKeeperMockRecorder) DeleteGroup(ctx, operator, groupName, opts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteGroup", reflect.TypeOf((*MockStorageKeeper)(nil).DeleteGroup), ctx, operator, groupName, opts) +} + +// DeleteObject mocks base method. +func (m *MockStorageKeeper) DeleteObject(ctx types3.Context, operator types3.AccAddress, bucketName, objectName string, opts DeleteObjectOptions) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteObject", ctx, operator, bucketName, objectName, opts) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteObject indicates an expected call of DeleteObject. +func (mr *MockStorageKeeperMockRecorder) DeleteObject(ctx, operator, bucketName, objectName, opts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteObject", reflect.TypeOf((*MockStorageKeeper)(nil).DeleteObject), ctx, operator, bucketName, objectName, opts) +} + +// GetBucketInfoById mocks base method. +func (m *MockStorageKeeper) GetBucketInfoById(ctx types3.Context, bucketId math.Uint) (*BucketInfo, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBucketInfoById", ctx, bucketId) + ret0, _ := ret[0].(*BucketInfo) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetBucketInfoById indicates an expected call of GetBucketInfoById. +func (mr *MockStorageKeeperMockRecorder) GetBucketInfoById(ctx, bucketId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBucketInfoById", reflect.TypeOf((*MockStorageKeeper)(nil).GetBucketInfoById), ctx, bucketId) +} + +// GetGroupInfoById mocks base method. +func (m *MockStorageKeeper) GetGroupInfoById(ctx types3.Context, groupId math.Uint) (*GroupInfo, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetGroupInfoById", ctx, groupId) + ret0, _ := ret[0].(*GroupInfo) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetGroupInfoById indicates an expected call of GetGroupInfoById. +func (mr *MockStorageKeeperMockRecorder) GetGroupInfoById(ctx, groupId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupInfoById", reflect.TypeOf((*MockStorageKeeper)(nil).GetGroupInfoById), ctx, groupId) +} + +// GetObjectInfoById mocks base method. +func (m *MockStorageKeeper) GetObjectInfoById(ctx types3.Context, objectId math.Uint) (*ObjectInfo, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetObjectInfoById", ctx, objectId) + ret0, _ := ret[0].(*ObjectInfo) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetObjectInfoById indicates an expected call of GetObjectInfoById. +func (mr *MockStorageKeeperMockRecorder) GetObjectInfoById(ctx, objectId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObjectInfoById", reflect.TypeOf((*MockStorageKeeper)(nil).GetObjectInfoById), ctx, objectId) +} + +// Logger mocks base method. +func (m *MockStorageKeeper) Logger(ctx types3.Context) log.Logger { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Logger", ctx) + ret0, _ := ret[0].(log.Logger) + return ret0 +} + +// Logger indicates an expected call of Logger. +func (mr *MockStorageKeeperMockRecorder) Logger(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Logger", reflect.TypeOf((*MockStorageKeeper)(nil).Logger), ctx) +} + +// SetBucketInfo mocks base method. +func (m *MockStorageKeeper) SetBucketInfo(ctx types3.Context, bucketInfo *BucketInfo) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetBucketInfo", ctx, bucketInfo) +} + +// SetBucketInfo indicates an expected call of SetBucketInfo. +func (mr *MockStorageKeeperMockRecorder) SetBucketInfo(ctx, bucketInfo interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBucketInfo", reflect.TypeOf((*MockStorageKeeper)(nil).SetBucketInfo), ctx, bucketInfo) +} + +// SetGroupInfo mocks base method. +func (m *MockStorageKeeper) SetGroupInfo(ctx types3.Context, groupInfo *GroupInfo) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetGroupInfo", ctx, groupInfo) +} + +// SetGroupInfo indicates an expected call of SetGroupInfo. +func (mr *MockStorageKeeperMockRecorder) SetGroupInfo(ctx, groupInfo interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetGroupInfo", reflect.TypeOf((*MockStorageKeeper)(nil).SetGroupInfo), ctx, groupInfo) +} + +// SetObjectInfo mocks base method. +func (m *MockStorageKeeper) SetObjectInfo(ctx types3.Context, objectInfo *ObjectInfo) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetObjectInfo", ctx, objectInfo) +} + +// SetObjectInfo indicates an expected call of SetObjectInfo. +func (mr *MockStorageKeeperMockRecorder) SetObjectInfo(ctx, objectInfo interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetObjectInfo", reflect.TypeOf((*MockStorageKeeper)(nil).SetObjectInfo), ctx, objectInfo) +} + +// UpdateGroupMember mocks base method. +func (m *MockStorageKeeper) UpdateGroupMember(ctx types3.Context, operator types3.AccAddress, groupInfo *GroupInfo, opts UpdateGroupMemberOptions) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateGroupMember", ctx, operator, groupInfo, opts) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateGroupMember indicates an expected call of UpdateGroupMember. +func (mr *MockStorageKeeperMockRecorder) UpdateGroupMember(ctx, operator, groupInfo, opts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGroupMember", reflect.TypeOf((*MockStorageKeeper)(nil).UpdateGroupMember), ctx, operator, groupInfo, opts) +} diff --git a/x/storage/types/message.go b/x/storage/types/message.go index e2b937fe6..b55a6e44a 100644 --- a/x/storage/types/message.go +++ b/x/storage/types/message.go @@ -523,7 +523,7 @@ func (msg *MsgSealObject) ValidateBasic() error { } if len(msg.GetSecondarySpBlsAggSignatures()) != sdk.BLSSignatureLength { - return errors.Wrap(sdkerrors.ErrInvalidRequest, + return errors.Wrap(gnfderrors.ErrInvalidBlsSignature, fmt.Sprintf("length of signature should be %d", sdk.BLSSignatureLength), ) } diff --git a/x/storage/types/message_object_test.go b/x/storage/types/message_object_test.go new file mode 100644 index 000000000..00543e315 --- /dev/null +++ b/x/storage/types/message_object_test.go @@ -0,0 +1,567 @@ +package types + +import ( + "strings" + "testing" + + "cosmossdk.io/math" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/prysmaticlabs/prysm/crypto/bls" + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/types/common" + gnfderrors "github.com/bnb-chain/greenfield/types/errors" +) + +func TestMsgCreateObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateObject + err error + }{ + { + name: "normal", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + PayloadSize: 1024, + Visibility: VISIBILITY_TYPE_PRIVATE, + ContentType: "content-type", + PrimarySpApproval: &common.Approval{}, + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + }, + }, { + name: "invalid object name", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "", + PayloadSize: 1024, + Visibility: VISIBILITY_TYPE_PRIVATE, + ContentType: "content-type", + PrimarySpApproval: &common.Approval{}, + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + }, + err: gnfderrors.ErrInvalidObjectName, + }, { + name: "invalid object name", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "../object", + PayloadSize: 1024, + Visibility: VISIBILITY_TYPE_PRIVATE, + ContentType: "content-type", + PrimarySpApproval: &common.Approval{}, + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + }, + err: gnfderrors.ErrInvalidObjectName, + }, { + name: "invalid object name", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "//object", + PayloadSize: 1024, + Visibility: VISIBILITY_TYPE_PRIVATE, + ContentType: "content-type", + PrimarySpApproval: &common.Approval{}, + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + }, + err: gnfderrors.ErrInvalidObjectName, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgCancelCreateObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCancelCreateObject + err error + }{ + { + name: "basic", + msg: MsgCancelCreateObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteObject + err error + }{ + { + name: "normal", + msg: MsgDeleteObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgCopyObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCopyObject + err error + }{ + { + name: "valid address", + msg: MsgCopyObject{ + Operator: sample.AccAddress(), + SrcBucketName: testBucketName, + SrcObjectName: testObjectName, + DstBucketName: "dst" + testBucketName, + DstObjectName: "dst" + testObjectName, + DstPrimarySpApproval: &common.Approval{ + ExpiredHeight: 100, + Sig: []byte("xxx"), + }, + }, + }, + { + name: "invalid address", + msg: MsgCopyObject{ + Operator: "invalid address", + SrcBucketName: testBucketName, + SrcObjectName: testObjectName, + DstBucketName: "dst" + testBucketName, + DstObjectName: "dst" + testObjectName, + DstPrimarySpApproval: &common.Approval{ + ExpiredHeight: 100, + Sig: []byte("xxx"), + }, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "empty approval", + msg: MsgCopyObject{ + Operator: sample.AccAddress(), + SrcBucketName: testBucketName, + SrcObjectName: testObjectName, + DstBucketName: "dst" + testBucketName, + DstObjectName: "dst" + testObjectName, + DstPrimarySpApproval: nil, + }, + err: ErrInvalidApproval, + }, + { + name: "invalid src bucket name", + msg: MsgCopyObject{ + Operator: sample.AccAddress(), + SrcBucketName: "1.1.1.1", + SrcObjectName: testObjectName, + DstBucketName: "dst" + testBucketName, + DstObjectName: "dst" + testObjectName, + DstPrimarySpApproval: &common.Approval{ + ExpiredHeight: 100, + Sig: []byte("xxx"), + }, + }, + err: gnfderrors.ErrInvalidBucketName, + }, + { + name: "invalid src object name", + msg: MsgCopyObject{ + Operator: sample.AccAddress(), + SrcBucketName: testBucketName, + SrcObjectName: "", + DstBucketName: "dst" + testBucketName, + DstObjectName: "dst" + testObjectName, + DstPrimarySpApproval: &common.Approval{ + ExpiredHeight: 100, + Sig: []byte("xxx"), + }, + }, + err: gnfderrors.ErrInvalidObjectName, + }, + { + name: "invalid dest bucket name", + msg: MsgCopyObject{ + Operator: sample.AccAddress(), + SrcBucketName: testBucketName, + SrcObjectName: testObjectName, + DstBucketName: "1.1.1.1", + DstObjectName: "dst" + testObjectName, + DstPrimarySpApproval: &common.Approval{ + ExpiredHeight: 100, + Sig: []byte("xxx"), + }, + }, + err: gnfderrors.ErrInvalidBucketName, + }, + { + name: "invalid dest object name", + msg: MsgCopyObject{ + Operator: sample.AccAddress(), + SrcBucketName: testBucketName, + SrcObjectName: testObjectName, + DstBucketName: "dst" + testBucketName, + DstObjectName: "", + DstPrimarySpApproval: &common.Approval{ + ExpiredHeight: 100, + Sig: []byte("xxx"), + }, + }, + err: gnfderrors.ErrInvalidObjectName, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgSealObject_ValidateBasic(t *testing.T) { + checksums := [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()} + blsSignDoc := NewSecondarySpSealObjectSignDoc("greenfield_9000-1", 1, math.NewUint(1), GenerateHash(checksums[:])).GetSignBytes() + blsPrivKey, _ := bls.RandKey() + aggSig := blsPrivKey.Sign(blsSignDoc[:]).Marshal() + tests := []struct { + name string + msg MsgSealObject + err error + }{ + { + name: "normal", + msg: MsgSealObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + SecondarySpBlsAggSignatures: aggSig, + }, + }, + { + name: "invalid address", + msg: MsgSealObject{ + Operator: "invalid address", + BucketName: testBucketName, + ObjectName: testObjectName, + SecondarySpBlsAggSignatures: aggSig, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid bucket name", + msg: MsgSealObject{ + Operator: sample.AccAddress(), + BucketName: "1.1.1.1", + ObjectName: testObjectName, + SecondarySpBlsAggSignatures: aggSig, + }, + err: gnfderrors.ErrInvalidBucketName, + }, + { + name: "invalid object name", + msg: MsgSealObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "", + SecondarySpBlsAggSignatures: aggSig, + }, + err: gnfderrors.ErrInvalidObjectName, + }, + { + name: "invalid signature", + msg: MsgSealObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + SecondarySpBlsAggSignatures: []byte("invalid signature"), + }, + err: gnfderrors.ErrInvalidBlsSignature, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgRejectSealObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgRejectSealObject + err error + }{ + { + name: "normal", + msg: MsgRejectSealObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + }, + }, + { + name: "invalid address", + msg: MsgRejectSealObject{ + Operator: "invalid address", + BucketName: "1.1.1.1", + ObjectName: testObjectName, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid bucket name", + msg: MsgRejectSealObject{ + Operator: sample.AccAddress(), + BucketName: "1.1.1.1", + ObjectName: testObjectName, + }, + err: gnfderrors.ErrInvalidBucketName, + }, + { + name: "invalid object name", + msg: MsgRejectSealObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "", + }, + err: gnfderrors.ErrInvalidObjectName, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgUpdateObjectInfo_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateObjectInfo + err error + }{ + { + name: "normal", + msg: MsgUpdateObjectInfo{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + Visibility: VISIBILITY_TYPE_INHERIT, + }, + }, + { + name: "invalid address", + msg: MsgUpdateObjectInfo{ + Operator: "invalid address", + BucketName: testBucketName, + ObjectName: testObjectName, + Visibility: VISIBILITY_TYPE_INHERIT, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid bucket name", + msg: MsgUpdateObjectInfo{ + Operator: sample.AccAddress(), + BucketName: "1.1.1.1", + ObjectName: testObjectName, + Visibility: VISIBILITY_TYPE_INHERIT, + }, + err: gnfderrors.ErrInvalidBucketName, + }, + { + name: "invalid bucket name", + msg: MsgUpdateObjectInfo{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "", + Visibility: VISIBILITY_TYPE_INHERIT, + }, + err: gnfderrors.ErrInvalidObjectName, + }, + { + name: "invalid visibility", + msg: MsgUpdateObjectInfo{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + Visibility: VISIBILITY_TYPE_UNSPECIFIED, + }, + err: ErrInvalidVisibility, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgMirrorObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgMirrorObject + err error + }{ + { + name: "normal", + msg: MsgMirrorObject{ + Operator: sample.AccAddress(), + Id: math.NewUint(1), + }, + }, + { + name: "invalid address", + msg: MsgMirrorObject{ + Operator: "wrong address", + Id: math.NewUint(1), + }, + err: sdkerrors.ErrInvalidAddress, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDiscontinueObject_ValidateBasic(t *testing.T) { + invalidObjectIds := [MaxDiscontinueObjects + 1]Uint{} + tests := []struct { + name string + msg MsgDiscontinueObject + err error + }{ + { + name: "normal", + msg: MsgDiscontinueObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectIds: []Uint{math.NewUint(1)}, + Reason: "valid reason", + }, + }, + { + name: "invalid address", + msg: MsgDiscontinueObject{ + Operator: "invalid address", + BucketName: testBucketName, + ObjectIds: []Uint{math.NewUint(1)}, + Reason: "valid reason", + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid bucket name", + msg: MsgDiscontinueObject{ + Operator: sample.AccAddress(), + BucketName: "1.11.1.1", + ObjectIds: []Uint{math.NewUint(1)}, + Reason: "valid reason", + }, + err: gnfderrors.ErrInvalidBucketName, + }, + { + name: "invalid object ids", + msg: MsgDiscontinueObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectIds: nil, + Reason: "valid reason", + }, + err: ErrInvalidObjectIds, + }, + { + name: "invalid object ids", + msg: MsgDiscontinueObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectIds: invalidObjectIds[:], + Reason: "valid reason", + }, + err: ErrInvalidObjectIds, + }, + { + name: "invalid reason", + msg: MsgDiscontinueObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectIds: []Uint{math.NewUint(1)}, + Reason: strings.Repeat("s", MaxDiscontinueReasonLen+1), + }, + err: ErrInvalidReason, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/storage/types/message_test.go b/x/storage/types/message_test.go index bb331524e..9762f19e7 100644 --- a/x/storage/types/message_test.go +++ b/x/storage/types/message_test.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/stretchr/testify/require" "github.com/bnb-chain/greenfield/testutil/sample" @@ -159,261 +158,6 @@ func TestMsgUpdateBucketInfo_ValidateBasic(t *testing.T) { } } -func TestMsgCreateObject_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgCreateObject - err error - }{ - { - name: "normal", - msg: MsgCreateObject{ - Creator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: testObjectName, - PayloadSize: 1024, - Visibility: VISIBILITY_TYPE_PRIVATE, - ContentType: "content-type", - PrimarySpApproval: &common.Approval{}, - ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, - }, - }, { - name: "invalid object name", - msg: MsgCreateObject{ - Creator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: "", - PayloadSize: 1024, - Visibility: VISIBILITY_TYPE_PRIVATE, - ContentType: "content-type", - PrimarySpApproval: &common.Approval{}, - ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, - }, - err: gnfderrors.ErrInvalidObjectName, - }, { - name: "invalid object name", - msg: MsgCreateObject{ - Creator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: "../object", - PayloadSize: 1024, - Visibility: VISIBILITY_TYPE_PRIVATE, - ContentType: "content-type", - PrimarySpApproval: &common.Approval{}, - ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, - }, - err: gnfderrors.ErrInvalidObjectName, - }, { - name: "invalid object name", - msg: MsgCreateObject{ - Creator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: "//object", - PayloadSize: 1024, - Visibility: VISIBILITY_TYPE_PRIVATE, - ContentType: "content-type", - PrimarySpApproval: &common.Approval{}, - ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, - }, - err: gnfderrors.ErrInvalidObjectName, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgCancelCreateObject_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgCancelCreateObject - err error - }{ - { - name: "basic", - msg: MsgCancelCreateObject{ - Operator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: testObjectName, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgDeleteObject_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgDeleteObject - err error - }{ - { - name: "normal", - msg: MsgDeleteObject{ - Operator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: testObjectName, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgCopyObject_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgCopyObject - err error - }{ - { - name: "valid address", - msg: MsgCopyObject{ - Operator: sample.AccAddress(), - SrcBucketName: testBucketName, - SrcObjectName: testObjectName, - DstBucketName: "dst" + testBucketName, - DstObjectName: "dst" + testObjectName, - DstPrimarySpApproval: &common.Approval{ - ExpiredHeight: 100, - Sig: []byte("xxx"), - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgSealObject_ValidateBasic(t *testing.T) { - checksums := [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()} - blsSignDoc := NewSecondarySpSealObjectSignDoc("greenfield_9000-1", 1, math.NewUint(1), GenerateHash(checksums[:])).GetSignBytes() - blsPrivKey, _ := bls.RandKey() - aggSig := blsPrivKey.Sign(blsSignDoc[:]).Marshal() - tests := []struct { - name string - msg MsgSealObject - err error - }{ - { - name: "normal", - msg: MsgSealObject{ - Operator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: testObjectName, - SecondarySpBlsAggSignatures: aggSig, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgRejectSealObject_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgRejectSealObject - err error - }{ - { - name: "normal", - msg: MsgRejectSealObject{ - Operator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: testObjectName, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgUpdateObjectInfo_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgUpdateObjectInfo - err error - }{ - { - name: "normal", - msg: MsgUpdateObjectInfo{ - Operator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: testObjectName, - Visibility: VISIBILITY_TYPE_INHERIT, - }, - }, - { - name: "abnormal", - msg: MsgUpdateObjectInfo{ - Operator: sample.AccAddress(), - BucketName: testBucketName, - ObjectName: testObjectName, - Visibility: VISIBILITY_TYPE_UNSPECIFIED, - }, - err: ErrInvalidVisibility, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - func TestMsgCreateGroup_ValidateBasic(t *testing.T) { tests := []struct { name string @@ -651,40 +395,6 @@ func TestMsgMirrorBucket_ValidateBasic(t *testing.T) { } } -func TestMsgMirrorObject_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgMirrorObject - err error - }{ - { - name: "normal", - msg: MsgMirrorObject{ - Operator: sample.AccAddress(), - Id: math.NewUint(1), - }, - }, - { - name: "invalid address", - msg: MsgMirrorObject{ - Operator: "wrong address", - Id: math.NewUint(1), - }, - err: sdkerrors.ErrInvalidAddress, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - func TestMsgMirrorGroup_ValidateBasic(t *testing.T) { tests := []struct { name string diff --git a/x/storage/keeper/options.go b/x/storage/types/options.go similarity index 59% rename from x/storage/keeper/options.go rename to x/storage/types/options.go index 5cf66a102..dc36988e8 100644 --- a/x/storage/keeper/options.go +++ b/x/storage/types/options.go @@ -1,13 +1,12 @@ -package keeper +package types import ( "github.com/bnb-chain/greenfield/types/common" - "github.com/bnb-chain/greenfield/x/storage/types" ) type CreateBucketOptions struct { - Visibility types.VisibilityType - SourceType types.SourceType + Visibility VisibilityType + SourceType SourceType ChargedReadQuota uint64 PaymentAddress string PrimarySpApproval *common.Approval @@ -15,51 +14,55 @@ type CreateBucketOptions struct { } type DeleteBucketOptions struct { - SourceType types.SourceType + SourceType SourceType } type UpdateBucketOptions struct { - Visibility types.VisibilityType - SourceType types.SourceType + Visibility VisibilityType + SourceType SourceType PaymentAddress string ChargedReadQuota *uint64 } type CreateObjectOptions struct { - Visibility types.VisibilityType + Visibility VisibilityType ContentType string - SourceType types.SourceType - RedundancyType types.RedundancyType + SourceType SourceType + RedundancyType RedundancyType Checksums [][]byte PrimarySpApproval *common.Approval ApprovalMsgBytes []byte } type CancelCreateObjectOptions struct { - SourceType types.SourceType + SourceType SourceType } type DeleteObjectOptions struct { - SourceType types.SourceType + SourceType SourceType } type CopyObjectOptions struct { - SourceType types.SourceType - Visibility types.VisibilityType + SourceType SourceType + Visibility VisibilityType PrimarySpApproval *common.Approval ApprovalMsgBytes []byte } type CreateGroupOptions struct { Members []string - SourceType types.SourceType + SourceType SourceType Extra string } type LeaveGroupOptions struct { - SourceType types.SourceType + SourceType SourceType } type UpdateGroupMemberOptions struct { - SourceType types.SourceType + SourceType SourceType MembersToAdd []string MembersToDelete []string } + +type DeleteGroupOptions struct { + SourceType SourceType +} diff --git a/x/virtualgroup/keeper/grpc_query.go b/x/virtualgroup/keeper/grpc_query.go index 2172429a0..2fe684529 100644 --- a/x/virtualgroup/keeper/grpc_query.go +++ b/x/virtualgroup/keeper/grpc_query.go @@ -29,10 +29,6 @@ func (k Keeper) GlobalVirtualGroup(goCtx context.Context, req *types.QueryGlobal ctx := sdk.UnwrapSDKContext(goCtx) - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - gvg, found := k.GetGVG(ctx, req.GlobalVirtualGroupId) if !found { return nil, types.ErrGVGNotExist @@ -71,10 +67,6 @@ func (k Keeper) GlobalVirtualGroupFamily(goCtx context.Context, req *types.Query ctx := sdk.UnwrapSDKContext(goCtx) - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - gvgFamily, found := k.GetGVGFamily(ctx, req.FamilyId) if !found { return nil, types.ErrGVGFamilyNotExist diff --git a/x/virtualgroup/types/message.go b/x/virtualgroup/types/message.go index dac1e3184..8bc75b594 100644 --- a/x/virtualgroup/types/message.go +++ b/x/virtualgroup/types/message.go @@ -64,7 +64,7 @@ func (msg *MsgCreateGlobalVirtualGroup) GetSigners() []sdk.AccAddress { func (msg *MsgCreateGlobalVirtualGroup) ValidateBasic() error { _, err := sdk.AccAddressFromHexUnsafe(msg.StorageProvider) if err != nil { - return err + return sdkerrors.ErrInvalidAddress.Wrapf("invalid storage provider address (%s)", err) } if !msg.Deposit.IsValid() || !msg.Deposit.Amount.IsPositive() { @@ -107,7 +107,7 @@ func (msg *MsgDeleteGlobalVirtualGroup) GetSigners() []sdk.AccAddress { func (msg *MsgDeleteGlobalVirtualGroup) ValidateBasic() error { _, err := sdk.AccAddressFromHexUnsafe(msg.StorageProvider) if err != nil { - return err + return sdkerrors.ErrInvalidAddress.Wrapf("invalid storage provider address (%s)", err) } return nil @@ -147,7 +147,7 @@ func (msg *MsgDeposit) GetSigners() []sdk.AccAddress { func (msg *MsgDeposit) ValidateBasic() error { _, err := sdk.AccAddressFromHexUnsafe(msg.StorageProvider) if err != nil { - return err + return sdkerrors.ErrInvalidAddress.Wrapf("invalid storage provider address (%s)", err) } if !msg.Deposit.IsValid() || !msg.Deposit.Amount.IsPositive() { @@ -188,7 +188,7 @@ func (msg *MsgWithdraw) GetSigners() []sdk.AccAddress { func (msg *MsgWithdraw) ValidateBasic() error { _, err := sdk.AccAddressFromHexUnsafe(msg.StorageProvider) if err != nil { - return err + return sdkerrors.ErrInvalidAddress.Wrapf("invalid storage provider address (%s)", err) } if !msg.Withdraw.IsValid() || !msg.Withdraw.Amount.IsPositive() { @@ -235,7 +235,7 @@ func (msg *MsgSwapOut) GetSigners() []sdk.AccAddress { func (msg *MsgSwapOut) ValidateBasic() error { _, err := sdk.AccAddressFromHexUnsafe(msg.StorageProvider) if err != nil { - return err + return sdkerrors.ErrInvalidAddress.Wrapf("invalid storage provider address (%s)", err) } if msg.GlobalVirtualGroupFamilyId == NoSpecifiedFamilyId { @@ -249,7 +249,11 @@ func (msg *MsgSwapOut) ValidateBasic() error { } if msg.SuccessorSpId == 0 { - return gnfderrors.ErrInvalidMessage.Wrap("The successor sp id is not specify.") + return gnfderrors.ErrInvalidMessage.Wrap("The successor sp id is not specified.") + } + + if msg.SuccessorSpApproval == nil { + return gnfderrors.ErrInvalidMessage.Wrap("The successor sp approval is not specified.") } return nil @@ -310,7 +314,7 @@ func (msg *MsgSettle) GetSigners() []sdk.AccAddress { func (msg *MsgSettle) ValidateBasic() error { _, err := sdk.AccAddressFromHexUnsafe(msg.StorageProvider) if err != nil { - return err + return sdkerrors.ErrInvalidAddress.Wrapf("invalid storage provider address (%s)", err) } if msg.GlobalVirtualGroupFamilyId == NoSpecifiedFamilyId { diff --git a/x/virtualgroup/types/message_cancel_swap_out_test.go b/x/virtualgroup/types/message_cancel_swap_out_test.go index 5aa4d79f6..4d6652b6a 100644 --- a/x/virtualgroup/types/message_cancel_swap_out_test.go +++ b/x/virtualgroup/types/message_cancel_swap_out_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/bnb-chain/greenfield/testutil/sample" + gnfderrors "github.com/bnb-chain/greenfield/types/errors" ) func TestMsgCancelSwapOut_ValidateBasic(t *testing.T) { @@ -15,6 +16,14 @@ func TestMsgCancelSwapOut_ValidateBasic(t *testing.T) { msg MsgCancelSwapOut err error }{ + { + name: "valid address", + msg: *NewMsgCancelSwapOut( + sample.RandAccAddress(), + 1, + []uint32{}, + ), + }, { name: "invalid address", msg: MsgCancelSwapOut{ @@ -22,12 +31,24 @@ func TestMsgCancelSwapOut_ValidateBasic(t *testing.T) { GlobalVirtualGroupFamilyId: 1, }, err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", + }, + { + name: "invalid gvg groups", msg: MsgCancelSwapOut{ StorageProvider: sample.AccAddress(), GlobalVirtualGroupFamilyId: 1, + GlobalVirtualGroupIds: []uint32{1, 2}, + }, + err: gnfderrors.ErrInvalidMessage, + }, + { + name: "invalid gvg groups", + msg: MsgCancelSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 0, + GlobalVirtualGroupIds: []uint32{}, }, + err: gnfderrors.ErrInvalidMessage, }, } for _, tt := range tests { diff --git a/x/virtualgroup/types/message_complete_storage_provider_exit_test.go b/x/virtualgroup/types/message_complete_storage_provider_exit_test.go index 97b94fedc..b9948939f 100644 --- a/x/virtualgroup/types/message_complete_storage_provider_exit_test.go +++ b/x/virtualgroup/types/message_complete_storage_provider_exit_test.go @@ -23,9 +23,7 @@ func TestMsgCompleteStorageProviderExit_ValidateBasic(t *testing.T) { err: sdkerrors.ErrInvalidAddress, }, { name: "valid address", - msg: MsgCompleteStorageProviderExit{ - StorageProvider: sample.AccAddress(), - }, + msg: *NewMsgCompleteStorageProviderExit(sample.RandAccAddress()), }, } for _, tt := range tests { diff --git a/x/virtualgroup/types/message_complete_swap_out_test.go b/x/virtualgroup/types/message_complete_swap_out_test.go index 7d17fcd8f..2f612e448 100644 --- a/x/virtualgroup/types/message_complete_swap_out_test.go +++ b/x/virtualgroup/types/message_complete_swap_out_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/bnb-chain/greenfield/testutil/sample" + gnfderrors "github.com/bnb-chain/greenfield/types/errors" ) func TestMsgCompleteSwapOut_ValidateBasic(t *testing.T) { @@ -15,6 +16,14 @@ func TestMsgCompleteSwapOut_ValidateBasic(t *testing.T) { msg MsgCompleteSwapOut err error }{ + { + name: "valid address", + msg: *NewMsgCompleteSwapOut( + sample.RandAccAddress(), + 1, + []uint32{}, + ), + }, { name: "invalid address", msg: MsgCompleteSwapOut{ @@ -22,12 +31,24 @@ func TestMsgCompleteSwapOut_ValidateBasic(t *testing.T) { GlobalVirtualGroupFamilyId: 1, }, err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", + }, + { + name: "invalid gvg groups", msg: MsgCompleteSwapOut{ StorageProvider: sample.AccAddress(), GlobalVirtualGroupFamilyId: 1, + GlobalVirtualGroupIds: []uint32{1, 2, 3}, + }, + err: gnfderrors.ErrInvalidMessage, + }, + { + name: "invalid gvg groups", + msg: MsgCompleteSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 0, + GlobalVirtualGroupIds: []uint32{}, }, + err: gnfderrors.ErrInvalidMessage, }, } for _, tt := range tests { diff --git a/x/virtualgroup/types/message_storage_provider_exit_test.go b/x/virtualgroup/types/message_storage_provider_exit_test.go index 49e2e2b57..e849077ee 100644 --- a/x/virtualgroup/types/message_storage_provider_exit_test.go +++ b/x/virtualgroup/types/message_storage_provider_exit_test.go @@ -23,9 +23,7 @@ func TestMsgStorageProviderExit_ValidateBasic(t *testing.T) { err: sdkerrors.ErrInvalidAddress, }, { name: "valid address", - msg: MsgStorageProviderExit{ - StorageProvider: sample.AccAddress(), - }, + msg: *NewMsgStorageProviderExit(sample.RandAccAddress()), }, } for _, tt := range tests { diff --git a/x/virtualgroup/types/message_test.go b/x/virtualgroup/types/message_test.go new file mode 100644 index 000000000..ebf893729 --- /dev/null +++ b/x/virtualgroup/types/message_test.go @@ -0,0 +1,381 @@ +package types + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/types/common" + gnfderrors "github.com/bnb-chain/greenfield/types/errors" +) + +func TestMsgDeposit_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeposit + err error + }{ + { + name: "invalid address", + msg: MsgDeposit{ + StorageProvider: "invalid_address", + GlobalVirtualGroupId: 1, + Deposit: types.Coin{ + Denom: "denom", + Amount: types.NewInt(1), + }, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid deposit amount", + msg: MsgDeposit{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupId: 1, + Deposit: types.Coin{ + Denom: "denom", + Amount: types.NewInt(0), + }, + }, + err: sdkerrors.ErrInvalidRequest, + }, + { + name: "valid case", + msg: *NewMsgDeposit( + sample.RandAccAddress(), + 1, + types.Coin{ + Denom: "denom", + Amount: types.NewInt(1), + }, + ), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgWithdraw_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgWithdraw + err error + }{ + { + name: "invalid address", + msg: MsgWithdraw{ + StorageProvider: "invalid_address", + GlobalVirtualGroupId: 1, + Withdraw: types.Coin{ + Denom: "denom", + Amount: types.NewInt(1), + }, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid deposit amount", + msg: MsgWithdraw{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupId: 1, + Withdraw: types.Coin{ + Denom: "denom", + Amount: types.NewInt(0), + }, + }, + err: sdkerrors.ErrInvalidRequest, + }, + { + name: "valid case", + msg: *NewMsgWithdraw( + sample.RandAccAddress(), + 1, + types.Coin{ + Denom: "denom", + Amount: types.NewInt(1), + }, + ), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgSwapOut_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgSwapOut + err error + }{ + { + name: "valid case", + msg: MsgSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 0, + GlobalVirtualGroupIds: []uint32{1, 2, 3}, + SuccessorSpId: 100, + SuccessorSpApproval: &common.Approval{ + ExpiredHeight: 100, + GlobalVirtualGroupFamilyId: 1, + Sig: []byte("sig"), + }, + }, + }, + { + name: "valid case", + msg: MsgSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 1, + GlobalVirtualGroupIds: []uint32{}, + SuccessorSpId: 100, + SuccessorSpApproval: &common.Approval{ + ExpiredHeight: 100, + GlobalVirtualGroupFamilyId: 1, + Sig: []byte("sig"), + }, + }, + }, + { + name: "invalid address", + msg: MsgSwapOut{ + StorageProvider: "invalid address", + GlobalVirtualGroupFamilyId: 1, + GlobalVirtualGroupIds: []uint32{}, + SuccessorSpId: 100, + SuccessorSpApproval: &common.Approval{ + ExpiredHeight: 100, + GlobalVirtualGroupFamilyId: 1, + Sig: []byte("sig"), + }, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid virtual group family", + msg: MsgSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 1, + GlobalVirtualGroupIds: []uint32{1}, + SuccessorSpId: 100, + SuccessorSpApproval: &common.Approval{ + ExpiredHeight: 100, + GlobalVirtualGroupFamilyId: 1, + Sig: []byte("sig"), + }, + }, + err: gnfderrors.ErrInvalidMessage, + }, + { + name: "invalid virtual group family", + msg: MsgSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 0, + GlobalVirtualGroupIds: []uint32{}, + SuccessorSpId: 100, + SuccessorSpApproval: &common.Approval{ + ExpiredHeight: 100, + GlobalVirtualGroupFamilyId: 1, + Sig: []byte("sig"), + }, + }, + err: gnfderrors.ErrInvalidMessage, + }, + { + name: "invalid successor sp id", + msg: MsgSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 1, + GlobalVirtualGroupIds: []uint32{}, + SuccessorSpId: 0, + SuccessorSpApproval: &common.Approval{ + ExpiredHeight: 100, + GlobalVirtualGroupFamilyId: 1, + Sig: []byte("sig"), + }, + }, + err: gnfderrors.ErrInvalidMessage, + }, + { + name: "invalid successor sp approval", + msg: MsgSwapOut{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 1, + GlobalVirtualGroupIds: []uint32{}, + SuccessorSpId: 1, + }, + err: gnfderrors.ErrInvalidMessage, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgCreateGlobalVirtualGroup_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateGlobalVirtualGroup + err error + }{ + { + name: "valid case", + msg: *NewMsgCreateGlobalVirtualGroup( + sample.RandAccAddress(), + 1, + []uint32{2, 3, 4}, + types.Coin{ + Denom: "denom", + Amount: types.NewInt(1), + }, + ), + }, + { + name: "invalid address", + msg: MsgCreateGlobalVirtualGroup{ + StorageProvider: "invalid_address", + FamilyId: 1, + SecondarySpIds: []uint32{2, 3, 4}, + Deposit: types.Coin{ + Denom: "denom", + Amount: types.NewInt(1), + }, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid deposit coin", + msg: MsgCreateGlobalVirtualGroup{ + StorageProvider: "invalid_address", + FamilyId: 1, + SecondarySpIds: []uint32{2, 3, 4}, + Deposit: types.Coin{ + Denom: "denom", + Amount: types.NewInt(0), + }, + }, + err: sdkerrors.ErrInvalidAddress, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteGlobalVirtualGroup_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteGlobalVirtualGroup + err error + }{ + { + name: "valid case", + msg: *NewMsgDeleteGlobalVirtualGroup( + sample.RandAccAddress(), + 1, + ), + }, + { + name: "invalid address", + msg: MsgDeleteGlobalVirtualGroup{ + StorageProvider: "invalid_address", + GlobalVirtualGroupId: 1, + }, + err: sdkerrors.ErrInvalidAddress, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgSettle_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgSettle + err error + }{ + { + name: "valid case", + msg: *NewMsgSettle( + sample.RandAccAddress(), + 1, + []uint32{1, 2, 3, 4}, + ), + }, + { + name: "invalid address", + msg: MsgSettle{ + StorageProvider: "invalid_address", + GlobalVirtualGroupFamilyId: 1, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid gvg ids", + msg: MsgSettle{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 0, + }, + err: ErrInvalidGVGCount, + }, + { + name: "invalid gvg ids", + msg: MsgSettle{ + StorageProvider: sample.AccAddress(), + GlobalVirtualGroupFamilyId: 0, + GlobalVirtualGroupIds: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, + }, + err: ErrInvalidGVGCount, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/virtualgroup/types/params.go b/x/virtualgroup/types/params.go index 4ee62fa37..f9962ffbf 100644 --- a/x/virtualgroup/types/params.go +++ b/x/virtualgroup/types/params.go @@ -120,7 +120,7 @@ func validateMaxStoreSizePerFamily(i interface{}) error { } if v == 0 { - return fmt.Errorf("max buckets per account must be positive: %d", v) + return fmt.Errorf("max store size of family must be positive: %d", v) } return nil diff --git a/x/virtualgroup/types/params_test.go b/x/virtualgroup/types/params_test.go new file mode 100644 index 000000000..da5c08091 --- /dev/null +++ b/x/virtualgroup/types/params_test.go @@ -0,0 +1,154 @@ +package types + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestDepositDenom(t *testing.T) { + tests := []struct { + name string + denom interface{} + err string + }{ + + { + name: "valid", + denom: "denom", + }, + { + name: "invalid type", + denom: 1, + err: "invalid parameter type", + }, + { + name: "empty", + denom: " ", + err: "deposit denom cannot be blank", + }, + { + name: "invalid denom", + denom: "%", + err: "invalid denom", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := validateDepositDenom(tt.denom) + if tt.err != "" { + require.ErrorContains(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestGVGStakingPerBytes(t *testing.T) { + tests := []struct { + name string + ratio interface{} + err string + }{ + + { + name: "valid", + ratio: sdk.NewDec(1), + }, + { + name: "invalid type", + ratio: 1, + err: "invalid parameter type", + }, + { + name: "invalid ratio", + ratio: sdk.NewDec(100), + err: "invalid secondary sp store price ratio", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := validateGVGStakingPerBytes(tt.ratio) + if tt.err != "" { + require.ErrorContains(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMaxGlobalVirtualGroupNumPerFamily(t *testing.T) { + tests := []struct { + name string + number interface{} + err string + }{ + + { + name: "valid", + number: uint32(1), + }, + { + name: "invalid type", + number: 1, + err: "invalid parameter type", + }, + { + name: "invalid size", + number: uint32(0), + err: "max buckets per account must be positive", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := validateMaxGlobalVirtualGroupNumPerFamily(tt.number) + if tt.err != "" { + require.ErrorContains(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMaxStoreSizePerFamily(t *testing.T) { + tests := []struct { + name string + size interface{} + err string + }{ + + { + name: "valid", + size: uint64(1), + }, + { + name: "invalid type", + size: 1, + err: "invalid parameter type", + }, + { + name: "invalid size", + size: uint64(0), + err: "max store size of family must be positive", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := validateMaxStoreSizePerFamily(tt.size) + if tt.err != "" { + require.ErrorContains(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestValidateParams(t *testing.T) { + err := DefaultParams().Validate() + require.NoError(t, err) +} From f0d7885c0305c5ba4a3a8227b946a47f010e8297 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Fri, 28 Jul 2023 15:24:57 +0800 Subject: [PATCH 07/24] chore: add unit test cases for payment module (#380) --- x/payment/keeper/auto_resume_record_test.go | 52 +++ x/payment/keeper/auto_settle_record.go | 22 -- x/payment/keeper/auto_settle_record_test.go | 42 +++ x/payment/keeper/grpc_query_test.go | 306 ++++++++++++++++++ .../msg_server_create_payment_account_test.go | 35 ++ x/payment/keeper/msg_server_deposit_test.go | 72 +++++ .../keeper/msg_server_disable_refund_test.go | 39 +++ x/payment/keeper/msg_server_test.go | 115 +++++++ x/payment/keeper/msg_server_withdraw_test.go | 86 +++++ x/payment/keeper/payment_account_count.go | 11 - .../keeper/payment_account_count_test.go | 46 +++ x/payment/keeper/payment_account_test.go | 52 +++ x/payment/keeper/price_test.go | 39 +++ x/payment/keeper/storage_fee_charge_test.go | 291 ++++++++++------- x/payment/keeper/stream_record_test.go | 129 ++++++++ 15 files changed, 1183 insertions(+), 154 deletions(-) create mode 100644 x/payment/keeper/auto_resume_record_test.go create mode 100644 x/payment/keeper/auto_settle_record_test.go create mode 100644 x/payment/keeper/grpc_query_test.go create mode 100644 x/payment/keeper/msg_server_create_payment_account_test.go create mode 100644 x/payment/keeper/msg_server_deposit_test.go create mode 100644 x/payment/keeper/msg_server_disable_refund_test.go create mode 100644 x/payment/keeper/msg_server_test.go create mode 100644 x/payment/keeper/msg_server_withdraw_test.go create mode 100644 x/payment/keeper/payment_account_count_test.go create mode 100644 x/payment/keeper/payment_account_test.go create mode 100644 x/payment/keeper/price_test.go diff --git a/x/payment/keeper/auto_resume_record_test.go b/x/payment/keeper/auto_resume_record_test.go new file mode 100644 index 000000000..eb175835d --- /dev/null +++ b/x/payment/keeper/auto_resume_record_test.go @@ -0,0 +1,52 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func TestAutoResumeRecord(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + + addr1 := sample.RandAccAddress() + record1 := &types.AutoResumeRecord{ + Addr: addr1.String(), + Timestamp: 100, + } + + addr2 := sample.RandAccAddress() + record2 := &types.AutoResumeRecord{ + Addr: addr2.String(), + Timestamp: 200, + } + + // set + keeper.SetAutoResumeRecord(ctx, record1) + keeper.SetAutoResumeRecord(ctx, record2) + + // exits + // before the timestamp + exist := keeper.ExistsAutoResumeRecord(ctx, 90, addr1) + require.True(t, !exist) + exist = keeper.ExistsAutoResumeRecord(ctx, 101, addr1) + require.True(t, exist) + + // at any time + exist = keeper.ExistsAutoResumeRecord(ctx, 0, addr1) + require.True(t, exist) + exist = keeper.ExistsAutoResumeRecord(ctx, 0, addr2) + require.True(t, exist) + + // remove + keeper.RemoveAutoResumeRecord(ctx, record1.Timestamp, addr1) + keeper.RemoveAutoResumeRecord(ctx, record2.Timestamp, addr2) + + exist = keeper.ExistsAutoResumeRecord(ctx, 0, addr1) + require.True(t, !exist) + exist = keeper.ExistsAutoResumeRecord(ctx, 0, addr2) + require.True(t, !exist) +} diff --git a/x/payment/keeper/auto_settle_record.go b/x/payment/keeper/auto_settle_record.go index 7c5c5f7c9..afd7ba074 100644 --- a/x/payment/keeper/auto_settle_record.go +++ b/x/payment/keeper/auto_settle_record.go @@ -18,28 +18,6 @@ func (k Keeper) SetAutoSettleRecord(ctx sdk.Context, autoSettleRecord *types.Aut ), b) } -// GetAutoSettleRecord returns a autoSettleRecord from its index -func (k Keeper) GetAutoSettleRecord( - ctx sdk.Context, - timestamp int64, - addr sdk.AccAddress, -) (*types.AutoSettleRecord, bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AutoSettleRecordKeyPrefix) - - b := store.Get(types.AutoSettleRecordKey( - timestamp, - addr, - )) - if b == nil { - return nil, false - } - - return &types.AutoSettleRecord{ - Timestamp: timestamp, - Addr: addr.String(), - }, true -} - // RemoveAutoSettleRecord removes a autoSettleRecord from the store func (k Keeper) RemoveAutoSettleRecord( ctx sdk.Context, diff --git a/x/payment/keeper/auto_settle_record_test.go b/x/payment/keeper/auto_settle_record_test.go new file mode 100644 index 000000000..1dfa6e663 --- /dev/null +++ b/x/payment/keeper/auto_settle_record_test.go @@ -0,0 +1,42 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func TestAutoSettleRecord(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + + addr1 := sample.RandAccAddress() + record1 := &types.AutoSettleRecord{ + Addr: addr1.String(), + Timestamp: 100, + } + + addr2 := sample.RandAccAddress() + record2 := &types.AutoSettleRecord{ + Addr: addr2.String(), + Timestamp: 200, + } + + // set + keeper.SetAutoSettleRecord(ctx, record1) + keeper.SetAutoSettleRecord(ctx, record2) + + // update to new time + keeper.UpdateAutoSettleRecord(ctx, addr1, record1.Timestamp, 110) + + // update to remove + keeper.UpdateAutoSettleRecord(ctx, addr2, record2.Timestamp, 0) + + // get all + records := keeper.GetAllAutoSettleRecord(ctx) + require.True(t, len(records) == 1) + require.True(t, records[0].Addr == addr1.String()) + require.True(t, records[0].Timestamp == 110) +} diff --git a/x/payment/keeper/grpc_query_test.go b/x/payment/keeper/grpc_query_test.go new file mode 100644 index 000000000..b7ce3a41f --- /dev/null +++ b/x/payment/keeper/grpc_query_test.go @@ -0,0 +1,306 @@ +package keeper_test + +import ( + "testing" + "time" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} + +func TestParamsByTimestampQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + + before := time.Now() + ctx = ctx.WithBlockTime(before) + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + after := time.Unix(before.Unix()+10, 0) + ctx = ctx.WithBlockTime(after) + newReserveTime := uint64(1000000000) + params.VersionedParams.ReserveTime = newReserveTime + err = keeper.SetParams(ctx, params) + require.NoError(t, err) + + response, err := keeper.ParamsByTimestamp(ctx, &types.QueryParamsByTimestampRequest{ + Timestamp: before.Unix(), + }) + require.NoError(t, err) + require.True(t, newReserveTime != response.Params.VersionedParams.ReserveTime) + + response, err = keeper.ParamsByTimestamp(ctx, &types.QueryParamsByTimestampRequest{ + Timestamp: after.Unix(), + }) + require.NoError(t, err) + require.True(t, newReserveTime == response.Params.VersionedParams.ReserveTime) +} + +func TestAutoSettleRecordQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + record := types.AutoSettleRecord{ + Timestamp: 123, + Addr: sample.RandAccAddress().String(), + } + keeper.SetAutoSettleRecord(ctx, &record) + + response, err := keeper.AutoSettleRecordAll(ctx, &types.QueryAllAutoSettleRecordRequest{}) + require.NoError(t, err) + require.Equal(t, record, response.AutoSettleRecord[0]) +} + +func TestDynamicBalanceQuery(t *testing.T) { + keeper, ctx, deepKeepers := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + deepKeepers.AccountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()). + Return(true).AnyTimes() + bankBalance := sdk.NewCoin("BNB", sdkmath.NewInt(1000)) + + deepKeepers.BankKeeper.EXPECT().GetBalance(gomock.Any(), gomock.Any(), gomock.Any()). + Return(bankBalance).AnyTimes() + + record := types.NewStreamRecord(sample.RandAccAddress(), ctx.BlockTime().Unix()) + record.StaticBalance = sdkmath.NewInt(100) + keeper.SetStreamRecord(ctx, record) + + response, err := keeper.DynamicBalance(ctx, &types.QueryDynamicBalanceRequest{Account: record.Account}) + require.NoError(t, err) + require.Equal(t, record.StaticBalance.Add(bankBalance.Amount), response.AvailableBalance) + require.Equal(t, bankBalance.Amount, response.BankBalance) +} + +func TestPaymentAccountAllQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner1 := sample.RandAccAddress() + record1 := types.PaymentAccount{ + Owner: owner1.String(), + Addr: sample.RandAccAddress().String(), + } + keeper.SetPaymentAccount(ctx, &record1) + + owner2 := sample.RandAccAddress() + record2 := types.PaymentAccount{ + Owner: owner2.String(), + Addr: sample.RandAccAddress().String(), + } + keeper.SetPaymentAccount(ctx, &record2) + + response, err := keeper.PaymentAccountAll(ctx, &types.QueryAllPaymentAccountRequest{}) + require.NoError(t, err) + require.Equal(t, 2, len(response.PaymentAccount)) +} + +func TestPaymentAccountQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner1 := sample.RandAccAddress() + addr1 := sample.RandAccAddress().String() + record1 := types.PaymentAccount{ + Owner: owner1.String(), + Addr: addr1, + } + keeper.SetPaymentAccount(ctx, &record1) + + owner2 := sample.RandAccAddress() + addr2 := sample.RandAccAddress().String() + record2 := types.PaymentAccount{ + Owner: owner2.String(), + Addr: addr2, + } + keeper.SetPaymentAccount(ctx, &record2) + + response, err := keeper.PaymentAccount(ctx, &types.QueryGetPaymentAccountRequest{ + Addr: addr1, + }) + require.NoError(t, err) + require.Equal(t, owner1.String(), response.PaymentAccount.Owner) + + response, err = keeper.PaymentAccount(ctx, &types.QueryGetPaymentAccountRequest{ + Addr: addr2, + }) + require.NoError(t, err) + require.Equal(t, owner2.String(), response.PaymentAccount.Owner) +} + +func TestPaymentAccountCountAllQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner1 := sample.RandAccAddress() + record1 := types.PaymentAccountCount{ + Owner: owner1.String(), + Count: 10, + } + keeper.SetPaymentAccountCount(ctx, &record1) + + owner2 := sample.RandAccAddress() + record2 := types.PaymentAccountCount{ + Owner: owner2.String(), + Count: 2, + } + keeper.SetPaymentAccountCount(ctx, &record2) + + response, err := keeper.PaymentAccountCountAll(ctx, &types.QueryAllPaymentAccountCountRequest{}) + require.NoError(t, err) + require.Equal(t, 2, len(response.PaymentAccountCount)) +} + +func TestPaymentAccountCountQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner1 := sample.RandAccAddress() + record1 := types.PaymentAccountCount{ + Owner: owner1.String(), + Count: 10, + } + keeper.SetPaymentAccountCount(ctx, &record1) + + owner2 := sample.RandAccAddress() + record2 := types.PaymentAccountCount{ + Owner: owner2.String(), + Count: 2, + } + keeper.SetPaymentAccountCount(ctx, &record2) + + response, err := keeper.PaymentAccountCount(ctx, &types.QueryGetPaymentAccountCountRequest{ + Owner: owner1.String(), + }) + require.NoError(t, err) + require.Equal(t, record1.Count, response.PaymentAccountCount.Count) + + response, err = keeper.PaymentAccountCount(ctx, &types.QueryGetPaymentAccountCountRequest{ + Owner: owner2.String(), + }) + require.NoError(t, err) + require.Equal(t, record2.Count, response.PaymentAccountCount.Count) +} + +func TestPaymentAccountsByOwnerQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner1 := sample.RandAccAddress() + record1 := types.PaymentAccountCount{ + Owner: owner1.String(), + Count: 2, + } + keeper.SetPaymentAccountCount(ctx, &record1) + + response, err := keeper.GetPaymentAccountsByOwner(ctx, &types.QueryGetPaymentAccountsByOwnerRequest{ + Owner: owner1.String(), + }) + require.NoError(t, err) + require.Equal(t, int(record1.Count), len(response.PaymentAccounts)) +} + +func TestStreamRecordAllQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner1 := sample.RandAccAddress() + record1 := types.NewStreamRecord(owner1, ctx.BlockTime().Unix()) + keeper.SetStreamRecord(ctx, record1) + + owner2 := sample.RandAccAddress() + record2 := types.NewStreamRecord(owner2, ctx.BlockTime().Unix()) + keeper.SetStreamRecord(ctx, record2) + + response, err := keeper.StreamRecordAll(ctx, &types.QueryAllStreamRecordRequest{}) + require.NoError(t, err) + require.Equal(t, 2, len(response.StreamRecord)) +} + +func TestStreamRecordQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner1 := sample.RandAccAddress() + record1 := types.NewStreamRecord(owner1, ctx.BlockTime().Unix()) + keeper.SetStreamRecord(ctx, record1) + + owner2 := sample.RandAccAddress() + record2 := types.NewStreamRecord(owner2, ctx.BlockTime().Unix()) + keeper.SetStreamRecord(ctx, record2) + + response, err := keeper.StreamRecord(ctx, &types.QueryGetStreamRecordRequest{ + Account: owner1.String(), + }) + require.NoError(t, err) + require.Equal(t, owner1.String(), response.StreamRecord.Account) + + response, err = keeper.StreamRecord(ctx, &types.QueryGetStreamRecordRequest{ + Account: owner2.String(), + }) + require.NoError(t, err) + require.Equal(t, owner2.String(), response.StreamRecord.Account) +} + +func TestOutFlowQuery(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + owner := sample.RandAccAddress() + record1 := types.OutFlow{ + ToAddress: sample.RandAccAddress().String(), + Rate: sdkmath.Int{}, + Status: types.OUT_FLOW_STATUS_FROZEN, + } + keeper.SetOutFlow(ctx, owner, &record1) + + record2 := types.OutFlow{ + ToAddress: sample.RandAccAddress().String(), + Rate: sdkmath.Int{}, + Status: types.OUT_FLOW_STATUS_ACTIVE, + } + keeper.SetOutFlow(ctx, owner, &record2) + + response, err := keeper.OutFlows(ctx, &types.QueryOutFlowsRequest{ + Account: owner.String(), + }) + require.NoError(t, err) + require.Equal(t, 2, len(response.OutFlows)) +} diff --git a/x/payment/keeper/msg_server_create_payment_account_test.go b/x/payment/keeper/msg_server_create_payment_account_test.go new file mode 100644 index 000000000..5abf93b27 --- /dev/null +++ b/x/payment/keeper/msg_server_create_payment_account_test.go @@ -0,0 +1,35 @@ +package keeper_test + +import ( + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func (s *TestSuite) TestCreatePaymentAccount() { + creator := sample.RandAccAddress() + + // create first one + msg := types.NewMsgCreatePaymentAccount(creator.String()) + _, err := s.msgServer.CreatePaymentAccount(s.ctx, msg) + s.Require().NoError(err) + + record, _ := s.paymentKeeper.GetPaymentAccountCount(s.ctx, creator) + s.Require().True(record.Count == 1) + + // create another one + msg = types.NewMsgCreatePaymentAccount(creator.String()) + _, err = s.msgServer.CreatePaymentAccount(s.ctx, msg) + s.Require().NoError(err) + + record, _ = s.paymentKeeper.GetPaymentAccountCount(s.ctx, creator) + s.Require().True(record.Count == 2) + + // limit the number of payment account + params := s.paymentKeeper.GetParams(s.ctx) + params.PaymentAccountCountLimit = 2 + _ = s.paymentKeeper.SetParams(s.ctx, params) + + msg = types.NewMsgCreatePaymentAccount(creator.String()) + _, err = s.msgServer.CreatePaymentAccount(s.ctx, msg) + s.Require().Error(err) +} diff --git a/x/payment/keeper/msg_server_deposit_test.go b/x/payment/keeper/msg_server_deposit_test.go new file mode 100644 index 000000000..72a42a131 --- /dev/null +++ b/x/payment/keeper/msg_server_deposit_test.go @@ -0,0 +1,72 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + "github.com/golang/mock/gomock" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func (s *TestSuite) TestDeposit_ToBankAccount() { + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(nil).AnyTimes() + s.accountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()). + Return(true).AnyTimes() + + // deposit to self + owner := sample.RandAccAddress() + msg := types.NewMsgDeposit(owner.String(), owner.String(), sdkmath.NewInt(1000)) + _, err := s.msgServer.Deposit(s.ctx, msg) + s.Require().NoError(err) + record, _ := s.paymentKeeper.GetStreamRecord(s.ctx, owner) + s.Require().True(record.StaticBalance.Int64() == msg.Amount.Int64()) + + // deposit to other account + to := sample.RandAccAddress() + msg = types.NewMsgDeposit(owner.String(), to.String(), sdkmath.NewInt(1000)) + _, err = s.msgServer.Deposit(s.ctx, msg) + s.Require().NoError(err) + record, _ = s.paymentKeeper.GetStreamRecord(s.ctx, to) + s.Require().True(record.StaticBalance.Int64() == msg.Amount.Int64()) +} + +func (s *TestSuite) TestDeposit_ToActiveStreamRecord() { + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(nil).AnyTimes() + s.accountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()). + Return(true).AnyTimes() + + owner := sample.RandAccAddress() + paymentAddr := sample.RandAccAddress() + record := types.NewStreamRecord(paymentAddr, s.ctx.BlockTime().Unix()) + s.paymentKeeper.SetStreamRecord(s.ctx, record) + + // deposit to active stream record + msg := types.NewMsgDeposit(owner.String(), paymentAddr.String(), sdkmath.NewInt(1000)) + _, err := s.msgServer.Deposit(s.ctx, msg) + s.Require().NoError(err) + recordAfter, _ := s.paymentKeeper.GetStreamRecord(s.ctx, paymentAddr) + s.Require().True(recordAfter.StaticBalance.Int64() == msg.Amount.Int64()) +} + +func (s *TestSuite) TestDeposit_ToFrozenStreamRecord() { + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(nil).AnyTimes() + s.accountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()). + Return(true).AnyTimes() + + owner := sample.RandAccAddress() + paymentAddr := sample.RandAccAddress() + record := types.NewStreamRecord(paymentAddr, s.ctx.BlockTime().Unix()) + record.Status = types.STREAM_ACCOUNT_STATUS_FROZEN + record.FrozenNetflowRate = sdkmath.NewInt(-10) + s.paymentKeeper.SetStreamRecord(s.ctx, record) + + // deposit to frozen stream record + msg := types.NewMsgDeposit(owner.String(), paymentAddr.String(), sdkmath.NewInt(1000)) + _, err := s.msgServer.Deposit(s.ctx, msg) + s.Require().NoError(err) + recordAfter, _ := s.paymentKeeper.GetStreamRecord(s.ctx, paymentAddr) + s.Require().True(recordAfter.StaticBalance.Int64() == msg.Amount.Int64()) +} diff --git a/x/payment/keeper/msg_server_disable_refund_test.go b/x/payment/keeper/msg_server_disable_refund_test.go new file mode 100644 index 000000000..172e93aca --- /dev/null +++ b/x/payment/keeper/msg_server_disable_refund_test.go @@ -0,0 +1,39 @@ +package keeper_test + +import ( + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func (s *TestSuite) TestDisableRefund() { + // payment account does not exist + creator1 := sample.RandAccAddress() + msg := types.NewMsgDisableRefund(creator1.String(), sample.RandAccAddress().String()) + _, err := s.msgServer.DisableRefund(s.ctx, msg) + s.Require().Error(err) + + // the message is not from the owner + creator2 := sample.RandAccAddress() + createAccountMsg := types.NewMsgCreatePaymentAccount(creator2.String()) + _, err = s.msgServer.CreatePaymentAccount(s.ctx, createAccountMsg) + s.Require().NoError(err) + paymentAccountAddr := s.paymentKeeper.DerivePaymentAccountAddress(creator2, 0) + record, _ := s.paymentKeeper.GetPaymentAccount(s.ctx, paymentAccountAddr) + s.Require().True(record.Owner == creator2.String()) + + msg = types.NewMsgDisableRefund(creator1.String(), paymentAccountAddr.String()) + _, err = s.msgServer.DisableRefund(s.ctx, msg) + s.Require().Error(err) + + // disable refund success + msg = types.NewMsgDisableRefund(creator2.String(), paymentAccountAddr.String()) + _, err = s.msgServer.DisableRefund(s.ctx, msg) + s.Require().NoError(err) + record, _ = s.paymentKeeper.GetPaymentAccount(s.ctx, paymentAccountAddr) + s.Require().True(record.Refundable == false) + + // cannot disable it again + msg = types.NewMsgDisableRefund(creator2.String(), paymentAccountAddr.String()) + _, err = s.msgServer.DisableRefund(s.ctx, msg) + s.Require().Error(err) +} diff --git a/x/payment/keeper/msg_server_test.go b/x/payment/keeper/msg_server_test.go new file mode 100644 index 000000000..c72134039 --- /dev/null +++ b/x/payment/keeper/msg_server_test.go @@ -0,0 +1,115 @@ +package keeper_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/challenge" + "github.com/bnb-chain/greenfield/x/payment/keeper" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +type TestSuite struct { + suite.Suite + + cdc codec.Codec + paymentKeeper *keeper.Keeper + + bankKeeper *types.MockBankKeeper + accountKeeper *types.MockAccountKeeper + spKeeper *types.MockSpKeeper + + ctx sdk.Context + queryClient types.QueryClient + msgServer types.MsgServer +} + +func (s *TestSuite) SetupTest() { + encCfg := moduletestutil.MakeTestEncodingConfig(challenge.AppModuleBasic{}) + key := storetypes.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) + s.ctx = testCtx.Ctx + + ctrl := gomock.NewController(s.T()) + + bankKeeper := types.NewMockBankKeeper(ctrl) + accountKeeper := types.NewMockAccountKeeper(ctrl) + spKeeper := types.NewMockSpKeeper(ctrl) + + s.paymentKeeper = keeper.NewKeeper( + encCfg.Codec, + key, + bankKeeper, + accountKeeper, + spKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + s.cdc = encCfg.Codec + s.bankKeeper = bankKeeper + s.accountKeeper = accountKeeper + s.spKeeper = spKeeper + + err := s.paymentKeeper.SetParams(s.ctx, types.DefaultParams()) + s.Require().NoError(err) + + queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, encCfg.InterfaceRegistry) + types.RegisterQueryServer(queryHelper, s.paymentKeeper) + + s.queryClient = types.NewQueryClient(queryHelper) + s.msgServer = keeper.NewMsgServerImpl(*s.paymentKeeper) +} + +func TestTestSuite(t *testing.T) { + suite.Run(t, new(TestSuite)) +} + +func (s *TestSuite) TestUpdateParams() { + params := types.DefaultParams() + params.MaxAutoResumeFlowCount = 5 + + tests := []struct { + name string + msg types.MsgUpdateParams + err bool + }{ + { + name: "invalid authority", + msg: types.MsgUpdateParams{ + Authority: sample.AccAddress(), + }, + err: true, + }, { + name: "success", + msg: types.MsgUpdateParams{ + Authority: s.paymentKeeper.GetAuthority(), + Params: params, + }, + }, + } + for _, tt := range tests { + s.T().Run(tt.name, func(t *testing.T) { + _, err := s.msgServer.UpdateParams(s.ctx, &tt.msg) + if tt.err { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } + + // verify storage + s.Require().Equal(params, s.paymentKeeper.GetParams(s.ctx)) +} diff --git a/x/payment/keeper/msg_server_withdraw_test.go b/x/payment/keeper/msg_server_withdraw_test.go new file mode 100644 index 000000000..8f836ee1f --- /dev/null +++ b/x/payment/keeper/msg_server_withdraw_test.go @@ -0,0 +1,86 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + "github.com/golang/mock/gomock" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func (s *TestSuite) TestWithdraw_Fail() { + creator1 := sample.RandAccAddress() + paymentAddr1 := sample.RandAccAddress() + + // stream record not found + msg := types.NewMsgWithdraw(creator1.String(), sample.RandAccAddress().String(), sdkmath.NewInt(100)) + _, err := s.msgServer.Withdraw(s.ctx, msg) + s.Require().Error(err) + + // stream record is frozen + record1 := types.NewStreamRecord(paymentAddr1, s.ctx.BlockTime().Unix()) + record1.Status = types.STREAM_ACCOUNT_STATUS_FROZEN + s.paymentKeeper.SetStreamRecord(s.ctx, record1) + + msg = types.NewMsgWithdraw(creator1.String(), paymentAddr1.String(), sdkmath.NewInt(100)) + _, err = s.msgServer.Withdraw(s.ctx, msg) + s.Require().Error(err) + + record1.Status = types.STREAM_ACCOUNT_STATUS_ACTIVE + s.paymentKeeper.SetStreamRecord(s.ctx, record1) + + // payment account does not exist + msg = types.NewMsgWithdraw(creator1.String(), paymentAddr1.String(), sdkmath.NewInt(100)) + _, err = s.msgServer.Withdraw(s.ctx, msg) + s.Require().Error(err) + + // the message is not from the owner + creator2 := sample.RandAccAddress() + createAccountMsg := types.NewMsgCreatePaymentAccount(creator2.String()) + _, err = s.msgServer.CreatePaymentAccount(s.ctx, createAccountMsg) + s.Require().NoError(err) + paymentAddr2 := s.paymentKeeper.DerivePaymentAccountAddress(creator2, 0) + paymentAccountRecord, _ := s.paymentKeeper.GetPaymentAccount(s.ctx, paymentAddr2) + s.Require().True(paymentAccountRecord.Owner == creator2.String()) + + record2 := types.NewStreamRecord(paymentAddr2, s.ctx.BlockTime().Unix()) + s.paymentKeeper.SetStreamRecord(s.ctx, record2) + + msg = types.NewMsgWithdraw(creator1.String(), paymentAddr2.String(), sdkmath.NewInt(100)) + _, err = s.msgServer.Withdraw(s.ctx, msg) + s.Require().Error(err) + + // cannot withdraw after disable refund + disableRefundMsg := types.NewMsgDisableRefund(creator2.String(), paymentAddr2.String()) + _, err = s.msgServer.DisableRefund(s.ctx, disableRefundMsg) + s.Require().NoError(err) + paymentAccountRecord, _ = s.paymentKeeper.GetPaymentAccount(s.ctx, paymentAddr2) + s.Require().True(paymentAccountRecord.Refundable == false) + + msg = types.NewMsgWithdraw(creator2.String(), paymentAddr2.String(), sdkmath.NewInt(100)) + _, err = s.msgServer.Withdraw(s.ctx, msg) + s.Require().Error(err) +} + +func (s *TestSuite) TestWithdraw_Success() { + s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(nil).AnyTimes() + s.accountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()). + Return(true).AnyTimes() + + creator := sample.RandAccAddress() + createAccountMsg := types.NewMsgCreatePaymentAccount(creator.String()) + _, err := s.msgServer.CreatePaymentAccount(s.ctx, createAccountMsg) + s.Require().NoError(err) + paymentAddr := s.paymentKeeper.DerivePaymentAccountAddress(creator, 0) + paymentAccountRecord, _ := s.paymentKeeper.GetPaymentAccount(s.ctx, paymentAddr) + s.Require().True(paymentAccountRecord.Owner == creator.String()) + + record := types.NewStreamRecord(paymentAddr, s.ctx.BlockTime().Unix()) + record.StaticBalance = sdkmath.NewInt(200) + s.paymentKeeper.SetStreamRecord(s.ctx, record) + + msg := types.NewMsgWithdraw(creator.String(), paymentAddr.String(), sdkmath.NewInt(100)) + _, err = s.msgServer.Withdraw(s.ctx, msg) + s.Require().NoError(err) +} diff --git a/x/payment/keeper/payment_account_count.go b/x/payment/keeper/payment_account_count.go index e57f00c92..b00b009c0 100644 --- a/x/payment/keeper/payment_account_count.go +++ b/x/payment/keeper/payment_account_count.go @@ -37,17 +37,6 @@ func (k Keeper) GetPaymentAccountCount( return val, true } -// RemovePaymentAccountCount removes a paymentAccountCount from the store -func (k Keeper) RemovePaymentAccountCount( - ctx sdk.Context, - owner sdk.AccAddress, -) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PaymentAccountCountKeyPrefix) - store.Delete(types.PaymentAccountCountKey( - owner, - )) -} - // GetAllPaymentAccountCount returns all paymentAccountCount func (k Keeper) GetAllPaymentAccountCount(ctx sdk.Context) (list []types.PaymentAccountCount) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PaymentAccountCountKeyPrefix) diff --git a/x/payment/keeper/payment_account_count_test.go b/x/payment/keeper/payment_account_count_test.go new file mode 100644 index 000000000..8e11e5eaa --- /dev/null +++ b/x/payment/keeper/payment_account_count_test.go @@ -0,0 +1,46 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func TestPaymentAccountCount(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + + owner1 := sample.RandAccAddress() + paymentCount1 := &types.PaymentAccountCount{ + Owner: owner1.String(), + Count: 1, + } + + owner2 := sample.RandAccAddress() + paymentCount2 := &types.PaymentAccountCount{ + Owner: owner2.String(), + Count: 3, + } + + // set + keeper.SetPaymentAccountCount(ctx, paymentCount1) + keeper.SetPaymentAccountCount(ctx, paymentCount2) + + // get + resp1, _ := keeper.GetPaymentAccountCount(ctx, owner1) + require.True(t, resp1.Owner == owner1.String()) + require.True(t, resp1.Count == paymentCount1.Count) + + resp2, _ := keeper.GetPaymentAccountCount(ctx, owner2) + require.True(t, resp2.Owner == owner2.String()) + require.True(t, resp2.Count == paymentCount2.Count) + + _, found := keeper.GetPaymentAccountCount(ctx, sample.RandAccAddress()) + require.True(t, !found) + + // get all + resp3 := keeper.GetAllPaymentAccountCount(ctx) + require.True(t, len(resp3) == 2) +} diff --git a/x/payment/keeper/payment_account_test.go b/x/payment/keeper/payment_account_test.go new file mode 100644 index 000000000..801881b4e --- /dev/null +++ b/x/payment/keeper/payment_account_test.go @@ -0,0 +1,52 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func TestPaymentAccount(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + + owner1 := sample.RandAccAddress() + addr1 := sample.RandAccAddress() + paymentAccount1 := &types.PaymentAccount{ + Owner: owner1.String(), + Addr: addr1.String(), + Refundable: true, + } + + owner2 := sample.RandAccAddress() + addr2 := sample.RandAccAddress() + paymentAccount2 := &types.PaymentAccount{ + Owner: owner2.String(), + Addr: addr2.String(), + Refundable: false, + } + + // set + keeper.SetPaymentAccount(ctx, paymentAccount1) + keeper.SetPaymentAccount(ctx, paymentAccount2) + + // get + resp1, _ := keeper.GetPaymentAccount(ctx, addr1) + require.True(t, resp1.Owner == owner1.String()) + require.True(t, resp1.Addr == addr1.String()) + require.True(t, resp1.Refundable == paymentAccount1.Refundable) + + resp2, _ := keeper.GetPaymentAccount(ctx, addr2) + require.True(t, resp2.Owner == owner2.String()) + require.True(t, resp2.Addr == addr2.String()) + require.True(t, resp2.Refundable == paymentAccount2.Refundable) + + _, found := keeper.GetPaymentAccount(ctx, sample.RandAccAddress()) + require.True(t, !found) + + // get all + resp3 := keeper.GetAllPaymentAccount(ctx) + require.True(t, len(resp3) == 2) +} diff --git a/x/payment/keeper/price_test.go b/x/payment/keeper/price_test.go new file mode 100644 index 000000000..15f2ba89d --- /dev/null +++ b/x/payment/keeper/price_test.go @@ -0,0 +1,39 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/x/payment/types" + sp "github.com/bnb-chain/greenfield/x/sp/types" +) + +func TestGetStoragePrice(t *testing.T) { + keeper, ctx, depKeepers := makePaymentKeeper(t) + + primaryPrice := sp.SpStoragePrice{ + ReadPrice: sdk.NewDecWithPrec(2, 2), + FreeReadQuota: 0, + StorePrice: sdk.NewDecWithPrec(5, 1), + } + depKeepers.SpKeeper.EXPECT().GetSpStoragePriceByTime(gomock.Any(), gomock.Any(), gomock.Any()). + Return(primaryPrice, nil).AnyTimes() + + secondaryPrice := sp.SecondarySpStorePrice{ + StorePrice: sdk.NewDecWithPrec(2, 1), + } + depKeepers.SpKeeper.EXPECT().GetSecondarySpStorePriceByTime(gomock.Any(), gomock.Any()). + Return(secondaryPrice, nil).AnyTimes() + + resp, err := keeper.GetStoragePrice(ctx, types.StoragePriceParams{ + PrimarySp: 1, + PriceTime: 1, + }) + require.NoError(t, err) + require.True(t, resp.ReadPrice.Equal(primaryPrice.ReadPrice)) + require.True(t, resp.PrimaryStorePrice.Equal(primaryPrice.StorePrice)) + require.True(t, resp.SecondaryStorePrice.Equal(secondaryPrice.StorePrice)) +} diff --git a/x/payment/keeper/storage_fee_charge_test.go b/x/payment/keeper/storage_fee_charge_test.go index 7faf16db7..018a6cc0d 100644 --- a/x/payment/keeper/storage_fee_charge_test.go +++ b/x/payment/keeper/storage_fee_charge_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "errors" "sort" "testing" "time" @@ -49,42 +50,6 @@ func TestApplyFlowChanges(t *testing.T) { t.Logf("sp stream record: %+v", spStreamRecord) } -func TestSettleStreamRecord(t *testing.T) { - keeper, ctx, _ := makePaymentKeeper(t) - ctx = ctx.WithBlockTime(time.Unix(100, 0)) - user := sample.RandAccAddress() - rate := sdkmath.NewInt(-100) - staticBalance := sdkmath.NewInt(1e10) - change := types.NewDefaultStreamRecordChangeWithAddr(user).WithRateChange(rate).WithStaticBalanceChange(staticBalance) - sr := &types.StreamRecord{Account: user.String(), - OutFlowCount: 1, - StaticBalance: sdkmath.ZeroInt(), - BufferBalance: sdkmath.ZeroInt(), - LockBalance: sdkmath.ZeroInt(), - NetflowRate: sdkmath.ZeroInt(), - FrozenNetflowRate: sdkmath.ZeroInt(), - } - keeper.SetStreamRecord(ctx, sr) - _, err := keeper.UpdateStreamRecordByAddr(ctx, change) - require.NoError(t, err) - // check - streamRecord, found := keeper.GetStreamRecord(ctx, user) - require.True(t, found) - t.Logf("stream record: %+v", streamRecord) - // 345 seconds pass - var seconds int64 = 345 - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(seconds) * time.Second)) - change = types.NewDefaultStreamRecordChangeWithAddr(user) - _, err = keeper.UpdateStreamRecordByAddr(ctx, change) - require.NoError(t, err) - userStreamRecord2, _ := keeper.GetStreamRecord(ctx, user) - t.Logf("stream record after %d seconds: %+v", seconds, userStreamRecord2) - require.Equal(t, userStreamRecord2.StaticBalance, streamRecord.StaticBalance.Add(rate.Mul(sdkmath.NewInt(seconds)))) - require.Equal(t, userStreamRecord2.BufferBalance, streamRecord.BufferBalance) - require.Equal(t, userStreamRecord2.NetflowRate, streamRecord.NetflowRate) - require.Equal(t, userStreamRecord2.CrudTimestamp, streamRecord.CrudTimestamp+seconds) -} - func TestMergeStreamRecordChanges(t *testing.T) { users := []sdk.AccAddress{ sample.RandAccAddress(), @@ -116,96 +81,180 @@ func TestMergeStreamRecordChanges(t *testing.T) { }) } -func TestAutoForceSettle(t *testing.T) { - keeper, ctx, depKeepers := makePaymentKeeper(t) - t.Logf("depKeepers: %+v", depKeepers) - params := keeper.GetParams(ctx) - var startTime int64 = 100 - ctx = ctx.WithBlockTime(time.Unix(startTime, 0)) - user := sample.RandAccAddress() - rate := sdkmath.NewInt(100) - sp := sample.RandAccAddress() - userInitBalance := sdkmath.NewInt(int64(100*params.VersionedParams.ReserveTime) + 1) // just enough for reserve - // init balance - streamRecordChanges := []types.StreamRecordChange{ - *types.NewDefaultStreamRecordChangeWithAddr(user).WithStaticBalanceChange(userInitBalance), +func TestApplyUserFlows_ActiveStreamRecord(t *testing.T) { + keeper, ctx, deepKeepers := makePaymentKeeper(t) + ctx = ctx.WithIsCheckTx(true) + + from := sample.RandAccAddress() + userFlows := types.UserFlows{ + From: from, } - err := keeper.ApplyStreamRecordChanges(ctx, streamRecordChanges) - require.NoError(t, err) - userStreamRecord, found := keeper.GetStreamRecord(ctx, user) - t.Logf("user stream record: %+v", userStreamRecord) - require.True(t, found) - flowChanges := []types.OutFlow{ - {ToAddress: sp.String(), Rate: rate}, + + toAddr1 := sample.RandAccAddress() + outFlow1 := types.OutFlow{ + ToAddress: toAddr1.String(), + Rate: sdkmath.NewInt(100), + } + userFlows.Flows = append(userFlows.Flows, outFlow1) + + toAddr2 := sample.RandAccAddress() + outFlow2 := types.OutFlow{ + ToAddress: toAddr2.String(), + Rate: sdkmath.NewInt(200), } - userFlows := types.UserFlows{Flows: flowChanges, From: user} + userFlows.Flows = append(userFlows.Flows, outFlow2) + + // no bank account + deepKeepers.AccountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()). + Return(false).Times(1) + err := keeper.ApplyUserFlowsList(ctx, []types.UserFlows{userFlows}) + require.ErrorContains(t, err, "balance not enough") + + // has bank account, but balance is not enough + deepKeepers.AccountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()). + Return(true).AnyTimes() + deepKeepers.BankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(errors.New("transfer error")).Times(1) + err = keeper.ApplyUserFlowsList(ctx, []types.UserFlows{userFlows}) + require.ErrorContains(t, err, "balance not enough") + + // has bank account, and balance is enough + deepKeepers.BankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(nil).AnyTimes() err = keeper.ApplyUserFlowsList(ctx, []types.UserFlows{userFlows}) require.NoError(t, err) - userStreamRecord, found = keeper.GetStreamRecord(ctx, user) - t.Logf("user stream record: %+v", userStreamRecord) - require.True(t, found) - outFlows := keeper.GetOutFlows(ctx, user) - require.Equal(t, 1, len(outFlows)) - require.Equal(t, outFlows[0].ToAddress, sp.String()) - spStreamRecord, found := keeper.GetStreamRecord(ctx, sp) - t.Logf("sp stream record: %+v", spStreamRecord) - require.True(t, found) - require.Equal(t, spStreamRecord.NetflowRate, rate) - require.Equal(t, spStreamRecord.StaticBalance, sdkmath.ZeroInt()) - require.Equal(t, spStreamRecord.BufferBalance, sdkmath.ZeroInt()) - // check auto settle queue - autoSettleQueue := keeper.GetAllAutoSettleRecord(ctx) - t.Logf("auto settle queue: %+v", autoSettleQueue) - require.Equal(t, len(autoSettleQueue), 1) - require.Equal(t, autoSettleQueue[0].Addr, user.String()) - require.Equal(t, autoSettleQueue[0].Timestamp, startTime+int64(params.VersionedParams.ReserveTime)-int64(params.ForcedSettleTime)) - // 1 day pass - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(86400) * time.Second)) - // update and deposit to user for extra 100s - depKeepers.AccountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()).Return(false).AnyTimes() - userAddBalance := rate.MulRaw(100) - change := types.NewDefaultStreamRecordChangeWithAddr(user).WithStaticBalanceChange(userAddBalance) - ret, err := keeper.UpdateStreamRecordByAddr(ctx, change) - require.NoError(t, err) - userStreamRecord = ret - t.Logf("user stream record: %+v", userStreamRecord) - require.True(t, found) - require.True(t, userStreamRecord.StaticBalance.IsNegative()) - change = types.NewDefaultStreamRecordChangeWithAddr(sp) - _, err = keeper.UpdateStreamRecordByAddr(ctx, change) - require.NoError(t, err) - spStreamRecord, _ = keeper.GetStreamRecord(ctx, sp) - t.Logf("sp stream record: %+v", spStreamRecord) - autoSettleQueue2 := keeper.GetAllAutoSettleRecord(ctx) - t.Logf("auto settle queue: %+v", autoSettleQueue2) - require.Equal(t, autoSettleQueue[0].Timestamp+100, autoSettleQueue2[0].Timestamp) - // reserve time - forced settle time - 1 day + 101s pass - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(params.VersionedParams.ReserveTime-params.ForcedSettleTime-86400+101) * time.Second)) - usrBeforeForceSettle, _ := keeper.GetStreamRecord(ctx, user) - t.Logf("usrBeforeForceSettle: %s", usrBeforeForceSettle) - ctx = ctx.WithValue(types.ForceUpdateStreamRecordKey, true) - time.Sleep(1 * time.Second) - keeper.AutoSettle(ctx) + fromRecord, _ := keeper.GetStreamRecord(ctx, from) + require.True(t, fromRecord.Status == types.STREAM_ACCOUNT_STATUS_ACTIVE) + require.True(t, fromRecord.NetflowRate.Int64() == -300) + require.True(t, fromRecord.StaticBalance.Int64() == 0) + require.True(t, fromRecord.FrozenNetflowRate.Int64() == 0) + require.True(t, fromRecord.LockBalance.Int64() == 0) + require.True(t, fromRecord.BufferBalance.Int64() > 0) - usrAfterForceSettle, found := keeper.GetStreamRecord(ctx, user) - require.True(t, found) - t.Logf("usrAfterForceSettle: %s", usrAfterForceSettle) - // user has been force settled - require.Equal(t, usrAfterForceSettle.StaticBalance, sdkmath.ZeroInt()) - require.Equal(t, usrAfterForceSettle.BufferBalance, sdkmath.ZeroInt()) - require.Equal(t, usrAfterForceSettle.NetflowRate, sdkmath.ZeroInt()) - require.Equal(t, usrAfterForceSettle.Status, types.STREAM_ACCOUNT_STATUS_FROZEN) - change = types.NewDefaultStreamRecordChangeWithAddr(sp) - _, err = keeper.UpdateStreamRecordByAddr(ctx, change) + to1Record, _ := keeper.GetStreamRecord(ctx, toAddr1) + require.True(t, to1Record.Status == types.STREAM_ACCOUNT_STATUS_ACTIVE) + require.True(t, to1Record.NetflowRate.Int64() == 100) + require.True(t, to1Record.StaticBalance.Int64() == 0) + require.True(t, to1Record.FrozenNetflowRate.Int64() == 0) + require.True(t, to1Record.LockBalance.Int64() == 0) + require.True(t, to1Record.BufferBalance.Int64() == 0) + + to2Record, _ := keeper.GetStreamRecord(ctx, toAddr2) + require.True(t, to2Record.Status == types.STREAM_ACCOUNT_STATUS_ACTIVE) + require.True(t, to2Record.NetflowRate.Int64() == 200) + require.True(t, to2Record.StaticBalance.Int64() == 0) + require.True(t, to2Record.FrozenNetflowRate.Int64() == 0) + require.True(t, to2Record.LockBalance.Int64() == 0) + require.True(t, to2Record.BufferBalance.Int64() == 0) +} + +func TestApplyUserFlows_Frozen(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + + from := sample.RandAccAddress() + toAddr1 := sample.RandAccAddress() + toAddr2 := sample.RandAccAddress() + + // the account is frozen, and during auto settle or auto resume + fromStreamRecord := types.NewStreamRecord(from, ctx.BlockTime().Unix()) + fromStreamRecord.Status = types.STREAM_ACCOUNT_STATUS_FROZEN + fromStreamRecord.NetflowRate = sdkmath.NewInt(-100) + fromStreamRecord.FrozenNetflowRate = sdkmath.NewInt(-200) + fromStreamRecord.StaticBalance = sdkmath.ZeroInt() + fromStreamRecord.OutFlowCount = 4 + keeper.SetStreamRecord(ctx, fromStreamRecord) + + keeper.SetOutFlow(ctx, from, &types.OutFlow{ + ToAddress: toAddr1.String(), + Rate: sdkmath.NewInt(40), + Status: types.OUT_FLOW_STATUS_ACTIVE, + }) + keeper.SetOutFlow(ctx, from, &types.OutFlow{ + ToAddress: sample.RandAccAddress().String(), + Rate: sdkmath.NewInt(60), + Status: types.OUT_FLOW_STATUS_ACTIVE, + }) + keeper.SetOutFlow(ctx, from, &types.OutFlow{ + ToAddress: toAddr2.String(), + Rate: sdkmath.NewInt(120), + Status: types.OUT_FLOW_STATUS_FROZEN, + }) + keeper.SetOutFlow(ctx, from, &types.OutFlow{ + ToAddress: sample.RandAccAddress().String(), + Rate: sdkmath.NewInt(80), + Status: types.OUT_FLOW_STATUS_FROZEN, + }) + + to1StreamRecord := types.NewStreamRecord(toAddr1, ctx.BlockTime().Unix()) + to1StreamRecord.NetflowRate = sdkmath.NewInt(300) + to1StreamRecord.StaticBalance = sdkmath.NewInt(300) + keeper.SetStreamRecord(ctx, to1StreamRecord) + + to2StreamRecord := types.NewStreamRecord(toAddr2, ctx.BlockTime().Unix()) + to2StreamRecord.NetflowRate = sdkmath.NewInt(400) + to2StreamRecord.StaticBalance = sdkmath.NewInt(400) + keeper.SetStreamRecord(ctx, to2StreamRecord) + + userFlows := types.UserFlows{ + From: from, + } + + outFlow1 := types.OutFlow{ + ToAddress: toAddr1.String(), + Rate: sdkmath.NewInt(-40), + } + userFlows.Flows = append(userFlows.Flows, outFlow1) + + outFlow2 := types.OutFlow{ + ToAddress: toAddr2.String(), + Rate: sdkmath.NewInt(-60), + } + userFlows.Flows = append(userFlows.Flows, outFlow2) + + // update frozen stream record needs force flag + err := keeper.ApplyUserFlowsList(ctx, []types.UserFlows{userFlows}) + require.ErrorContains(t, err, "frozen") + + ctx = ctx.WithValue(types.ForceUpdateStreamRecordKey, true) + err = keeper.ApplyUserFlowsList(ctx, []types.UserFlows{userFlows}) require.NoError(t, err) - spStreamRecord, _ = keeper.GetStreamRecord(ctx, sp) - t.Logf("sp stream record: %+v", spStreamRecord) - autoSettleQueue3 := keeper.GetAllAutoSettleRecord(ctx) - t.Logf("auto settle queue: %+v", autoSettleQueue3) - require.Equal(t, len(autoSettleQueue3), 0) - govStreamRecord, found := keeper.GetStreamRecord(ctx, types.GovernanceAddress) - require.True(t, found) - t.Logf("gov stream record: %+v", govStreamRecord) - require.Equal(t, govStreamRecord.StaticBalance.Add(spStreamRecord.StaticBalance), userInitBalance.Add(userAddBalance)) + + fromRecord, _ := keeper.GetStreamRecord(ctx, from) + require.True(t, fromRecord.Status == types.STREAM_ACCOUNT_STATUS_FROZEN) + require.True(t, fromRecord.StaticBalance.Int64() == 0) + require.True(t, fromRecord.NetflowRate.Int64() == -60) + require.True(t, fromRecord.FrozenNetflowRate.Int64() == -140) + require.True(t, fromRecord.LockBalance.Int64() == 0) + require.True(t, fromRecord.BufferBalance.Int64() == 0) + + outFlows := keeper.GetOutFlows(ctx, from) + require.True(t, len(outFlows) == 3) + // the out flow to toAddr1 should be deleted + // the out flow to toAddr2 should be still there + to1Found := false + for _, outFlow := range outFlows { + if outFlow.ToAddress == toAddr1.String() { + to1Found = true + } + if outFlow.ToAddress == toAddr2.String() { + require.True(t, outFlow.Rate.Int64() == 60) + require.True(t, outFlow.Status == types.OUT_FLOW_STATUS_FROZEN) + } + } + require.True(t, !to1Found) + + to1Record, _ := keeper.GetStreamRecord(ctx, toAddr1) + require.True(t, to1Record.Status == types.STREAM_ACCOUNT_STATUS_ACTIVE) + require.True(t, to1Record.NetflowRate.Int64() == 260) + require.True(t, to1Record.FrozenNetflowRate.Int64() == 0) + require.True(t, to1Record.LockBalance.Int64() == 0) + require.True(t, to1Record.BufferBalance.Int64() == 0) + + to2Record, _ := keeper.GetStreamRecord(ctx, toAddr2) + require.True(t, to2Record.Status == types.STREAM_ACCOUNT_STATUS_ACTIVE) + require.True(t, to2Record.NetflowRate.Int64() == 400) // the outflow is frozen, which means the flow had been deduced + require.True(t, to2Record.FrozenNetflowRate.Int64() == 0) + require.True(t, to2Record.LockBalance.Int64() == 0) + require.True(t, to2Record.BufferBalance.Int64() == 0) } diff --git a/x/payment/keeper/stream_record_test.go b/x/payment/keeper/stream_record_test.go index 4c6f57327..2f5c13855 100644 --- a/x/payment/keeper/stream_record_test.go +++ b/x/payment/keeper/stream_record_test.go @@ -787,5 +787,134 @@ func TestUpdateStreamRecord_FrozenAccountLockBalance(t *testing.T) { require.True(t, streamRecord.Status == types.STREAM_ACCOUNT_STATUS_FROZEN) require.True(t, streamRecord.LockBalance.IsZero()) require.True(t, streamRecord.StaticBalance.Int64() == 1000) +} + +func TestSettleStreamRecord(t *testing.T) { + keeper, ctx, _ := makePaymentKeeper(t) + ctx = ctx.WithBlockTime(time.Unix(100, 0)) + user := sample.RandAccAddress() + rate := sdkmath.NewInt(-100) + staticBalance := sdkmath.NewInt(1e10) + change := types.NewDefaultStreamRecordChangeWithAddr(user).WithRateChange(rate).WithStaticBalanceChange(staticBalance) + sr := &types.StreamRecord{Account: user.String(), + OutFlowCount: 1, + StaticBalance: sdkmath.ZeroInt(), + BufferBalance: sdkmath.ZeroInt(), + LockBalance: sdkmath.ZeroInt(), + NetflowRate: sdkmath.ZeroInt(), + FrozenNetflowRate: sdkmath.ZeroInt(), + } + keeper.SetStreamRecord(ctx, sr) + _, err := keeper.UpdateStreamRecordByAddr(ctx, change) + require.NoError(t, err) + // check + streamRecord, found := keeper.GetStreamRecord(ctx, user) + require.True(t, found) + t.Logf("stream record: %+v", streamRecord) + // 345 seconds pass + var seconds int64 = 345 + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(seconds) * time.Second)) + change = types.NewDefaultStreamRecordChangeWithAddr(user) + _, err = keeper.UpdateStreamRecordByAddr(ctx, change) + require.NoError(t, err) + userStreamRecord2, _ := keeper.GetStreamRecord(ctx, user) + t.Logf("stream record after %d seconds: %+v", seconds, userStreamRecord2) + require.Equal(t, userStreamRecord2.StaticBalance, streamRecord.StaticBalance.Add(rate.Mul(sdkmath.NewInt(seconds)))) + require.Equal(t, userStreamRecord2.BufferBalance, streamRecord.BufferBalance) + require.Equal(t, userStreamRecord2.NetflowRate, streamRecord.NetflowRate) + require.Equal(t, userStreamRecord2.CrudTimestamp, streamRecord.CrudTimestamp+seconds) +} + +func TestAutoForceSettle(t *testing.T) { + keeper, ctx, depKeepers := makePaymentKeeper(t) + t.Logf("depKeepers: %+v", depKeepers) + params := keeper.GetParams(ctx) + var startTime int64 = 100 + ctx = ctx.WithBlockTime(time.Unix(startTime, 0)) + user := sample.RandAccAddress() + rate := sdkmath.NewInt(100) + sp := sample.RandAccAddress() + userInitBalance := sdkmath.NewInt(int64(100*params.VersionedParams.ReserveTime) + 1) // just enough for reserve + // init balance + streamRecordChanges := []types.StreamRecordChange{ + *types.NewDefaultStreamRecordChangeWithAddr(user).WithStaticBalanceChange(userInitBalance), + } + err := keeper.ApplyStreamRecordChanges(ctx, streamRecordChanges) + require.NoError(t, err) + userStreamRecord, found := keeper.GetStreamRecord(ctx, user) + t.Logf("user stream record: %+v", userStreamRecord) + require.True(t, found) + flowChanges := []types.OutFlow{ + {ToAddress: sp.String(), Rate: rate}, + } + userFlows := types.UserFlows{Flows: flowChanges, From: user} + err = keeper.ApplyUserFlowsList(ctx, []types.UserFlows{userFlows}) + require.NoError(t, err) + userStreamRecord, found = keeper.GetStreamRecord(ctx, user) + t.Logf("user stream record: %+v", userStreamRecord) + require.True(t, found) + outFlows := keeper.GetOutFlows(ctx, user) + require.Equal(t, 1, len(outFlows)) + require.Equal(t, outFlows[0].ToAddress, sp.String()) + spStreamRecord, found := keeper.GetStreamRecord(ctx, sp) + t.Logf("sp stream record: %+v", spStreamRecord) + require.True(t, found) + require.Equal(t, spStreamRecord.NetflowRate, rate) + require.Equal(t, spStreamRecord.StaticBalance, sdkmath.ZeroInt()) + require.Equal(t, spStreamRecord.BufferBalance, sdkmath.ZeroInt()) + // check auto settle queue + autoSettleQueue := keeper.GetAllAutoSettleRecord(ctx) + t.Logf("auto settle queue: %+v", autoSettleQueue) + require.Equal(t, len(autoSettleQueue), 1) + require.Equal(t, autoSettleQueue[0].Addr, user.String()) + require.Equal(t, autoSettleQueue[0].Timestamp, startTime+int64(params.VersionedParams.ReserveTime)-int64(params.ForcedSettleTime)) + // 1 day pass + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(86400) * time.Second)) + // update and deposit to user for extra 100s + depKeepers.AccountKeeper.EXPECT().HasAccount(gomock.Any(), gomock.Any()).Return(false).AnyTimes() + userAddBalance := rate.MulRaw(100) + change := types.NewDefaultStreamRecordChangeWithAddr(user).WithStaticBalanceChange(userAddBalance) + ret, err := keeper.UpdateStreamRecordByAddr(ctx, change) + require.NoError(t, err) + userStreamRecord = ret + t.Logf("user stream record: %+v", userStreamRecord) + require.True(t, found) + require.True(t, userStreamRecord.StaticBalance.IsNegative()) + change = types.NewDefaultStreamRecordChangeWithAddr(sp) + _, err = keeper.UpdateStreamRecordByAddr(ctx, change) + require.NoError(t, err) + spStreamRecord, _ = keeper.GetStreamRecord(ctx, sp) + t.Logf("sp stream record: %+v", spStreamRecord) + autoSettleQueue2 := keeper.GetAllAutoSettleRecord(ctx) + t.Logf("auto settle queue: %+v", autoSettleQueue2) + require.Equal(t, autoSettleQueue[0].Timestamp+100, autoSettleQueue2[0].Timestamp) + // reserve time - forced settle time - 1 day + 101s pass + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(params.VersionedParams.ReserveTime-params.ForcedSettleTime-86400+101) * time.Second)) + usrBeforeForceSettle, _ := keeper.GetStreamRecord(ctx, user) + t.Logf("usrBeforeForceSettle: %s", usrBeforeForceSettle) + + ctx = ctx.WithValue(types.ForceUpdateStreamRecordKey, true) + time.Sleep(1 * time.Second) + keeper.AutoSettle(ctx) + usrAfterForceSettle, found := keeper.GetStreamRecord(ctx, user) + require.True(t, found) + t.Logf("usrAfterForceSettle: %s", usrAfterForceSettle) + // user has been force settled + require.Equal(t, usrAfterForceSettle.StaticBalance, sdkmath.ZeroInt()) + require.Equal(t, usrAfterForceSettle.BufferBalance, sdkmath.ZeroInt()) + require.Equal(t, usrAfterForceSettle.NetflowRate, sdkmath.ZeroInt()) + require.Equal(t, usrAfterForceSettle.Status, types.STREAM_ACCOUNT_STATUS_FROZEN) + change = types.NewDefaultStreamRecordChangeWithAddr(sp) + _, err = keeper.UpdateStreamRecordByAddr(ctx, change) + require.NoError(t, err) + spStreamRecord, _ = keeper.GetStreamRecord(ctx, sp) + t.Logf("sp stream record: %+v", spStreamRecord) + autoSettleQueue3 := keeper.GetAllAutoSettleRecord(ctx) + t.Logf("auto settle queue: %+v", autoSettleQueue3) + require.Equal(t, len(autoSettleQueue3), 0) + govStreamRecord, found := keeper.GetStreamRecord(ctx, types.GovernanceAddress) + require.True(t, found) + t.Logf("gov stream record: %+v", govStreamRecord) + require.Equal(t, govStreamRecord.StaticBalance.Add(spStreamRecord.StaticBalance), userInitBalance.Add(userAddBalance)) } From 11371f097ea6b4cb22c59f2d3f849fd668e1fb42 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Fri, 28 Jul 2023 15:25:36 +0800 Subject: [PATCH 08/24] fix: fix returned operation type in group cross chain app (#385) --- x/storage/keeper/cross_app_group.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/storage/keeper/cross_app_group.go b/x/storage/keeper/cross_app_group.go index 665f74cf6..77b8e27a0 100644 --- a/x/storage/keeper/cross_app_group.go +++ b/x/storage/keeper/cross_app_group.go @@ -78,7 +78,7 @@ func (app *GroupApp) ExecuteFailAckPackage(ctx sdk.Context, appCtx *sdk.CrossCha operationType = types.OperationDeleteGroup result = app.handleDeleteGroupFailAckPackage(ctx, appCtx, p) case *types.UpdateGroupMemberSynPackage: - operationType = types.OperationDeleteGroup + operationType = types.OperationUpdateGroupMember result = app.handleUpdateGroupMemberFailAckPackage(ctx, appCtx, p) default: panic("unknown cross chain ack package type") From 186de549b655427fe36c15d6b8f3bc3c8f570a1c Mon Sep 17 00:00:00 2001 From: Roshan <48975233+Pythonberg1997@users.noreply.github.com> Date: Fri, 28 Jul 2023 15:26:44 +0800 Subject: [PATCH 09/24] chore: add tests for bridge module (#381) * chore: add tests for bridge module * refactor sample methods --- .github/workflows/{e2e-test.yml => tests.yml} | 12 +- .testcoverage.yml | 12 +- Makefile | 9 +- e2e/tests/bridge_test.go | 42 ++++ testutil/sample/sample.go | 28 +-- types/grn_test.go | 2 +- x/bridge/client/cli/query.go | 2 +- x/bridge/keeper/cross_app.go | 69 +----- x/bridge/keeper/cross_app_test.go | 210 ++++++------------ x/bridge/{ => keeper}/genesis.go | 7 +- x/bridge/keeper/genesis_test.go | 29 +++ x/bridge/module.go | 6 +- x/bridge/module_simulation.go | 2 +- x/bridge/types/message_transfer_out_test.go | 12 +- x/bridge/types/types.go | 66 +++--- x/challenge/keeper/msg_server_attest_test.go | 12 +- x/challenge/keeper/msg_server_submit_test.go | 22 +- .../keeper/msg_server_update_params_test.go | 2 +- x/challenge/module_simulation.go | 2 +- x/challenge/types/message_attest_test.go | 16 +- x/challenge/types/message_submit_test.go | 16 +- .../types/message_update_params_test.go | 4 +- x/payment/client/cli/query.go | 2 +- x/payment/module.go | 2 +- x/payment/module_simulation.go | 2 +- x/permission/module_simulation.go | 2 +- x/sp/keeper/msg_server_test.go | 2 +- x/sp/keeper/sp_test.go | 20 +- x/sp/module_simulation.go | 2 +- x/storage/module_simulation.go | 2 +- .../message_cancel_migrate_bucket_test.go | 2 +- .../message_complete_migrate_bucket_test.go | 2 +- .../types/message_migrate_bucket_test.go | 2 +- x/storage/types/message_object_test.go | 58 ++--- x/storage/types/message_test.go | 76 +++---- x/virtualgroup/module_simulation.go | 2 +- .../types/message_cancel_swap_out_test.go | 4 +- .../types/message_complete_swap_out_test.go | 4 +- x/virtualgroup/types/message_test.go | 20 +- 39 files changed, 378 insertions(+), 408 deletions(-) rename .github/workflows/{e2e-test.yml => tests.yml} (90%) rename x/bridge/{ => keeper}/genesis.go (64%) create mode 100644 x/bridge/keeper/genesis_test.go diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/tests.yml similarity index 90% rename from .github/workflows/e2e-test.yml rename to .github/workflows/tests.yml index 00dabebfe..8800e6dd0 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: End to End Test +name: Tests / Code Coverage on: push: @@ -9,7 +9,7 @@ on: pull_request: jobs: - end-to-end-test: + tests: strategy: matrix: go-version: [1.20.x] @@ -44,22 +44,22 @@ jobs: ${{ runner.os }}-go- - name: Setup GitHub Token run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/ - - name: run e2e test + - name: run tests run: | - make e2e_test + make test - 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 '## 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 + make check-coverage >> coverage-report.txt echo '```' >> coverage-report.txt echo >> coverage-report.txt echo '
' >> coverage-report.txt diff --git a/.testcoverage.yml b/.testcoverage.yml index 8415c3bba..052ad1dc8 100644 --- a/.testcoverage.yml +++ b/.testcoverage.yml @@ -34,9 +34,15 @@ exclude: - \.pb\.gw\.go$ # excludes all protobuf generated files - .*_mocks.go$ # excludes all protobuf generated files - testutil/.* - - e2e/.* + - e2e/.* + - types/.* + - sdk/.* - internal/sequence/.* - + - x/types/.* + - .*/simulation/.* + - .*/module.go + - .*/module_simulation.go + # 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 +# current OS file path separator to properly work on Windows diff --git a/Makefile b/Makefile index b1c725ad7..f9653fbf1 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ docker-image: go mod vendor # temporary, should be removed after open source docker build . -t ${IMAGE_NAME} -test: +unit_test: go test -failfast $$(go list ./... | grep -v e2e | grep -v sdk) e2e_init_localchain: build @@ -56,12 +56,15 @@ e2e_init_localchain: build bash ./deployment/localup/localup.sh generate 1 7 e2e_test: e2e_init_localchain - go test -p 1 -failfast -v ./e2e/... -coverpkg=./... -covermode=atomic -coverprofile=./coverage.out -timeout 99999s + go test -p 1 -failfast -v ./e2e/... -timeout 99999s + +test: e2e_init_localchain + go test -p 1 -failfast -v $$(go list ./... | grep -v sdk) -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 +check-coverage: install-go-test-coverage @go-test-coverage --config=./.testcoverage.yml || true lint: diff --git a/e2e/tests/bridge_test.go b/e2e/tests/bridge_test.go index 4d6df2237..7795a9a44 100644 --- a/e2e/tests/bridge_test.go +++ b/e2e/tests/bridge_test.go @@ -8,9 +8,12 @@ import ( "time" sdkmath "cosmossdk.io/math" + sdkClient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" crosschaintypes "github.com/cosmos/cosmos-sdk/x/crosschain/types" @@ -23,6 +26,7 @@ import ( "github.com/bnb-chain/greenfield/e2e/core" gnfdtypes "github.com/bnb-chain/greenfield/sdk/types" types2 "github.com/bnb-chain/greenfield/sdk/types" + "github.com/bnb-chain/greenfield/x/bridge/client/cli" bridgetypes "github.com/bnb-chain/greenfield/x/bridge/types" ) @@ -36,6 +40,44 @@ func (s *BridgeTestSuite) SetupSuite() { func (s *BridgeTestSuite) SetupTest() {} +func (s *BridgeTestSuite) TestCliQuery() { + ctx := context.Background() + cliCtx := &sdkClient.Context{Client: s.TmClient.TmClient, Codec: s.Client.GetCodec()} + ctx = context.WithValue(ctx, sdkClient.ClientContextKey, cliCtx) + queryCmd := cli.GetQueryCmd() + + // query params + queryCmd.SetArgs([]string{"params"}) + s.Require().NoError(queryCmd.ExecuteContext(ctx)) +} + +func (s *BridgeTestSuite) TestCliTx() { + ctx := context.Background() + txCfg := authtx.NewTxConfig(s.Client.GetCodec(), []signing.SignMode{signing.SignMode_SIGN_MODE_EIP_712}) + cliCtx := &sdkClient.Context{ + FromAddress: s.Validator.GetAddr(), + Client: s.TmClient.TmClient, + InterfaceRegistry: s.Client.GetCodec().InterfaceRegistry(), + Codec: s.Client.GetCodec(), + From: s.Validator.String(), + AccountRetriever: authtypes.AccountRetriever{}, + ChainID: s.Config.ChainId, + TxConfig: txCfg, + SkipConfirm: true, + Simulate: true, + } + ctx = context.WithValue(ctx, sdkClient.ClientContextKey, cliCtx) + txCmd := cli.GetTxCmd() + + // wrong to address + txCmd.SetArgs([]string{"transfer-out", "test", "1000000000000000000BNB"}) + s.Require().Contains(txCmd.ExecuteContext(ctx).Error(), "invalid address hex length") + + // tx transfer-out + txCmd.SetArgs([]string{"transfer-out", sdk.AccAddress("test").String(), "1000000000000000000BNB"}) + s.Require().NoError(txCmd.ExecuteContext(ctx)) +} + func (s *BridgeTestSuite) TestTransferOut() { users := s.GenAndChargeAccounts(2, 1000000) diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 1c3561189..be3f0b796 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -5,20 +5,28 @@ import ( "encoding/hex" "github.com/cometbft/cometbft/crypto/tmhash" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/prysmaticlabs/prysm/crypto/bls" ) -// AccAddress returns a sample account address -func AccAddress() string { - pk := ed25519.GenPrivKey().PubKey() - addr := pk.Address() - return sdk.AccAddress(addr).String() +func RandAccAddress() sdk.AccAddress { + pk, err := ethsecp256k1.GenPrivKey() + if err != nil { + panic(err) + } + return sdk.AccAddress(pk.PubKey().Address()) +} + +func RandAccAddressHex() string { + pk, err := ethsecp256k1.GenPrivKey() + if err != nil { + panic(err) + } + return sdk.AccAddress(pk.PubKey().Address()).String() } -func RandSignBytes() (addr sdk.AccAddress, signBytes []byte, sig []byte) { +func RandSignBytes() (addr sdk.AccAddress, signBytes, sig []byte) { signBytes = RandStr(256) privKey, _ := ethsecp256k1.GenPrivKey() @@ -28,12 +36,6 @@ func RandSignBytes() (addr sdk.AccAddress, signBytes []byte, sig []byte) { return addr, signBytes, sig } -func RandAccAddress() sdk.AccAddress { - pk := ed25519.GenPrivKey().PubKey() - addr := pk.Address() - return sdk.AccAddress(addr) -} - func Checksum() []byte { return sdk.Keccak256(RandStr(256)) } diff --git a/types/grn_test.go b/types/grn_test.go index f85fd1e9d..f5dd6a33b 100644 --- a/types/grn_test.go +++ b/types/grn_test.go @@ -17,7 +17,7 @@ func TestGRNBasic(t *testing.T) { var grn types3.GRN testBucketName := storageutils.GenRandomBucketName() testObjectName := storageutils.GenRandomObjectName() - testAcc := sample.AccAddress() + testAcc := sample.RandAccAddressHex() testGroupName := storageutils.GenRandomGroupName() err := grn.ParseFromString("grn:b::"+testBucketName, false) diff --git a/x/bridge/client/cli/query.go b/x/bridge/client/cli/query.go index f15f54f23..dbdb274b9 100644 --- a/x/bridge/client/cli/query.go +++ b/x/bridge/client/cli/query.go @@ -10,7 +10,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { +func GetQueryCmd() *cobra.Command { // Group bridge queries under a subcommand cmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/bridge/keeper/cross_app.go b/x/bridge/keeper/cross_app.go index de0a4dc08..15c3e4e16 100644 --- a/x/bridge/keeper/cross_app.go +++ b/x/bridge/keeper/cross_app.go @@ -2,11 +2,9 @@ package keeper import ( "encoding/hex" - "math/big" "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" crosschaintypes "github.com/cosmos/cosmos-sdk/x/crosschain/types" "github.com/bnb-chain/greenfield/x/bridge/types" @@ -38,17 +36,6 @@ func NewTransferOutApp(keeper Keeper) *TransferOutApp { } } -func (app *TransferOutApp) CheckPackage(refundPackage *types.TransferOutRefundPackage) error { - if refundPackage.RefundAddr.Empty() { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "refund address is empty") - } - - if refundPackage.RefundAmount.Cmp(big.NewInt(0)) < 0 { - return errors.Wrapf(types.ErrInvalidAmount, "amount to refund should not be negative") - } - return nil -} - func (app *TransferOutApp) ExecuteAckPackage(ctx sdk.Context, appCtx *sdk.CrossChainAppContext, payload []byte) sdk.ExecuteResult { if len(payload) == 0 { return sdk.ExecuteResult{} @@ -58,22 +45,14 @@ func (app *TransferOutApp) ExecuteAckPackage(ctx sdk.Context, appCtx *sdk.CrossC refundPackage, err := types.DeserializeTransferOutRefundPackage(payload) if err != nil { - app.bridgeKeeper.Logger(ctx).Error("unmarshal transfer out refund claim error", "err", err.Error(), "claim", hex.EncodeToString(payload)) - return sdk.ExecuteResult{ - Err: err, - } - } - - err = app.CheckPackage(refundPackage) - if err != nil { - app.bridgeKeeper.Logger(ctx).Error("check transfer out refund package error", "err", err.Error(), "claim", hex.EncodeToString(payload)) + app.bridgeKeeper.Logger(ctx).Error("decode transfer out refund claim error", "err", err.Error(), "claim", hex.EncodeToString(payload)) return sdk.ExecuteResult{ Err: err, } } denom := app.bridgeKeeper.stakingKeeper.BondDenom(ctx) // only support native token so far - err = app.bridgeKeeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, crosschaintypes.ModuleName, refundPackage.RefundAddr, + err = app.bridgeKeeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, crosschaintypes.ModuleName, refundPackage.RefundAddress, sdk.Coins{ sdk.Coin{ Denom: denom, @@ -89,7 +68,7 @@ func (app *TransferOutApp) ExecuteAckPackage(ctx sdk.Context, appCtx *sdk.CrossC } err = ctx.EventManager().EmitTypedEvent(&types.EventCrossTransferOutRefund{ - RefundAddress: refundPackage.RefundAddr.String(), + RefundAddress: refundPackage.RefundAddress.String(), Amount: &sdk.Coin{ Denom: denom, Amount: sdk.NewIntFromBigInt(refundPackage.RefundAmount), @@ -116,12 +95,6 @@ func (app *TransferOutApp) ExecuteFailAckPackage(ctx sdk.Context, appCtx *sdk.Cr } } - if transferOutPackage.Amount.Cmp(big.NewInt(0)) < 0 { - return sdk.ExecuteResult{ - Err: errors.Wrapf(types.ErrInvalidAmount, "amount to refund should not be negative"), - } - } - denom := app.bridgeKeeper.stakingKeeper.BondDenom(ctx) // only support native token so far err = app.bridgeKeeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, crosschaintypes.ModuleName, transferOutPackage.RefundAddress, sdk.Coins{ @@ -173,22 +146,6 @@ func NewTransferInApp(bridgeKeeper Keeper) *TransferInApp { } } -func (app *TransferInApp) CheckTransferInSynPackage(transferInPackage *types.TransferInSynPackage) error { - if transferInPackage.Amount.Cmp(big.NewInt(0)) < 0 { - return errors.Wrapf(types.ErrInvalidAmount, "amount should not be negative") - } - - if transferInPackage.ReceiverAddress.Empty() { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "receiver address should not be empty") - } - - if transferInPackage.RefundAddress.Empty() { - return errors.Wrapf(types.ErrInvalidAddress, "refund address should not be empty") - } - - return nil -} - func (app *TransferInApp) ExecuteAckPackage(ctx sdk.Context, header *sdk.CrossChainAppContext, payload []byte) sdk.ExecuteResult { app.bridgeKeeper.Logger(ctx).Error("received transfer in ack package", "payload", hex.EncodeToString(payload)) return sdk.ExecuteResult{} @@ -202,14 +159,8 @@ func (app *TransferInApp) ExecuteFailAckPackage(ctx sdk.Context, header *sdk.Cro func (app *TransferInApp) ExecuteSynPackage(ctx sdk.Context, appCtx *sdk.CrossChainAppContext, payload []byte) sdk.ExecuteResult { transferInPackage, err := types.DeserializeTransferInSynPackage(payload) if err != nil { - app.bridgeKeeper.Logger(ctx).Error("unmarshal transfer in claim error", "err", err.Error(), "claim", string(payload)) - panic("unmarshal transfer in claim error") - } - - err = app.CheckTransferInSynPackage(transferInPackage) - if err != nil { - app.bridgeKeeper.Logger(ctx).Error("check transfer in package error", "err", err.Error(), "claim", string(payload)) - panic(err) + app.bridgeKeeper.Logger(ctx).Error("decode transfer in claim error", "err", err.Error(), "claim", string(payload)) + panic("decode transfer in claim error") } denom := app.bridgeKeeper.stakingKeeper.BondDenom(ctx) @@ -218,14 +169,14 @@ func (app *TransferInApp) ExecuteSynPackage(ctx sdk.Context, appCtx *sdk.CrossCh err = app.bridgeKeeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, crosschaintypes.ModuleName, transferInPackage.ReceiverAddress, sdk.Coins{amount}) if err != nil { app.bridgeKeeper.Logger(ctx).Error("send coins error", "err", err.Error()) - refundPackage, err := app.bridgeKeeper.GetRefundTransferInPayload(transferInPackage, uint32(types.REFUND_REASON_INSUFFICIENT_BALANCE)) - if err != nil { - app.bridgeKeeper.Logger(ctx).Error("get refund transfer in payload error", "err", err.Error()) - panic(err) + refundPackage, refundErr := app.bridgeKeeper.GetRefundTransferInPayload(transferInPackage, uint32(types.REFUND_REASON_INSUFFICIENT_BALANCE)) + if refundErr != nil { + app.bridgeKeeper.Logger(ctx).Error("get refund transfer in payload error", "err", refundErr.Error()) + panic(refundErr) } return sdk.ExecuteResult{ Payload: refundPackage, - Err: errors.Wrapf(types.ErrInvalidLength, "balance of cross chain module is insufficient"), + Err: errors.Wrapf(types.ErrInvalidPackage, "send coins error: %s", err.Error()), } } diff --git a/x/bridge/keeper/cross_app_test.go b/x/bridge/keeper/cross_app_test.go index 00289c465..970f5bffe 100644 --- a/x/bridge/keeper/cross_app_test.go +++ b/x/bridge/keeper/cross_app_test.go @@ -1,76 +1,22 @@ package keeper_test import ( - "bytes" + "fmt" "math/big" - "testing" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/golang/mock/gomock" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/bnb-chain/greenfield/x/bridge/keeper" "github.com/bnb-chain/greenfield/x/bridge/types" ) -func TestTransferOutCheck(t *testing.T) { - tests := []struct { - refundPackage types.TransferOutRefundPackage - expectedPass bool - errorMsg string - }{ - { - refundPackage: types.TransferOutRefundPackage{ - RefundAmount: big.NewInt(1), - RefundAddr: []byte{}, - RefundReason: 0, - }, - expectedPass: false, - errorMsg: "refund address is empty", - }, - { - refundPackage: types.TransferOutRefundPackage{ - RefundAmount: big.NewInt(-1), - RefundAddr: bytes.Repeat([]byte{1}, 20), - RefundReason: 0, - }, - expectedPass: false, - errorMsg: "amount to refund should not be negative", - }, - { - refundPackage: types.TransferOutRefundPackage{ - RefundAmount: big.NewInt(1), - RefundAddr: bytes.Repeat([]byte{1}, 20), - RefundReason: 0, - }, - expectedPass: true, - }, - } - - crossApp := keeper.NewTransferOutApp(keeper.Keeper{}) - for _, test := range tests { - err := crossApp.CheckPackage(&test.refundPackage) - if test.expectedPass { - require.Nil(t, err, "error should be nil") - } else { - require.NotNil(t, err, " error should not be nil") - require.Contains(t, err.Error(), test.errorMsg) - } - } -} - func (s *TestSuite) TestTransferOutAck() { - addr1, _, err := testutil.GenerateCoinKey(hd.Secp256k1, s.cdc) - s.Require().Nil(err, "generate key failed") - refundPackage := types.TransferOutRefundPackage{ - RefundAmount: big.NewInt(1), - RefundAddr: addr1, - RefundReason: 1, + RefundAmount: big.NewInt(1), + RefundAddress: sdk.AccAddress("refundAddress"), + RefundReason: 1, } packageBytes, err := refundPackage.Serialize() @@ -79,20 +25,32 @@ func (s *TestSuite) TestTransferOutAck() { transferOutApp := keeper.NewTransferOutApp(*s.bridgeKeeper) s.stakingKeeper.EXPECT().BondDenom(gomock.Any()).Return("BNB").AnyTimes() - s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - result := transferOutApp.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) + // empty payload + result := transferOutApp.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, nil) + s.Require().Nil(result.Err, "result should be nil") + s.Require().Nil(result.Payload, "result should be nil") + + // wrong payload + result = transferOutApp.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, []byte{1}) + s.Require().Contains(result.Err.Error(), "deserialize transfer out refund package failed") + + // send coins failed + s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("test send coins error")).Times(1) + result = transferOutApp.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) + s.Require().Contains(result.Err.Error(), "test send coins error") + + // success case + s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) + result = transferOutApp.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) s.Require().Nil(err, result.Err, "error should be nil") } -func (s *TestSuite) TestTransferOutFailAck() { - addr1, _, err := testutil.GenerateCoinKey(hd.Secp256k1, s.cdc) - s.Require().Nil(err, "generate key failed") - +func (s *TestSuite) TestTransferOutSynAndFailAck() { synPackage := types.TransferOutSynPackage{ Amount: big.NewInt(1), Recipient: sdk.AccAddress{}, - RefundAddress: addr1, + RefundAddress: sdk.AccAddress("refundAddress"), } packageBytes, err := synPackage.Serialize() @@ -102,75 +60,32 @@ func (s *TestSuite) TestTransferOutFailAck() { s.crossChainKeeper.EXPECT().CreateRawIBCPackageWithFee(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(uint64(0), nil).AnyTimes() s.stakingKeeper.EXPECT().BondDenom(gomock.Any()).Return("BNB").AnyTimes() - s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - result := transferOutApp.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) - s.Require().Nil(err, result.Err, "error should be nil") -} + // syn package + result := transferOutApp.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, nil) + s.Require().Nil(result.Payload, "result should be nil") -func TestTransferInCheck(t *testing.T) { - tests := []struct { - transferInPackage types.TransferInSynPackage - expectedPass bool - errorMsg string - }{ - { - transferInPackage: types.TransferInSynPackage{ - Amount: big.NewInt(1), - ReceiverAddress: sdk.AccAddress{}, - RefundAddress: sdk.AccAddress{1}, - }, - expectedPass: false, - errorMsg: "receiver address should not be empty", - }, - { - transferInPackage: types.TransferInSynPackage{ - Amount: big.NewInt(1), - ReceiverAddress: sdk.AccAddress{1}, - RefundAddress: sdk.AccAddress{}, - }, - expectedPass: false, - errorMsg: "refund address should not be empty", - }, - { - transferInPackage: types.TransferInSynPackage{ - Amount: big.NewInt(-1), - ReceiverAddress: sdk.AccAddress{1}, - RefundAddress: sdk.AccAddress{1}, - }, - expectedPass: false, - errorMsg: "amount should not be negative", - }, - { - transferInPackage: types.TransferInSynPackage{ - Amount: big.NewInt(1), - ReceiverAddress: sdk.AccAddress{1}, - RefundAddress: sdk.AccAddress{1}, - }, - expectedPass: true, - }, - } + // fail ack package + // wrong payload + result = transferOutApp.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, []byte{1}) + s.Require().Contains(result.Err.Error(), "deserialize transfer out syn package failed") - crossApp := keeper.NewTransferInApp(keeper.Keeper{}) - for _, test := range tests { - err := crossApp.CheckTransferInSynPackage(&test.transferInPackage) - if test.expectedPass { - require.Nil(t, err, "error should be nil") - } else { - require.NotNil(t, err, " error should not be nil") - require.Contains(t, err.Error(), test.errorMsg) - } - } -} + // send coins failed + s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("test send coins error")).Times(1) + result = transferOutApp.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) + s.Require().Contains(result.Err.Error(), "send coins error") -func (s *TestSuite) TestTransferInSyn() { - addr1, _, err := testutil.GenerateCoinKey(hd.Secp256k1, s.cdc) - s.Require().Nil(err, "generate key failed") + // success case + s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) + result = transferOutApp.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) + s.Require().Nil(err, result.Err, "error should be nil") +} +func (s *TestSuite) TestTransferIn() { transferInSynPackage := types.TransferInSynPackage{ Amount: big.NewInt(1), - ReceiverAddress: addr1, - RefundAddress: sdk.AccAddress{1}, + ReceiverAddress: sdk.AccAddress("receiverAddress"), + RefundAddress: sdk.AccAddress("refundAddress"), } packageBytes, err := transferInSynPackage.Serialize() @@ -180,20 +95,35 @@ func (s *TestSuite) TestTransferInSyn() { s.crossChainKeeper.EXPECT().CreateRawIBCPackageWithFee(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(uint64(0), nil).AnyTimes() s.stakingKeeper.EXPECT().BondDenom(gomock.Any()).Return("BNB").AnyTimes() - s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + // syn package + // wrong payload + s.Require().Panics(func() { transferInApp.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, []byte{1}) }) + + // send coins failed and refund + s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("test send coins error")).Times(1) result := transferInApp.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) - s.Require().Nil(err, result.Err, "error should be nil") -} + s.Require().Contains(result.Err.Error(), "test send coins error") + unpacked, err := types.TransferInRefundPackageArgs.Unpack(result.Payload) + s.Require().NoError(err) -func (s *TestSuite) TestTransferInRefund() { - transferInRefundPackage := types.TransferInRefundPackage{ - RefundAmount: big.NewInt(1), - RefundAddress: sdk.AccAddress{123, 123, 123}, - RefundReason: 123, - } + unpackedStruct := abi.ConvertType(unpacked[0], types.TransferInRefundPackageStruct{}) + pkgStruct, ok := unpackedStruct.(types.TransferInRefundPackageStruct) + s.Require().True(ok) - packageBytes, err := transferInRefundPackage.Serialize() - assert.Equal(s.T(), packageBytes, hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000007b7b7b000000000000000000000000000000000000000000000000000000000000007b")) - s.Require().Nil(err, "encode refund package error") + s.Require().Equal(transferInSynPackage.Amount, pkgStruct.RefundAmount) + s.Require().Equal(transferInSynPackage.RefundAddress.String(), pkgStruct.RefundAddress.String()) + s.Require().Equal(uint32(types.REFUND_REASON_INSUFFICIENT_BALANCE), pkgStruct.RefundReason) + + // success case + s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) + result = transferInApp.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, packageBytes) + s.Require().Nil(result.Err, "error should be nil") + + // unexpected package type + result = transferInApp.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, nil) + s.Require().Nil(result.Payload, "result should be nil") + + result = transferInApp.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{Sequence: 1}, nil) + s.Require().Nil(result.Payload, "result should be nil") } diff --git a/x/bridge/genesis.go b/x/bridge/keeper/genesis.go similarity index 64% rename from x/bridge/genesis.go rename to x/bridge/keeper/genesis.go index 270b49939..58b9bb91c 100644 --- a/x/bridge/genesis.go +++ b/x/bridge/keeper/genesis.go @@ -1,14 +1,13 @@ -package bridge +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/bnb-chain/greenfield/x/bridge/keeper" "github.com/bnb-chain/greenfield/x/bridge/types" ) // InitGenesis initializes the module's state from a provided genesis state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { +func InitGenesis(ctx sdk.Context, k Keeper, genState types.GenesisState) { err := k.SetParams(ctx, genState.Params) if err != nil { panic(err) @@ -16,7 +15,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) } // ExportGenesis returns the module's exported genesis -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { +func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) diff --git a/x/bridge/keeper/genesis_test.go b/x/bridge/keeper/genesis_test.go new file mode 100644 index 000000000..4bf996edf --- /dev/null +++ b/x/bridge/keeper/genesis_test.go @@ -0,0 +1,29 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + + "github.com/bnb-chain/greenfield/x/bridge/keeper" + "github.com/bnb-chain/greenfield/x/bridge/types" +) + +func (s *TestSuite) TestExportGenesis() { + ctx := s.ctx + + s.Require().NoError(s.bridgeKeeper.SetParams(ctx, types.DefaultParams())) + exportGenesis := keeper.ExportGenesis(ctx, *s.bridgeKeeper) + + s.Require().Equal(types.DefaultParams().BscTransferOutRelayerFee, exportGenesis.Params.BscTransferOutRelayerFee) + s.Require().Equal(types.DefaultParams().BscTransferOutAckRelayerFee, exportGenesis.Params.BscTransferOutAckRelayerFee) +} + +func (s *TestSuite) TestInitGenesis() { + g := types.DefaultGenesis() + k := s.bridgeKeeper + keeper.InitGenesis(s.ctx, *k, *g) + + // Check that the genesis state was set correctly. + params := k.GetParams(s.ctx) + s.Require().Equal(sdkmath.NewInt(250000000000000), params.BscTransferOutRelayerFee) + s.Require().Equal(sdkmath.NewInt(0), params.BscTransferOutAckRelayerFee) +} diff --git a/x/bridge/module.go b/x/bridge/module.go index 0c6037851..42ba17b2c 100644 --- a/x/bridge/module.go +++ b/x/bridge/module.go @@ -81,7 +81,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- @@ -126,14 +126,14 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra // Initialize global index to index in genesis state cdc.MustUnmarshalJSON(gs, &genState) - InitGenesis(ctx, am.keeper, genState) + keeper.InitGenesis(ctx, am.keeper, genState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the module's exported genesis state as raw JSON bytes. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := ExportGenesis(ctx, am.keeper) + genState := keeper.ExportGenesis(ctx, am.keeper) return cdc.MustMarshalJSON(genState) } diff --git a/x/bridge/module_simulation.go b/x/bridge/module_simulation.go index b8881daa3..86d4388c9 100644 --- a/x/bridge/module_simulation.go +++ b/x/bridge/module_simulation.go @@ -16,7 +16,7 @@ import ( // avoid unused import issue var ( - _ = sample.AccAddress + _ = sample.RandAccAddressHex _ = bridgesimulation.FindAccount _ = simulation.MsgEntryKind _ = baseapp.Paramspace diff --git a/x/bridge/types/message_transfer_out_test.go b/x/bridge/types/message_transfer_out_test.go index 97ed5bf8f..f75f0936a 100644 --- a/x/bridge/types/message_transfer_out_test.go +++ b/x/bridge/types/message_transfer_out_test.go @@ -25,7 +25,7 @@ func TestMsgTransferOut_ValidateBasic(t *testing.T) { }, { name: "invalid to address", msg: MsgTransferOut{ - From: sample.AccAddress(), + From: sample.RandAccAddressHex(), To: "invalid address", }, err: sdkerrors.ErrInvalidAddress, @@ -33,7 +33,7 @@ func TestMsgTransferOut_ValidateBasic(t *testing.T) { { name: "invalid amount", msg: MsgTransferOut{ - From: sample.AccAddress(), + From: sample.RandAccAddressHex(), To: "0x0000000000000000000000000000000000001000", Amount: nil, }, @@ -42,7 +42,7 @@ func TestMsgTransferOut_ValidateBasic(t *testing.T) { { name: "invalid amount", msg: MsgTransferOut{ - From: sample.AccAddress(), + From: sample.RandAccAddressHex(), To: "0x0000000000000000000000000000000000001000", Amount: &sdk.Coin{ Denom: "%%%%%", @@ -54,7 +54,7 @@ func TestMsgTransferOut_ValidateBasic(t *testing.T) { { name: "invalid amount", msg: MsgTransferOut{ - From: sample.AccAddress(), + From: sample.RandAccAddressHex(), To: "0x0000000000000000000000000000000000001000", Amount: &sdk.Coin{ Denom: "coin", @@ -66,7 +66,7 @@ func TestMsgTransferOut_ValidateBasic(t *testing.T) { { name: "invalid amount", msg: MsgTransferOut{ - From: sample.AccAddress(), + From: sample.RandAccAddressHex(), To: "0x0000000000000000000000000000000000001000", Amount: &sdk.Coin{ Denom: "coin", @@ -78,7 +78,7 @@ func TestMsgTransferOut_ValidateBasic(t *testing.T) { { name: "invalid amount", msg: MsgTransferOut{ - From: sample.AccAddress(), + From: sample.RandAccAddressHex(), To: "0x0000000000000000000000000000000000001000", Amount: &sdk.Coin{ Denom: "coin", diff --git a/x/bridge/types/types.go b/x/bridge/types/types.go index af1fe1ced..37847b670 100644 --- a/x/bridge/types/types.go +++ b/x/bridge/types/types.go @@ -39,19 +39,19 @@ type TransferOutSynPackageStruct struct { } var ( - transferOutSynPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ + TransferOutSynPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ {Name: "Amount", Type: "uint256"}, {Name: "Recipient", Type: "address"}, {Name: "RefundAddress", Type: "address"}, }) - transferOutSynPackageArgs = abi.Arguments{ - {Type: transferOutSynPackageType}, + TransferOutSynPackageArgs = abi.Arguments{ + {Type: TransferOutSynPackageType}, } ) func (pkg *TransferOutSynPackage) Serialize() ([]byte, error) { - return transferOutSynPackageArgs.Pack(&TransferOutSynPackageStruct{ + return TransferOutSynPackageArgs.Pack(&TransferOutSynPackageStruct{ SafeBigInt(pkg.Amount), common.BytesToAddress(pkg.Recipient), common.BytesToAddress(pkg.RefundAddress), @@ -59,9 +59,9 @@ func (pkg *TransferOutSynPackage) Serialize() ([]byte, error) { } func DeserializeTransferOutSynPackage(serializedPackage []byte) (*TransferOutSynPackage, error) { - unpacked, err := transferOutSynPackageArgs.Unpack(serializedPackage) + unpacked, err := TransferOutSynPackageArgs.Unpack(serializedPackage) if err != nil { - return nil, errors.Wrapf(ErrInvalidPackage, "deserialize transfer out sync package failed") + return nil, errors.Wrapf(ErrInvalidPackage, "deserialize transfer out syn package failed") } unpackedStruct := abi.ConvertType(unpacked[0], TransferOutSynPackageStruct{}) @@ -79,39 +79,43 @@ func DeserializeTransferOutSynPackage(serializedPackage []byte) (*TransferOutSyn } type TransferOutRefundPackage struct { - RefundAmount *big.Int - RefundAddr sdk.AccAddress - RefundReason uint32 + RefundAmount *big.Int + RefundAddress sdk.AccAddress + RefundReason uint32 } type TransferOutRefundPackageStruct struct { - RefundAmount *big.Int - RefundAddr common.Address - RefundReason uint32 + RefundAmount *big.Int + RefundAddress common.Address + RefundReason uint32 } var ( - transferOutRefundPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ + TransferOutRefundPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ {Name: "RefundAmount", Type: "uint256"}, - {Name: "RefundAddr", Type: "address"}, + {Name: "RefundAddress", Type: "address"}, {Name: "RefundReason", Type: "uint32"}, }) - transferOutRefundPackageArgs = abi.Arguments{ - {Type: transferOutRefundPackageType}, + TransferOutRefundPackageArgs = abi.Arguments{ + {Type: TransferOutRefundPackageType}, } ) func (pkg *TransferOutRefundPackage) Serialize() ([]byte, error) { - return transferOutRefundPackageArgs.Pack(&TransferOutRefundPackageStruct{ + if pkg.RefundAmount.Cmp(big.NewInt(0)) < 0 { + return nil, errors.Wrapf(ErrInvalidPackage, "refund amount should not be negative") + } + + return TransferOutRefundPackageArgs.Pack(&TransferOutRefundPackageStruct{ SafeBigInt(pkg.RefundAmount), - common.BytesToAddress(pkg.RefundAddr), + common.BytesToAddress(pkg.RefundAddress), pkg.RefundReason, }) } func DeserializeTransferOutRefundPackage(serializedPackage []byte) (*TransferOutRefundPackage, error) { - unpacked, err := transferOutRefundPackageArgs.Unpack(serializedPackage) + unpacked, err := TransferOutRefundPackageArgs.Unpack(serializedPackage) if err != nil { return nil, errors.Wrapf(ErrInvalidPackage, "deserialize transfer out refund package failed") } @@ -124,7 +128,7 @@ func DeserializeTransferOutRefundPackage(serializedPackage []byte) (*TransferOut tp := TransferOutRefundPackage{ pkgStruct.RefundAmount, - pkgStruct.RefundAddr.Bytes(), + pkgStruct.RefundAddress.Bytes(), pkgStruct.RefundReason, } return &tp, nil @@ -143,19 +147,19 @@ type TransferInSynPackageStruct struct { } var ( - transferInSynPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ + TransferInSynPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ {Name: "Amount", Type: "uint256"}, {Name: "ReceiverAddress", Type: "address"}, {Name: "RefundAddress", Type: "address"}, }) - transferInSynPackageArgs = abi.Arguments{ - {Type: transferInSynPackageType}, + TransferInSynPackageArgs = abi.Arguments{ + {Type: TransferInSynPackageType}, } ) func (pkg *TransferInSynPackage) Serialize() ([]byte, error) { - return transferInSynPackageArgs.Pack(&TransferInSynPackageStruct{ + return TransferInSynPackageArgs.Pack(&TransferInSynPackageStruct{ SafeBigInt(pkg.Amount), common.BytesToAddress(pkg.ReceiverAddress), common.BytesToAddress(pkg.RefundAddress), @@ -163,7 +167,7 @@ func (pkg *TransferInSynPackage) Serialize() ([]byte, error) { } func DeserializeTransferInSynPackage(serializedPackage []byte) (*TransferInSynPackage, error) { - unpacked, err := transferInSynPackageArgs.Unpack(serializedPackage) + unpacked, err := TransferInSynPackageArgs.Unpack(serializedPackage) if err != nil { return nil, errors.Wrapf(ErrInvalidPackage, "deserialize transfer in sync package failed") } @@ -195,19 +199,23 @@ type TransferInRefundPackageStruct struct { } var ( - transferInRefundPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ + TransferInRefundPackageType, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ {Name: "RefundAmount", Type: "uint256"}, {Name: "RefundAddress", Type: "address"}, {Name: "RefundReason", Type: "uint32"}, }) - transferInRefundPackageArgs = abi.Arguments{ - {Type: transferInRefundPackageType}, + TransferInRefundPackageArgs = abi.Arguments{ + {Type: TransferInRefundPackageType}, } ) func (pkg *TransferInRefundPackage) Serialize() ([]byte, error) { - return transferInRefundPackageArgs.Pack(&TransferInRefundPackageStruct{ + if pkg.RefundAmount.Cmp(big.NewInt(0)) < 0 { + return nil, errors.Wrapf(ErrInvalidPackage, "refund amount should not be negative") + } + + return TransferInRefundPackageArgs.Pack(&TransferInRefundPackageStruct{ SafeBigInt(pkg.RefundAmount), common.BytesToAddress(pkg.RefundAddress), pkg.RefundReason, diff --git a/x/challenge/keeper/msg_server_attest_test.go b/x/challenge/keeper/msg_server_attest_test.go index 3d9f2831e..cfd03edeb 100644 --- a/x/challenge/keeper/msg_server_attest_test.go +++ b/x/challenge/keeper/msg_server_attest_test.go @@ -59,8 +59,8 @@ func (s *TestSuite) TestAttest_Invalid() { name: "unknown challenge", msg: types.MsgAttest{ ChallengeId: 1, - Submitter: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Submitter: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), }, err: types.ErrInvalidChallengeId, }, @@ -68,8 +68,8 @@ func (s *TestSuite) TestAttest_Invalid() { name: "not valid submitter", msg: types.MsgAttest{ ChallengeId: 100, - Submitter: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Submitter: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), }, err: types.ErrNotChallenger, }, @@ -78,7 +78,7 @@ func (s *TestSuite) TestAttest_Invalid() { msg: types.MsgAttest{ ChallengeId: 100, Submitter: validSubmitter.String(), - SpOperatorAddress: sample.AccAddress(), + SpOperatorAddress: sample.RandAccAddressHex(), ObjectId: math.NewUint(10), VoteValidatorSet: []uint64{}, VoteAggSignature: []byte{}, @@ -90,7 +90,7 @@ func (s *TestSuite) TestAttest_Invalid() { msg: types.MsgAttest{ ChallengeId: 100, Submitter: validSubmitter.String(), - SpOperatorAddress: sample.AccAddress(), + SpOperatorAddress: sample.RandAccAddressHex(), ObjectId: math.NewUint(10), VoteValidatorSet: []uint64{1}, VoteAggSignature: []byte{}, diff --git a/x/challenge/keeper/msg_server_submit_test.go b/x/challenge/keeper/msg_server_submit_test.go index 8bbf1a0fa..4b6146337 100644 --- a/x/challenge/keeper/msg_server_submit_test.go +++ b/x/challenge/keeper/msg_server_submit_test.go @@ -85,8 +85,8 @@ func (s *TestSuite) TestSubmit() { { name: "incorrect sp status", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), BucketName: jailedBucketName, ObjectName: jailedObjectName, }, @@ -95,8 +95,8 @@ func (s *TestSuite) TestSubmit() { { name: "not store on the sp", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), BucketName: existBucketName, ObjectName: existObjectName, }, @@ -105,7 +105,7 @@ func (s *TestSuite) TestSubmit() { { name: "unknown bucket", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), SpOperatorAddress: existSpAddr.String(), BucketName: "unknownbucket", ObjectName: "nonexistobject", @@ -115,7 +115,7 @@ func (s *TestSuite) TestSubmit() { { name: "unknown object", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), SpOperatorAddress: existSpAddr.String(), BucketName: existBucketName, ObjectName: "nonexistobject", @@ -125,7 +125,7 @@ func (s *TestSuite) TestSubmit() { { name: "invalid segment index", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), SpOperatorAddress: existSpAddr.String(), BucketName: existBucketName, ObjectName: existObjectName, @@ -136,7 +136,7 @@ func (s *TestSuite) TestSubmit() { { name: "success with specific index", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), SpOperatorAddress: existSpAddr.String(), BucketName: existBucketName, ObjectName: existObjectName, @@ -145,7 +145,7 @@ func (s *TestSuite) TestSubmit() { }, { name: "success with random index", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), SpOperatorAddress: existSpAddr.String(), BucketName: existBucketName, ObjectName: existObjectName, @@ -154,7 +154,7 @@ func (s *TestSuite) TestSubmit() { }, { name: "success with secondary sp", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), SpOperatorAddress: secondarySpAddr.String(), BucketName: existBucketName, ObjectName: existObjectName, @@ -192,7 +192,7 @@ func (s *TestSuite) TestSubmit() { { name: "failed due to recent slash", msg: types.MsgSubmit{ - Challenger: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), SpOperatorAddress: existSpAddr.String(), BucketName: existBucketName, ObjectName: existObjectName, diff --git a/x/challenge/keeper/msg_server_update_params_test.go b/x/challenge/keeper/msg_server_update_params_test.go index d20b43b70..d1390cc84 100644 --- a/x/challenge/keeper/msg_server_update_params_test.go +++ b/x/challenge/keeper/msg_server_update_params_test.go @@ -21,7 +21,7 @@ func (s *TestSuite) TestUpdateParams() { { name: "invalid authority", msg: types.MsgUpdateParams{ - Authority: sample.AccAddress(), + Authority: sample.RandAccAddressHex(), }, err: true, }, { diff --git a/x/challenge/module_simulation.go b/x/challenge/module_simulation.go index 4c1c2824c..971952cfd 100644 --- a/x/challenge/module_simulation.go +++ b/x/challenge/module_simulation.go @@ -16,7 +16,7 @@ import ( // avoid unused import issue var ( - _ = sample.AccAddress + _ = sample.RandAccAddressHex _ = challengesimulation.FindAccount _ = simulation.MsgEntryKind _ = baseapp.Paramspace diff --git a/x/challenge/types/message_attest_test.go b/x/challenge/types/message_attest_test.go index 04a2313e4..3b5cbcf95 100644 --- a/x/challenge/types/message_attest_test.go +++ b/x/challenge/types/message_attest_test.go @@ -25,16 +25,16 @@ func TestMsgAttest_ValidateBasic(t *testing.T) { }, { name: "invalid vote result", msg: MsgAttest{ - Submitter: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Submitter: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), VoteResult: 100, }, err: ErrInvalidVoteResult, }, { name: "invalid vote result", msg: MsgAttest{ - Submitter: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Submitter: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), VoteResult: CHALLENGE_SUCCEED, VoteValidatorSet: make([]uint64, 0), }, @@ -42,8 +42,8 @@ func TestMsgAttest_ValidateBasic(t *testing.T) { }, { name: "invalid vote aggregated signature", msg: MsgAttest{ - Submitter: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Submitter: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), VoteResult: CHALLENGE_SUCCEED, VoteValidatorSet: []uint64{1}, VoteAggSignature: []byte{1, 2, 3}, @@ -52,8 +52,8 @@ func TestMsgAttest_ValidateBasic(t *testing.T) { }, { name: "valid message", msg: MsgAttest{ - Submitter: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Submitter: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), VoteResult: CHALLENGE_SUCCEED, VoteValidatorSet: []uint64{1}, VoteAggSignature: sig[:], diff --git a/x/challenge/types/message_submit_test.go b/x/challenge/types/message_submit_test.go index 7cd18c44d..c3ee86256 100644 --- a/x/challenge/types/message_submit_test.go +++ b/x/challenge/types/message_submit_test.go @@ -25,16 +25,16 @@ func TestMsgSubmit_ValidateBasic(t *testing.T) { }, { name: "invalid bucket name", msg: MsgSubmit{ - Challenger: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), BucketName: "1", }, err: gnfderrors.ErrInvalidBucketName, }, { name: "invalid object name", msg: MsgSubmit{ - Challenger: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), BucketName: "bucket", ObjectName: "", }, @@ -42,8 +42,8 @@ func TestMsgSubmit_ValidateBasic(t *testing.T) { }, { name: "valid message with random index", msg: MsgSubmit{ - Challenger: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), BucketName: "bucket", ObjectName: "object", RandomIndex: true, @@ -52,8 +52,8 @@ func TestMsgSubmit_ValidateBasic(t *testing.T) { }, { name: "valid message with specific index", msg: MsgSubmit{ - Challenger: sample.AccAddress(), - SpOperatorAddress: sample.AccAddress(), + Challenger: sample.RandAccAddressHex(), + SpOperatorAddress: sample.RandAccAddressHex(), BucketName: "bucket", ObjectName: "object", RandomIndex: false, diff --git a/x/challenge/types/message_update_params_test.go b/x/challenge/types/message_update_params_test.go index 8d6e34eab..7f69da570 100644 --- a/x/challenge/types/message_update_params_test.go +++ b/x/challenge/types/message_update_params_test.go @@ -29,14 +29,14 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) { }, { name: "invalid params", msg: MsgUpdateParams{ - Authority: sample.AccAddress(), + Authority: sample.RandAccAddressHex(), Params: wrongParams, }, err: ErrInvalidParams, }, { name: "valid authority and params", msg: MsgUpdateParams{ - Authority: sample.AccAddress(), + Authority: sample.RandAccAddressHex(), Params: DefaultParams(), }, }, diff --git a/x/payment/client/cli/query.go b/x/payment/client/cli/query.go index bfffe9292..7c130eb7b 100644 --- a/x/payment/client/cli/query.go +++ b/x/payment/client/cli/query.go @@ -10,7 +10,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { +func GetQueryCmd() *cobra.Command { // Group payment queries under a subcommand cmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/payment/module.go b/x/payment/module.go index 3dc2e77e5..0c3abf803 100644 --- a/x/payment/module.go +++ b/x/payment/module.go @@ -81,7 +81,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- diff --git a/x/payment/module_simulation.go b/x/payment/module_simulation.go index 62b240343..99746bd8a 100644 --- a/x/payment/module_simulation.go +++ b/x/payment/module_simulation.go @@ -15,7 +15,7 @@ import ( // avoid unused import issue var ( - _ = sample.AccAddress + _ = sample.RandAccAddressHex _ = paymentsimulation.FindAccount _ = simulation.MsgEntryKind _ = baseapp.Paramspace diff --git a/x/permission/module_simulation.go b/x/permission/module_simulation.go index b62b7b00f..5a1bd3239 100644 --- a/x/permission/module_simulation.go +++ b/x/permission/module_simulation.go @@ -14,7 +14,7 @@ import ( // avoid unused import issue var ( - _ = sample.AccAddress + _ = sample.RandAccAddressHex _ = permissionsimulation.FindAccount _ = simulation.MsgEntryKind _ = baseapp.Paramspace diff --git a/x/sp/keeper/msg_server_test.go b/x/sp/keeper/msg_server_test.go index e0085691c..a069bd3cc 100644 --- a/x/sp/keeper/msg_server_test.go +++ b/x/sp/keeper/msg_server_test.go @@ -52,7 +52,7 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() { Identity: "", }, SpAddress: operatorAddr.String(), - FundingAddress: sample.AccAddress(), + FundingAddress: sample.RandAccAddressHex(), SealAddress: sealAddr.String(), ApprovalAddress: approvalAddr.String(), GcAddress: gcAddr.String(), diff --git a/x/sp/keeper/sp_test.go b/x/sp/keeper/sp_test.go index a92f2d150..64b2ec52f 100644 --- a/x/sp/keeper/sp_test.go +++ b/x/sp/keeper/sp_test.go @@ -17,7 +17,7 @@ func (s *KeeperTestSuite) TestSetGetStorageProvider() { keeper := s.spKeeper ctx := s.ctx sp := &types.StorageProvider{Id: 100} - spAccStr := sample.AccAddress() + spAccStr := sample.RandAccAddressHex() spAcc := sdk.MustAccAddressFromHex(spAccStr) sp.OperatorAddress = spAcc.String() @@ -34,16 +34,16 @@ func (s *KeeperTestSuite) TestSetGetStorageProvider() { func (s *KeeperTestSuite) TestStorageProviderBasics() { k := s.spKeeper ctx := s.ctx - spAccStr := sample.AccAddress() + spAccStr := sample.RandAccAddressHex() spAcc := sdk.MustAccAddressFromHex(spAccStr) - fundingAccStr := sample.AccAddress() + fundingAccStr := sample.RandAccAddressHex() fundingAcc := sdk.MustAccAddressFromHex(fundingAccStr) - sealAccStr := sample.AccAddress() + sealAccStr := sample.RandAccAddressHex() sealAcc := sdk.MustAccAddressFromHex(sealAccStr) - approvalAccStr := sample.AccAddress() + approvalAccStr := sample.RandAccAddressHex() approvalAcc := sdk.MustAccAddressFromHex(approvalAccStr) blsPubKey := sample.RandBlsPubKey() @@ -98,16 +98,16 @@ func (s *KeeperTestSuite) TestSlashBasic() { k := s.spKeeper ctx := s.ctx - spAccStr := sample.AccAddress() + spAccStr := sample.RandAccAddressHex() spAcc := sdk.MustAccAddressFromHex(spAccStr) - fundingAccStr := sample.AccAddress() + fundingAccStr := sample.RandAccAddressHex() fundingAcc := sdk.MustAccAddressFromHex(fundingAccStr) - sealAccStr := sample.AccAddress() + sealAccStr := sample.RandAccAddressHex() sealAcc := sdk.MustAccAddressFromHex(sealAccStr) - approvalAccStr := sample.AccAddress() + approvalAccStr := sample.RandAccAddressHex() approvalAcc := sdk.MustAccAddressFromHex(approvalAccStr) blsPubKey := sample.RandBlsPubKey() @@ -130,7 +130,7 @@ func (s *KeeperTestSuite) TestSlashBasic() { require.EqualValues(s.T(), found, true) rewardInfo := types.RewardInfo{ - Address: sample.AccAddress(), + Address: sample.RandAccAddressHex(), Amount: sdk.NewCoin(types2.Denom, math.NewIntWithDecimal(10, types2.DecimalBNB)), } diff --git a/x/sp/module_simulation.go b/x/sp/module_simulation.go index 369c1a97e..35d2a7207 100644 --- a/x/sp/module_simulation.go +++ b/x/sp/module_simulation.go @@ -14,7 +14,7 @@ import ( // avoid unused import issue var ( - _ = sample.AccAddress + _ = sample.RandAccAddressHex _ = spsimulation.FindAccount _ = simulation.MsgEntryKind _ = baseapp.Paramspace diff --git a/x/storage/module_simulation.go b/x/storage/module_simulation.go index 2262f412b..6d58c4a58 100644 --- a/x/storage/module_simulation.go +++ b/x/storage/module_simulation.go @@ -14,7 +14,7 @@ import ( // avoid unused import issue var ( - _ = sample.AccAddress + _ = sample.RandAccAddressHex _ = storagesimulation.FindAccount _ = simulation.MsgEntryKind _ = baseapp.Paramspace diff --git a/x/storage/types/message_cancel_migrate_bucket_test.go b/x/storage/types/message_cancel_migrate_bucket_test.go index 9e79b0995..86897c824 100644 --- a/x/storage/types/message_cancel_migrate_bucket_test.go +++ b/x/storage/types/message_cancel_migrate_bucket_test.go @@ -25,7 +25,7 @@ func TestMsgCancelMigrateBucket_ValidateBasic(t *testing.T) { }, { name: "valid address", msg: MsgCancelMigrateBucket{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, }, }, diff --git a/x/storage/types/message_complete_migrate_bucket_test.go b/x/storage/types/message_complete_migrate_bucket_test.go index 1ad3783d0..4a25973b9 100644 --- a/x/storage/types/message_complete_migrate_bucket_test.go +++ b/x/storage/types/message_complete_migrate_bucket_test.go @@ -25,7 +25,7 @@ func TestMsgCompleteMigrateBucket_ValidateBasic(t *testing.T) { }, { name: "valid address", msg: MsgCompleteMigrateBucket{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: "bucketname", GlobalVirtualGroupFamilyId: 1, GvgMappings: []*GVGMapping{{1, 2, []byte("xxxxxxxxxxx")}}, diff --git a/x/storage/types/message_migrate_bucket_test.go b/x/storage/types/message_migrate_bucket_test.go index 84d11d107..c0c4f7581 100644 --- a/x/storage/types/message_migrate_bucket_test.go +++ b/x/storage/types/message_migrate_bucket_test.go @@ -26,7 +26,7 @@ func TestMsgMigrateBucket_ValidateBasic(t *testing.T) { }, { name: "valid address", msg: MsgMigrateBucket{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: "bucketname", DstPrimarySpId: 1, DstPrimarySpApproval: &common.Approval{ExpiredHeight: 10, Sig: []byte("XXXTentacion")}, diff --git a/x/storage/types/message_object_test.go b/x/storage/types/message_object_test.go index 00543e315..0a6d38a14 100644 --- a/x/storage/types/message_object_test.go +++ b/x/storage/types/message_object_test.go @@ -23,7 +23,7 @@ func TestMsgCreateObject_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgCreateObject{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, PayloadSize: 1024, @@ -35,7 +35,7 @@ func TestMsgCreateObject_ValidateBasic(t *testing.T) { }, { name: "invalid object name", msg: MsgCreateObject{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: "", PayloadSize: 1024, @@ -48,7 +48,7 @@ func TestMsgCreateObject_ValidateBasic(t *testing.T) { }, { name: "invalid object name", msg: MsgCreateObject{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: "../object", PayloadSize: 1024, @@ -61,7 +61,7 @@ func TestMsgCreateObject_ValidateBasic(t *testing.T) { }, { name: "invalid object name", msg: MsgCreateObject{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: "//object", PayloadSize: 1024, @@ -94,7 +94,7 @@ func TestMsgCancelCreateObject_ValidateBasic(t *testing.T) { { name: "basic", msg: MsgCancelCreateObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, }, @@ -121,7 +121,7 @@ func TestMsgDeleteObject_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgDeleteObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, }, @@ -148,7 +148,7 @@ func TestMsgCopyObject_ValidateBasic(t *testing.T) { { name: "valid address", msg: MsgCopyObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), SrcBucketName: testBucketName, SrcObjectName: testObjectName, DstBucketName: "dst" + testBucketName, @@ -177,7 +177,7 @@ func TestMsgCopyObject_ValidateBasic(t *testing.T) { { name: "empty approval", msg: MsgCopyObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), SrcBucketName: testBucketName, SrcObjectName: testObjectName, DstBucketName: "dst" + testBucketName, @@ -189,7 +189,7 @@ func TestMsgCopyObject_ValidateBasic(t *testing.T) { { name: "invalid src bucket name", msg: MsgCopyObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), SrcBucketName: "1.1.1.1", SrcObjectName: testObjectName, DstBucketName: "dst" + testBucketName, @@ -204,7 +204,7 @@ func TestMsgCopyObject_ValidateBasic(t *testing.T) { { name: "invalid src object name", msg: MsgCopyObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), SrcBucketName: testBucketName, SrcObjectName: "", DstBucketName: "dst" + testBucketName, @@ -219,7 +219,7 @@ func TestMsgCopyObject_ValidateBasic(t *testing.T) { { name: "invalid dest bucket name", msg: MsgCopyObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), SrcBucketName: testBucketName, SrcObjectName: testObjectName, DstBucketName: "1.1.1.1", @@ -234,7 +234,7 @@ func TestMsgCopyObject_ValidateBasic(t *testing.T) { { name: "invalid dest object name", msg: MsgCopyObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), SrcBucketName: testBucketName, SrcObjectName: testObjectName, DstBucketName: "dst" + testBucketName, @@ -272,7 +272,7 @@ func TestMsgSealObject_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgSealObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, SecondarySpBlsAggSignatures: aggSig, @@ -291,7 +291,7 @@ func TestMsgSealObject_ValidateBasic(t *testing.T) { { name: "invalid bucket name", msg: MsgSealObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: "1.1.1.1", ObjectName: testObjectName, SecondarySpBlsAggSignatures: aggSig, @@ -301,7 +301,7 @@ func TestMsgSealObject_ValidateBasic(t *testing.T) { { name: "invalid object name", msg: MsgSealObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: "", SecondarySpBlsAggSignatures: aggSig, @@ -311,7 +311,7 @@ func TestMsgSealObject_ValidateBasic(t *testing.T) { { name: "invalid signature", msg: MsgSealObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, SecondarySpBlsAggSignatures: []byte("invalid signature"), @@ -340,7 +340,7 @@ func TestMsgRejectSealObject_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgRejectSealObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, }, @@ -357,7 +357,7 @@ func TestMsgRejectSealObject_ValidateBasic(t *testing.T) { { name: "invalid bucket name", msg: MsgRejectSealObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: "1.1.1.1", ObjectName: testObjectName, }, @@ -366,7 +366,7 @@ func TestMsgRejectSealObject_ValidateBasic(t *testing.T) { { name: "invalid object name", msg: MsgRejectSealObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: "", }, @@ -394,7 +394,7 @@ func TestMsgUpdateObjectInfo_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgUpdateObjectInfo{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, Visibility: VISIBILITY_TYPE_INHERIT, @@ -413,7 +413,7 @@ func TestMsgUpdateObjectInfo_ValidateBasic(t *testing.T) { { name: "invalid bucket name", msg: MsgUpdateObjectInfo{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: "1.1.1.1", ObjectName: testObjectName, Visibility: VISIBILITY_TYPE_INHERIT, @@ -423,7 +423,7 @@ func TestMsgUpdateObjectInfo_ValidateBasic(t *testing.T) { { name: "invalid bucket name", msg: MsgUpdateObjectInfo{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: "", Visibility: VISIBILITY_TYPE_INHERIT, @@ -433,7 +433,7 @@ func TestMsgUpdateObjectInfo_ValidateBasic(t *testing.T) { { name: "invalid visibility", msg: MsgUpdateObjectInfo{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectName: testObjectName, Visibility: VISIBILITY_TYPE_UNSPECIFIED, @@ -462,7 +462,7 @@ func TestMsgMirrorObject_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgMirrorObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), Id: math.NewUint(1), }, }, @@ -497,7 +497,7 @@ func TestMsgDiscontinueObject_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgDiscontinueObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectIds: []Uint{math.NewUint(1)}, Reason: "valid reason", @@ -516,7 +516,7 @@ func TestMsgDiscontinueObject_ValidateBasic(t *testing.T) { { name: "invalid bucket name", msg: MsgDiscontinueObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: "1.11.1.1", ObjectIds: []Uint{math.NewUint(1)}, Reason: "valid reason", @@ -526,7 +526,7 @@ func TestMsgDiscontinueObject_ValidateBasic(t *testing.T) { { name: "invalid object ids", msg: MsgDiscontinueObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectIds: nil, Reason: "valid reason", @@ -536,7 +536,7 @@ func TestMsgDiscontinueObject_ValidateBasic(t *testing.T) { { name: "invalid object ids", msg: MsgDiscontinueObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectIds: invalidObjectIds[:], Reason: "valid reason", @@ -546,7 +546,7 @@ func TestMsgDiscontinueObject_ValidateBasic(t *testing.T) { { name: "invalid reason", msg: MsgDiscontinueObject{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, ObjectIds: []Uint{math.NewUint(1)}, Reason: strings.Repeat("s", MaxDiscontinueReasonLen+1), diff --git a/x/storage/types/message_test.go b/x/storage/types/message_test.go index 9762f19e7..f3343a3bf 100644 --- a/x/storage/types/message_test.go +++ b/x/storage/types/message_test.go @@ -32,54 +32,54 @@ func TestMsgCreateBucket_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgCreateBucket{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: testBucketName, Visibility: VISIBILITY_TYPE_PUBLIC_READ, - PaymentAddress: sample.AccAddress(), - PrimarySpAddress: sample.AccAddress(), + PaymentAddress: sample.RandAccAddressHex(), + PrimarySpAddress: sample.RandAccAddressHex(), PrimarySpApproval: &common.Approval{}, }, }, { name: "invalid bucket name", msg: MsgCreateBucket{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: "TestBucket", Visibility: VISIBILITY_TYPE_PUBLIC_READ, - PaymentAddress: sample.AccAddress(), - PrimarySpAddress: sample.AccAddress(), + PaymentAddress: sample.RandAccAddressHex(), + PrimarySpAddress: sample.RandAccAddressHex(), PrimarySpApproval: &common.Approval{}, }, err: gnfderrors.ErrInvalidBucketName, }, { name: "invalid bucket name", msg: MsgCreateBucket{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: "Test-Bucket", Visibility: VISIBILITY_TYPE_PUBLIC_READ, - PaymentAddress: sample.AccAddress(), - PrimarySpAddress: sample.AccAddress(), + PaymentAddress: sample.RandAccAddressHex(), + PrimarySpAddress: sample.RandAccAddressHex(), PrimarySpApproval: &common.Approval{}, }, err: gnfderrors.ErrInvalidBucketName, }, { name: "invalid bucket name", msg: MsgCreateBucket{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: "ss", Visibility: VISIBILITY_TYPE_PUBLIC_READ, - PaymentAddress: sample.AccAddress(), - PrimarySpAddress: sample.AccAddress(), + PaymentAddress: sample.RandAccAddressHex(), + PrimarySpAddress: sample.RandAccAddressHex(), PrimarySpApproval: &common.Approval{}, }, err: gnfderrors.ErrInvalidBucketName, }, { name: "invalid bucket name", msg: MsgCreateBucket{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), BucketName: string(testInvalidBucketNameWithLongLength[:]), Visibility: VISIBILITY_TYPE_PUBLIC_READ, - PaymentAddress: sample.AccAddress(), - PrimarySpAddress: sample.AccAddress(), + PaymentAddress: sample.RandAccAddressHex(), + PrimarySpAddress: sample.RandAccAddressHex(), PrimarySpApproval: &common.Approval{}, }, err: gnfderrors.ErrInvalidBucketName, @@ -106,13 +106,13 @@ func TestMsgDeleteBucket_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgDeleteBucket{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, }, }, { name: "invalid bucket name", msg: MsgDeleteBucket{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: "testBucket", }, err: gnfderrors.ErrInvalidBucketName, @@ -139,9 +139,9 @@ func TestMsgUpdateBucketInfo_ValidateBasic(t *testing.T) { { name: "basic", msg: MsgUpdateBucketInfo{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), BucketName: testBucketName, - PaymentAddress: sample.AccAddress(), + PaymentAddress: sample.RandAccAddressHex(), ChargedReadQuota: &common.UInt64Value{Value: 10000}, }, }, @@ -167,9 +167,9 @@ func TestMsgCreateGroup_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgCreateGroup{ - Creator: sample.AccAddress(), + Creator: sample.RandAccAddressHex(), GroupName: testGroupName, - Members: []string{sample.AccAddress(), sample.AccAddress()}, + Members: []string{sample.RandAccAddressHex(), sample.RandAccAddressHex()}, }, }, } @@ -194,7 +194,7 @@ func TestMsgDeleteGroup_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgDeleteGroup{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), GroupName: testGroupName, }, }, @@ -220,8 +220,8 @@ func TestMsgLeaveGroup_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgLeaveGroup{ - Member: sample.AccAddress(), - GroupOwner: sample.AccAddress(), + Member: sample.RandAccAddressHex(), + GroupOwner: sample.RandAccAddressHex(), GroupName: testGroupName, }, }, @@ -247,11 +247,11 @@ func TestMsgUpdateGroupMember_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgUpdateGroupMember{ - Operator: sample.AccAddress(), - GroupOwner: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), + GroupOwner: sample.RandAccAddressHex(), GroupName: testGroupName, - MembersToAdd: []string{sample.AccAddress(), sample.AccAddress()}, - MembersToDelete: []string{sample.AccAddress(), sample.AccAddress()}, + MembersToAdd: []string{sample.RandAccAddressHex(), sample.RandAccAddressHex()}, + MembersToDelete: []string{sample.RandAccAddressHex(), sample.RandAccAddressHex()}, }, }, } @@ -277,8 +277,8 @@ func TestMsgUpdateGroupExtra_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgUpdateGroupExtra{ - Operator: sample.AccAddress(), - GroupOwner: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), + GroupOwner: sample.RandAccAddressHex(), GroupName: testGroupName, Extra: "testExtra", }, @@ -286,8 +286,8 @@ func TestMsgUpdateGroupExtra_ValidateBasic(t *testing.T) { { name: "extra field is too long", msg: MsgUpdateGroupExtra{ - Operator: sample.AccAddress(), - GroupOwner: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), + GroupOwner: sample.RandAccAddressHex(), GroupName: testGroupName, Extra: strings.Repeat("abcdefg", 80), }, @@ -315,9 +315,9 @@ func TestMsgPutPolicy_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgPutPolicy{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), Resource: types2.NewBucketGRN(testBucketName).String(), - Principal: types.NewPrincipalWithAccount(sdk.MustAccAddressFromHex(sample.AccAddress())), + Principal: types.NewPrincipalWithAccount(sdk.MustAccAddressFromHex(sample.RandAccAddressHex())), Statements: []*types.Statement{{Effect: types.EFFECT_ALLOW, Actions: []types.ActionType{types.ACTION_DELETE_BUCKET}}}, }, @@ -344,9 +344,9 @@ func TestMsgDeletePolicy_ValidateBasic(t *testing.T) { { name: "valid address", msg: MsgDeletePolicy{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), Resource: types2.NewBucketGRN(testBucketName).String(), - Principal: types.NewPrincipalWithAccount(sdk.MustAccAddressFromHex(sample.AccAddress())), + Principal: types.NewPrincipalWithAccount(sdk.MustAccAddressFromHex(sample.RandAccAddressHex())), }, }, } @@ -371,7 +371,7 @@ func TestMsgMirrorBucket_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgMirrorBucket{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), Id: math.NewUint(1), }, }, { @@ -404,7 +404,7 @@ func TestMsgMirrorGroup_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgMirrorGroup{ - Operator: sample.AccAddress(), + Operator: sample.RandAccAddressHex(), Id: math.NewUint(1), }, }, diff --git a/x/virtualgroup/module_simulation.go b/x/virtualgroup/module_simulation.go index 44168c0aa..1862eda20 100644 --- a/x/virtualgroup/module_simulation.go +++ b/x/virtualgroup/module_simulation.go @@ -16,7 +16,7 @@ import ( // avoid unused import issue var ( - _ = sample.AccAddress + _ = sample.RandAccAddressHex _ = virtualgroupsimulation.FindAccount _ = simulation.MsgEntryKind _ = baseapp.Paramspace diff --git a/x/virtualgroup/types/message_cancel_swap_out_test.go b/x/virtualgroup/types/message_cancel_swap_out_test.go index 4d6652b6a..ee657ba38 100644 --- a/x/virtualgroup/types/message_cancel_swap_out_test.go +++ b/x/virtualgroup/types/message_cancel_swap_out_test.go @@ -35,7 +35,7 @@ func TestMsgCancelSwapOut_ValidateBasic(t *testing.T) { { name: "invalid gvg groups", msg: MsgCancelSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 1, GlobalVirtualGroupIds: []uint32{1, 2}, }, @@ -44,7 +44,7 @@ func TestMsgCancelSwapOut_ValidateBasic(t *testing.T) { { name: "invalid gvg groups", msg: MsgCancelSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 0, GlobalVirtualGroupIds: []uint32{}, }, diff --git a/x/virtualgroup/types/message_complete_swap_out_test.go b/x/virtualgroup/types/message_complete_swap_out_test.go index 2f612e448..96a396836 100644 --- a/x/virtualgroup/types/message_complete_swap_out_test.go +++ b/x/virtualgroup/types/message_complete_swap_out_test.go @@ -35,7 +35,7 @@ func TestMsgCompleteSwapOut_ValidateBasic(t *testing.T) { { name: "invalid gvg groups", msg: MsgCompleteSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 1, GlobalVirtualGroupIds: []uint32{1, 2, 3}, }, @@ -44,7 +44,7 @@ func TestMsgCompleteSwapOut_ValidateBasic(t *testing.T) { { name: "invalid gvg groups", msg: MsgCompleteSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 0, GlobalVirtualGroupIds: []uint32{}, }, diff --git a/x/virtualgroup/types/message_test.go b/x/virtualgroup/types/message_test.go index ebf893729..8e77991dc 100644 --- a/x/virtualgroup/types/message_test.go +++ b/x/virtualgroup/types/message_test.go @@ -33,7 +33,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) { { name: "invalid deposit amount", msg: MsgDeposit{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupId: 1, Deposit: types.Coin{ Denom: "denom", @@ -87,7 +87,7 @@ func TestMsgWithdraw_ValidateBasic(t *testing.T) { { name: "invalid deposit amount", msg: MsgWithdraw{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupId: 1, Withdraw: types.Coin{ Denom: "denom", @@ -129,7 +129,7 @@ func TestMsgSwapOut_ValidateBasic(t *testing.T) { { name: "valid case", msg: MsgSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 0, GlobalVirtualGroupIds: []uint32{1, 2, 3}, SuccessorSpId: 100, @@ -143,7 +143,7 @@ func TestMsgSwapOut_ValidateBasic(t *testing.T) { { name: "valid case", msg: MsgSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 1, GlobalVirtualGroupIds: []uint32{}, SuccessorSpId: 100, @@ -172,7 +172,7 @@ func TestMsgSwapOut_ValidateBasic(t *testing.T) { { name: "invalid virtual group family", msg: MsgSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 1, GlobalVirtualGroupIds: []uint32{1}, SuccessorSpId: 100, @@ -187,7 +187,7 @@ func TestMsgSwapOut_ValidateBasic(t *testing.T) { { name: "invalid virtual group family", msg: MsgSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 0, GlobalVirtualGroupIds: []uint32{}, SuccessorSpId: 100, @@ -202,7 +202,7 @@ func TestMsgSwapOut_ValidateBasic(t *testing.T) { { name: "invalid successor sp id", msg: MsgSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 1, GlobalVirtualGroupIds: []uint32{}, SuccessorSpId: 0, @@ -217,7 +217,7 @@ func TestMsgSwapOut_ValidateBasic(t *testing.T) { { name: "invalid successor sp approval", msg: MsgSwapOut{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 1, GlobalVirtualGroupIds: []uint32{}, SuccessorSpId: 1, @@ -353,7 +353,7 @@ func TestMsgSettle_ValidateBasic(t *testing.T) { { name: "invalid gvg ids", msg: MsgSettle{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 0, }, err: ErrInvalidGVGCount, @@ -361,7 +361,7 @@ func TestMsgSettle_ValidateBasic(t *testing.T) { { name: "invalid gvg ids", msg: MsgSettle{ - StorageProvider: sample.AccAddress(), + StorageProvider: sample.RandAccAddressHex(), GlobalVirtualGroupFamilyId: 0, GlobalVirtualGroupIds: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, }, From 16d35787b051518657cfa6e04b7bc1602996dfad Mon Sep 17 00:00:00 2001 From: yutianwu Date: Mon, 31 Jul 2023 11:25:14 +0800 Subject: [PATCH 10/24] fix: register gov cross-chain app (#398) --- app/app.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/app.go b/app/app.go index 13d7e146d..87c87658e 100644 --- a/app/app.go +++ b/app/app.go @@ -729,6 +729,7 @@ func (app *App) initModules(ctx sdk.Context) { app.initBridge() app.initStorage() + app.initGov() } func (app *App) initCrossChain() { @@ -744,6 +745,13 @@ func (app *App) initStorage() { storagemodulekeeper.RegisterCrossApps(app.StorageKeeper) } +func (app *App) initGov() { + err := app.GovKeeper.RegisterCrossChainSyncParamsApp() + if err != nil { + panic(err) + } +} + // Name returns the name of the App func (app *App) Name() string { return app.BaseApp.Name() } From ee7beff47dbad733a6024e18ad35a15396306024 Mon Sep 17 00:00:00 2001 From: Roshan <48975233+Pythonberg1997@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:13:33 +0800 Subject: [PATCH 11/24] chore: add cli tests (#388) * chore: add cli tests * fix lint issues * remove CLI from test coverage exclusion --- .testcoverage.yml | 8 +- app/ante/ante_test.go | 60 +++---- app/ante/utils_test.go | 81 ++-------- app/export_test.go | 22 +++ e2e/tests/bridge_test.go | 42 ----- testutil/app.go | 82 ++++++++++ x/bridge/client/cli/query_test.go | 54 +++++++ x/bridge/client/cli/tx_test.go | 128 +++++++++++++++ x/challenge/client/cli/query.go | 2 +- x/challenge/client/cli/query_test.go | 74 +++++++++ x/challenge/client/cli/tx_test.go | 70 ++++++++ x/challenge/module.go | 2 +- x/payment/client/cli/query_test.go | 150 ++++++++++++++++++ x/payment/client/cli/tx_test.go | 70 ++++++++ x/payment/keeper/msg_server_test.go | 2 +- x/permission/client/cli/query_test.go | 54 +++++++ x/permission/client/cli/tx_test.go | 70 ++++++++ x/sp/client/cli/query.go | 8 +- x/sp/client/cli/query_test.go | 87 ++++++++++ x/sp/client/cli/tx_test.go | 70 ++++++++ x/sp/module.go | 2 +- x/storage/client/cli/query.go | 4 +- x/storage/client/cli/query_test.go | 149 +++++++++++++++++ x/storage/client/cli/tx_test.go | 70 ++++++++ x/storage/module.go | 2 +- x/virtualgroup/client/cli/query.go | 2 +- ...query_global_virtual_group_by_family_id.go | 1 - .../query_global_virtual_group_families.go | 5 +- x/virtualgroup/client/cli/query_test.go | 98 ++++++++++++ x/virtualgroup/client/cli/tx_test.go | 70 ++++++++ x/virtualgroup/module.go | 2 +- 31 files changed, 1380 insertions(+), 161 deletions(-) create mode 100644 app/export_test.go create mode 100644 testutil/app.go create mode 100644 x/bridge/client/cli/query_test.go create mode 100644 x/bridge/client/cli/tx_test.go create mode 100644 x/challenge/client/cli/query_test.go create mode 100644 x/challenge/client/cli/tx_test.go create mode 100644 x/payment/client/cli/query_test.go create mode 100644 x/payment/client/cli/tx_test.go create mode 100644 x/permission/client/cli/query_test.go create mode 100644 x/permission/client/cli/tx_test.go create mode 100644 x/sp/client/cli/query_test.go create mode 100644 x/sp/client/cli/tx_test.go create mode 100644 x/storage/client/cli/query_test.go create mode 100644 x/storage/client/cli/tx_test.go create mode 100644 x/virtualgroup/client/cli/query_test.go create mode 100644 x/virtualgroup/client/cli/tx_test.go diff --git a/.testcoverage.yml b/.testcoverage.yml index 052ad1dc8..aafc6be78 100644 --- a/.testcoverage.yml +++ b/.testcoverage.yml @@ -33,13 +33,15 @@ exclude: - \.pb\.go$ # excludes all protobuf generated files - \.pb\.gw\.go$ # excludes all protobuf generated files - .*_mocks.go$ # excludes all protobuf generated files + - types/.* + - simulation/.* - testutil/.* - e2e/.* - - types/.* - sdk/.* + - version/.* + - cmd/gnfd/.* - internal/sequence/.* - - x/types/.* - - .*/simulation/.* + - x/gensp/.* - .*/module.go - .*/module_simulation.go diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index 1cb1dc1b0..410e6d84b 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -33,7 +33,7 @@ func (suite *AnteTestSuite) TestAnteHandler() { bz, _ := hex.DecodeString(test.TEST_PUBKEY) faucetPubKey := ðsecp256k1.PubKey{Key: bz} err := suite.app.BankKeeper.SendCoins(suite.ctx, faucetPubKey.Address().Bytes(), acc.GetAddress(), sdk.Coins{sdk.Coin{ - Denom: sdk.DefaultBondDenom, + Denom: test.TEST_TOKEN_NAME, Amount: sdk.NewInt(100000000000000), }}) if err != nil { @@ -53,8 +53,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "success - DeliverTx EIP712 signed Cosmos Tx MsgSend", func() sdk.Tx { gas := uint64(12e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, true, }, @@ -62,8 +62,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "success - DeliverTx EIP712 signed Cosmos Tx MsgDelegate", func() sdk.Tx { gas := uint64(12e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgDelegate(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgDelegate(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, true, }, @@ -71,8 +71,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "success - DeliverTx EIP712 signed Cosmos Tx MsgCreateValidator", func() sdk.Tx { gas := uint64(2e8) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712MsgCreateValidator(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712MsgCreateValidator(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, true, }, @@ -80,8 +80,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "success - DeliverTx EIP712 signed Cosmos Tx MsgGrantAllowance", func() sdk.Tx { gas := uint64(16e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712GrantAllowance(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712GrantAllowance(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, true, }, @@ -89,8 +89,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "success - DeliverTx EIP712 signed Cosmos Tx MsgEditValidator", func() sdk.Tx { gas := uint64(2e7) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712MsgEditValidator(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712MsgEditValidator(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, true, }, @@ -98,8 +98,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "success - DeliverTx EIP712 signed Cosmos Tx MsgSubmitProposalV1", func() sdk.Tx { gas := uint64(2e8) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgSubmitProposalV1(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgSubmitProposalV1(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, true, }, @@ -107,8 +107,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "success - DeliverTx EIP712 signed Cosmos Tx MsgGrant", func() sdk.Tx { gas := uint64(16e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgGrant(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgGrant(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, true, }, @@ -116,9 +116,9 @@ func (suite *AnteTestSuite) TestAnteHandler() { "fails - DeliverTx legacy msg MsgSubmitProposal v1beta", func() sdk.Tx { gas := uint64(2000000000) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - deposit := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(20))) - txBuilder := suite.CreateTestEIP712SubmitProposal(addr, privKey, "greenfield_9000-1", gas, fee, deposit) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + deposit := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(20))) + txBuilder := suite.CreateTestEIP712SubmitProposal(addr, privKey, test.TEST_CHAIN_ID, gas, fee, deposit) return txBuilder.GetTx() }, true, false, false, }, @@ -126,8 +126,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "fails - DeliverTx unregistered msg type MsgSubmitEvidence", func() sdk.Tx { gas := uint64(2000000000) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712MsgSubmitEvidence(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712MsgSubmitEvidence(addr, privKey, test.TEST_CHAIN_ID, gas, fee) return txBuilder.GetTx() }, true, false, false, }, @@ -135,7 +135,7 @@ func (suite *AnteTestSuite) TestAnteHandler() { "fails - DeliverTx EIP712 signed Cosmos Tx with wrong Chain ID", func() sdk.Tx { gas := uint64(12e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, "ethermint_9002-1", gas, fee) return txBuilder.GetTx() }, true, false, false, @@ -144,10 +144,10 @@ func (suite *AnteTestSuite) TestAnteHandler() { "fails - DeliverTx EIP712 signed Cosmos Tx with different gas fees", func() sdk.Tx { gas := uint64(12e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, test.TEST_CHAIN_ID, gas, fee) txBuilder.SetGasLimit(uint64(300000)) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(30)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdkmath.NewInt(30)))) return txBuilder.GetTx() }, true, false, false, }, @@ -155,8 +155,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "fails - DeliverTx EIP712 signed Cosmos Tx with empty signature", func() sdk.Tx { gas := uint64(12e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, test.TEST_CHAIN_ID, gas, fee) sigsV2 := signing.SignatureV2{ PubKey: privKey.PubKey(), } @@ -169,8 +169,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "fails - DeliverTx EIP712 signed Cosmos Tx with invalid sequence", func() sdk.Tx { gas := uint64(12e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, test.TEST_CHAIN_ID, gas, fee) nonce, err := suite.app.AccountKeeper.GetSequence(suite.ctx, addr) suite.Require().NoError(err) sigsV2 := signing.SignatureV2{ @@ -189,8 +189,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "fails - DeliverTx EIP712 signed Cosmos Tx with invalid signMode", func() sdk.Tx { gas := uint64(12e3) - fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewIntFromUint64(gas))) - txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, "greenfield_9000-1", gas, fee) + fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas))) + txBuilder := suite.CreateTestEIP712TxBuilderMsgSend(addr, privKey, test.TEST_CHAIN_ID, gas, fee) nonce, err := suite.app.AccountKeeper.GetSequence(suite.ctx, addr) suite.Require().NoError(err) sigsV2 := signing.SignatureV2{ diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index 46a8d434d..aa309b1cb 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -1,7 +1,6 @@ package ante_test import ( - "encoding/hex" "encoding/json" "fmt" "math/big" @@ -10,17 +9,11 @@ import ( sdkmath "cosmossdk.io/math" dbm "github.com/cometbft/cometbft-db" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1" storetypes "github.com/cosmos/cosmos-sdk/store/types" - "github.com/cosmos/cosmos-sdk/testutil/mock" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" @@ -43,6 +36,7 @@ import ( "github.com/bnb-chain/greenfield/e2e/core" "github.com/bnb-chain/greenfield/sdk/client/test" "github.com/bnb-chain/greenfield/sdk/keys" + "github.com/bnb-chain/greenfield/testutil" "github.com/bnb-chain/greenfield/testutil/sample" ) @@ -61,10 +55,12 @@ func TestAnteTestSuite(t *testing.T) { func (suite *AnteTestSuite) SetupTest() { var encCfg params.EncodingConfig - suite.app, encCfg, _ = NewApp(baseapp.SetChainID("greenfield_9000-1")) + logger := log.NewNopLogger() + db := dbm.NewMemDB() + suite.app, encCfg, _ = testutil.NewTestApp(logger, db, nil, true, test.TEST_CHAIN_ID) - suite.ctx = suite.app.NewContext(false, tmproto.Header{Height: 2, ChainID: "greenfield_9000-1", Time: time.Now().UTC()}) - suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(sdk.DefaultBondDenom, sdk.OneInt()))) // set to 1 stake + suite.ctx = suite.app.NewUncachedContext(false, tmproto.Header{Height: 2, ChainID: test.TEST_CHAIN_ID, Time: time.Now().UTC()}) + suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(test.TEST_TOKEN_NAME, sdk.OneInt()))) // set to 1 stake infCtx := suite.ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) err := suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams()) @@ -84,13 +80,13 @@ func (suite *AnteTestSuite) SetupTest() { func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgSend(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder { recipient := core.GenRandomAddr() - msgSend := banktypes.NewMsgSend(from, recipient, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1)))) + msgSend := banktypes.NewMsgSend(from, recipient, sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdkmath.NewInt(1)))) return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgSend) } func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgDelegate(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder { validator := core.GenRandomAddr() - msgSend := stakingtypes.NewMsgDelegate(from, validator, sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(20))) + msgSend := stakingtypes.NewMsgDelegate(from, validator, sdk.NewCoin(test.TEST_TOKEN_NAME, sdkmath.NewInt(20))) return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgSend) } @@ -100,7 +96,7 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator(from sdk.AccAddre msgCreate, err := stakingtypes.NewMsgCreateValidator( from, privEd.PubKey(), - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20)), + sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewInt(20)), stakingtypes.NewDescription("moniker", "identity", "website", "security_contract", "details"), stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), sdk.OneInt(), @@ -124,7 +120,7 @@ func (suite *AnteTestSuite) CreateTestEIP712SubmitProposal(from sdk.AccAddress, } func (suite *AnteTestSuite) CreateTestEIP712GrantAllowance(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder { - spendLimit := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 10)) + spendLimit := sdk.NewCoins(sdk.NewInt64Coin(test.TEST_TOKEN_NAME, 10)) threeHours := time.Now().Add(3 * time.Hour) basic := &feegrant.BasicAllowance{ SpendLimit: spendLimit, @@ -173,7 +169,7 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgSubmitProposalV1(from sd msgCreate, err := stakingtypes.NewMsgCreateValidator( from, privEd.PubKey(), - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20)), + sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewInt(20)), stakingtypes.NewDescription("moniker", "indentity", "website", "security_contract", "details"), stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), sdk.OneInt(), @@ -187,7 +183,7 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgSubmitProposalV1(from sd suite.Require().NoError(err) msgSubmitProposal, err := govtypesv1.NewMsgSubmitProposal( []sdk.Msg{msgCreate}, - sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20))}, + sdk.Coins{sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewInt(20))}, from.String(), "test", "test", "test", ) @@ -265,56 +261,3 @@ func (suite *AnteTestSuite) CreateTestEIP712CosmosTxBuilder( suite.Require().NoError(err) return txBuilder } - -func NewApp(options ...func(baseApp *baseapp.BaseApp)) (*app.App, params.EncodingConfig, error) { - // create public key - privVal := mock.NewPV() - pubKey, _ := privVal.GetPubKey() - - // create validator set with single validator - validator := tmtypes.NewValidator(pubKey, 1) - valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) - - // generate genesis account - bz, _ := hex.DecodeString(test.TEST_PUBKEY) - faucetPubKey := ðsecp256k1.PubKey{Key: bz} - - acc := authtypes.NewBaseAccount(faucetPubKey.Address().Bytes(), faucetPubKey, 0, 0) - balance := banktypes.Balance{ - Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), - } - - logger := log.NewNopLogger() - db := dbm.NewMemDB() - encCfg := app.MakeEncodingConfig() - - nApp := app.New( - logger, - db, - nil, - true, - app.DefaultNodeHome, - 0, - encCfg, - &app.AppConfig{CrossChain: app.NewDefaultAppConfig().CrossChain}, - simtestutil.EmptyAppOptions{}, - options..., - ) - - genesisState := app.NewDefaultGenesisState(encCfg.Marshaler) - genesisState, _ = simtestutil.GenesisStateWithValSet(nApp.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) - - stateBytes, _ := json.MarshalIndent(genesisState, "", " ") - - // Initialize the chain - nApp.InitChain( - abci.RequestInitChain{ - ChainId: "greenfield_9000-1", - Validators: []abci.ValidatorUpdate{}, - AppStateBytes: stateBytes, - }, - ) - - return nApp, encCfg, nil -} diff --git a/app/export_test.go b/app/export_test.go new file mode 100644 index 000000000..a9c3cd26a --- /dev/null +++ b/app/export_test.go @@ -0,0 +1,22 @@ +package app_test + +import ( + "testing" + + "github.com/bnb-chain/greenfield/sdk/client/test" + "github.com/bnb-chain/greenfield/testutil" + dbm "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +func TestExportAppStateAndValidators(t *testing.T) { + logger := log.NewNopLogger() + db := dbm.NewMemDB() + app, _, _ := testutil.NewTestApp(logger, db, nil, true, test.TEST_CHAIN_ID) + + _, err := app.ExportAppStateAndValidators(false, nil, []string{banktypes.ModuleName}) + if err != nil { + t.Fatalf("error exporting state: %s", err) + } +} diff --git a/e2e/tests/bridge_test.go b/e2e/tests/bridge_test.go index 7795a9a44..4d6df2237 100644 --- a/e2e/tests/bridge_test.go +++ b/e2e/tests/bridge_test.go @@ -8,12 +8,9 @@ import ( "time" sdkmath "cosmossdk.io/math" - sdkClient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" crosschaintypes "github.com/cosmos/cosmos-sdk/x/crosschain/types" @@ -26,7 +23,6 @@ import ( "github.com/bnb-chain/greenfield/e2e/core" gnfdtypes "github.com/bnb-chain/greenfield/sdk/types" types2 "github.com/bnb-chain/greenfield/sdk/types" - "github.com/bnb-chain/greenfield/x/bridge/client/cli" bridgetypes "github.com/bnb-chain/greenfield/x/bridge/types" ) @@ -40,44 +36,6 @@ func (s *BridgeTestSuite) SetupSuite() { func (s *BridgeTestSuite) SetupTest() {} -func (s *BridgeTestSuite) TestCliQuery() { - ctx := context.Background() - cliCtx := &sdkClient.Context{Client: s.TmClient.TmClient, Codec: s.Client.GetCodec()} - ctx = context.WithValue(ctx, sdkClient.ClientContextKey, cliCtx) - queryCmd := cli.GetQueryCmd() - - // query params - queryCmd.SetArgs([]string{"params"}) - s.Require().NoError(queryCmd.ExecuteContext(ctx)) -} - -func (s *BridgeTestSuite) TestCliTx() { - ctx := context.Background() - txCfg := authtx.NewTxConfig(s.Client.GetCodec(), []signing.SignMode{signing.SignMode_SIGN_MODE_EIP_712}) - cliCtx := &sdkClient.Context{ - FromAddress: s.Validator.GetAddr(), - Client: s.TmClient.TmClient, - InterfaceRegistry: s.Client.GetCodec().InterfaceRegistry(), - Codec: s.Client.GetCodec(), - From: s.Validator.String(), - AccountRetriever: authtypes.AccountRetriever{}, - ChainID: s.Config.ChainId, - TxConfig: txCfg, - SkipConfirm: true, - Simulate: true, - } - ctx = context.WithValue(ctx, sdkClient.ClientContextKey, cliCtx) - txCmd := cli.GetTxCmd() - - // wrong to address - txCmd.SetArgs([]string{"transfer-out", "test", "1000000000000000000BNB"}) - s.Require().Contains(txCmd.ExecuteContext(ctx).Error(), "invalid address hex length") - - // tx transfer-out - txCmd.SetArgs([]string{"transfer-out", sdk.AccAddress("test").String(), "1000000000000000000BNB"}) - s.Require().NoError(txCmd.ExecuteContext(ctx)) -} - func (s *BridgeTestSuite) TestTransferOut() { users := s.GenAndChargeAccounts(2, 1000000) diff --git a/testutil/app.go b/testutil/app.go new file mode 100644 index 000000000..4a62c3237 --- /dev/null +++ b/testutil/app.go @@ -0,0 +1,82 @@ +package testutil + +import ( + "encoding/hex" + "encoding/json" + "io" + + dbm "github.com/cometbft/cometbft-db" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cometbft/cometbft/libs/log" + tmtypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1" + "github.com/cosmos/cosmos-sdk/testutil/mock" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" +) + +func NewTestApp( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + loadLatest bool, + chainID string, + options ...func(baseApp *baseapp.BaseApp), +) (*app.App, params.EncodingConfig, error) { + // create public key + privVal := mock.NewPV() + pubKey, _ := privVal.GetPubKey() + + // create validator set with single validator + validator := tmtypes.NewValidator(pubKey, 1) + valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) + + // generate genesis account + bz, _ := hex.DecodeString(test.TEST_PUBKEY) + faucetPubKey := ðsecp256k1.PubKey{Key: bz} + + acc := authtypes.NewBaseAccount(faucetPubKey.Address().Bytes(), faucetPubKey, 0, 0) + balance := banktypes.Balance{ + Address: acc.GetAddress().String(), + Coins: sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewInt(100000000000000))), + } + + encCfg := app.MakeEncodingConfig() + options = append(options, baseapp.SetChainID(chainID)) + nApp := app.New( + logger, + db, + traceStore, + loadLatest, + app.DefaultNodeHome, + 0, + encCfg, + &app.AppConfig{CrossChain: app.NewDefaultAppConfig().CrossChain}, + simtestutil.EmptyAppOptions{}, + options..., + ) + + genesisState := app.NewDefaultGenesisState(encCfg.Marshaler) + genesisState, _ = simtestutil.GenesisStateWithValSet(nApp.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) + + stateBytes, _ := json.MarshalIndent(genesisState, "", " ") + + // Initialize the chain + nApp.InitChain( + abci.RequestInitChain{ + ChainId: chainID, + Validators: []abci.ValidatorUpdate{}, + AppStateBytes: stateBytes, + }, + ) + nApp.Commit() + + return nApp, encCfg, nil +} diff --git a/x/bridge/client/cli/query_test.go b/x/bridge/client/cli/query_test.go new file mode 100644 index 000000000..00b7d55be --- /dev/null +++ b/x/bridge/client/cli/query_test.go @@ -0,0 +1,54 @@ +package cli_test + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/gogoproto/proto" + + "github.com/bnb-chain/greenfield/x/bridge/client/cli" + "github.com/bnb-chain/greenfield/x/bridge/types" +) + +func (s *CLITestSuite) TestQueryCmd() { + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagOutput, "json"), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + }{ + { + "query params", + append( + []string{ + "params", + }, + commonFlags..., + ), + false, "", &types.QueryParamsResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetQueryCmd() + out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} diff --git a/x/bridge/client/cli/tx_test.go b/x/bridge/client/cli/tx_test.go new file mode 100644 index 000000000..3f04f8dfb --- /dev/null +++ b/x/bridge/client/cli/tx_test.go @@ -0,0 +1,128 @@ +package cli_test + +import ( + "bytes" + "fmt" + "io" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/bridge/client/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/testutil" +) + +type CLITestSuite struct { + suite.Suite + + kr keyring.Keyring + baseCtx client.Context + encCfg params.EncodingConfig + clientCtx client.Context +} + +func TestCLITestSuite(t *testing.T) { + suite.Run(t, new(CLITestSuite)) +} + +func (s *CLITestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.encCfg = app.MakeEncodingConfig() + s.kr = keyring.NewInMemory(s.encCfg.Marshaler) + s.baseCtx = client.Context{}. + WithKeyring(s.kr). + WithTxConfig(s.encCfg.TxConfig). + WithCodec(s.encCfg.Marshaler). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID(test.TEST_CHAIN_ID) + + accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) + s.baseCtx = s.baseCtx.WithFrom(accounts[0].Address.String()) + s.baseCtx = s.baseCtx.WithFromName(accounts[0].Name) + s.baseCtx = s.baseCtx.WithFromAddress(accounts[0].Address) + + var outBuf bytes.Buffer + ctxGen := func() client.Context { + bz, _ := s.encCfg.Marshaler.Marshal(&sdk.TxResponse{}) + c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + Value: bz, + }) + + return s.baseCtx.WithClient(c) + } + s.clientCtx = ctxGen().WithOutput(&outBuf) + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } +} + +func (s *CLITestSuite) TestTxCmdTransferOut() { + clientCtx := s.clientCtx + + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + } + + testCases := []struct { + name string + args []string + expectErr bool + expErrMsg string + }{ + { + "invalid to address", + append( + []string{ + "invalidAddress", + "1000000000000000000BNB", + }, + commonFlags..., + ), + true, "invalid address hex length", + }, + { + "success case", + append( + []string{ + sample.RandAccAddressHex(), + "1000000000000000000BNB", + }, + commonFlags..., + ), + false, "", + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.CmdTransferOut() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &sdk.TxResponse{}), out.String()) + } + }) + } +} diff --git a/x/challenge/client/cli/query.go b/x/challenge/client/cli/query.go index d4a8ce07a..fc0d8924f 100644 --- a/x/challenge/client/cli/query.go +++ b/x/challenge/client/cli/query.go @@ -11,7 +11,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { +func GetQueryCmd() *cobra.Command { // Group challenge queries under a subcommand cmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/challenge/client/cli/query_test.go b/x/challenge/client/cli/query_test.go new file mode 100644 index 000000000..cfb109862 --- /dev/null +++ b/x/challenge/client/cli/query_test.go @@ -0,0 +1,74 @@ +package cli_test + +import ( + "fmt" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/gogoproto/proto" + + "github.com/bnb-chain/greenfield/x/challenge/client/cli" + "github.com/bnb-chain/greenfield/x/challenge/types" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +func (s *CLITestSuite) TestQueryCmd() { + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagOutput, "json"), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + }{ + { + "query params", + append( + []string{ + "params", + }, + commonFlags..., + ), + false, "", &types.QueryParamsResponse{}, + }, + { + "query latest-attested-challenges", + append( + []string{ + "latest-attested-challenges", + }, + commonFlags..., + ), + false, "", &types.QueryLatestAttestedChallengesResponse{}, + }, + { + "query inturn-attestation-submitter", + append( + []string{ + "inturn-attestation-submitter", + }, + commonFlags..., + ), + false, "", &types.QueryInturnAttestationSubmitterResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetQueryCmd() + out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} diff --git a/x/challenge/client/cli/tx_test.go b/x/challenge/client/cli/tx_test.go new file mode 100644 index 000000000..0c726d75b --- /dev/null +++ b/x/challenge/client/cli/tx_test.go @@ -0,0 +1,70 @@ +package cli_test + +import ( + "bytes" + "io" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" +) + +type CLITestSuite struct { + suite.Suite + + kr keyring.Keyring + baseCtx client.Context + encCfg params.EncodingConfig + clientCtx client.Context +} + +func TestCLITestSuite(t *testing.T) { + suite.Run(t, new(CLITestSuite)) +} + +func (s *CLITestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.encCfg = app.MakeEncodingConfig() + s.kr = keyring.NewInMemory(s.encCfg.Marshaler) + s.baseCtx = client.Context{}. + WithKeyring(s.kr). + WithTxConfig(s.encCfg.TxConfig). + WithCodec(s.encCfg.Marshaler). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID(test.TEST_CHAIN_ID) + + accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) + s.baseCtx = s.baseCtx.WithFrom(accounts[0].Address.String()) + s.baseCtx = s.baseCtx.WithFromName(accounts[0].Name) + s.baseCtx = s.baseCtx.WithFromAddress(accounts[0].Address) + + var outBuf bytes.Buffer + ctxGen := func() client.Context { + bz, _ := s.encCfg.Marshaler.Marshal(&sdk.TxResponse{}) + c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + Value: bz, + }) + + return s.baseCtx.WithClient(c) + } + s.clientCtx = ctxGen().WithOutput(&outBuf) + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } +} + +// TODO: Add more tests diff --git a/x/challenge/module.go b/x/challenge/module.go index 41ae438a2..808a8702f 100644 --- a/x/challenge/module.go +++ b/x/challenge/module.go @@ -78,7 +78,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- diff --git a/x/payment/client/cli/query_test.go b/x/payment/client/cli/query_test.go new file mode 100644 index 000000000..3428869ee --- /dev/null +++ b/x/payment/client/cli/query_test.go @@ -0,0 +1,150 @@ +package cli_test + +import ( + "fmt" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/gogoproto/proto" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/payment/client/cli" + "github.com/bnb-chain/greenfield/x/payment/types" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +func (s *CLITestSuite) TestQueryCmd() { + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagOutput, "json"), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + }{ + { + "query params", + append( + []string{ + "params", + }, + commonFlags..., + ), + false, "", &types.QueryParamsResponse{}, + }, + { + "query dynamic-balance", + append( + []string{ + "dynamic-balance", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryDynamicBalanceResponse{}, + }, + { + "query get-payment-accounts-by-owner", + append( + []string{ + "get-payment-accounts-by-owner", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryGetPaymentAccountsByOwnerResponse{}, + }, + { + "query list-auto-settle-record", + append( + []string{ + "list-auto-settle-record", + }, + commonFlags..., + ), + false, "", &types.QueryAllAutoSettleRecordResponse{}, + }, + { + "query list-payment-account", + append( + []string{ + "list-payment-account", + }, + commonFlags..., + ), + false, "", &types.QueryAllPaymentAccountResponse{}, + }, + { + "query list-payment-account-count", + append( + []string{ + "list-payment-account-count", + }, + commonFlags..., + ), + false, "", &types.QueryAllPaymentAccountCountResponse{}, + }, + { + "query list-stream-record", + append( + []string{ + "list-stream-record", + }, + commonFlags..., + ), + false, "", &types.QueryAllStreamRecordResponse{}, + }, + { + "query show-payment-account", + append( + []string{ + "show-payment-account", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryGetPaymentAccountResponse{}, + }, + { + "query show-payment-account-count", + append( + []string{ + "show-payment-account-count", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryGetPaymentAccountCountResponse{}, + }, + { + "query show-stream-record", + append( + []string{ + "show-stream-record", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryGetStreamRecordResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetQueryCmd() + out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} diff --git a/x/payment/client/cli/tx_test.go b/x/payment/client/cli/tx_test.go new file mode 100644 index 000000000..0c726d75b --- /dev/null +++ b/x/payment/client/cli/tx_test.go @@ -0,0 +1,70 @@ +package cli_test + +import ( + "bytes" + "io" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" +) + +type CLITestSuite struct { + suite.Suite + + kr keyring.Keyring + baseCtx client.Context + encCfg params.EncodingConfig + clientCtx client.Context +} + +func TestCLITestSuite(t *testing.T) { + suite.Run(t, new(CLITestSuite)) +} + +func (s *CLITestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.encCfg = app.MakeEncodingConfig() + s.kr = keyring.NewInMemory(s.encCfg.Marshaler) + s.baseCtx = client.Context{}. + WithKeyring(s.kr). + WithTxConfig(s.encCfg.TxConfig). + WithCodec(s.encCfg.Marshaler). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID(test.TEST_CHAIN_ID) + + accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) + s.baseCtx = s.baseCtx.WithFrom(accounts[0].Address.String()) + s.baseCtx = s.baseCtx.WithFromName(accounts[0].Name) + s.baseCtx = s.baseCtx.WithFromAddress(accounts[0].Address) + + var outBuf bytes.Buffer + ctxGen := func() client.Context { + bz, _ := s.encCfg.Marshaler.Marshal(&sdk.TxResponse{}) + c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + Value: bz, + }) + + return s.baseCtx.WithClient(c) + } + s.clientCtx = ctxGen().WithOutput(&outBuf) + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } +} + +// TODO: Add more tests diff --git a/x/payment/keeper/msg_server_test.go b/x/payment/keeper/msg_server_test.go index c72134039..c7c3f735f 100644 --- a/x/payment/keeper/msg_server_test.go +++ b/x/payment/keeper/msg_server_test.go @@ -88,7 +88,7 @@ func (s *TestSuite) TestUpdateParams() { { name: "invalid authority", msg: types.MsgUpdateParams{ - Authority: sample.AccAddress(), + Authority: sample.RandAccAddressHex(), }, err: true, }, { diff --git a/x/permission/client/cli/query_test.go b/x/permission/client/cli/query_test.go new file mode 100644 index 000000000..44d63f5c6 --- /dev/null +++ b/x/permission/client/cli/query_test.go @@ -0,0 +1,54 @@ +package cli_test + +import ( + "fmt" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/gogoproto/proto" + + "github.com/bnb-chain/greenfield/x/payment/client/cli" + "github.com/bnb-chain/greenfield/x/payment/types" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +func (s *CLITestSuite) TestQueryCmd() { + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagOutput, "json"), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + }{ + { + "query params", + append( + []string{ + "params", + }, + commonFlags..., + ), + false, "", &types.QueryParamsResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetQueryCmd() + out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} diff --git a/x/permission/client/cli/tx_test.go b/x/permission/client/cli/tx_test.go new file mode 100644 index 000000000..0c726d75b --- /dev/null +++ b/x/permission/client/cli/tx_test.go @@ -0,0 +1,70 @@ +package cli_test + +import ( + "bytes" + "io" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" +) + +type CLITestSuite struct { + suite.Suite + + kr keyring.Keyring + baseCtx client.Context + encCfg params.EncodingConfig + clientCtx client.Context +} + +func TestCLITestSuite(t *testing.T) { + suite.Run(t, new(CLITestSuite)) +} + +func (s *CLITestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.encCfg = app.MakeEncodingConfig() + s.kr = keyring.NewInMemory(s.encCfg.Marshaler) + s.baseCtx = client.Context{}. + WithKeyring(s.kr). + WithTxConfig(s.encCfg.TxConfig). + WithCodec(s.encCfg.Marshaler). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID(test.TEST_CHAIN_ID) + + accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) + s.baseCtx = s.baseCtx.WithFrom(accounts[0].Address.String()) + s.baseCtx = s.baseCtx.WithFromName(accounts[0].Name) + s.baseCtx = s.baseCtx.WithFromAddress(accounts[0].Address) + + var outBuf bytes.Buffer + ctxGen := func() client.Context { + bz, _ := s.encCfg.Marshaler.Marshal(&sdk.TxResponse{}) + c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + Value: bz, + }) + + return s.baseCtx.WithClient(c) + } + s.clientCtx = ctxGen().WithOutput(&outBuf) + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } +} + +// TODO: Add more tests diff --git a/x/sp/client/cli/query.go b/x/sp/client/cli/query.go index 8972c6b39..2bc625bf7 100644 --- a/x/sp/client/cli/query.go +++ b/x/sp/client/cli/query.go @@ -13,7 +13,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { +func GetQueryCmd() *cobra.Command { // Group sp queries under a subcommand cmd := &cobra.Command{ Use: types.ModuleName, @@ -67,7 +67,7 @@ func CmdStorageProviders() *cobra.Command { func CmdStorageProvider() *cobra.Command { cmd := &cobra.Command{ Use: "storage-provider [sp-id]", - Short: "Query storage provider with specify operator address", + Short: "Query storage provider with specify sp id", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { reqSpID := args[0] @@ -103,8 +103,8 @@ func CmdStorageProvider() *cobra.Command { func CmdStorageProviderByOperatorAddress() *cobra.Command { cmd := &cobra.Command{ Use: "storage-provider-by-operator-address [operator address]", - Short: "Query StorageProviderByOperatorAddress", - Args: cobra.ExactArgs(0), + Short: "Query storage provider with specify operator address", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { reqSpAddr := args[0] diff --git a/x/sp/client/cli/query_test.go b/x/sp/client/cli/query_test.go new file mode 100644 index 000000000..f7dbf1a80 --- /dev/null +++ b/x/sp/client/cli/query_test.go @@ -0,0 +1,87 @@ +package cli_test + +import ( + "fmt" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/gogoproto/proto" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/sp/client/cli" + "github.com/bnb-chain/greenfield/x/sp/types" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +func (s *CLITestSuite) TestQueryCmd() { + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagOutput, "json"), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + }{ + { + "query params", + append( + []string{ + "params", + }, + commonFlags..., + ), + false, "", &types.QueryParamsResponse{}, + }, + { + "query storage-provider", + append( + []string{ + "storage-provider", + "1", + }, + commonFlags..., + ), + false, "", &types.QueryStorageProviderResponse{}, + }, + { + "query storage-provider-by-operator-address", + append( + []string{ + "storage-provider-by-operator-address", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryStorageProviderByOperatorAddressResponse{}, + }, + { + "query storage-providers", + append( + []string{ + "storage-providers", + }, + commonFlags..., + ), + false, "", &types.QueryStorageProvidersResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetQueryCmd() + out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} diff --git a/x/sp/client/cli/tx_test.go b/x/sp/client/cli/tx_test.go new file mode 100644 index 000000000..0c726d75b --- /dev/null +++ b/x/sp/client/cli/tx_test.go @@ -0,0 +1,70 @@ +package cli_test + +import ( + "bytes" + "io" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" +) + +type CLITestSuite struct { + suite.Suite + + kr keyring.Keyring + baseCtx client.Context + encCfg params.EncodingConfig + clientCtx client.Context +} + +func TestCLITestSuite(t *testing.T) { + suite.Run(t, new(CLITestSuite)) +} + +func (s *CLITestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.encCfg = app.MakeEncodingConfig() + s.kr = keyring.NewInMemory(s.encCfg.Marshaler) + s.baseCtx = client.Context{}. + WithKeyring(s.kr). + WithTxConfig(s.encCfg.TxConfig). + WithCodec(s.encCfg.Marshaler). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID(test.TEST_CHAIN_ID) + + accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) + s.baseCtx = s.baseCtx.WithFrom(accounts[0].Address.String()) + s.baseCtx = s.baseCtx.WithFromName(accounts[0].Name) + s.baseCtx = s.baseCtx.WithFromAddress(accounts[0].Address) + + var outBuf bytes.Buffer + ctxGen := func() client.Context { + bz, _ := s.encCfg.Marshaler.Marshal(&sdk.TxResponse{}) + c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + Value: bz, + }) + + return s.baseCtx.WithClient(c) + } + s.clientCtx = ctxGen().WithOutput(&outBuf) + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } +} + +// TODO: Add more tests diff --git a/x/sp/module.go b/x/sp/module.go index ddab571e7..1cd21a2b7 100644 --- a/x/sp/module.go +++ b/x/sp/module.go @@ -78,7 +78,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- diff --git a/x/storage/client/cli/query.go b/x/storage/client/cli/query.go index b0f3fdf6d..6d8075541 100644 --- a/x/storage/client/cli/query.go +++ b/x/storage/client/cli/query.go @@ -12,7 +12,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { +func GetQueryCmd() *cobra.Command { // Group storage queries under a subcommand storageQueryCmd := &cobra.Command{ Use: types.ModuleName, @@ -109,7 +109,7 @@ func CmdHeadObject() *cobra.Command { func CmdListBuckets() *cobra.Command { cmd := &cobra.Command{ Use: "list-buckets", - Short: "Query list buckets of the user", + Short: "Query all list buckets", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx := client.GetClientContextFromCmd(cmd) diff --git a/x/storage/client/cli/query_test.go b/x/storage/client/cli/query_test.go new file mode 100644 index 000000000..ff984294c --- /dev/null +++ b/x/storage/client/cli/query_test.go @@ -0,0 +1,149 @@ +package cli_test + +import ( + "fmt" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/gogoproto/proto" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/storage/client/cli" + "github.com/bnb-chain/greenfield/x/storage/types" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +func (s *CLITestSuite) TestQueryCmd() { + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagOutput, "json"), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + }{ + { + "query params", + append( + []string{ + "params", + }, + commonFlags..., + ), + false, "", &types.QueryParamsResponse{}, + }, + { + "query head-bucket", + append( + []string{ + "head-bucket", + "bucketName", + }, + commonFlags..., + ), + false, "", &types.QueryHeadBucketResponse{}, + }, + { + "query head-group", + append( + []string{ + "head-group", + sample.RandAccAddressHex(), + "groupName", + }, + commonFlags..., + ), + false, "", &types.QueryHeadGroupResponse{}, + }, + { + "query head-group-member", + append( + []string{ + "head-group-member", + sample.RandAccAddressHex(), + "groupName", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryHeadGroupMemberResponse{}, + }, + { + "query head-object", + append( + []string{ + "head-object", + "bucketName", + "objectName", + }, + commonFlags..., + ), + false, "", &types.QueryHeadObjectResponse{}, + }, + { + "query list-buckets", + append( + []string{ + "list-buckets", + }, + commonFlags..., + ), + false, "", &types.QueryListBucketsResponse{}, + }, + { + "query list-group", + append( + []string{ + "list-group", + sample.RandAccAddressHex(), + }, + commonFlags..., + ), + false, "", &types.QueryListGroupResponse{}, + }, + { + "query list-objects", + append( + []string{ + "list-objects", + "bucketName", + }, + commonFlags..., + ), + false, "", &types.QueryListObjectsResponse{}, + }, + { + "query verify-permission", + append( + []string{ + "verify-permission", + sample.RandAccAddressHex(), + "bucketName", + "objectName", + "ACTION_TYPE_ALL", + }, + commonFlags..., + ), + false, "", &types.QueryVerifyPermissionResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetQueryCmd() + out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} diff --git a/x/storage/client/cli/tx_test.go b/x/storage/client/cli/tx_test.go new file mode 100644 index 000000000..0c726d75b --- /dev/null +++ b/x/storage/client/cli/tx_test.go @@ -0,0 +1,70 @@ +package cli_test + +import ( + "bytes" + "io" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" +) + +type CLITestSuite struct { + suite.Suite + + kr keyring.Keyring + baseCtx client.Context + encCfg params.EncodingConfig + clientCtx client.Context +} + +func TestCLITestSuite(t *testing.T) { + suite.Run(t, new(CLITestSuite)) +} + +func (s *CLITestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.encCfg = app.MakeEncodingConfig() + s.kr = keyring.NewInMemory(s.encCfg.Marshaler) + s.baseCtx = client.Context{}. + WithKeyring(s.kr). + WithTxConfig(s.encCfg.TxConfig). + WithCodec(s.encCfg.Marshaler). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID(test.TEST_CHAIN_ID) + + accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) + s.baseCtx = s.baseCtx.WithFrom(accounts[0].Address.String()) + s.baseCtx = s.baseCtx.WithFromName(accounts[0].Name) + s.baseCtx = s.baseCtx.WithFromAddress(accounts[0].Address) + + var outBuf bytes.Buffer + ctxGen := func() client.Context { + bz, _ := s.encCfg.Marshaler.Marshal(&sdk.TxResponse{}) + c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + Value: bz, + }) + + return s.baseCtx.WithClient(c) + } + s.clientCtx = ctxGen().WithOutput(&outBuf) + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } +} + +// TODO: Add more tests diff --git a/x/storage/module.go b/x/storage/module.go index a63693144..005621bea 100644 --- a/x/storage/module.go +++ b/x/storage/module.go @@ -79,7 +79,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- diff --git a/x/virtualgroup/client/cli/query.go b/x/virtualgroup/client/cli/query.go index 0ca76153b..7193e9ffd 100644 --- a/x/virtualgroup/client/cli/query.go +++ b/x/virtualgroup/client/cli/query.go @@ -12,7 +12,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { +func GetQueryCmd() *cobra.Command { // Group storage queries under a subcommand cmd := &cobra.Command{ Use: types.ModuleName, 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 8fbc62947..5c57f751e 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 @@ -19,7 +19,6 @@ func CmdGlobalVirtualGroupByFamilyID() *cobra.Command { Short: "query virtual group by family id", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { - familyID, err := strconv.ParseInt(args[0], 10, 32) if err != nil || familyID <= 0 { return fmt.Errorf("invalid GVG id %s", args[1]) diff --git a/x/virtualgroup/client/cli/query_global_virtual_group_families.go b/x/virtualgroup/client/cli/query_global_virtual_group_families.go index 6714a67dd..dba4e5311 100644 --- a/x/virtualgroup/client/cli/query_global_virtual_group_families.go +++ b/x/virtualgroup/client/cli/query_global_virtual_group_families.go @@ -20,10 +20,9 @@ func CmdGlobalVirtualGroupFamilies() *cobra.Command { Short: "query all global virtual groups families of the storage provider.", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { - - limit, err := strconv.ParseInt(args[1], 10, 32) + limit, err := strconv.ParseInt(args[0], 10, 32) if err != nil || limit <= 0 { - return fmt.Errorf("invalid GVG id %s", args[1]) + return fmt.Errorf("invalid limit %s", args[0]) } clientCtx, err := client.GetClientQueryContext(cmd) diff --git a/x/virtualgroup/client/cli/query_test.go b/x/virtualgroup/client/cli/query_test.go new file mode 100644 index 000000000..51838ba12 --- /dev/null +++ b/x/virtualgroup/client/cli/query_test.go @@ -0,0 +1,98 @@ +package cli_test + +import ( + "fmt" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/gogoproto/proto" + + "github.com/bnb-chain/greenfield/x/virtualgroup/client/cli" + "github.com/bnb-chain/greenfield/x/virtualgroup/types" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +func (s *CLITestSuite) TestQueryCmd() { + commonFlags := []string{ + fmt.Sprintf("--%s=%s", flags.FlagOutput, "json"), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + }{ + { + "query params", + append( + []string{ + "params", + }, + commonFlags..., + ), + false, "", &types.QueryParamsResponse{}, + }, + { + "query global-virtual-group", + append( + []string{ + "global-virtual-group", + "1", + }, + commonFlags..., + ), + false, "", &types.QueryGlobalVirtualGroupResponse{}, + }, + { + "query global-virtual-group-by-family-id", + append( + []string{ + "global-virtual-group-by-family-id", + "1", + }, + commonFlags..., + ), + false, "", &types.QueryGlobalVirtualGroupByFamilyIDResponse{}, + }, + { + "query global-virtual-group-families", + append( + []string{ + "global-virtual-group-families", + "100", + }, + commonFlags..., + ), + false, "", &types.QueryGlobalVirtualGroupFamiliesResponse{}, + }, + { + "query global-virtual-group-family", + append( + []string{ + "global-virtual-group-family", + "1", + }, + commonFlags..., + ), + false, "", &types.QueryGlobalVirtualGroupFamilyResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetQueryCmd() + out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectErrMsg) + } else { + s.Require().NoError(err) + s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} diff --git a/x/virtualgroup/client/cli/tx_test.go b/x/virtualgroup/client/cli/tx_test.go new file mode 100644 index 000000000..0c726d75b --- /dev/null +++ b/x/virtualgroup/client/cli/tx_test.go @@ -0,0 +1,70 @@ +package cli_test + +import ( + "bytes" + "io" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/app/params" + "github.com/bnb-chain/greenfield/sdk/client/test" +) + +type CLITestSuite struct { + suite.Suite + + kr keyring.Keyring + baseCtx client.Context + encCfg params.EncodingConfig + clientCtx client.Context +} + +func TestCLITestSuite(t *testing.T) { + suite.Run(t, new(CLITestSuite)) +} + +func (s *CLITestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.encCfg = app.MakeEncodingConfig() + s.kr = keyring.NewInMemory(s.encCfg.Marshaler) + s.baseCtx = client.Context{}. + WithKeyring(s.kr). + WithTxConfig(s.encCfg.TxConfig). + WithCodec(s.encCfg.Marshaler). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID(test.TEST_CHAIN_ID) + + accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) + s.baseCtx = s.baseCtx.WithFrom(accounts[0].Address.String()) + s.baseCtx = s.baseCtx.WithFromName(accounts[0].Name) + s.baseCtx = s.baseCtx.WithFromAddress(accounts[0].Address) + + var outBuf bytes.Buffer + ctxGen := func() client.Context { + bz, _ := s.encCfg.Marshaler.Marshal(&sdk.TxResponse{}) + c := clitestutil.NewMockTendermintRPC(abci.ResponseQuery{ + Value: bz, + }) + + return s.baseCtx.WithClient(c) + } + s.clientCtx = ctxGen().WithOutput(&outBuf) + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } +} + +// TODO: Add more tests diff --git a/x/virtualgroup/module.go b/x/virtualgroup/module.go index 9afdd6832..8d05904be 100644 --- a/x/virtualgroup/module.go +++ b/x/virtualgroup/module.go @@ -81,7 +81,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- From cb7efe874a392551b3e5952caeeb5a2bf0d5e704 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Tue, 1 Aug 2023 10:01:19 +0800 Subject: [PATCH 12/24] chore: add more test cases for cross chain apps (#389) * chore: add more test cases for cross chain apps * add test cases for cross chain apps * delete unused file * exclude cli dir * exclude genesis file * add test cases for genesis * add more test cases * delete unused code * add more test cases * add tests for discontinue count * add test cases for permission * add tests for grpc query * fix imports --- .testcoverage.yml | 1 + e2e/tests/permission_test.go | 103 ++++++++ e2e/tests/storage_test.go | 111 ++++++++ x/storage/{ => keeper}/abci.go | 7 +- x/storage/keeper/cross_app_bucket_test.go | 205 ++++++++++++++- x/storage/keeper/cross_app_group_test.go | 307 ++++++++++++++++++++++ x/storage/keeper/cross_app_object_test.go | 162 ++++++++++++ x/storage/keeper/grpc_query_test.go | 304 +++++++++++++++++++++ x/storage/keeper/keeper.go | 16 +- x/storage/keeper/keeper_test.go | 29 ++ x/storage/keeper/msg_server_test.go | 1 - x/storage/keeper/query.go | 6 +- x/storage/module.go | 4 +- x/storage/types/crosschain.go | 52 +++- x/virtualgroup/keeper/genesis_test.go | 27 ++ 15 files changed, 1312 insertions(+), 23 deletions(-) rename x/storage/{ => keeper}/abci.go (88%) create mode 100644 x/storage/keeper/cross_app_group_test.go create mode 100644 x/storage/keeper/cross_app_object_test.go create mode 100644 x/storage/keeper/keeper_test.go delete mode 100644 x/storage/keeper/msg_server_test.go create mode 100644 x/virtualgroup/keeper/genesis_test.go diff --git a/.testcoverage.yml b/.testcoverage.yml index aafc6be78..5a675d980 100644 --- a/.testcoverage.yml +++ b/.testcoverage.yml @@ -37,6 +37,7 @@ exclude: - simulation/.* - testutil/.* - e2e/.* + - .*/cli/.* - sdk/.* - version/.* - cmd/gnfd/.* diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index df5ccf718..c11900632 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1107,6 +1107,109 @@ func (s *StorageTestSuite) TestStalePermissionForAccountGC() { s.Require().ErrorContains(err, "No such Policy") } +func (s *StorageTestSuite) TestDeleteObjectPolicy() { + var err error + ctx := context.Background() + user1 := s.GenAndChargeAccounts(1, 1000000)[0] + + _, owner, bucketName, _, objectName, objectId := s.createObjectWithVisibility(storagetypes.VISIBILITY_TYPE_PUBLIC_READ) + + principal := types.NewPrincipalWithAccount(user1.GetAddr()) + + // Put bucket policy + bucketStatement := &types.Statement{ + Actions: []types.ActionType{types.ACTION_DELETE_BUCKET}, + Effect: types.EFFECT_ALLOW, + } + msgPutBucketPolicy := storagetypes.NewMsgPutPolicy(owner.GetAddr(), types2.NewBucketGRN(bucketName).String(), + principal, []*types.Statement{bucketStatement}, nil) + s.SendTxBlock(owner, msgPutBucketPolicy) + + // Put Object policy + objectStatement := &types.Statement{ + Actions: []types.ActionType{types.ACTION_DELETE_OBJECT}, + Effect: types.EFFECT_ALLOW, + } + msgPutObjectPolicy := storagetypes.NewMsgPutPolicy(owner.GetAddr(), types2.NewObjectGRN(bucketName, objectName).String(), + principal, []*types.Statement{objectStatement}, nil) + s.SendTxBlock(owner, msgPutObjectPolicy) + + // Query the policy which is enforced on bucket and object + grn1 := types2.NewObjectGRN(bucketName, objectName) + queryPolicyForAccountResp, err := s.Client.QueryPolicyForAccount(ctx, &storagetypes.QueryPolicyForAccountRequest{Resource: grn1.String(), + PrincipalAddress: user1.GetAddr().String()}) + s.Require().NoError(err) + s.Require().Equal(objectId, queryPolicyForAccountResp.Policy.ResourceId) + + // Delete object policy + msgDeletePolicy := storagetypes.NewMsgDeletePolicy(owner.GetAddr(), grn1.String(), types.NewPrincipalWithAccount(user1.GetAddr())) + s.SendTxBlock(owner, msgDeletePolicy) + + // verify permission + verifyPermReq := storagetypes.QueryVerifyPermissionRequest{ + Operator: user1.GetAddr().String(), + BucketName: bucketName, + ObjectName: objectName, + ActionType: types.ACTION_DELETE_OBJECT, + } + verifyPermResp, err := s.Client.VerifyPermission(ctx, &verifyPermReq) + s.T().Logf("resp: %s, rep %s", verifyPermReq.String(), verifyPermResp.String()) + s.Require().NoError(err) + s.Require().Equal(verifyPermResp.Effect, types.EFFECT_DENY) +} + +func (s *StorageTestSuite) TestDeleteGroupPolicy() { + var err error + ctx := context.Background() + + user := s.GenAndChargeAccounts(4, 1000000) + owner := user[0] + _ = s.BaseSuite.PickStorageProvider() + + // Create Group + testGroupName := "testGroup" + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, + []sdk.AccAddress{user[1].GetAddr(), user[2].GetAddr(), user[3].GetAddr()}, + "") + s.SendTxBlock(owner, msgCreateGroup) + + // Head Group + headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} + headGroupResponse, err := s.Client.HeadGroup(ctx, &headGroupRequest) + s.Require().NoError(err) + s.Require().Equal(headGroupResponse.GroupInfo.GroupName, testGroupName) + s.Require().True(owner.GetAddr().Equals(sdk.MustAccAddressFromHex(headGroupResponse.GroupInfo.Owner))) + s.T().Logf("GroupInfo: %s", headGroupResponse.GetGroupInfo().String()) + + // Put policy + groupStatement := &types.Statement{ + Actions: []types.ActionType{types.ACTION_UPDATE_GROUP_MEMBER}, + Effect: types.EFFECT_ALLOW, + } + msgPutGroupPolicy := storagetypes.NewMsgPutPolicy(owner.GetAddr(), types2.NewGroupGRN(owner.GetAddr(), testGroupName).String(), + types.NewPrincipalWithAccount(user[1].GetAddr()), []*types.Statement{groupStatement}, nil) + s.SendTxBlock(owner, msgPutGroupPolicy) + + // Query for policy + grn := types2.NewGroupGRN(owner.GetAddr(), testGroupName) + queryPolicyForAccountReq := storagetypes.QueryPolicyForAccountRequest{Resource: grn.String(), + PrincipalAddress: user[1].GetAddr().String()} + + queryPolicyForAccountResp, err := s.Client.QueryPolicyForAccount(ctx, &queryPolicyForAccountReq) + s.Require().NoError(err) + s.Require().Equal(queryPolicyForAccountResp.Policy.ResourceType, resource.RESOURCE_TYPE_GROUP) + s.T().Logf("policy is %s", queryPolicyForAccountResp.Policy.String()) + + // Delete policy + msgDeletePolicy := storagetypes.NewMsgDeletePolicy(owner.GetAddr(), grn.String(), types.NewPrincipalWithAccount(user[1].GetAddr())) + s.SendTxBlock(owner, msgDeletePolicy) + + // verify permission + _, err = s.Client.QueryPolicyForAccount(ctx, &queryPolicyForAccountReq) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such Policy") +} + // When resources are deleted, policies which associated with group and resources(Bucket and Object) // will also be garbage collected. func (s *StorageTestSuite) TestStalePermissionForGroupGC() { diff --git a/e2e/tests/storage_test.go b/e2e/tests/storage_test.go index 5b04412ba..4aa84e72e 100644 --- a/e2e/tests/storage_test.go +++ b/e2e/tests/storage_test.go @@ -99,6 +99,26 @@ func (s *StorageTestSuite) TestCreateBucket() { s.Require().NoError(err) s.Require().Equal(queryHeadBucketResponseAfterUpdateBucket.BucketInfo.Visibility, storagetypes.VISIBILITY_TYPE_PRIVATE) + // verify HeadBucketById + queryHeadBucketResponseAfterUpdateBucket, err = s.Client.HeadBucketById(ctx, &storagetypes.QueryHeadBucketByIdRequest{BucketId: queryHeadBucketResponseAfterUpdateBucket.BucketInfo.Id.String()}) + s.Require().NoError(err) + s.Require().Equal(queryHeadBucketResponseAfterUpdateBucket.BucketInfo.Visibility, storagetypes.VISIBILITY_TYPE_PRIVATE) + s.Require().Equal(queryHeadBucketResponseAfterUpdateBucket.BucketInfo.BucketName, bucketName) + + // verify HeadBucketNFT + headBucketNftResponse, err := s.Client.HeadBucketNFT(ctx, &storagetypes.QueryNFTRequest{ + TokenId: queryHeadBucketResponseAfterUpdateBucket.BucketInfo.Id.String(), + }) + s.Require().NoError(err) + s.Require().Equal(headBucketNftResponse.MetaData.BucketName, bucketName) + + // verify QueryIsPriceChanged + isPriceChanged, err := s.Client.QueryIsPriceChanged(ctx, &storagetypes.QueryIsPriceChangedRequest{ + BucketName: bucketName, + }) + s.Require().NoError(err) + s.Require().Equal(isPriceChanged.Changed, false) + // DeleteBucket msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) s.SendTxBlock(user, msgDeleteBucket) @@ -205,6 +225,21 @@ func (s *StorageTestSuite) TestCreateObject() { s.Require().Equal(len(queryListObjectsResponse.ObjectInfos), 1) s.Require().Equal(queryListObjectsResponse.ObjectInfos[0].ObjectName, objectName) + // verify ListObjectsByBucketId + queryListObjectsResponse, err = s.Client.ListObjectsByBucketId(ctx, &storagetypes.QueryListObjectsByBucketIdRequest{ + BucketId: queryHeadBucketResponse.BucketInfo.Id.String(), + }) + s.Require().NoError(err) + s.Require().Equal(len(queryListObjectsResponse.ObjectInfos), 1) + s.Require().Equal(queryListObjectsResponse.ObjectInfos[0].ObjectName, objectName) + + // verify HeadObjectNFT + headObjectNftResponse, err := s.Client.HeadObjectNFT(ctx, &storagetypes.QueryNFTRequest{ + TokenId: queryListObjectsResponse.ObjectInfos[0].Id.String(), + }) + s.Require().NoError(err) + s.Require().Equal(headObjectNftResponse.MetaData.ObjectName, objectName) + // UpdateObjectInfo updateObjectInfo := storagetypes.NewMsgUpdateObjectInfo( user.GetAddr(), bucketName, objectName, storagetypes.VISIBILITY_TYPE_INHERIT) @@ -218,6 +253,12 @@ func (s *StorageTestSuite) TestCreateObject() { s.Require().NoError(err) s.Require().Equal(queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.Visibility, storagetypes.VISIBILITY_TYPE_INHERIT) + // verify HeadObjectById + queryHeadObjectAfterUpdateObjectResponse, err = s.Client.HeadObjectById(context.Background(), &storagetypes.QueryHeadObjectByIdRequest{ObjectId: queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.Id.String()}) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.Visibility, storagetypes.VISIBILITY_TYPE_INHERIT) + s.Require().Equal(queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.ObjectName, objectName) + // DeleteObject msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName) s.SendTxBlock(user, msgDeleteObject) @@ -246,6 +287,13 @@ func (s *StorageTestSuite) TestCreateGroup() { s.Require().Equal(queryHeadGroupResp.GroupInfo.GroupName, groupName) s.Require().Equal(queryHeadGroupResp.GroupInfo.Owner, owner.GetAddr().String()) + // 2.1. HeadGroupNFT + headGroupNftResponse, err := s.Client.HeadGroupNFT(ctx, &storagetypes.QueryNFTRequest{ + TokenId: queryHeadGroupResp.GroupInfo.Id.String(), + }) + s.Require().NoError(err) + s.Require().Equal(headGroupNftResponse.MetaData.GroupName, groupName) + // 3. ListGroup queryListGroupReq := storagetypes.QueryListGroupRequest{GroupOwner: owner.GetAddr().String()} queryListGroupResp, err := s.Client.ListGroup(ctx, &queryListGroupReq) @@ -292,6 +340,69 @@ func (s *StorageTestSuite) TestCreateGroup() { s.SendTxBlockWithExpectErrorString(msgCreateGroup, owner, "exists") } +func (s *StorageTestSuite) TestLeaveGroup() { + ctx := context.Background() + + owner := s.GenAndChargeAccounts(1, 1000000)[0] + member := s.GenAndChargeAccounts(1, 1000000)[0] + groupName := storageutils.GenRandomGroupName() + + // 1. CreateGroup + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, []sdk.AccAddress{member.GetAddr()}, "") + s.SendTxBlock(owner, msgCreateGroup) + s.T().Logf("CerateGroup success, owner: %s, group name: %s", owner.GetAddr().String(), groupName) + + // 2. HeadGroup + queryHeadGroupReq := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: groupName} + queryHeadGroupResp, err := s.Client.HeadGroup(ctx, &queryHeadGroupReq) + s.Require().NoError(err) + s.Require().Equal(queryHeadGroupResp.GroupInfo.GroupName, groupName) + s.Require().Equal(queryHeadGroupResp.GroupInfo.Owner, owner.GetAddr().String()) + + // 2.1. HeadGroupNFT + headGroupNftResponse, err := s.Client.HeadGroupNFT(ctx, &storagetypes.QueryNFTRequest{ + TokenId: queryHeadGroupResp.GroupInfo.Id.String(), + }) + s.Require().NoError(err) + s.Require().Equal(headGroupNftResponse.MetaData.GroupName, groupName) + + // 3. ListGroup + queryListGroupReq := storagetypes.QueryListGroupRequest{GroupOwner: owner.GetAddr().String()} + queryListGroupResp, err := s.Client.ListGroup(ctx, &queryListGroupReq) + s.Require().NoError(err) + s.Require().GreaterOrEqual(len(queryListGroupResp.GroupInfos), 1) + + // 3. HeadGroupMember + queryHeadGroupMemberReq := storagetypes.QueryHeadGroupMemberRequest{ + Member: member.GetAddr().String(), + GroupName: groupName, + GroupOwner: owner.GetAddr().String(), + } + queryHeadGroupMemberResp, err := s.Client.HeadGroupMember(ctx, &queryHeadGroupMemberReq) + s.Require().NoError(err) + s.Require().Equal(queryHeadGroupMemberResp.GroupMember.GroupId, queryHeadGroupResp.GroupInfo.Id) + + // 4. UpdateGroupMember + member2 := s.GenAndChargeAccounts(1, 1000000)[0] + membersToAdd := []sdk.AccAddress{member2.GetAddr()} + membersToDelete := []sdk.AccAddress{member.GetAddr()} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), groupName, membersToAdd, membersToDelete) + s.SendTxBlock(owner, msgUpdateGroupMember) + + // 5. leave group + msgLeaveGroup := storagetypes.NewMsgLeaveGroup(member2.GetAddr(), owner.GetAddr(), groupName) + s.SendTxBlock(member2, msgLeaveGroup) + + // 6. HeadGroupMember (leave) + queryHeadGroupMemberReqDelete := storagetypes.QueryHeadGroupMemberRequest{ + Member: member2.GetAddr().String(), + GroupName: groupName, + GroupOwner: owner.GetAddr().String(), + } + _, err = s.Client.HeadGroupMember(ctx, &queryHeadGroupMemberReqDelete) + s.Require().True(strings.Contains(err.Error(), storagetypes.ErrNoSuchGroupMember.Error())) +} + func (s *StorageTestSuite) TestDeleteBucket() { var err error user := s.GenAndChargeAccounts(1, 1000000)[0] diff --git a/x/storage/abci.go b/x/storage/keeper/abci.go similarity index 88% rename from x/storage/abci.go rename to x/storage/keeper/abci.go index b395f512c..01877b4b6 100644 --- a/x/storage/abci.go +++ b/x/storage/keeper/abci.go @@ -1,13 +1,12 @@ -package storage +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" paymenttypes "github.com/bnb-chain/greenfield/x/payment/types" - k "github.com/bnb-chain/greenfield/x/storage/keeper" ) -func BeginBlocker(ctx sdk.Context, keeper k.Keeper) { +func BeginBlocker(ctx sdk.Context, keeper Keeper) { blockHeight := uint64(ctx.BlockHeight()) countingWindow := keeper.DiscontinueCountingWindow(ctx) if blockHeight > 0 && countingWindow > 0 && blockHeight%countingWindow == 0 { @@ -16,7 +15,7 @@ func BeginBlocker(ctx sdk.Context, keeper k.Keeper) { } } -func EndBlocker(ctx sdk.Context, keeper k.Keeper) { +func EndBlocker(ctx sdk.Context, keeper Keeper) { deletionMax := keeper.DiscontinueDeletionMax(ctx) if deletionMax == 0 { return diff --git a/x/storage/keeper/cross_app_bucket_test.go b/x/storage/keeper/cross_app_bucket_test.go index c4e9f35df..43bf71c60 100644 --- a/x/storage/keeper/cross_app_bucket_test.go +++ b/x/storage/keeper/cross_app_bucket_test.go @@ -13,12 +13,6 @@ import ( ) func (s *TestSuite) TestSynDeleteBucket() { - pack := types.DeleteBucketAckPackage{ - Status: 1, - Id: big.NewInt(10), - ExtraData: []byte("x"), - } - pack.MustSerialize() ctrl := gomock.NewController(s.T()) storageKeeper := types.NewMockStorageKeeper(ctrl) storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() @@ -55,3 +49,202 @@ func (s *TestSuite) TestSynDeleteBucket() { res = app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) s.Require().NoError(res.Err) } + +func (s *TestSuite) TestSynCreateBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + createSynPackage := types.CreateBucketSynPackage{ + Creator: sample.RandAccAddress(), + BucketName: "bucketname", + ExtraData: []byte("extra data"), + PaymentAddress: sample.RandAccAddress(), + PrimarySpAddress: sample.RandAccAddress(), + } + serializedSynPackage := createSynPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationCreateBucket}, serializedSynPackage...) + + // case 1: invalid package + res := app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().ErrorContains(res.Err, "Invalid type of visibility") + + // case 2: create bucket error + createSynPackage.Visibility = uint32(types.VISIBILITY_TYPE_PUBLIC_READ) + serializedSynPackage = createSynPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationCreateBucket}, serializedSynPackage...) + + storageKeeper.EXPECT().CreateBucket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(sdk.NewUint(1), fmt.Errorf("create error")) + res = app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().ErrorContains(res.Err, "create error") + + // case 3: create bucket success + createSynPackage.Visibility = uint32(types.VISIBILITY_TYPE_PUBLIC_READ) + serializedSynPackage = createSynPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationCreateBucket}, serializedSynPackage...) + + storageKeeper.EXPECT().CreateBucket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(sdk.NewUint(1), nil) + res = app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestSynMirrorBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + synPackage := types.MirrorBucketSynPackage{ + Owner: sample.RandAccAddress(), + Id: big.NewInt(10), + } + + serializedSynPack, err := synPackage.Serialize() + s.Require().NoError(err) + serializedSynPack = append([]byte{types.OperationMirrorBucket}, serializedSynPack...) + + // case 1: normal case + res := app.ExecuteSynPackage(s.ctx, nil, serializedSynPack) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestAckMirrorBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + ackPackage := types.MirrorBucketAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + } + + serializedAckPack, err := ackPackage.Serialize() + s.Require().NoError(err) + serializedAckPack = append([]byte{types.OperationMirrorBucket}, serializedAckPack...) + + // case 1: bucket not found + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + + res := app.ExecuteAckPackage(s.ctx, nil, serializedAckPack) + s.Require().ErrorIs(res.Err, types.ErrNoSuchBucket) + + // case 2: success case + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&types.BucketInfo{}, true) + storageKeeper.EXPECT().SetBucketInfo(gomock.Any(), gomock.Any()).Return() + + res = app.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPack) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestAckCreateBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + ackPackage := types.CreateBucketAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + Creator: sample.RandAccAddress(), + ExtraData: []byte("extra data"), + } + + serializedAckPack := ackPackage.MustSerialize() + serializedAckPack = append([]byte{types.OperationCreateBucket}, serializedAckPack...) + + // case 1: normal case + res := app.ExecuteAckPackage(s.ctx, nil, serializedAckPack) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestAckDeleteBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + ackPackage := types.DeleteBucketAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedAckPack := ackPackage.MustSerialize() + serializedAckPack = append([]byte{types.OperationDeleteBucket}, serializedAckPack...) + + // case 1: normal case + res := app.ExecuteAckPackage(s.ctx, nil, serializedAckPack) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckMirrorBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + ackPackage := types.MirrorBucketSynPackage{ + Id: big.NewInt(10), + Owner: sample.RandAccAddress(), + } + + serializedAckPack, err := ackPackage.Serialize() + s.Require().NoError(err) + serializedAckPack = append([]byte{types.OperationMirrorBucket}, serializedAckPack...) + + // case 1: bucket not found + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&types.BucketInfo{}, false) + + res := app.ExecuteFailAckPackage(s.ctx, nil, serializedAckPack) + s.Require().ErrorIs(res.Err, types.ErrNoSuchBucket) + + // case 2: normal case + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&types.BucketInfo{}, true) + storageKeeper.EXPECT().SetBucketInfo(gomock.Any(), gomock.Any()).Return() + + res = app.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPack) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckCreateBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + createSynPackage := types.CreateBucketSynPackage{ + Creator: sample.RandAccAddress(), + BucketName: "bucketname", + ExtraData: []byte("extra data"), + PaymentAddress: sample.RandAccAddress(), + PrimarySpAddress: sample.RandAccAddress(), + } + serializedSynPackage := createSynPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationCreateBucket}, serializedSynPackage...) + + // case 1: normal case + res := app.ExecuteFailAckPackage(s.ctx, nil, serializedSynPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckDeleteBucket() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewBucketApp(storageKeeper) + deleteSynPackage := types.DeleteBucketSynPackage{ + Operator: sample.RandAccAddress(), + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedSynPackage := deleteSynPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationDeleteBucket}, serializedSynPackage...) + + // case 1: normal case + res := app.ExecuteFailAckPackage(s.ctx, nil, serializedSynPackage) + s.Require().NoError(res.Err) +} diff --git a/x/storage/keeper/cross_app_group_test.go b/x/storage/keeper/cross_app_group_test.go new file mode 100644 index 000000000..23a3a6aed --- /dev/null +++ b/x/storage/keeper/cross_app_group_test.go @@ -0,0 +1,307 @@ +package keeper_test + +import ( + "fmt" + "math/big" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + + "github.com/bnb-chain/greenfield/testutil/sample" + gnfderrors "github.com/bnb-chain/greenfield/types/errors" + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" +) + +func (s *TestSuite) TestAckMirrorGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + ackPackage := types.MirrorGroupAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + } + + serializedAckPackage, err := ackPackage.Serialize() + s.Require().NoError(err) + serializedAckPackage = append([]byte{types.OperationMirrorGroup}, serializedAckPackage...) + + // case 1: mirror group not found + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteAckPackage(s.ctx, nil, serializedAckPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchGroup) + + // case 2: normal case + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(&types.GroupInfo{}, true) + storageKeeper.EXPECT().SetGroupInfo(gomock.Any(), gomock.Any()).Return() + res = app.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestAckCreateGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + ackPackage := types.CreateGroupAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + Creator: sample.RandAccAddress(), + ExtraData: []byte("extra data"), + } + + serializedAckPackage := ackPackage.MustSerialize() + serializedAckPackage = append([]byte{types.OperationCreateGroup}, serializedAckPackage...) + + // case 1: normal case + res := app.ExecuteAckPackage(s.ctx, nil, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestAckDeleteGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + ackPackage := types.DeleteGroupAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedAckPackage := ackPackage.MustSerialize() + serializedAckPackage = append([]byte{types.OperationDeleteGroup}, serializedAckPackage...) + + // case 1: normal case + res := app.ExecuteAckPackage(s.ctx, nil, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckMirrorGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + ackPackage := types.MirrorGroupSynPackage{ + Id: big.NewInt(10), + Owner: sample.RandAccAddress(), + } + + serializedAckPackage, err := ackPackage.Serialize() + s.Require().NoError(err) + serializedAckPackage = append([]byte{types.OperationMirrorGroup}, serializedAckPackage...) + + // case 1: group not found + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteFailAckPackage(s.ctx, nil, serializedAckPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchGroup) + + // case 2: normal case + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(&types.GroupInfo{}, true) + storageKeeper.EXPECT().SetGroupInfo(gomock.Any(), gomock.Any()).Return() + res = app.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckCreateGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + ackPackage := types.CreateGroupSynPackage{ + Creator: sample.RandAccAddress(), + GroupName: "group", + ExtraData: []byte("extra data"), + } + + serializedAckPackage := ackPackage.MustSerialize() + serializedAckPackage = append([]byte{types.OperationCreateGroup}, serializedAckPackage...) + + // case 1: normal case + res := app.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckDeleteGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + ackPackage := types.DeleteBucketSynPackage{ + Operator: sample.RandAccAddress(), + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedAckPackage := ackPackage.MustSerialize() + serializedAckPackage = append([]byte{types.OperationDeleteGroup}, serializedAckPackage...) + + // case 1: normal case + res := app.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckUpdateGroupMember() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + ackPackage := types.UpdateGroupMemberSynPackage{ + Operator: sample.RandAccAddress(), + GroupId: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedAckPackage := ackPackage.MustSerialize() + serializedAckPackage = append([]byte{types.OperationUpdateGroupMember}, serializedAckPackage...) + + // case 1: normal case + res := app.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestSynMirrorGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + synPackage := types.MirrorGroupSynPackage{ + Owner: sample.RandAccAddress(), + Id: big.NewInt(10), + } + + serializedSynPackage, err := synPackage.Serialize() + s.Require().NoError(err) + serializedSynPackage = append([]byte{types.OperationMirrorGroup}, serializedSynPackage...) + + // case 1: normal case + res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestSynCreateGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + synPackage := types.CreateGroupSynPackage{ + Creator: sample.RandAccAddress(), + GroupName: "group", + ExtraData: []byte("extra data"), + } + + // case 1: invalid group name + synPackage.GroupName = "g" + serializedSynPackage := synPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationCreateGroup}, serializedSynPackage...) + + res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorIs(res.Err, gnfderrors.ErrInvalidGroupName) + s.Require().NotEmpty(res.Payload) + + // case 2: create group error + synPackage.GroupName = "group" + serializedSynPackage = synPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationCreateGroup}, serializedSynPackage...) + + storageKeeper.EXPECT().CreateGroup(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(math.NewUint(0), fmt.Errorf("create group error")) + res = app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorContains(res.Err, "create group error") + + // case 3: normal case + storageKeeper.EXPECT().CreateGroup(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(math.NewUint(10), nil) + res = app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestSynDeleteGroup() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + synPackage := types.DeleteBucketSynPackage{ + Operator: sample.RandAccAddress(), + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + serializedSynPackage := synPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationDeleteGroup}, serializedSynPackage...) + + // case 1: group not exist + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchGroup) + s.Require().NotEmpty(res.Payload) + + // case 2: delete group error + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(&types.GroupInfo{}, true) + storageKeeper.EXPECT().DeleteGroup(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("delete group error")) + res = app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorContains(res.Err, "delete group error") + + // case 3: normal case + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(&types.GroupInfo{ + Id: sdk.NewUint(10), + }, true) + storageKeeper.EXPECT().DeleteGroup(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + res = app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestSynUpdateGroupMember() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewGroupApp(storageKeeper) + synPackage := types.UpdateGroupMemberSynPackage{ + Operator: sample.RandAccAddress(), + GroupId: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + // case 1: invalid package + synPackage.OperationType = 3 + serializedSynPackage := synPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationUpdateGroupMember}, serializedSynPackage...) + + res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorIs(res.Err, types.ErrInvalidOperationType) + s.Require().NotEmpty(res.Payload) + + // case 2: group not exist + synPackage.OperationType = types.OperationAddGroupMember + serializedSynPackage = synPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationUpdateGroupMember}, serializedSynPackage...) + + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res = app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchGroup) + s.Require().NotEmpty(res.Payload) + + // case 3: update group member error + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(&types.GroupInfo{}, true) + storageKeeper.EXPECT().UpdateGroupMember(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("update group member error")) + res = app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorContains(res.Err, "update group member error") + + // case 4: normal case + storageKeeper.EXPECT().GetGroupInfoById(gomock.Any(), gomock.Any()).Return(&types.GroupInfo{ + Id: sdk.NewUint(10), + }, true) + storageKeeper.EXPECT().UpdateGroupMember(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + res = app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().NoError(res.Err) +} diff --git a/x/storage/keeper/cross_app_object_test.go b/x/storage/keeper/cross_app_object_test.go new file mode 100644 index 000000000..d535d3aeb --- /dev/null +++ b/x/storage/keeper/cross_app_object_test.go @@ -0,0 +1,162 @@ +package keeper_test + +import ( + "fmt" + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + + "github.com/bnb-chain/greenfield/testutil/sample" + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" +) + +func (s *TestSuite) TestAckMirrorObject() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewObjectApp(storageKeeper) + ackPackage := types.MirrorObjectAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + } + + serializedAckPackage, err := ackPackage.Serialize() + s.Require().NoError(err) + serializedAckPackage = append([]byte{types.OperationMirrorObject}, serializedAckPackage...) + + // case 1: object not exist + storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteAckPackage(s.ctx, nil, serializedAckPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchObject) + + // case 2: normal case + storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Any()).Return(&types.ObjectInfo{}, true) + storageKeeper.EXPECT().SetObjectInfo(gomock.Any(), gomock.Any()).Return() + res = app.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestAckDeleteObject() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewObjectApp(storageKeeper) + ackPackage := types.DeleteObjectAckPackage{ + Status: types.StatusSuccess, + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedAckPackage := ackPackage.MustSerialize() + serializedAckPackage = append([]byte{types.OperationDeleteObject}, serializedAckPackage...) + + // case 1: normal case + res := app.ExecuteAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckMirrorObject() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewObjectApp(storageKeeper) + ackPackage := types.MirrorObjectSynPackage{ + Owner: sample.RandAccAddress(), + Id: big.NewInt(10), + } + + serializedAckPackage, err := ackPackage.Serialize() + s.Require().NoError(err) + serializedAckPackage = append([]byte{types.OperationMirrorObject}, serializedAckPackage...) + + // case 1: object not exist + storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteFailAckPackage(s.ctx, nil, serializedAckPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchObject) + + // case 2: normal case + storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Any()).Return(&types.ObjectInfo{}, true) + storageKeeper.EXPECT().SetObjectInfo(gomock.Any(), gomock.Any()).Return() + res = app.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestFailAckDeleteObject() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewObjectApp(storageKeeper) + ackPackage := types.DeleteBucketSynPackage{ + Operator: sample.RandAccAddress(), + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedAckPackage := ackPackage.MustSerialize() + serializedAckPackage = append([]byte{types.OperationDeleteObject}, serializedAckPackage...) + + // case 1: normal case + res := app.ExecuteFailAckPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedAckPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestSynMirrorObject() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewObjectApp(storageKeeper) + synPackage := types.MirrorObjectSynPackage{ + Owner: sample.RandAccAddress(), + Id: big.NewInt(10), + } + + serializedSynPackage, err := synPackage.Serialize() + s.Require().NoError(err) + serializedSynPackage = append([]byte{types.OperationMirrorObject}, serializedSynPackage...) + + // case 1: normal case + res := app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().NoError(res.Err) +} + +func (s *TestSuite) TestSynDeleteObject() { + ctrl := gomock.NewController(s.T()) + storageKeeper := types.NewMockStorageKeeper(ctrl) + storageKeeper.EXPECT().Logger(gomock.Any()).Return(s.ctx.Logger()).AnyTimes() + + app := keeper.NewObjectApp(storageKeeper) + synPackage := types.DeleteBucketSynPackage{ + Operator: sample.RandAccAddress(), + Id: big.NewInt(10), + ExtraData: []byte("extra data"), + } + + serializedSynPackage := synPackage.MustSerialize() + serializedSynPackage = append([]byte{types.OperationDeleteObject}, serializedSynPackage...) + + // case 1: object not exist + storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().ErrorIs(res.Err, types.ErrNoSuchObject) + + // case 2: delete object error + storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Any()).Return(&types.ObjectInfo{}, true) + storageKeeper.EXPECT().DeleteObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("delete object error")) + res = app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().ErrorContains(res.Err, "delete object error") + + // case 3: normal case + storageKeeper.EXPECT().GetObjectInfoById(gomock.Any(), gomock.Any()).Return(&types.ObjectInfo{ + Id: sdk.NewUint(10), + }, true) + storageKeeper.EXPECT().DeleteObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + res = app.ExecuteSynPackage(s.ctx, nil, serializedSynPackage) + s.Require().NoError(res.Err) +} diff --git a/x/storage/keeper/grpc_query_test.go b/x/storage/keeper/grpc_query_test.go index 05c1199b7..05c911219 100644 --- a/x/storage/keeper/grpc_query_test.go +++ b/x/storage/keeper/grpc_query_test.go @@ -8,11 +8,13 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/types/query" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/mint" "github.com/stretchr/testify/require" + "github.com/bnb-chain/greenfield/testutil/sample" "github.com/bnb-chain/greenfield/x/storage/keeper" "github.com/bnb-chain/greenfield/x/storage/types" ) @@ -85,3 +87,305 @@ func TestVersionedParamsQuery(t *testing.T) { p = responseT2.GetParams() require.EqualValues(t, p.GetMaxSegmentSize(), 2) } + +func TestHeadBucket(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadBucket(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadBucket(ctx, &types.QueryHeadBucketRequest{ + BucketName: "bucket", + }) + require.ErrorIs(t, err, types.ErrNoSuchBucket) +} + +func TestHeadGroupNFT(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadGroupNFT(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadGroupNFT(ctx, &types.QueryNFTRequest{ + TokenId: "xxx", + }) + require.ErrorContains(t, err, "invalid token id") + + // group not exist + _, err = k.HeadGroupNFT(ctx, &types.QueryNFTRequest{ + TokenId: "0", + }) + require.ErrorIs(t, err, types.ErrNoSuchGroup) +} + +func TestHeadObjectNFT(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadObjectNFT(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadObjectNFT(ctx, &types.QueryNFTRequest{ + TokenId: "xxx", + }) + require.ErrorContains(t, err, "invalid token id") + + // object not exist + _, err = k.HeadObjectNFT(ctx, &types.QueryNFTRequest{ + TokenId: "0", + }) + require.ErrorIs(t, err, types.ErrNoSuchObject) +} + +func TestHeadBucketNFT(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadBucketNFT(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadBucketNFT(ctx, &types.QueryNFTRequest{ + TokenId: "xxx", + }) + require.ErrorContains(t, err, "invalid token id") + + // bucket not exist + _, err = k.HeadBucketNFT(ctx, &types.QueryNFTRequest{ + TokenId: "0", + }) + require.ErrorIs(t, err, types.ErrNoSuchBucket) +} + +func TestHeadBucketById(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadBucketById(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadBucketById(ctx, &types.QueryHeadBucketByIdRequest{ + BucketId: "xxx", + }) + require.ErrorContains(t, err, "invalid bucket id") + + // bucket not exist + _, err = k.HeadBucketById(ctx, &types.QueryHeadBucketByIdRequest{ + BucketId: "0", + }) + require.ErrorIs(t, err, types.ErrNoSuchBucket) +} + +func TestHeadObject(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadObject(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + // object not exist + _, err = k.HeadObject(ctx, &types.QueryHeadObjectRequest{ + BucketName: "bucket", + ObjectName: "object", + }) + require.ErrorIs(t, err, types.ErrNoSuchObject) +} + +func TestHeadObjectById(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadBucketById(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadObjectById(ctx, &types.QueryHeadObjectByIdRequest{ + ObjectId: "xxx", + }) + require.ErrorContains(t, err, "invalid object id") + + // bucket not exist + _, err = k.HeadObjectById(ctx, &types.QueryHeadObjectByIdRequest{ + ObjectId: "1", + }) + require.ErrorIs(t, err, types.ErrNoSuchObject) +} + +func TestListBuckets(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.ListBuckets(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.ListBuckets(ctx, &types.QueryListBucketsRequest{ + Pagination: &query.PageRequest{ + Limit: types.MaxPaginationLimit + 1, + }, + }) + require.ErrorContains(t, err, "exceed pagination limit") +} + +func TestListObjects(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.ListObjects(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.ListObjects(ctx, &types.QueryListObjectsRequest{ + Pagination: &query.PageRequest{ + Limit: types.MaxPaginationLimit + 1, + }, + }) + require.ErrorContains(t, err, "exceed pagination limit") +} + +func TestListObjectsByBucketId(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.ListObjectsByBucketId(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.ListObjectsByBucketId(ctx, &types.QueryListObjectsByBucketIdRequest{ + Pagination: &query.PageRequest{ + Limit: types.MaxPaginationLimit + 1, + }, + }) + require.ErrorContains(t, err, "exceed pagination limit") + + _, err = k.ListObjectsByBucketId(ctx, &types.QueryListObjectsByBucketIdRequest{ + BucketId: "xxx", + }) + require.ErrorContains(t, err, "invalid bucket id") + + _, err = k.ListObjectsByBucketId(ctx, &types.QueryListObjectsByBucketIdRequest{ + BucketId: "0", + }) + require.ErrorIs(t, err, types.ErrNoSuchBucket) +} + +func TestQueryPolicyForAccount(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.QueryPolicyForAccount(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.QueryPolicyForAccount(ctx, &types.QueryPolicyForAccountRequest{ + PrincipalAddress: "xxxx", + }) + require.ErrorContains(t, err, "invalid address hex length") + + _, err = k.QueryPolicyForAccount(ctx, &types.QueryPolicyForAccountRequest{ + PrincipalAddress: sample.RandAccAddressHex(), + Resource: "xxx", + }) + require.ErrorContains(t, err, "regex match error") +} + +func TestQueryPolicyForGroup(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.QueryPolicyForGroup(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.QueryPolicyForGroup(ctx, &types.QueryPolicyForGroupRequest{ + PrincipalGroupId: "xxx", + }) + require.ErrorContains(t, err, "invalid group id") + + _, err = k.QueryPolicyForGroup(ctx, &types.QueryPolicyForGroupRequest{ + PrincipalGroupId: "10", + Resource: "xxx", + }) + require.ErrorContains(t, err, "regex match error") +} + +func TestVerifyPermission(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.VerifyPermission(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.VerifyPermission(ctx, &types.QueryVerifyPermissionRequest{ + Operator: "xxx", + }) + require.ErrorContains(t, err, "invalid operator address") + + _, err = k.VerifyPermission(ctx, &types.QueryVerifyPermissionRequest{ + Operator: sample.RandAccAddressHex(), + BucketName: "", + }) + require.ErrorContains(t, err, "No bucket specified") + + _, err = k.VerifyPermission(ctx, &types.QueryVerifyPermissionRequest{ + Operator: sample.RandAccAddressHex(), + BucketName: "bucket", + }) + require.ErrorIs(t, err, types.ErrNoSuchBucket) +} + +func TestHeadGroup(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.HeadGroup(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadGroup(ctx, &types.QueryHeadGroupRequest{ + GroupOwner: "xxx", + }) + require.ErrorContains(t, err, "invalid address hex length") + + _, err = k.HeadGroup(ctx, &types.QueryHeadGroupRequest{ + GroupOwner: sample.RandAccAddressHex(), + GroupName: "group", + }) + require.ErrorIs(t, err, types.ErrNoSuchGroup) +} + +func TestListGroup(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.ListGroup(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.ListGroup(ctx, &types.QueryListGroupRequest{ + Pagination: &query.PageRequest{ + Limit: types.MaxPaginationLimit + 1, + }, + }) + require.ErrorContains(t, err, "exceed pagination limit") + + _, err = k.ListGroup(ctx, &types.QueryListGroupRequest{ + GroupOwner: "xxx", + }) + require.ErrorContains(t, err, "invalid address hex length") +} + +func TestHeadGroupMember(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.ListGroup(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.HeadGroupMember(ctx, &types.QueryHeadGroupMemberRequest{ + Member: "xxx", + }) + require.ErrorContains(t, err, "invalid address hex length") + + _, err = k.HeadGroupMember(ctx, &types.QueryHeadGroupMemberRequest{ + Member: sample.RandAccAddressHex(), + GroupOwner: "xxx", + }) + require.ErrorContains(t, err, "invalid address hex length") + + _, err = k.HeadGroupMember(ctx, &types.QueryHeadGroupMemberRequest{ + Member: sample.RandAccAddressHex(), + GroupOwner: sample.RandAccAddressHex(), + GroupName: "group", + }) + require.ErrorIs(t, err, types.ErrNoSuchGroup) +} + +func TestQueryPolicyById(t *testing.T) { + // invalid argument + k, ctx := makeKeeper(t) + _, err := k.QueryPolicyById(ctx, nil) + require.ErrorContains(t, err, "invalid request") + + _, err = k.QueryPolicyById(ctx, &types.QueryPolicyByIdRequest{ + PolicyId: "xxx", + }) + require.ErrorContains(t, err, "invalid policy id") +} diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index b6a350e03..d06a6e275 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -446,7 +446,7 @@ func (k Keeper) DiscontinueBucket(ctx sdk.Context, operator sdk.AccAddress, buck "only primary sp is allowed to do discontinue bucket, expect sp id : %d", spInState.Id) } - count := k.getDiscontinueBucketCount(ctx, operator) + count := k.GetDiscontinueBucketCount(ctx, operator) max := k.DiscontinueBucketMax(ctx) if count+1 > max { return types.ErrNoMoreDiscontinue.Wrapf("no more buckets can be requested in this window") @@ -461,7 +461,7 @@ func (k Keeper) DiscontinueBucket(ctx sdk.Context, operator sdk.AccAddress, buck deleteAt := ctx.BlockTime().Unix() + k.DiscontinueConfirmPeriod(ctx) k.appendDiscontinueBucketIds(ctx, deleteAt, []sdkmath.Uint{bucketInfo.Id}) - k.setDiscontinueBucketCount(ctx, operator, count+1) + k.SetDiscontinueBucketCount(ctx, operator, count+1) if err := ctx.EventManager().EmitTypedEvents(&types.EventDiscontinueBucket{ BucketId: bucketInfo.Id, @@ -1126,7 +1126,7 @@ func (k Keeper) DiscontinueObject(ctx sdk.Context, operator sdk.AccAddress, buck return errors.Wrapf(types.ErrAccessDenied, "only primary sp is allowed to do discontinue objects") } - count := k.getDiscontinueObjectCount(ctx, operator) + count := k.GetDiscontinueObjectCount(ctx, operator) max := k.DiscontinueObjectMax(ctx) if count+uint64(len(objectIds)) > max { return types.ErrNoMoreDiscontinue.Wrapf("only %d objects can be requested in this window", max-count) @@ -1155,7 +1155,7 @@ func (k Keeper) DiscontinueObject(ctx sdk.Context, operator sdk.AccAddress, buck deleteAt := ctx.BlockTime().Unix() + k.DiscontinueConfirmPeriod(ctx) k.AppendDiscontinueObjectIds(ctx, deleteAt, objectIds) - k.setDiscontinueObjectCount(ctx, operator, count+uint64(len(objectIds))) + k.SetDiscontinueObjectCount(ctx, operator, count+uint64(len(objectIds))) events := make([]proto.Message, 0) for _, objectId := range objectIds { @@ -1470,7 +1470,7 @@ func (k Keeper) isNonEmptyBucket(ctx sdk.Context, bucketName string) bool { return iter.Valid() } -func (k Keeper) getDiscontinueObjectCount(ctx sdk.Context, operator sdk.AccAddress) uint64 { +func (k Keeper) GetDiscontinueObjectCount(ctx sdk.Context, operator sdk.AccAddress) uint64 { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.DiscontinueObjectCountPrefix) bz := store.Get(operator.Bytes()) @@ -1480,7 +1480,7 @@ func (k Keeper) getDiscontinueObjectCount(ctx sdk.Context, operator sdk.AccAddre return binary.BigEndian.Uint64(bz) } -func (k Keeper) setDiscontinueObjectCount(ctx sdk.Context, operator sdk.AccAddress, count uint64) { +func (k Keeper) SetDiscontinueObjectCount(ctx sdk.Context, operator sdk.AccAddress, count uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.DiscontinueObjectCountPrefix) countBytes := make([]byte, 8) @@ -1551,7 +1551,7 @@ func (k Keeper) DeleteDiscontinueObjectsUntil(ctx sdk.Context, timestamp int64, return deleted, nil } -func (k Keeper) getDiscontinueBucketCount(ctx sdk.Context, operator sdk.AccAddress) uint64 { +func (k Keeper) GetDiscontinueBucketCount(ctx sdk.Context, operator sdk.AccAddress) uint64 { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.DiscontinueBucketCountPrefix) bz := store.Get(operator.Bytes()) @@ -1561,7 +1561,7 @@ func (k Keeper) getDiscontinueBucketCount(ctx sdk.Context, operator sdk.AccAddre return binary.BigEndian.Uint64(bz) } -func (k Keeper) setDiscontinueBucketCount(ctx sdk.Context, operator sdk.AccAddress, count uint64) { +func (k Keeper) SetDiscontinueBucketCount(ctx sdk.Context, operator sdk.AccAddress, count uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.DiscontinueBucketCountPrefix) countBytes := make([]byte, 8) diff --git a/x/storage/keeper/keeper_test.go b/x/storage/keeper/keeper_test.go new file mode 100644 index 000000000..5c0c44b2c --- /dev/null +++ b/x/storage/keeper/keeper_test.go @@ -0,0 +1,29 @@ +package keeper_test + +import "github.com/bnb-chain/greenfield/testutil/sample" + +func (s *TestSuite) TestClearDiscontinueBucketCount() { + acc1 := sample.RandAccAddress() + s.storageKeeper.SetDiscontinueBucketCount(s.ctx, acc1, 1) + + count := s.storageKeeper.GetDiscontinueBucketCount(s.ctx, acc1) + s.Require().Equal(uint64(1), count) + + s.storageKeeper.ClearDiscontinueBucketCount(s.ctx) + + count = s.storageKeeper.GetDiscontinueBucketCount(s.ctx, acc1) + s.Require().Equal(uint64(0), count) +} + +func (s *TestSuite) TestClearDiscontinueObjectCount() { + acc1 := sample.RandAccAddress() + s.storageKeeper.SetDiscontinueObjectCount(s.ctx, acc1, 1) + + count := s.storageKeeper.GetDiscontinueObjectCount(s.ctx, acc1) + s.Require().Equal(uint64(1), count) + + s.storageKeeper.ClearDiscontinueObjectCount(s.ctx) + + count = s.storageKeeper.GetDiscontinueObjectCount(s.ctx, acc1) + s.Require().Equal(uint64(0), count) +} diff --git a/x/storage/keeper/msg_server_test.go b/x/storage/keeper/msg_server_test.go deleted file mode 100644 index 942926490..000000000 --- a/x/storage/keeper/msg_server_test.go +++ /dev/null @@ -1 +0,0 @@ -package keeper_test diff --git a/x/storage/keeper/query.go b/x/storage/keeper/query.go index f18e900e1..185b60908 100644 --- a/x/storage/keeper/query.go +++ b/x/storage/keeper/query.go @@ -252,7 +252,7 @@ func (k Keeper) HeadGroupNFT(goCtx context.Context, req *types.QueryNFTRequest) ctx := sdk.UnwrapSDKContext(goCtx) groupInfo, found := k.GetGroupInfoById(ctx, id) if !found { - return nil, types.ErrNoSuchObject + return nil, types.ErrNoSuchGroup } return &types.QueryGroupNFTResponse{ MetaData: groupInfo.ToNFTMetadata(), @@ -443,6 +443,10 @@ func (k Keeper) HeadGroupMember(goCtx context.Context, req *types.QueryHeadGroup func (k Keeper) QueryPolicyById(goCtx context.Context, req *types.QueryPolicyByIdRequest) (*types. QueryPolicyByIdResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) policyId, err := math.ParseUint(req.PolicyId) if err != nil { diff --git a/x/storage/module.go b/x/storage/module.go index 005621bea..1dbf7ea73 100644 --- a/x/storage/module.go +++ b/x/storage/module.go @@ -143,11 +143,11 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { - BeginBlocker(ctx, am.keeper) + keeper.BeginBlocker(ctx, am.keeper) } // EndBlock contains the logic that is automatically triggered at the end of each block func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - EndBlocker(ctx, am.keeper) + keeper.EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} } diff --git a/x/storage/types/crosschain.go b/x/storage/types/crosschain.go index 36938efd8..e43b2650b 100644 --- a/x/storage/types/crosschain.go +++ b/x/storage/types/crosschain.go @@ -381,6 +381,24 @@ var ( } ) +func (p CreateBucketSynPackage) MustSerialize() []byte { + encodedBytes, err := createBucketSynPackageStructArgs.Pack(&CreateBucketSynPackageStruct{ + Creator: common.BytesToAddress(p.Creator), + BucketName: p.BucketName, + Visibility: p.Visibility, + PaymentAddress: common.BytesToAddress(p.PaymentAddress), + PrimarySpAddress: common.BytesToAddress(p.PrimarySpAddress), + PrimarySpApprovalExpiredHeight: p.PrimarySpApprovalExpiredHeight, + PrimarySpApprovalSignature: p.PrimarySpApprovalSignature, + ChargedReadQuota: p.ChargedReadQuota, + ExtraData: p.ExtraData, + }) + if err != nil { + panic("encode create bucket syn package error") + } + return encodedBytes +} + func (p CreateBucketSynPackage) ValidateBasic() error { msg := MsgCreateBucket{ Creator: p.Creator.String(), @@ -643,6 +661,18 @@ func (p CreateGroupSynPackage) ValidateBasic() error { return msg.ValidateBasic() } +func (p CreateGroupSynPackage) MustSerialize() []byte { + encodedBytes, err := createGroupSynPackageArgs.Pack(&CreateGroupSynPackageStruct{ + Creator: common.BytesToAddress(p.Creator), + GroupName: p.GroupName, + ExtraData: p.ExtraData, + }) + if err != nil { + panic("encode create group syn package error") + } + return encodedBytes +} + func DeserializeCreateGroupSynPackage(serializedPackage []byte) (interface{}, error) { unpacked, err := createGroupSynPackageArgs.Unpack(serializedPackage) if err != nil { @@ -883,6 +913,26 @@ func (p UpdateGroupMemberSynPackage) GetMembers() []string { return members } +func (p UpdateGroupMemberSynPackage) MustSerialize() []byte { + totalMember := len(p.Members) + members := make([]common.Address, totalMember) + for i, member := range p.Members { + members[i] = common.BytesToAddress(member) + } + + encodedBytes, err := updateGroupMemberSynPackageArgs.Pack(&UpdateGroupMemberSynPackageStruct{ + common.BytesToAddress(p.Operator), + SafeBigInt(p.GroupId), + p.OperationType, + members, + p.ExtraData, + }) + if err != nil { + panic("encode update group member syn package error") + } + return encodedBytes +} + func (p UpdateGroupMemberSynPackage) ValidateBasic() error { if p.OperationType != OperationAddGroupMember && p.OperationType != OperationDeleteGroupMember { return ErrInvalidOperationType @@ -1007,7 +1057,7 @@ func (p UpdateGroupMemberAckPackage) MustSerialize() []byte { p.ExtraData, }) if err != nil { - panic("encode delete group ack package error") + panic("encode update group member ack package error") } return encodedBytes } diff --git a/x/virtualgroup/keeper/genesis_test.go b/x/virtualgroup/keeper/genesis_test.go new file mode 100644 index 000000000..49adbad00 --- /dev/null +++ b/x/virtualgroup/keeper/genesis_test.go @@ -0,0 +1,27 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + types2 "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/golang/mock/gomock" + + "github.com/bnb-chain/greenfield/x/virtualgroup" + "github.com/bnb-chain/greenfield/x/virtualgroup/types" +) + +func (s *TestSuite) TestGenesis() { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + s.accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), gomock.Any()).Return(types2.NewEmptyModuleAccount(types.ModuleName)) + s.accountKeeper.EXPECT().SetModuleAccount(gomock.Any(), gomock.Any()).Return() + s.bankKeeper.EXPECT().GetAllBalances(gomock.Any(), gomock.Any()).Return(sdk.NewCoins(sdk.NewCoin(genesisState.Params.DepositDenom, sdk.ZeroInt()))) + virtualgroup.InitGenesis(s.ctx, *s.virtualgroupKeeper, genesisState) + + got := virtualgroup.ExportGenesis(s.ctx, *s.virtualgroupKeeper) + s.Require().NotNil(got) + s.Require().Equal(genesisState.Params, got.Params) +} From 846b6b4fe7df1d653dce0ac5dc03156a29a2a801 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Tue, 1 Aug 2023 14:32:58 +0800 Subject: [PATCH 13/24] chore: add more e2e test cases for payment module (#387) --- deployment/localup/localup.sh | 5 +- e2e/tests/payment_test.go | 1547 ++++----------------- e2e/tests/storage_bill_test.go | 1374 ++++++++++++++++++ x/storage/keeper/payment_test.go | 2 - x/storage/types/expected_keepers.go | 4 - x/storage/types/expected_keepers_mocks.go | 57 - 6 files changed, 1626 insertions(+), 1363 deletions(-) diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index 72fcbacaf..f4fe16708 100644 --- a/deployment/localup/localup.sh +++ b/deployment/localup/localup.sh @@ -150,7 +150,7 @@ function generate_genesis() { sed -i -e "s/\"heartbeat_interval\": \"1000\"/\"heartbeat_interval\": \"100\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"attestation_inturn_interval\": \"120\"/\"attestation_inturn_interval\": \"10\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"discontinue_confirm_period\": \"604800\"/\"discontinue_confirm_period\": \"5\"/g" ${workspace}/.local/validator${i}/config/genesis.json - sed -i -e "s/\"discontinue_deletion_max\": \"10000\"/\"discontinue_deletion_max\": \"2\"/g" ${workspace}/.local/validator${i}/config/genesis.json + sed -i -e "s/\"discontinue_deletion_max\": \"100\"/\"discontinue_deletion_max\": \"2\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"voting_period\": \"30s\"/\"voting_period\": \"5s\"/g" ${workspace}/.local/validator${i}/config/genesis.json #sed -i -e "s/\"community_tax\": \"0.020000000000000000\"/\"community_tax\": \"0\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/log_level = \"info\"/\log_level= \"debug\"/g" ${workspace}/.local/validator${i}/config/config.toml @@ -159,6 +159,9 @@ function generate_genesis() { # enable swagger API for validator0 sed -i -e "/Enable defines if the API server should be enabled/{N;s/enable = false/enable = true/;}" ${workspace}/.local/validator0/config/app.toml sed -i -e 's/swagger = false/swagger = true/' ${workspace}/.local/validator0/config/app.toml + + # enable telemetry for validator0 + sed -i -e "/other sinks such as Prometheus/{N;s/enable = false/enable = true/;}" ${workspace}/.local/validator0/config/app.toml } function start() { diff --git a/e2e/tests/payment_test.go b/e2e/tests/payment_test.go index 7ceaa3bda..302d403ed 100644 --- a/e2e/tests/payment_test.go +++ b/e2e/tests/payment_test.go @@ -6,7 +6,6 @@ import ( "fmt" "math" "reflect" - "sort" "strconv" "testing" "time" @@ -926,1304 +925,6 @@ func (s *PaymentTestSuite) TestWithdraw() { s.Require().Equal(paymentAccountStreamRecord.StaticBalance.Sub(paymentAccountStreamRecordAfter.StaticBalance).Int64(), amount.Add(staticBalanceChange).Int64()) } -func (s *PaymentTestSuite) TestStorageBill_DeleteBucket_WithReadQuota() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - - // CreateBucket - chargedReadQuota := uint64(100) - bucketName := storagetestutils.GenRandomBucketName() - msgCreateBucket := storagetypes.NewMsgCreateBucket( - user.GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PUBLIC_READ, sp.OperatorKey.GetAddr(), - nil, math.MaxUint, nil, chargedReadQuota) - msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId - msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) - s.Require().NoError(err) - s.SendTxBlock(user, msgCreateBucket) - - streamRecordsBeforeDelete := s.getStreamRecords(streamAddresses) - s.T().Logf("streamRecordsBeforeDelete: %s", core.YamlString(streamRecordsBeforeDelete)) - s.Require().NotEqual(streamRecordsBeforeDelete.User.NetflowRate.String(), "0") - - // DeleteBucket - msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) - s.SendTxBlock(user, msgDeleteBucket) - - // check the billing change - streamRecordsAfterDelete := s.getStreamRecords(streamAddresses) - s.T().Logf("streamRecordsBeforeDelete: %s", core.YamlString(streamRecordsAfterDelete)) - s.Require().Equal(streamRecordsAfterDelete.User.NetflowRate.String(), "0") -} - -func (s *PaymentTestSuite) TestStorageBill_Smoke() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBeforeCreateBucket := s.getStreamRecords(streamAddresses) - s.T().Logf("streamRecordsBeforeCreateBucket: %s", core.YamlString(streamRecordsBeforeCreateBucket)) - - params := s.queryParams() - - // create bucket - bucketName := storagetestutils.GenRandomBucketName() - bucketChargedReadQuota := uint64(1000) - msgCreateBucket := storagetypes.NewMsgCreateBucket( - user.GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PRIVATE, sp.OperatorKey.GetAddr(), - nil, math.MaxUint, nil, 0) - msgCreateBucket.ChargedReadQuota = bucketChargedReadQuota - msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId - msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) - s.Require().NoError(err) - s.SendTxBlock(user, msgCreateBucket) - - // check bill after creating bucket - userBankAccount, err := s.Client.Balance(ctx, &banktypes.QueryBalanceRequest{ - Address: user.GetAddr().String(), - Denom: s.Config.Denom, - }) - s.Require().NoError(err) - s.T().Logf("user bank account %s", userBankAccount) - - streamRecordsAfterCreateBucket := s.getStreamRecords(streamAddresses) - userStreamRecord := streamRecordsAfterCreateBucket.User - s.Require().Equal(userStreamRecord.StaticBalance, sdkmath.ZeroInt()) - - // check price and rate calculation - queryHeadBucketRequest := storagetypes.QueryHeadBucketRequest{ - BucketName: bucketName, - } - queryHeadBucketResponse, err := s.Client.HeadBucket(ctx, &queryHeadBucketRequest) - s.Require().NoError(err) - - queryGetSpStoragePriceByTimeResp, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ - SpAddr: sp.OperatorKey.GetAddr().String(), - Timestamp: queryHeadBucketResponse.BucketInfo.CreateAt, - }) - s.T().Logf("queryGetSpStoragePriceByTimeResp %s, err: %v", queryGetSpStoragePriceByTimeResp, err) - s.Require().NoError(err) - - readPrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.ReadPrice - readChargeRate := readPrice.MulInt(sdk.NewIntFromUint64(queryHeadBucketResponse.BucketInfo.ChargedReadQuota)).TruncateInt() - s.T().Logf("readPrice: %s, readChargeRate: %s", readPrice, readChargeRate) - userTaxRate := params.VersionedParams.ValidatorTaxRate.MulInt(readChargeRate).TruncateInt() - userTotalRate := readChargeRate.Add(userTaxRate) - s.Require().Equal(userStreamRecord.NetflowRate.Abs(), userTotalRate) - expectedOutFlows := []paymenttypes.OutFlow{ - {ToAddress: family.VirtualPaymentAddress, Rate: readChargeRate}, - {ToAddress: paymenttypes.ValidatorTaxPoolAddress.String(), Rate: userTaxRate}, - } - userOutFlowsResponse, err := s.Client.OutFlows(ctx, &paymenttypes.QueryOutFlowsRequest{Account: user.GetAddr().String()}) - s.Require().NoError(err) - sort.Slice(userOutFlowsResponse.OutFlows, func(i, j int) bool { - return userOutFlowsResponse.OutFlows[i].ToAddress < userOutFlowsResponse.OutFlows[j].ToAddress - }) - sort.Slice(expectedOutFlows, func(i, j int) bool { - return expectedOutFlows[i].ToAddress < expectedOutFlows[j].ToAddress - }) - s.Require().Equal(expectedOutFlows, userOutFlowsResponse.OutFlows) - - // CreateObject - objectName := storagetestutils.GenRandomObjectName() - // create test buffer - var buffer bytes.Buffer - // 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.GetAddr(), bucketName, objectName, uint64(payloadSize), storagetypes.VISIBILITY_TYPE_PRIVATE, expectChecksum, contextType, storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil) - msgCreateObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateObject.GetApprovalBytes()) - s.Require().NoError(err) - // simulate - res := s.SimulateTx(msgCreateObject, user) - s.T().Logf("res %v", res.Result) - // check EventFeePreview in simulation result - var feePreviewEventEmitted bool - events := res.Result.Events - for _, event := range events { - if event.Type == "greenfield.payment.EventFeePreview" { - s.T().Logf("event %v", event) - feePreviewEventEmitted = true - } - } - s.Require().True(feePreviewEventEmitted) - s.SendTxBlock(user, msgCreateObject) - - // check lock balance - queryHeadBucketResponseAfterCreateObj, err := s.Client.HeadBucket(ctx, &queryHeadBucketRequest) - s.T().Logf("queryHeadBucketResponseAfterCreateObj %s, err: %v", queryHeadBucketResponseAfterCreateObj, err) - s.Require().NoError(err) - queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ - BucketName: bucketName, - ObjectName: objectName, - } - queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) - s.T().Logf("queryHeadObjectResponse %s, err: %v", queryHeadObjectResponse, err) - s.Require().NoError(err) - - queryGetSecondarySpStorePriceByTime, err := s.Client.QueryGetSecondarySpStorePriceByTime(ctx, &sptypes.QueryGetSecondarySpStorePriceByTimeRequest{ - Timestamp: queryHeadBucketResponse.BucketInfo.CreateAt, - }) - s.T().Logf("queryGetSecondarySpStorePriceByTime %s, err: %v", queryGetSecondarySpStorePriceByTime, err) - s.Require().NoError(err) - primaryStorePrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.StorePrice - secondaryStorePrice := queryGetSecondarySpStorePriceByTime.SecondarySpStorePrice.StorePrice - chargeSize := s.getChargeSize(queryHeadObjectResponse.ObjectInfo.PayloadSize) - expectedChargeRate := primaryStorePrice.Add(secondaryStorePrice.MulInt64(6)).MulInt(sdk.NewIntFromUint64(chargeSize)).TruncateInt() - expectedChargeRate = params.VersionedParams.ValidatorTaxRate.MulInt(expectedChargeRate).TruncateInt().Add(expectedChargeRate) - expectedLockedBalance := expectedChargeRate.Mul(sdkmath.NewIntFromUint64(params.VersionedParams.ReserveTime)) - - streamRecordsAfterCreateObject := s.getStreamRecords(streamAddresses) - s.T().Logf("streamRecordsAfterCreateObject %s", core.YamlString(streamRecordsAfterCreateObject)) - userStreamAccountAfterCreateObj := streamRecordsAfterCreateObject.User - - s.Require().Equal(expectedLockedBalance.String(), userStreamAccountAfterCreateObj.LockBalance.String()) - - // seal object - gvgId := gvg.Id - msgSealObject := storagetypes.NewMsgSealObject(sp.SealKey.GetAddr(), bucketName, objectName, gvg.Id, nil) - secondarySigs := make([][]byte, 0) - secondarySPBlsPubKeys := make([]bls.PublicKey, 0) - blsSignHash := storagetypes.NewSecondarySpSealObjectSignDoc(s.GetChainID(), gvgId, queryHeadObjectResponse.ObjectInfo.Id, storagetypes.GenerateHash(expectChecksum[:])).GetBlsSignHash() - // every secondary sp signs the checksums - for _, spID := range gvg.SecondarySpIds { - sig, err := core.BlsSignAndVerify(s.StorageProviders[spID], blsSignHash) - s.Require().NoError(err) - secondarySigs = append(secondarySigs, sig) - pk, err := bls.PublicKeyFromBytes(s.StorageProviders[spID].BlsKey.PubKey().Bytes()) - s.Require().NoError(err) - secondarySPBlsPubKeys = append(secondarySPBlsPubKeys, pk) - } - aggBlsSig, err := core.BlsAggregateAndVerify(secondarySPBlsPubKeys, blsSignHash, secondarySigs) - s.Require().NoError(err) - msgSealObject.SecondarySpBlsAggSignatures = aggBlsSig - s.T().Logf("msg %s", msgSealObject.String()) - s.SendTxBlock(sp.SealKey, msgSealObject) - - // check bill after seal - streamRecordsAfterSeal := s.getStreamRecords(streamAddresses) - s.T().Logf("streamRecordsAfterSeal %s", core.YamlString(streamRecordsAfterSeal)) - s.Require().Equal(sdkmath.ZeroInt(), streamRecordsAfterSeal.User.LockBalance) - s.checkStreamRecordsBeforeAndAfter(streamRecordsAfterCreateObject, streamRecordsAfterSeal, readPrice, readChargeRate, primaryStorePrice, secondaryStorePrice, chargeSize, uint64(payloadSize)) - - // query dynamic balance - time.Sleep(3 * time.Second) - queryDynamicBalanceRequest := paymenttypes.QueryDynamicBalanceRequest{ - Account: user.GetAddr().String(), - } - queryDynamicBalanceResponse, err := s.Client.DynamicBalance(ctx, &queryDynamicBalanceRequest) - s.Require().NoError(err) - s.T().Logf("queryDynamicBalanceResponse %s", core.YamlString(queryDynamicBalanceResponse)) - - // create empty object - streamRecordsBeforeCreateEmptyObject := s.getStreamRecords(streamAddresses) - s.T().Logf("streamRecordsBeforeCreateEmptyObject %s", core.YamlString(streamRecordsBeforeCreateEmptyObject)) - - emptyObjectName := "sub_directory/" - // create empty test buffer - var emptyBuffer bytes.Buffer - emptyPayloadSize := emptyBuffer.Len() - emptyChecksum := sdk.Keccak256(emptyBuffer.Bytes()) - emptyExpectChecksum := [][]byte{emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum} - msgCreateEmptyObject := storagetypes.NewMsgCreateObject(user.GetAddr(), bucketName, emptyObjectName, uint64(emptyPayloadSize), storagetypes.VISIBILITY_TYPE_PRIVATE, emptyExpectChecksum, contextType, storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil) - msgCreateEmptyObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateEmptyObject.GetApprovalBytes()) - s.Require().NoError(err) - s.SendTxBlock(user, msgCreateEmptyObject) - - streamRecordsAfterCreateEmptyObject := s.getStreamRecords(streamAddresses) - s.T().Logf("streamRecordsAfterCreateEmptyObject %s", core.YamlString(streamRecordsAfterCreateEmptyObject)) - chargeSize = s.getChargeSize(uint64(emptyPayloadSize)) - s.checkStreamRecordsBeforeAndAfter(streamRecordsBeforeCreateEmptyObject, streamRecordsAfterCreateEmptyObject, readPrice, readChargeRate, primaryStorePrice, secondaryStorePrice, chargeSize, uint64(emptyPayloadSize)) - - // test query auto settle records - queryAllAutoSettleRecordRequest := paymenttypes.QueryAllAutoSettleRecordRequest{} - queryAllAutoSettleRecordResponse, err := s.Client.AutoSettleRecordAll(ctx, &queryAllAutoSettleRecordRequest) - s.Require().NoError(err) - s.T().Logf("queryAllAutoSettleRecordResponse %s", core.YamlString(queryAllAutoSettleRecordResponse)) - s.Require().True(len(queryAllAutoSettleRecordResponse.AutoSettleRecord) >= 1) - - // simulate delete object, check fee preview - deleteObjectMsg := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName) - deleteObjectSimRes := s.SimulateTx(deleteObjectMsg, user) - s.T().Logf("deleteObjectSimRes %v", deleteObjectSimRes.Result) -} - -func (s *PaymentTestSuite) TestStorageBill_DeleteObjectBucket_WithoutPriceChange() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBefore := s.getStreamRecords(streamAddresses) - - // create bucket - bucketName := s.createBucket(sp, user, 256) - - //simulate delete bucket gas - msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) - simulateResponse := s.SimulateTx(msgDeleteBucket, user) - gasLimit := simulateResponse.GasInfo.GetGasUsed() - gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas := gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))) - s.T().Log("total gas", "gas", gas) - - // create & seal objects - _, _, objectName1, objectId1, checksums1, _ := s.createObject(user, bucketName, false) - s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) - - // for payment - time.Sleep(2 * time.Second) - - //transfer gas - msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( - sdk.NewCoin(s.Config.Denom, sdkmath.NewInt(5*types.DecimalGwei)), - )) - simulateResponse = s.SimulateTx(msgSend, user) - gasLimit = simulateResponse.GasInfo.GetGasUsed() - gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) - s.T().Log("total gas", "gas", gas) - - //delete object gas - msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) - simulateResponse = s.SimulateTx(msgDeleteObject, user) - gasLimit = simulateResponse.GasInfo.GetGasUsed() - gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) - s.T().Log("total gas", "gas", gas) - - // transfer out user's balance - queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} - queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - - msgSend.Amount = sdk.NewCoins( - sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gas)), - ) - s.SendTxBlock(user, msgSend) - _, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - - s.SendTxBlock(user, msgDeleteObject) - s.SendTxBlock(user, msgDeleteBucket) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.NetflowRate, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) -} - -func (s *PaymentTestSuite) TestStorageBill_DeleteObjectBucket_WithPriceChange() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBefore := s.getStreamRecords(streamAddresses) - - // create bucket - bucketName := s.createBucket(sp, user, 256) - - //simulate delete bucket gas - msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) - simulateResponse := s.SimulateTx(msgDeleteBucket, user) - gasLimit := simulateResponse.GasInfo.GetGasUsed() - gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas := gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))) - s.T().Log("total gas", "gas", gas) - - // create & seal objects - _, _, objectName1, objectId1, checksums1, _ := s.createObject(user, bucketName, false) - s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) - - // for payment - time.Sleep(2 * time.Second) - - //transfer gas - msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( - sdk.NewCoin(s.Config.Denom, sdkmath.NewInt(5*types.DecimalGwei)), - )) - simulateResponse = s.SimulateTx(msgSend, user) - gasLimit = simulateResponse.GasInfo.GetGasUsed() - gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) - s.T().Log("total gas", "gas", gas) - - //delete object gas - msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) - simulateResponse = s.SimulateTx(msgDeleteObject, user) - gasLimit = simulateResponse.GasInfo.GetGasUsed() - gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) - s.T().Log("total gas", "gas", gas) - - // transfer out user's balance - queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} - queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - - msgSend.Amount = sdk.NewCoins( - sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gas)), - ) - s.SendTxBlock(user, msgSend) - _, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - - // sp price changes - priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ - SpAddr: sp.OperatorKey.GetAddr().String(), - Timestamp: 0, - }) - s.Require().NoError(err) - s.T().Log("price", priceRes.SpStoragePrice) - - // update new price - msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(1000), - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(10000), - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) - - s.SendTxBlock(user, msgDeleteObject) - s.SendTxBlock(user, msgDeleteBucket) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.NetflowRate, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) - - // revert price - msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice, - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice, - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) -} - -func (s *PaymentTestSuite) TestStorageBill_DeleteObjectBucket_WithPriceChangeReserveTimeChange() { - defer s.revertParams() - - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBefore := s.getStreamRecords(streamAddresses) - - // create bucket - bucketName := s.createBucket(sp, user, 256) - - //simulate delete bucket gas - msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) - simulateResponse := s.SimulateTx(msgDeleteBucket, user) - gasLimit := simulateResponse.GasInfo.GetGasUsed() - gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas := gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))) - s.T().Log("total gas", "gas", gas) - - // create & seal objects - _, _, objectName1, objectId1, checksums1, _ := s.createObject(user, bucketName, false) - s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) - - // for payment - time.Sleep(2 * time.Second) - - //transfer gas - msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( - sdk.NewCoin(s.Config.Denom, sdkmath.NewInt(5*types.DecimalGwei)), - )) - simulateResponse = s.SimulateTx(msgSend, user) - gasLimit = simulateResponse.GasInfo.GetGasUsed() - gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) - s.T().Log("total gas", "gas", gas) - - //delete object gas - msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) - simulateResponse = s.SimulateTx(msgDeleteObject, user) - gasLimit = simulateResponse.GasInfo.GetGasUsed() - gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - - gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) - s.T().Log("total gas", "gas", gas) - - // transfer out user's balance - queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} - queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - - msgSend.Amount = sdk.NewCoins( - sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gas)), - ) - s.SendTxBlock(user, msgSend) - _, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - - // sp price changes - priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ - SpAddr: sp.OperatorKey.GetAddr().String(), - Timestamp: 0, - }) - s.Require().NoError(err) - s.T().Log("price", priceRes.SpStoragePrice) - - // update new price - msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(1000), - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(10000), - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) - - // update params - params := s.queryParams() - oldReserveTime := params.VersionedParams.ReserveTime - oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate - - params.VersionedParams.ReserveTime = oldReserveTime * 2 - params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) - s.updateParams(params) - - s.SendTxBlock(user, msgDeleteObject) - s.SendTxBlock(user, msgDeleteBucket) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.NetflowRate, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) - - // revert price - msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice, - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice, - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) -} - -func (s *PaymentTestSuite) TestStorageBill_DeleteObject_WithStoreLessThanReserveTime() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - params := s.queryParams() - reserveTime := params.VersionedParams.ReserveTime - - // create bucket - bucketName := s.createBucket(sp, user, 256) - - // create & seal objects - _, _, objectName1, objectId1, checksums1, payloadSize := s.createObject(user, bucketName, false) - s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) - - headObjectRes, err := s.Client.HeadObject(ctx, &storagetypes.QueryHeadObjectRequest{ - BucketName: bucketName, - ObjectName: objectName1, - }) - s.Require().NoError(err) - s.T().Log("headObjectRes", headObjectRes) - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, userRateRead := s.calculateReadRates(sp, bucketName) - _, _, _, userRateStore := s.calculateStorageRates(sp, bucketName, objectName1, payloadSize, 0) - - msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) - s.SendTxBlock(user, msgDeleteObject) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - - settledTime := streamRecordsAfter.User.CrudTimestamp - streamRecordsBefore.User.CrudTimestamp - timeToPay := int64(reserveTime) + headObjectRes.ObjectInfo.CreateAt - streamRecordsAfter.User.CrudTimestamp - balanceDelta := userRateRead.Add(userRateStore).MulRaw(settledTime).Add(userRateStore.MulRaw(timeToPay)) - - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), userRateStore.Int64()) - userBalanceChange := streamRecordsAfter.User.BufferBalance.Add(streamRecordsAfter.User.StaticBalance). - Sub(streamRecordsBefore.User.BufferBalance.Add(streamRecordsBefore.User.StaticBalance)) - s.Require().Equal(userBalanceChange.Neg().Int64(), balanceDelta.Int64()) - - familyDelta := streamRecordsAfter.GVGFamily.StaticBalance.Sub(streamRecordsBefore.GVGFamily.StaticBalance) - gvgDelta := streamRecordsAfter.GVG.StaticBalance.Sub(streamRecordsBefore.GVG.StaticBalance) - taxPoolDelta := streamRecordsAfter.Tax.StaticBalance.Sub(streamRecordsBefore.Tax.StaticBalance) - s.T().Log("familyDelta", familyDelta, "gvgDelta", gvgDelta, "taxPoolDelta", taxPoolDelta) - s.Require().True(familyDelta.Add(gvgDelta).Add(taxPoolDelta).Int64() >= balanceDelta.Int64()) // could exist other buckets/objects on the gvg & family -} - -func (s *PaymentTestSuite) TestStorageBill_DeleteObject_WithStoreMoreThanReserveTime() { - defer s.revertParams() - - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - params := s.queryParams() - params.VersionedParams.ReserveTime = 5 - params.ForcedSettleTime = 2 - s.updateParams(params) - - // create bucket - bucketName := s.createBucket(sp, user, 256) - - // create & seal objects - _, _, objectName1, objectId1, checksums1, payloadSize := s.createObject(user, bucketName, false) - s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) - - headObjectRes, err := s.Client.HeadObject(ctx, &storagetypes.QueryHeadObjectRequest{ - BucketName: bucketName, - ObjectName: objectName1, - }) - s.Require().NoError(err) - s.T().Log("headObjectRes", headObjectRes) - - time.Sleep(5 * time.Second) - queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} - queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - balanceBefore := queryBalanceResponse.Balance.Amount - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, userRateRead := s.calculateReadRates(sp, bucketName) - _, _, _, userRateStore := s.calculateStorageRates(sp, bucketName, objectName1, payloadSize, 0) - - msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) - simulateResponse := s.SimulateTx(msgDeleteObject, user) - gasLimit := simulateResponse.GasInfo.GetGasUsed() - gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) - s.Require().NoError(err) - gas := gasPrice.Amount.MulRaw(int64(gasLimit)) - - // delete object - s.SendTxBlock(user, msgDeleteObject) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - queryBalanceRequest = banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} - queryBalanceResponse, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) - s.Require().NoError(err) - balanceAfter := queryBalanceResponse.Balance.Amount - - settledTime := streamRecordsAfter.User.CrudTimestamp - streamRecordsBefore.User.CrudTimestamp - balanceDelta := userRateRead.Add(userRateStore).MulRaw(settledTime) - - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), userRateStore.Int64()) - userBalanceChange := streamRecordsBefore.User.BufferBalance.Add(streamRecordsBefore.User.StaticBalance). - Sub(streamRecordsAfter.User.BufferBalance.Add(streamRecordsAfter.User.StaticBalance)) - userBalanceChange = userBalanceChange.Add(balanceBefore.Sub(balanceAfter)).Sub(gas) - s.Require().Equal(userBalanceChange.Int64(), balanceDelta.Int64()) - - familyDelta := streamRecordsAfter.GVGFamily.StaticBalance.Sub(streamRecordsBefore.GVGFamily.StaticBalance) - gvgDelta := streamRecordsAfter.GVG.StaticBalance.Sub(streamRecordsBefore.GVG.StaticBalance) - taxPoolDelta := streamRecordsAfter.Tax.StaticBalance.Sub(streamRecordsBefore.Tax.StaticBalance) - s.T().Log("familyDelta", familyDelta, "gvgDelta", gvgDelta, "taxPoolDelta", taxPoolDelta) - s.Require().True(familyDelta.Add(gvgDelta).Add(taxPoolDelta).Int64() >= balanceDelta.Int64()) // could exist other buckets/objects on the gvg & family -} - -func (s *PaymentTestSuite) TestStorageBill_CreateBucket_WithZeroNoneZeroReadQuota() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBefore := s.getStreamRecords(streamAddresses) - - params := s.queryParams() - - // case: create bucket with zero read quota - bucketName := s.createBucket(sp, user, 0) - - // bucket created - queryHeadBucketRequest := storagetypes.QueryHeadBucketRequest{ - BucketName: bucketName, - } - _, err = s.Client.HeadBucket(ctx, &queryHeadBucketRequest) - s.Require().NoError(err) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.NetflowRate, streamRecordsBefore.User.NetflowRate) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate, streamRecordsBefore.GVGFamily.NetflowRate) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate, streamRecordsBefore.Tax.NetflowRate) - - // case: create bucket with none zero read quota - bucketName = s.createBucket(sp, user, 10240) - - // bucket created - queryHeadBucketRequest = storagetypes.QueryHeadBucketRequest{ - BucketName: bucketName, - } - queryHeadBucketResponse, err := s.Client.HeadBucket(ctx, &queryHeadBucketRequest) - s.Require().NoError(err) - - // check price and rate calculation - queryGetSpStoragePriceByTimeResp, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ - SpAddr: sp.OperatorKey.GetAddr().String(), - Timestamp: queryHeadBucketResponse.BucketInfo.CreateAt, - }) - s.T().Logf("queryGetSpStoragePriceByTimeResp %s, err: %v", queryGetSpStoragePriceByTimeResp, err) - s.Require().NoError(err) - - readPrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.ReadPrice - readChargeRate := readPrice.MulInt(sdk.NewIntFromUint64(queryHeadBucketResponse.BucketInfo.ChargedReadQuota)).TruncateInt() - s.T().Logf("readPrice: %s, readChargeRate: %s", readPrice, readChargeRate) - taxRate := params.VersionedParams.ValidatorTaxRate.MulInt(readChargeRate).TruncateInt() - userTotalRate := readChargeRate.Add(taxRate) - - // assertions - streamRecordsAfter = s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRate.Neg()) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), readChargeRate) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRate) - - expectedOutFlows := []paymenttypes.OutFlow{ - {ToAddress: family.VirtualPaymentAddress, Rate: readChargeRate}, - {ToAddress: paymenttypes.ValidatorTaxPoolAddress.String(), Rate: taxRate}, - } - userOutFlowsResponse, err := s.Client.OutFlows(ctx, &paymenttypes.QueryOutFlowsRequest{Account: user.GetAddr().String()}) - s.Require().NoError(err) - sort.Slice(userOutFlowsResponse.OutFlows, func(i, j int) bool { - return userOutFlowsResponse.OutFlows[i].ToAddress < userOutFlowsResponse.OutFlows[j].ToAddress - }) - sort.Slice(expectedOutFlows, func(i, j int) bool { - return expectedOutFlows[i].ToAddress < expectedOutFlows[j].ToAddress - }) - s.Require().Equal(expectedOutFlows, userOutFlowsResponse.OutFlows) -} - -func (s *PaymentTestSuite) TestStorageBill_CreateObject_WithZeroNoneZeroPayload() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - - bucketName := s.createBucket(sp, user, 0) - - // case: create object with zero payload size - streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, objectName, _, _, payloadSize := s.createObject(user, bucketName, true) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) - gvgFamilyRate, gvgRate, taxRate, userTotalRate := s.calculateStorageRates(sp, bucketName, objectName, payloadSize, 0) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRate.Neg()) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRate) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRate) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRate) - - // case: create object with none zero payload size - streamRecordsBefore = s.getStreamRecords(streamAddresses) - _, _, objectName, _, _, payloadSize = s.createObject(user, bucketName, false) - - // assertions - streamRecordsAfter = s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) - s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) -} - -func (s *PaymentTestSuite) TestStorageBill_CreateObject_WithReserveTimeValidatorTaxRateChange() { - defer s.revertParams() - - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - - bucketName := s.createBucket(sp, user, 0) - - // create object with none zero payload size - streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, objectName, _, _, payloadSize := s.createObject(user, bucketName, false) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) - s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) - - // update params - - params := s.queryParams() - oldReserveTime := params.VersionedParams.ReserveTime - oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate - - params.VersionedParams.ReserveTime = oldReserveTime * 2 - params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) - s.updateParams(params) - - // create another object after parameter changes - streamRecordsBefore = s.getStreamRecords(streamAddresses) - _, _, objectName, _, _, payloadSize = s.createObject(user, bucketName, false) - - // assertions - streamRecordsAfter = s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - lockFeeAfterParameterChange := s.calculateLockFee(sp, bucketName, objectName, payloadSize) - s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFeeAfterParameterChange) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) - s.Require().True(lockFeeAfterParameterChange.GT(lockFee.MulRaw(2))) -} - -func (s *PaymentTestSuite) TestStorageBill_CancelCreateObject() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - - bucketName := s.createBucket(sp, user, 0) - - // create object with none zero payload size - streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, objectName, _, _, payloadSize := s.createObject(user, bucketName, false) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) - s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) - - // cancel create object - s.cancelCreateObject(user, bucketName, objectName) - - // assertions - streamRecordsAfter = s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, lockFee) - s.Require().Equal(streamRecordsAfter.User.LockBalance.Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) -} - -func (s *PaymentTestSuite) TestStorageBill_SealObject_WithoutPriceChange() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - - bucketName := s.createBucket(sp, user, 0) - - // create object with none zero payload size - streamRecordsBefore := s.getStreamRecords(streamAddresses) - _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) - s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) - - // case: seal object without price change - s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) - - // assertions - streamRecordsAfter = s.getStreamRecords(streamAddresses) - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) - gvgFamilyRate, gvgRate, taxRate, userTotalRate := s.calculateStorageRates(sp, bucketName, objectName, payloadSize, 0) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRate.Neg()) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRate) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRate) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRate) -} - -func (s *PaymentTestSuite) TestStorageBill_SealObject_WithPriceChange() { - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - - bucketName := s.createBucket(sp, user, 102400) - - // case: seal object with read price change and storage price change - _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) - - priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ - SpAddr: sp.OperatorKey.GetAddr().String(), - Timestamp: 0, - }) - s.Require().NoError(err) - // update new price - msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(2), - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(2), - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) - - streamRecordsBefore := s.getStreamRecords(streamAddresses) - gvgFamilyRateReadBefore, taxRateReadBefore, userTotalRateReadBefore := s.calculateReadRates(sp, bucketName) - - // seal object - s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - gvgFamilyRateReadAfter, taxRateReadAfter, userTotalRateReadAfter := s.calculateReadRatesCurrentTimestamp(sp, bucketName) - gvgFamilyRateStore, gvgRateStore, taxRateStore, userTotalRateStore := s.calculateStorageRatesCurrentTimestamp(sp, bucketName, objectName, payloadSize) - - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) - - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRateReadAfter.Sub(userTotalRateReadBefore).Add(userTotalRateStore).Neg()) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRateStore) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRateReadAfter.Sub(gvgFamilyRateReadBefore).Add(gvgFamilyRateStore)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRateReadAfter.Sub(taxRateReadBefore).Add(taxRateStore)) -} - -func (s *PaymentTestSuite) TestStorageBill_SealObject_WithPriceChangeValidatorTaxRateChange() { - defer s.revertParams() - - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - - bucketName := s.createBucket(sp, user, 102400) - - // case: seal object with read price change and storage price change - _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) - - priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ - SpAddr: sp.OperatorKey.GetAddr().String(), - Timestamp: 0, - }) - s.Require().NoError(err) - // update new price - msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(2), - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(2), - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) - - streamRecordsBefore := s.getStreamRecords(streamAddresses) - gvgFamilyRateReadBefore, taxRateReadBefore, userTotalRateReadBefore := s.calculateReadRates(sp, bucketName) - - // seal object - s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - gvgFamilyRateReadAfter, taxRateReadAfter, userTotalRateReadAfter := s.calculateReadRatesCurrentTimestamp(sp, bucketName) - gvgFamilyRateStore, gvgRateStore, taxRateStore, userTotalRateStore := s.calculateStorageRatesCurrentTimestamp(sp, bucketName, objectName, payloadSize) - - s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) - s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) - - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRateReadAfter.Sub(userTotalRateReadBefore).Add(userTotalRateStore).Neg()) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRateStore) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRateReadAfter.Sub(gvgFamilyRateReadBefore).Add(gvgFamilyRateStore)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRateReadAfter.Sub(taxRateReadBefore).Add(taxRateStore)) - - // update params - params := s.queryParams() - oldReserveTime := params.VersionedParams.ReserveTime - oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate - - params.VersionedParams.ReserveTime = oldReserveTime * 2 - params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) - s.updateParams(params) - - _, _, objectName, objectId, checksums, payloadSize = s.createObject(user, bucketName, false) - s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) - - // assertions - streamRecordsAfter = s.getStreamRecords(streamAddresses) - gvgFamilyRateReadAfter, taxRateReadAfter, userTotalRateReadAfter = s.calculateReadRatesCurrentTimestamp(sp, bucketName) - 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()) - - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRateReadAfter.Sub(userTotalRateReadBefore).Add(userTotalRateStore).Neg()) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRateStore) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRateReadAfter.Sub(gvgFamilyRateReadBefore).Add(gvgFamilyRateStore)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRateReadAfter.Sub(taxRateReadBefore).Add(taxRateStore)) -} - -func (s *PaymentTestSuite) TestStorageBill_FullLifecycle() { - defer s.revertParams() - - var err error - ctx := context.Background() - sp := s.PickStorageProvider() - gvg, found := sp.GetFirstGlobalVirtualGroup() - s.Require().True(found) - queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ - FamilyId: gvg.FamilyId, - }) - s.Require().NoError(err) - family := queryFamilyResponse.GlobalVirtualGroupFamily - user := s.GenAndChargeAccounts(1, 1000000)[0] - - // query storage price - priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ - SpAddr: sp.OperatorKey.GetAddr().String(), - Timestamp: 0, - }) - s.Require().NoError(err) - s.T().Log("price", priceRes.SpStoragePrice) - - streamAddresses := []string{ - user.GetAddr().String(), - family.VirtualPaymentAddress, - gvg.VirtualPaymentAddress, - paymenttypes.ValidatorTaxPoolAddress.String(), - } - streamRecordsBefore := s.getStreamRecords(streamAddresses) - - // full lifecycle - bucketName1 := s.createBucket(sp, user, 0) - _, _, objectName1, _, _, _ := s.createObject(user, bucketName1, true) - _, _, objectName2, objectId2, checksums2, _ := s.createObject(user, bucketName1, false) - s.sealObject(sp, gvg, bucketName1, objectName2, objectId2, checksums2) - - bucketName2 := s.createBucket(sp, user, 1024) - _, _, objectName3, objectId3, checksums3, _ := s.createObject(user, bucketName2, false) - s.sealObject(sp, gvg, bucketName2, objectName3, objectId3, checksums3) - - // update params - params := s.queryParams() - params.VersionedParams.ReserveTime = params.VersionedParams.ReserveTime * 3 - params.ForcedSettleTime = params.ForcedSettleTime * 2 - s.updateParams(params) - - _, _, objectName4, objectId4, checksums4, _ := s.createObject(user, bucketName2, false) - s.sealObject(sp, gvg, bucketName2, objectName4, objectId4, checksums4) - - bucketName3 := s.createBucket(sp, user, 1024) - _, _, objectName5, objectId5, checksums5, _ := s.createObject(user, bucketName3, false) - s.sealObject(sp, gvg, bucketName3, objectName5, objectId5, checksums5) - - // update new price - msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice, - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(10000), - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) - - // update params - params = s.queryParams() - params.VersionedParams.ReserveTime = params.VersionedParams.ReserveTime / 2 - params.ForcedSettleTime = params.ForcedSettleTime / 3 - s.updateParams(params) - - _, _, objectName6, objectId6, checksums6, _ := s.createObject(user, bucketName3, false) - s.sealObject(sp, gvg, bucketName3, objectName6, objectId6, checksums6) - - bucketName4 := s.createBucket(sp, user, 1024) - _, _, objectName7, objectId7, checksums7, _ := s.createObject(user, bucketName4, false) - s.sealObject(sp, gvg, bucketName4, objectName7, objectId7, checksums7) - - // update params - params = s.queryParams() - params.VersionedParams.ValidatorTaxRate = params.VersionedParams.ValidatorTaxRate.MulInt64(2) - s.updateParams(params) - - _, _, objectName8, objectId8, checksums8, _ := s.createObject(user, bucketName4, false) - s.sealObject(sp, gvg, bucketName4, objectName8, objectId8, checksums8) - - time.Sleep(3 * time.Second) - - _ = s.deleteObject(user, bucketName1, objectName1) - _ = s.deleteObject(user, bucketName1, objectName2) - - // update params - params = s.queryParams() - params.VersionedParams.ValidatorTaxRate = params.VersionedParams.ValidatorTaxRate.MulInt64(3) - s.updateParams(params) - - _ = s.deleteObject(user, bucketName2, objectName3) - _ = s.deleteObject(user, bucketName2, objectName4) - err = s.deleteBucket(user, bucketName1) - s.Require().Error(err) - err = s.deleteBucket(user, bucketName2) - s.Require().Error(err) - - _ = s.deleteObject(user, bucketName3, objectName5) - _ = s.deleteObject(user, bucketName3, objectName6) - _ = s.deleteObject(user, bucketName4, objectName7) - _ = s.deleteObject(user, bucketName4, objectName8) - err = s.deleteBucket(user, bucketName3) - s.Require().Error(err) - err = s.deleteBucket(user, bucketName4) - s.Require().Error(err) - - // assertions - streamRecordsAfter := s.getStreamRecords(streamAddresses) - s.Require().True(!streamRecordsAfter.User.StaticBalance.IsZero()) - s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) - s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) - - // revert price - msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: sp.OperatorKey.GetAddr().String(), - ReadPrice: priceRes.SpStoragePrice.ReadPrice, - FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, - StorePrice: priceRes.SpStoragePrice.StorePrice, - } - s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) -} - func (s *PaymentTestSuite) TestVirtualGroup_Settle() { var err error ctx := context.Background() @@ -3038,6 +1739,8 @@ func (s *PaymentTestSuite) TestDiscontinue_InBlocks_WithPriceChangeReserveTimeCh s.Require().NoError(err) s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_SEALED) time.Sleep(200 * time.Millisecond) + userStream := s.getStreamRecord(user.GetAddr().String()) + s.Require().True(userStream.LockBalance.IsPositive()) } queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} @@ -3122,6 +1825,238 @@ func (s *PaymentTestSuite) TestDiscontinue_InBlocks_WithPriceChangeReserveTimeCh s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) } +func (s *PaymentTestSuite) TestDiscontinue_MultiObjects() { + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + + // create bucket + bucketName := s.createBucket(sp, user, 0) + objectIds := []sdkmath.Uint{} + + // create objects + for i := 0; i < 3; i++ { + _, _, objectName, objectId, _, _ := s.createObject(user, bucketName, false) + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_CREATED) + time.Sleep(200 * time.Millisecond) + objectIds = append(objectIds, objectId) + } + + // create & seal objects + for i := 0; i < 3; i++ { + _, _, objectName, objectId, checksums, _ := s.createObject(user, bucketName, false) + s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_SEALED) + time.Sleep(200 * time.Millisecond) + objectIds = append(objectIds, objectId) + } + + queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.SubRaw(5*types.DecimalGwei)), + )) + + simulateResponse := s.SimulateTx(msgSend, user) + gasLimit := simulateResponse.GasInfo.GetGasUsed() + gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + msgSend.Amount = sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))))), + ) + s.SendTxBlock(user, msgSend) + queryBalanceResponse, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + s.Require().Equal(int64(0), queryBalanceResponse.Balance.Amount.Int64()) + + // for payment + time.Sleep(2 * time.Second) + + // force objects + msgs := make([]sdk.Msg, 0) + for _, id := range objectIds { + msgDiscontinueObject := storagetypes.NewMsgDiscontinueObject(sp.GcKey.GetAddr(), bucketName, []sdkmath.Uint{id}, "test") + msgs = append(msgs, msgDiscontinueObject) + } + msgs = append(msgs, storagetypes.NewMsgDiscontinueBucket(sp.GcKey.GetAddr(), bucketName, "test")) + txRes := s.SendTxBlock(sp.GcKey, msgs...) + deleteAt := filterDiscontinueObjectEventFromTx(txRes).DeleteAt + + for { + time.Sleep(200 * time.Millisecond) + statusRes, err := s.TmClient.TmClient.Status(context.Background()) + s.Require().NoError(err) + blockTime := statusRes.SyncInfo.LatestBlockTime.Unix() + + s.T().Logf("current blockTime: %d, delete blockTime: %d", blockTime, deleteAt) + + if blockTime > deleteAt+5 { + break + } + } + + _, err = s.Client.HeadBucket(ctx, &storagetypes.QueryHeadBucketRequest{BucketName: bucketName}) + s.Require().ErrorContains(err, "No such bucket") + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + s.Require().True(streamRecordsAfter.User.LockBalance.IsZero()) +} + +func (s *PaymentTestSuite) TestDiscontinue_MultiBuckets() { + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + + bucketNames := []string{} + // create bucket + bucketName1 := s.createBucket(sp, user, 1023) + bucketNames = append(bucketNames, bucketName1) + + // create objects + for i := 0; i < 2; i++ { + _, _, objectName, _, _, _ := s.createObject(user, bucketName1, false) + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName1, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_CREATED) + time.Sleep(200 * time.Millisecond) + } + + // create & seal objects + for i := 0; i < 2; i++ { + _, _, objectName, objectId, checksums, _ := s.createObject(user, bucketName1, false) + s.sealObject(sp, gvg, bucketName1, objectName, objectId, checksums) + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName1, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_SEALED) + time.Sleep(200 * time.Millisecond) + } + + // create bucket + bucketName2 := s.createBucket(sp, user, 21023) + bucketNames = append(bucketNames, bucketName2) + + // create bucket + bucketName3 := s.createBucket(sp, user, 0) + bucketNames = append(bucketNames, bucketName3) + + // create bucket + bucketName4 := s.createBucket(sp, user, 55) + bucketNames = append(bucketNames, bucketName4) + + queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.SubRaw(5*types.DecimalGwei)), + )) + + simulateResponse := s.SimulateTx(msgSend, user) + gasLimit := simulateResponse.GasInfo.GetGasUsed() + gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + msgSend.Amount = sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))))), + ) + s.SendTxBlock(user, msgSend) + queryBalanceResponse, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + s.Require().Equal(int64(0), queryBalanceResponse.Balance.Amount.Int64()) + + // for payment + time.Sleep(2 * time.Second) + + // force objects + msgs := make([]sdk.Msg, 0) + for _, bucketName := range bucketNames { + msgDiscontinueBucket := storagetypes.NewMsgDiscontinueBucket(sp.GcKey.GetAddr(), bucketName, "test") + msgs = append(msgs, msgDiscontinueBucket) + } + txRes := s.SendTxBlock(sp.GcKey, msgs...) + deleteAt := filterDiscontinueBucketEventFromTx(txRes).DeleteAt + + for { + time.Sleep(200 * time.Millisecond) + statusRes, err := s.TmClient.TmClient.Status(context.Background()) + s.Require().NoError(err) + blockTime := statusRes.SyncInfo.LatestBlockTime.Unix() + + s.T().Logf("current blockTime: %d, delete blockTime: %d", blockTime, deleteAt) + + if blockTime > deleteAt+5 { + break + } + } + + for _, bucketName := range bucketNames { + _, err = s.Client.HeadBucket(ctx, &storagetypes.QueryHeadBucketRequest{BucketName: bucketName}) + s.Require().ErrorContains(err, "No such bucket") + } + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + s.Require().True(streamRecordsAfter.User.LockBalance.IsZero()) +} + func TestPaymentTestSuite(t *testing.T) { suite.Run(t, new(PaymentTestSuite)) } @@ -3576,6 +2511,20 @@ func (s *PaymentTestSuite) sealObject(sp *core.StorageProvider, gvg *virtualgrou return gvg } +func (s *PaymentTestSuite) rejectSealObject(sp *core.StorageProvider, gvg *virtualgrouptypes.GlobalVirtualGroup, bucketName, objectName string) { + msgRejectSealObject := storagetypes.NewMsgRejectUnsealedObject(sp.SealKey.GetAddr(), bucketName, objectName) + + s.T().Logf("msg %s", msgRejectSealObject.String()) + s.SendTxBlock(sp.SealKey, msgRejectSealObject) + + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + _, err := s.Client.HeadObject(context.Background(), &queryHeadObjectRequest) + s.Require().Error(err) +} + func (s *PaymentTestSuite) deleteObject(user keys.KeyManager, bucketName, objectName string) error { msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName) s.SendTxBlock(user, msgDeleteObject) diff --git a/e2e/tests/storage_bill_test.go b/e2e/tests/storage_bill_test.go index 0c73fe4d2..b55bf930b 100644 --- a/e2e/tests/storage_bill_test.go +++ b/e2e/tests/storage_bill_test.go @@ -1,7 +1,9 @@ package tests import ( + "bytes" "context" + "fmt" "math" "sort" "time" @@ -21,6 +23,1378 @@ import ( virtualgrouptypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" ) +func (s *PaymentTestSuite) TestStorageBill_DeleteBucket_WithReadQuota() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + // CreateBucket + chargedReadQuota := uint64(100) + bucketName := storagetestutils.GenRandomBucketName() + msgCreateBucket := storagetypes.NewMsgCreateBucket( + user.GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PUBLIC_READ, sp.OperatorKey.GetAddr(), + nil, math.MaxUint, nil, chargedReadQuota) + msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId + msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxBlock(user, msgCreateBucket) + + streamRecordsBeforeDelete := s.getStreamRecords(streamAddresses) + s.T().Logf("streamRecordsBeforeDelete: %s", core.YamlString(streamRecordsBeforeDelete)) + s.Require().NotEqual(streamRecordsBeforeDelete.User.NetflowRate.String(), "0") + + // DeleteBucket + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) + s.SendTxBlock(user, msgDeleteBucket) + + // check the billing change + streamRecordsAfterDelete := s.getStreamRecords(streamAddresses) + s.T().Logf("streamRecordsBeforeDelete: %s", core.YamlString(streamRecordsAfterDelete)) + s.Require().Equal(streamRecordsAfterDelete.User.NetflowRate.String(), "0") +} + +func (s *PaymentTestSuite) TestStorageBill_Smoke() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBeforeCreateBucket := s.getStreamRecords(streamAddresses) + s.T().Logf("streamRecordsBeforeCreateBucket: %s", core.YamlString(streamRecordsBeforeCreateBucket)) + + params := s.queryParams() + + // create bucket + bucketName := storagetestutils.GenRandomBucketName() + bucketChargedReadQuota := uint64(1000) + msgCreateBucket := storagetypes.NewMsgCreateBucket( + user.GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PRIVATE, sp.OperatorKey.GetAddr(), + nil, math.MaxUint, nil, 0) + msgCreateBucket.ChargedReadQuota = bucketChargedReadQuota + msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId + msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxBlock(user, msgCreateBucket) + + // check bill after creating bucket + userBankAccount, err := s.Client.Balance(ctx, &banktypes.QueryBalanceRequest{ + Address: user.GetAddr().String(), + Denom: s.Config.Denom, + }) + s.Require().NoError(err) + s.T().Logf("user bank account %s", userBankAccount) + + streamRecordsAfterCreateBucket := s.getStreamRecords(streamAddresses) + userStreamRecord := streamRecordsAfterCreateBucket.User + s.Require().Equal(userStreamRecord.StaticBalance, sdkmath.ZeroInt()) + + // check price and rate calculation + queryHeadBucketRequest := storagetypes.QueryHeadBucketRequest{ + BucketName: bucketName, + } + queryHeadBucketResponse, err := s.Client.HeadBucket(ctx, &queryHeadBucketRequest) + s.Require().NoError(err) + + queryGetSpStoragePriceByTimeResp, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: queryHeadBucketResponse.BucketInfo.CreateAt, + }) + s.T().Logf("queryGetSpStoragePriceByTimeResp %s, err: %v", queryGetSpStoragePriceByTimeResp, err) + s.Require().NoError(err) + + readPrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.ReadPrice + readChargeRate := readPrice.MulInt(sdk.NewIntFromUint64(queryHeadBucketResponse.BucketInfo.ChargedReadQuota)).TruncateInt() + s.T().Logf("readPrice: %s, readChargeRate: %s", readPrice, readChargeRate) + userTaxRate := params.VersionedParams.ValidatorTaxRate.MulInt(readChargeRate).TruncateInt() + userTotalRate := readChargeRate.Add(userTaxRate) + s.Require().Equal(userStreamRecord.NetflowRate.Abs(), userTotalRate) + expectedOutFlows := []paymenttypes.OutFlow{ + {ToAddress: family.VirtualPaymentAddress, Rate: readChargeRate}, + {ToAddress: paymenttypes.ValidatorTaxPoolAddress.String(), Rate: userTaxRate}, + } + userOutFlowsResponse, err := s.Client.OutFlows(ctx, &paymenttypes.QueryOutFlowsRequest{Account: user.GetAddr().String()}) + s.Require().NoError(err) + sort.Slice(userOutFlowsResponse.OutFlows, func(i, j int) bool { + return userOutFlowsResponse.OutFlows[i].ToAddress < userOutFlowsResponse.OutFlows[j].ToAddress + }) + sort.Slice(expectedOutFlows, func(i, j int) bool { + return expectedOutFlows[i].ToAddress < expectedOutFlows[j].ToAddress + }) + s.Require().Equal(expectedOutFlows, userOutFlowsResponse.OutFlows) + + // CreateObject + objectName := storagetestutils.GenRandomObjectName() + // create test buffer + var buffer bytes.Buffer + // 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.GetAddr(), bucketName, objectName, uint64(payloadSize), storagetypes.VISIBILITY_TYPE_PRIVATE, expectChecksum, contextType, storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil) + msgCreateObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateObject.GetApprovalBytes()) + s.Require().NoError(err) + // simulate + res := s.SimulateTx(msgCreateObject, user) + s.T().Logf("res %v", res.Result) + // check EventFeePreview in simulation result + var feePreviewEventEmitted bool + events := res.Result.Events + for _, event := range events { + if event.Type == "greenfield.payment.EventFeePreview" { + s.T().Logf("event %v", event) + feePreviewEventEmitted = true + } + } + s.Require().True(feePreviewEventEmitted) + s.SendTxBlock(user, msgCreateObject) + + // check lock balance + queryHeadBucketResponseAfterCreateObj, err := s.Client.HeadBucket(ctx, &queryHeadBucketRequest) + s.T().Logf("queryHeadBucketResponseAfterCreateObj %s, err: %v", queryHeadBucketResponseAfterCreateObj, err) + s.Require().NoError(err) + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.T().Logf("queryHeadObjectResponse %s, err: %v", queryHeadObjectResponse, err) + s.Require().NoError(err) + + queryGetSecondarySpStorePriceByTime, err := s.Client.QueryGetSecondarySpStorePriceByTime(ctx, &sptypes.QueryGetSecondarySpStorePriceByTimeRequest{ + Timestamp: queryHeadBucketResponse.BucketInfo.CreateAt, + }) + s.T().Logf("queryGetSecondarySpStorePriceByTime %s, err: %v", queryGetSecondarySpStorePriceByTime, err) + s.Require().NoError(err) + primaryStorePrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.StorePrice + secondaryStorePrice := queryGetSecondarySpStorePriceByTime.SecondarySpStorePrice.StorePrice + chargeSize := s.getChargeSize(queryHeadObjectResponse.ObjectInfo.PayloadSize) + expectedChargeRate := primaryStorePrice.Add(secondaryStorePrice.MulInt64(6)).MulInt(sdk.NewIntFromUint64(chargeSize)).TruncateInt() + expectedChargeRate = params.VersionedParams.ValidatorTaxRate.MulInt(expectedChargeRate).TruncateInt().Add(expectedChargeRate) + expectedLockedBalance := expectedChargeRate.Mul(sdkmath.NewIntFromUint64(params.VersionedParams.ReserveTime)) + + streamRecordsAfterCreateObject := s.getStreamRecords(streamAddresses) + s.T().Logf("streamRecordsAfterCreateObject %s", core.YamlString(streamRecordsAfterCreateObject)) + userStreamAccountAfterCreateObj := streamRecordsAfterCreateObject.User + + s.Require().Equal(expectedLockedBalance.String(), userStreamAccountAfterCreateObj.LockBalance.String()) + + // seal object + gvgId := gvg.Id + msgSealObject := storagetypes.NewMsgSealObject(sp.SealKey.GetAddr(), bucketName, objectName, gvg.Id, nil) + secondarySigs := make([][]byte, 0) + secondarySPBlsPubKeys := make([]bls.PublicKey, 0) + blsSignHash := storagetypes.NewSecondarySpSealObjectSignDoc(s.GetChainID(), gvgId, queryHeadObjectResponse.ObjectInfo.Id, storagetypes.GenerateHash(expectChecksum[:])).GetBlsSignHash() + // every secondary sp signs the checksums + for _, spID := range gvg.SecondarySpIds { + sig, err := core.BlsSignAndVerify(s.StorageProviders[spID], blsSignHash) + s.Require().NoError(err) + secondarySigs = append(secondarySigs, sig) + pk, err := bls.PublicKeyFromBytes(s.StorageProviders[spID].BlsKey.PubKey().Bytes()) + s.Require().NoError(err) + secondarySPBlsPubKeys = append(secondarySPBlsPubKeys, pk) + } + aggBlsSig, err := core.BlsAggregateAndVerify(secondarySPBlsPubKeys, blsSignHash, secondarySigs) + s.Require().NoError(err) + msgSealObject.SecondarySpBlsAggSignatures = aggBlsSig + s.T().Logf("msg %s", msgSealObject.String()) + s.SendTxBlock(sp.SealKey, msgSealObject) + + // check bill after seal + streamRecordsAfterSeal := s.getStreamRecords(streamAddresses) + s.T().Logf("streamRecordsAfterSeal %s", core.YamlString(streamRecordsAfterSeal)) + s.Require().Equal(sdkmath.ZeroInt(), streamRecordsAfterSeal.User.LockBalance) + s.checkStreamRecordsBeforeAndAfter(streamRecordsAfterCreateObject, streamRecordsAfterSeal, readPrice, readChargeRate, primaryStorePrice, secondaryStorePrice, chargeSize, uint64(payloadSize)) + + // query dynamic balance + time.Sleep(3 * time.Second) + queryDynamicBalanceRequest := paymenttypes.QueryDynamicBalanceRequest{ + Account: user.GetAddr().String(), + } + queryDynamicBalanceResponse, err := s.Client.DynamicBalance(ctx, &queryDynamicBalanceRequest) + s.Require().NoError(err) + s.T().Logf("queryDynamicBalanceResponse %s", core.YamlString(queryDynamicBalanceResponse)) + + // create empty object + streamRecordsBeforeCreateEmptyObject := s.getStreamRecords(streamAddresses) + s.T().Logf("streamRecordsBeforeCreateEmptyObject %s", core.YamlString(streamRecordsBeforeCreateEmptyObject)) + + emptyObjectName := "sub_directory/" + // create empty test buffer + var emptyBuffer bytes.Buffer + emptyPayloadSize := emptyBuffer.Len() + emptyChecksum := sdk.Keccak256(emptyBuffer.Bytes()) + emptyExpectChecksum := [][]byte{emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum, emptyChecksum} + msgCreateEmptyObject := storagetypes.NewMsgCreateObject(user.GetAddr(), bucketName, emptyObjectName, uint64(emptyPayloadSize), storagetypes.VISIBILITY_TYPE_PRIVATE, emptyExpectChecksum, contextType, storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil) + msgCreateEmptyObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateEmptyObject.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxBlock(user, msgCreateEmptyObject) + + streamRecordsAfterCreateEmptyObject := s.getStreamRecords(streamAddresses) + s.T().Logf("streamRecordsAfterCreateEmptyObject %s", core.YamlString(streamRecordsAfterCreateEmptyObject)) + chargeSize = s.getChargeSize(uint64(emptyPayloadSize)) + s.checkStreamRecordsBeforeAndAfter(streamRecordsBeforeCreateEmptyObject, streamRecordsAfterCreateEmptyObject, readPrice, readChargeRate, primaryStorePrice, secondaryStorePrice, chargeSize, uint64(emptyPayloadSize)) + + // test query auto settle records + queryAllAutoSettleRecordRequest := paymenttypes.QueryAllAutoSettleRecordRequest{} + queryAllAutoSettleRecordResponse, err := s.Client.AutoSettleRecordAll(ctx, &queryAllAutoSettleRecordRequest) + s.Require().NoError(err) + s.T().Logf("queryAllAutoSettleRecordResponse %s", core.YamlString(queryAllAutoSettleRecordResponse)) + s.Require().True(len(queryAllAutoSettleRecordResponse.AutoSettleRecord) >= 1) + + // simulate delete object, check fee preview + deleteObjectMsg := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName) + deleteObjectSimRes := s.SimulateTx(deleteObjectMsg, user) + s.T().Logf("deleteObjectSimRes %v", deleteObjectSimRes.Result) +} + +func (s *PaymentTestSuite) TestStorageBill_DeleteObjectBucket_WithoutPriceChange() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + + // create bucket + bucketName := s.createBucket(sp, user, 256) + + //simulate delete bucket gas + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) + simulateResponse := s.SimulateTx(msgDeleteBucket, user) + gasLimit := simulateResponse.GasInfo.GetGasUsed() + gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas := gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))) + s.T().Log("total gas", "gas", gas) + + // create & seal objects + _, _, objectName1, objectId1, checksums1, _ := s.createObject(user, bucketName, false) + s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) + + // for payment + time.Sleep(2 * time.Second) + + //transfer gas + msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, sdkmath.NewInt(5*types.DecimalGwei)), + )) + simulateResponse = s.SimulateTx(msgSend, user) + gasLimit = simulateResponse.GasInfo.GetGasUsed() + gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) + s.T().Log("total gas", "gas", gas) + + //delete object gas + msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) + simulateResponse = s.SimulateTx(msgDeleteObject, user) + gasLimit = simulateResponse.GasInfo.GetGasUsed() + gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) + s.T().Log("total gas", "gas", gas) + + // transfer out user's balance + queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + msgSend.Amount = sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gas)), + ) + s.SendTxBlock(user, msgSend) + _, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + s.SendTxBlock(user, msgDeleteObject) + s.SendTxBlock(user, msgDeleteBucket) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.NetflowRate, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) +} + +func (s *PaymentTestSuite) TestStorageBill_DeleteObjectBucket_WithPriceChange() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + + // create bucket + bucketName := s.createBucket(sp, user, 256) + + //simulate delete bucket gas + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) + simulateResponse := s.SimulateTx(msgDeleteBucket, user) + gasLimit := simulateResponse.GasInfo.GetGasUsed() + gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas := gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))) + s.T().Log("total gas", "gas", gas) + + // create & seal objects + _, _, objectName1, objectId1, checksums1, _ := s.createObject(user, bucketName, false) + s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) + + // for payment + time.Sleep(2 * time.Second) + + //transfer gas + msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, sdkmath.NewInt(5*types.DecimalGwei)), + )) + simulateResponse = s.SimulateTx(msgSend, user) + gasLimit = simulateResponse.GasInfo.GetGasUsed() + gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) + s.T().Log("total gas", "gas", gas) + + //delete object gas + msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) + simulateResponse = s.SimulateTx(msgDeleteObject, user) + gasLimit = simulateResponse.GasInfo.GetGasUsed() + gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) + s.T().Log("total gas", "gas", gas) + + // transfer out user's balance + queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + msgSend.Amount = sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gas)), + ) + s.SendTxBlock(user, msgSend) + _, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + // sp price changes + priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: 0, + }) + s.Require().NoError(err) + s.T().Log("price", priceRes.SpStoragePrice) + + // update new price + msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(1000), + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(10000), + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) + + s.SendTxBlock(user, msgDeleteObject) + s.SendTxBlock(user, msgDeleteBucket) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.NetflowRate, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + + // revert price + msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice, + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice, + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) +} + +func (s *PaymentTestSuite) TestStorageBill_DeleteObjectBucket_WithPriceChangeReserveTimeChange() { + defer s.revertParams() + + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + + // create bucket + bucketName := s.createBucket(sp, user, 256) + + //simulate delete bucket gas + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) + simulateResponse := s.SimulateTx(msgDeleteBucket, user) + gasLimit := simulateResponse.GasInfo.GetGasUsed() + gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas := gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))) + s.T().Log("total gas", "gas", gas) + + // create & seal objects + _, _, objectName1, objectId1, checksums1, _ := s.createObject(user, bucketName, false) + s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) + + // for payment + time.Sleep(2 * time.Second) + + //transfer gas + msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, sdkmath.NewInt(5*types.DecimalGwei)), + )) + simulateResponse = s.SimulateTx(msgSend, user) + gasLimit = simulateResponse.GasInfo.GetGasUsed() + gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) + s.T().Log("total gas", "gas", gas) + + //delete object gas + msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) + simulateResponse = s.SimulateTx(msgDeleteObject, user) + gasLimit = simulateResponse.GasInfo.GetGasUsed() + gasPrice, err = sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + gas = gas.Add(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit)))) + s.T().Log("total gas", "gas", gas) + + // transfer out user's balance + queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + msgSend.Amount = sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gas)), + ) + s.SendTxBlock(user, msgSend) + _, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + // sp price changes + priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: 0, + }) + s.Require().NoError(err) + s.T().Log("price", priceRes.SpStoragePrice) + + // update new price + msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(1000), + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(10000), + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) + + // update params + params := s.queryParams() + oldReserveTime := params.VersionedParams.ReserveTime + oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate + + params.VersionedParams.ReserveTime = oldReserveTime * 2 + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) + s.updateParams(params) + + s.SendTxBlock(user, msgDeleteObject) + s.SendTxBlock(user, msgDeleteBucket) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.NetflowRate, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + + // revert price + msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice, + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice, + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) +} + +func (s *PaymentTestSuite) TestStorageBill_DeleteObject_WithStoreLessThanReserveTime() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + params := s.queryParams() + reserveTime := params.VersionedParams.ReserveTime + + // create bucket + bucketName := s.createBucket(sp, user, 256) + + // create & seal objects + _, _, objectName1, objectId1, checksums1, payloadSize := s.createObject(user, bucketName, false) + s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) + + headObjectRes, err := s.Client.HeadObject(ctx, &storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName1, + }) + s.Require().NoError(err) + s.T().Log("headObjectRes", headObjectRes) + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + _, _, userRateRead := s.calculateReadRates(sp, bucketName) + _, _, _, userRateStore := s.calculateStorageRates(sp, bucketName, objectName1, payloadSize, 0) + + msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) + s.SendTxBlock(user, msgDeleteObject) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + + settledTime := streamRecordsAfter.User.CrudTimestamp - streamRecordsBefore.User.CrudTimestamp + timeToPay := int64(reserveTime) + headObjectRes.ObjectInfo.CreateAt - streamRecordsAfter.User.CrudTimestamp + balanceDelta := userRateRead.Add(userRateStore).MulRaw(settledTime).Add(userRateStore.MulRaw(timeToPay)) + + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), userRateStore.Int64()) + userBalanceChange := streamRecordsAfter.User.BufferBalance.Add(streamRecordsAfter.User.StaticBalance). + Sub(streamRecordsBefore.User.BufferBalance.Add(streamRecordsBefore.User.StaticBalance)) + s.Require().Equal(userBalanceChange.Neg().Int64(), balanceDelta.Int64()) + + familyDelta := streamRecordsAfter.GVGFamily.StaticBalance.Sub(streamRecordsBefore.GVGFamily.StaticBalance) + gvgDelta := streamRecordsAfter.GVG.StaticBalance.Sub(streamRecordsBefore.GVG.StaticBalance) + taxPoolDelta := streamRecordsAfter.Tax.StaticBalance.Sub(streamRecordsBefore.Tax.StaticBalance) + s.T().Log("familyDelta", familyDelta, "gvgDelta", gvgDelta, "taxPoolDelta", taxPoolDelta) + s.Require().True(familyDelta.Add(gvgDelta).Add(taxPoolDelta).Int64() >= balanceDelta.Int64()) // could exist other buckets/objects on the gvg & family +} + +func (s *PaymentTestSuite) TestStorageBill_DeleteObject_WithStoreMoreThanReserveTime() { + defer s.revertParams() + + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + params := s.queryParams() + params.VersionedParams.ReserveTime = 5 + params.ForcedSettleTime = 2 + s.updateParams(params) + + // create bucket + bucketName := s.createBucket(sp, user, 256) + + // create & seal objects + _, _, objectName1, objectId1, checksums1, payloadSize := s.createObject(user, bucketName, false) + s.sealObject(sp, gvg, bucketName, objectName1, objectId1, checksums1) + + headObjectRes, err := s.Client.HeadObject(ctx, &storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName1, + }) + s.Require().NoError(err) + s.T().Log("headObjectRes", headObjectRes) + + time.Sleep(5 * time.Second) + queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + balanceBefore := queryBalanceResponse.Balance.Amount + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + _, _, userRateRead := s.calculateReadRates(sp, bucketName) + _, _, _, userRateStore := s.calculateStorageRates(sp, bucketName, objectName1, payloadSize, 0) + + msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName1) + simulateResponse := s.SimulateTx(msgDeleteObject, user) + gasLimit := simulateResponse.GasInfo.GetGasUsed() + gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + gas := gasPrice.Amount.MulRaw(int64(gasLimit)) + + // delete object + s.SendTxBlock(user, msgDeleteObject) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + queryBalanceRequest = banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + balanceAfter := queryBalanceResponse.Balance.Amount + + settledTime := streamRecordsAfter.User.CrudTimestamp - streamRecordsBefore.User.CrudTimestamp + balanceDelta := userRateRead.Add(userRateStore).MulRaw(settledTime) + + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), userRateStore.Int64()) + userBalanceChange := streamRecordsBefore.User.BufferBalance.Add(streamRecordsBefore.User.StaticBalance). + Sub(streamRecordsAfter.User.BufferBalance.Add(streamRecordsAfter.User.StaticBalance)) + userBalanceChange = userBalanceChange.Add(balanceBefore.Sub(balanceAfter)).Sub(gas) + s.Require().Equal(userBalanceChange.Int64(), balanceDelta.Int64()) + + familyDelta := streamRecordsAfter.GVGFamily.StaticBalance.Sub(streamRecordsBefore.GVGFamily.StaticBalance) + gvgDelta := streamRecordsAfter.GVG.StaticBalance.Sub(streamRecordsBefore.GVG.StaticBalance) + taxPoolDelta := streamRecordsAfter.Tax.StaticBalance.Sub(streamRecordsBefore.Tax.StaticBalance) + s.T().Log("familyDelta", familyDelta, "gvgDelta", gvgDelta, "taxPoolDelta", taxPoolDelta) + s.Require().True(familyDelta.Add(gvgDelta).Add(taxPoolDelta).Int64() >= balanceDelta.Int64()) // could exist other buckets/objects on the gvg & family +} + +func (s *PaymentTestSuite) TestStorageBill_CreateBucket_WithZeroNoneZeroReadQuota() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + + params := s.queryParams() + + // case: create bucket with zero read quota + bucketName := s.createBucket(sp, user, 0) + + // bucket created + queryHeadBucketRequest := storagetypes.QueryHeadBucketRequest{ + BucketName: bucketName, + } + _, err = s.Client.HeadBucket(ctx, &queryHeadBucketRequest) + s.Require().NoError(err) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.NetflowRate, streamRecordsBefore.User.NetflowRate) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate, streamRecordsBefore.GVGFamily.NetflowRate) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate, streamRecordsBefore.Tax.NetflowRate) + + // case: create bucket with none zero read quota + bucketName = s.createBucket(sp, user, 10240) + + // bucket created + queryHeadBucketRequest = storagetypes.QueryHeadBucketRequest{ + BucketName: bucketName, + } + queryHeadBucketResponse, err := s.Client.HeadBucket(ctx, &queryHeadBucketRequest) + s.Require().NoError(err) + + // check price and rate calculation + queryGetSpStoragePriceByTimeResp, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: queryHeadBucketResponse.BucketInfo.CreateAt, + }) + s.T().Logf("queryGetSpStoragePriceByTimeResp %s, err: %v", queryGetSpStoragePriceByTimeResp, err) + s.Require().NoError(err) + + readPrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.ReadPrice + readChargeRate := readPrice.MulInt(sdk.NewIntFromUint64(queryHeadBucketResponse.BucketInfo.ChargedReadQuota)).TruncateInt() + s.T().Logf("readPrice: %s, readChargeRate: %s", readPrice, readChargeRate) + taxRate := params.VersionedParams.ValidatorTaxRate.MulInt(readChargeRate).TruncateInt() + userTotalRate := readChargeRate.Add(taxRate) + + // assertions + streamRecordsAfter = s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRate.Neg()) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), readChargeRate) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRate) + + expectedOutFlows := []paymenttypes.OutFlow{ + {ToAddress: family.VirtualPaymentAddress, Rate: readChargeRate}, + {ToAddress: paymenttypes.ValidatorTaxPoolAddress.String(), Rate: taxRate}, + } + userOutFlowsResponse, err := s.Client.OutFlows(ctx, &paymenttypes.QueryOutFlowsRequest{Account: user.GetAddr().String()}) + s.Require().NoError(err) + sort.Slice(userOutFlowsResponse.OutFlows, func(i, j int) bool { + return userOutFlowsResponse.OutFlows[i].ToAddress < userOutFlowsResponse.OutFlows[j].ToAddress + }) + sort.Slice(expectedOutFlows, func(i, j int) bool { + return expectedOutFlows[i].ToAddress < expectedOutFlows[j].ToAddress + }) + s.Require().Equal(expectedOutFlows, userOutFlowsResponse.OutFlows) +} + +func (s *PaymentTestSuite) TestStorageBill_CreateObject_WithZeroNoneZeroPayload() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + bucketName := s.createBucket(sp, user, 0) + + // case: create object with zero payload size + streamRecordsBefore := s.getStreamRecords(streamAddresses) + _, _, objectName, _, _, payloadSize := s.createObject(user, bucketName, true) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) + gvgFamilyRate, gvgRate, taxRate, userTotalRate := s.calculateStorageRates(sp, bucketName, objectName, payloadSize, 0) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRate.Neg()) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRate) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRate) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRate) + + // case: create object with none zero payload size + streamRecordsBefore = s.getStreamRecords(streamAddresses) + _, _, objectName, _, _, payloadSize = s.createObject(user, bucketName, false) + + // assertions + streamRecordsAfter = s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) + s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) +} + +func (s *PaymentTestSuite) TestStorageBill_CreateObject_WithReserveTimeValidatorTaxRateChange() { + defer s.revertParams() + + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + bucketName := s.createBucket(sp, user, 0) + + // create object with none zero payload size + streamRecordsBefore := s.getStreamRecords(streamAddresses) + _, _, objectName, _, _, payloadSize := s.createObject(user, bucketName, false) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) + s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + + // update params + + params := s.queryParams() + oldReserveTime := params.VersionedParams.ReserveTime + oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate + + params.VersionedParams.ReserveTime = oldReserveTime * 2 + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) + s.updateParams(params) + + // create another object after parameter changes + streamRecordsBefore = s.getStreamRecords(streamAddresses) + _, _, objectName, _, _, payloadSize = s.createObject(user, bucketName, false) + + // assertions + streamRecordsAfter = s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + lockFeeAfterParameterChange := s.calculateLockFee(sp, bucketName, objectName, payloadSize) + s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFeeAfterParameterChange) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + s.Require().True(lockFeeAfterParameterChange.GT(lockFee.MulRaw(2))) +} + +func (s *PaymentTestSuite) TestStorageBill_CancelCreateObject() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + bucketName := s.createBucket(sp, user, 0) + + // create object with none zero payload size + streamRecordsBefore := s.getStreamRecords(streamAddresses) + _, _, objectName, _, _, payloadSize := s.createObject(user, bucketName, false) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) + s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + + // cancel create object + s.cancelCreateObject(user, bucketName, objectName) + + // assertions + streamRecordsAfter = s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, lockFee) + s.Require().Equal(streamRecordsAfter.User.LockBalance.Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) +} + +func (s *PaymentTestSuite) TestStorageBill_SealObject_WithoutPriceChange() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + bucketName := s.createBucket(sp, user, 0) + + // create object with none zero payload size + streamRecordsBefore := s.getStreamRecords(streamAddresses) + _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + lockFee := s.calculateLockFee(sp, bucketName, objectName, payloadSize) + s.Require().Equal(streamRecordsAfter.User.LockBalance.Sub(streamRecordsBefore.User.LockBalance), lockFee) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + + // case: seal object without price change + s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) + + // assertions + streamRecordsAfter = s.getStreamRecords(streamAddresses) + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) + gvgFamilyRate, gvgRate, taxRate, userTotalRate := s.calculateStorageRates(sp, bucketName, objectName, payloadSize, 0) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRate.Neg()) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRate) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRate) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRate) +} + +func (s *PaymentTestSuite) TestStorageBill_SealObject_WithPriceChange() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + bucketName := s.createBucket(sp, user, 102400) + + // case: seal object with read price change and storage price change + _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) + + priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: 0, + }) + s.Require().NoError(err) + // update new price + msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(2), + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(2), + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) + + streamRecordsBefore := s.getStreamRecords(streamAddresses) + gvgFamilyRateReadBefore, taxRateReadBefore, userTotalRateReadBefore := s.calculateReadRates(sp, bucketName) + + // seal object + s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + gvgFamilyRateReadAfter, taxRateReadAfter, userTotalRateReadAfter := s.calculateReadRatesCurrentTimestamp(sp, bucketName) + gvgFamilyRateStore, gvgRateStore, taxRateStore, userTotalRateStore := s.calculateStorageRatesCurrentTimestamp(sp, bucketName, objectName, payloadSize) + + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) + + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRateReadAfter.Sub(userTotalRateReadBefore).Add(userTotalRateStore).Neg()) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRateStore) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRateReadAfter.Sub(gvgFamilyRateReadBefore).Add(gvgFamilyRateStore)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRateReadAfter.Sub(taxRateReadBefore).Add(taxRateStore)) +} + +func (s *PaymentTestSuite) TestStorageBill_SealObject_WithPriceChangeValidatorTaxRateChange() { + defer s.revertParams() + + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + bucketName := s.createBucket(sp, user, 102400) + + // case: seal object with read price change and storage price change + _, _, objectName, objectId, checksums, payloadSize := s.createObject(user, bucketName, false) + + priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: 0, + }) + s.Require().NoError(err) + // update new price + msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(2), + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(2), + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) + + streamRecordsBefore := s.getStreamRecords(streamAddresses) + gvgFamilyRateReadBefore, taxRateReadBefore, userTotalRateReadBefore := s.calculateReadRates(sp, bucketName) + + // seal object + s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + gvgFamilyRateReadAfter, taxRateReadAfter, userTotalRateReadAfter := s.calculateReadRatesCurrentTimestamp(sp, bucketName) + gvgFamilyRateStore, gvgRateStore, taxRateStore, userTotalRateStore := s.calculateStorageRatesCurrentTimestamp(sp, bucketName, objectName, payloadSize) + + s.Require().Equal(streamRecordsAfter.User.StaticBalance, sdkmath.ZeroInt()) + s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) + + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRateReadAfter.Sub(userTotalRateReadBefore).Add(userTotalRateStore).Neg()) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRateStore) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRateReadAfter.Sub(gvgFamilyRateReadBefore).Add(gvgFamilyRateStore)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRateReadAfter.Sub(taxRateReadBefore).Add(taxRateStore)) + + // update params + params := s.queryParams() + oldReserveTime := params.VersionedParams.ReserveTime + oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate + + params.VersionedParams.ReserveTime = oldReserveTime * 2 + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) + s.updateParams(params) + + _, _, objectName, objectId, checksums, payloadSize = s.createObject(user, bucketName, false) + s.sealObject(sp, gvg, bucketName, objectName, objectId, checksums) + + // assertions + streamRecordsAfter = s.getStreamRecords(streamAddresses) + gvgFamilyRateReadAfter, taxRateReadAfter, userTotalRateReadAfter = s.calculateReadRatesCurrentTimestamp(sp, bucketName) + 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()) + + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate), userTotalRateReadAfter.Sub(userTotalRateReadBefore).Add(userTotalRateStore).Neg()) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate), gvgRateStore) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate), gvgFamilyRateReadAfter.Sub(gvgFamilyRateReadBefore).Add(gvgFamilyRateStore)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate), taxRateReadAfter.Sub(taxRateReadBefore).Add(taxRateStore)) + + // revert price + msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice, + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice, + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) +} + +func (s *PaymentTestSuite) TestStorageBill_RejectSealObject_WithPriceChange() { + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + + bucketName := s.createBucket(sp, user, 102400) + + // case: seal object with read price change and storage price change + _, _, objectName, _, _, _ := s.createObject(user, bucketName, false) + + priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: 0, + }) + s.Require().NoError(err) + // update new price + msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice.MulInt64(2), + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(2), + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) + + streamRecordsBefore := s.getStreamRecords(streamAddresses) + s.Require().True(streamRecordsBefore.User.LockBalance.IsPositive()) + + // reject seal object + s.rejectSealObject(sp, gvg, bucketName, objectName) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().True(streamRecordsAfter.User.StaticBalance.IsPositive()) + s.Require().Equal(streamRecordsAfter.User.LockBalance, sdkmath.ZeroInt()) + + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + + // revert price + msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice, + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice, + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) +} + +func (s *PaymentTestSuite) TestStorageBill_FullLifecycle() { + defer s.revertParams() + + var err error + ctx := context.Background() + sp := s.PickStorageProvider() + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + queryFamilyResponse, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{ + FamilyId: gvg.FamilyId, + }) + s.Require().NoError(err) + family := queryFamilyResponse.GlobalVirtualGroupFamily + user := s.GenAndChargeAccounts(1, 1000000)[0] + + // query storage price + priceRes, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ + SpAddr: sp.OperatorKey.GetAddr().String(), + Timestamp: 0, + }) + s.Require().NoError(err) + s.T().Log("price", priceRes.SpStoragePrice) + + streamAddresses := []string{ + user.GetAddr().String(), + family.VirtualPaymentAddress, + gvg.VirtualPaymentAddress, + paymenttypes.ValidatorTaxPoolAddress.String(), + } + streamRecordsBefore := s.getStreamRecords(streamAddresses) + + // full lifecycle + bucketName1 := s.createBucket(sp, user, 0) + _, _, objectName1, _, _, _ := s.createObject(user, bucketName1, true) + _, _, objectName2, objectId2, checksums2, _ := s.createObject(user, bucketName1, false) + s.sealObject(sp, gvg, bucketName1, objectName2, objectId2, checksums2) + + bucketName2 := s.createBucket(sp, user, 1024) + _, _, objectName3, objectId3, checksums3, _ := s.createObject(user, bucketName2, false) + s.sealObject(sp, gvg, bucketName2, objectName3, objectId3, checksums3) + + // update params + params := s.queryParams() + params.VersionedParams.ReserveTime = params.VersionedParams.ReserveTime * 3 + params.ForcedSettleTime = params.ForcedSettleTime * 2 + s.updateParams(params) + + _, _, objectName4, objectId4, checksums4, _ := s.createObject(user, bucketName2, false) + s.sealObject(sp, gvg, bucketName2, objectName4, objectId4, checksums4) + + bucketName3 := s.createBucket(sp, user, 1024) + _, _, objectName5, objectId5, checksums5, _ := s.createObject(user, bucketName3, false) + s.sealObject(sp, gvg, bucketName3, objectName5, objectId5, checksums5) + + // update new price + msgUpdatePrice := &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice, + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice.MulInt64(10000), + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) + + // update params + params = s.queryParams() + params.VersionedParams.ReserveTime = params.VersionedParams.ReserveTime / 2 + params.ForcedSettleTime = params.ForcedSettleTime / 3 + s.updateParams(params) + + _, _, objectName6, objectId6, checksums6, _ := s.createObject(user, bucketName3, false) + s.sealObject(sp, gvg, bucketName3, objectName6, objectId6, checksums6) + + bucketName4 := s.createBucket(sp, user, 1024) + _, _, objectName7, objectId7, checksums7, _ := s.createObject(user, bucketName4, false) + s.sealObject(sp, gvg, bucketName4, objectName7, objectId7, checksums7) + + // update params + params = s.queryParams() + params.VersionedParams.ValidatorTaxRate = params.VersionedParams.ValidatorTaxRate.MulInt64(2) + s.updateParams(params) + + _, _, objectName8, objectId8, checksums8, _ := s.createObject(user, bucketName4, false) + s.sealObject(sp, gvg, bucketName4, objectName8, objectId8, checksums8) + + time.Sleep(3 * time.Second) + + _ = s.deleteObject(user, bucketName1, objectName1) + _ = s.deleteObject(user, bucketName1, objectName2) + + // update params + params = s.queryParams() + params.VersionedParams.ValidatorTaxRate = params.VersionedParams.ValidatorTaxRate.MulInt64(3) + s.updateParams(params) + + _ = s.deleteObject(user, bucketName2, objectName3) + _ = s.deleteObject(user, bucketName2, objectName4) + err = s.deleteBucket(user, bucketName1) + s.Require().Error(err) + err = s.deleteBucket(user, bucketName2) + s.Require().Error(err) + + _ = s.deleteObject(user, bucketName3, objectName5) + _ = s.deleteObject(user, bucketName3, objectName6) + _ = s.deleteObject(user, bucketName4, objectName7) + _ = s.deleteObject(user, bucketName4, objectName8) + err = s.deleteBucket(user, bucketName3) + s.Require().Error(err) + err = s.deleteBucket(user, bucketName4) + s.Require().Error(err) + + // assertions + streamRecordsAfter := s.getStreamRecords(streamAddresses) + s.Require().True(!streamRecordsAfter.User.StaticBalance.IsZero()) + s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0)) + s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0)) + + // revert price + msgUpdatePrice = &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: sp.OperatorKey.GetAddr().String(), + ReadPrice: priceRes.SpStoragePrice.ReadPrice, + FreeReadQuota: priceRes.SpStoragePrice.FreeReadQuota, + StorePrice: priceRes.SpStoragePrice.StorePrice, + } + s.SendTxBlock(sp.OperatorKey, msgUpdatePrice) +} + // TestStorageBill_CopyObject_WithoutPriceChange func (s *PaymentTestSuite) TestStorageBill_CopyObject_WithoutPriceChange() { var err error diff --git a/x/storage/keeper/payment_test.go b/x/storage/keeper/payment_test.go index 5a9614572..a13db11d6 100644 --- a/x/storage/keeper/payment_test.go +++ b/x/storage/keeper/payment_test.go @@ -112,8 +112,6 @@ func (s *TestSuite) TestGetObjectLockFee() { s.paymentKeeper.EXPECT().GetStoragePrice(gomock.Any(), gomock.Any()). Return(price, nil).AnyTimes() params := paymenttypes.DefaultParams() - s.paymentKeeper.EXPECT().GetParams(gomock.Any()). - Return(params).AnyTimes() s.paymentKeeper.EXPECT().GetVersionedParamsWithTs(gomock.Any(), gomock.Any()). Return(params.VersionedParams, nil).AnyTimes() diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 85b43af1f..1ff74670e 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -41,15 +41,11 @@ type SpKeeper interface { } type PaymentKeeper interface { - GetParams(ctx sdk.Context) paymenttypes.Params GetVersionedParamsWithTs(ctx sdk.Context, time int64) (paymenttypes.VersionedParams, error) IsPaymentAccountOwner(ctx sdk.Context, addr, owner sdk.AccAddress) bool GetStoragePrice(ctx sdk.Context, params paymenttypes.StoragePriceParams) (price paymenttypes.StoragePrice, err error) ApplyUserFlowsList(ctx sdk.Context, userFlows []paymenttypes.UserFlows) (err error) UpdateStreamRecordByAddr(ctx sdk.Context, change *paymenttypes.StreamRecordChange) (ret *paymenttypes.StreamRecord, err error) - GetStreamRecord(ctx sdk.Context, account sdk.AccAddress) (val *paymenttypes.StreamRecord, found bool) - UpdateStreamRecord(ctx sdk.Context, streamRecord *paymenttypes.StreamRecord, change *paymenttypes.StreamRecordChange) error - Withdraw(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amount math.Int) error } type PermissionKeeper interface { diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 12d9f9a5f..e5a20df47 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -285,20 +285,6 @@ func (mr *MockPaymentKeeperMockRecorder) ApplyUserFlowsList(ctx, userFlows inter return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyUserFlowsList", reflect.TypeOf((*MockPaymentKeeper)(nil).ApplyUserFlowsList), ctx, userFlows) } -// GetParams mocks base method. -func (m *MockPaymentKeeper) GetParams(ctx types3.Context) types.Params { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types.Params) - return ret0 -} - -// GetParams indicates an expected call of GetParams. -func (mr *MockPaymentKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockPaymentKeeper)(nil).GetParams), ctx) -} - // GetStoragePrice mocks base method. func (m *MockPaymentKeeper) GetStoragePrice(ctx types3.Context, params types.StoragePriceParams) (types.StoragePrice, error) { m.ctrl.T.Helper() @@ -314,21 +300,6 @@ func (mr *MockPaymentKeeperMockRecorder) GetStoragePrice(ctx, params interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStoragePrice", reflect.TypeOf((*MockPaymentKeeper)(nil).GetStoragePrice), ctx, params) } -// GetStreamRecord mocks base method. -func (m *MockPaymentKeeper) GetStreamRecord(ctx types3.Context, account types3.AccAddress) (*types.StreamRecord, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStreamRecord", ctx, account) - ret0, _ := ret[0].(*types.StreamRecord) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// GetStreamRecord indicates an expected call of GetStreamRecord. -func (mr *MockPaymentKeeperMockRecorder) GetStreamRecord(ctx, account interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStreamRecord", reflect.TypeOf((*MockPaymentKeeper)(nil).GetStreamRecord), ctx, account) -} - // GetVersionedParamsWithTs mocks base method. func (m *MockPaymentKeeper) GetVersionedParamsWithTs(ctx types3.Context, time int64) (types.VersionedParams, error) { m.ctrl.T.Helper() @@ -358,20 +329,6 @@ func (mr *MockPaymentKeeperMockRecorder) IsPaymentAccountOwner(ctx, addr, owner return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsPaymentAccountOwner", reflect.TypeOf((*MockPaymentKeeper)(nil).IsPaymentAccountOwner), ctx, addr, owner) } -// UpdateStreamRecord mocks base method. -func (m *MockPaymentKeeper) UpdateStreamRecord(ctx types3.Context, streamRecord *types.StreamRecord, change *types.StreamRecordChange) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateStreamRecord", ctx, streamRecord, change) - ret0, _ := ret[0].(error) - return ret0 -} - -// UpdateStreamRecord indicates an expected call of UpdateStreamRecord. -func (mr *MockPaymentKeeperMockRecorder) UpdateStreamRecord(ctx, streamRecord, change interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStreamRecord", reflect.TypeOf((*MockPaymentKeeper)(nil).UpdateStreamRecord), ctx, streamRecord, change) -} - // UpdateStreamRecordByAddr mocks base method. func (m *MockPaymentKeeper) UpdateStreamRecordByAddr(ctx types3.Context, change *types.StreamRecordChange) (*types.StreamRecord, error) { m.ctrl.T.Helper() @@ -387,20 +344,6 @@ func (mr *MockPaymentKeeperMockRecorder) UpdateStreamRecordByAddr(ctx, change in return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStreamRecordByAddr", reflect.TypeOf((*MockPaymentKeeper)(nil).UpdateStreamRecordByAddr), ctx, change) } -// Withdraw mocks base method. -func (m *MockPaymentKeeper) Withdraw(ctx types3.Context, fromAddr, toAddr types3.AccAddress, amount math.Int) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Withdraw", ctx, fromAddr, toAddr, amount) - ret0, _ := ret[0].(error) - return ret0 -} - -// Withdraw indicates an expected call of Withdraw. -func (mr *MockPaymentKeeperMockRecorder) Withdraw(ctx, fromAddr, toAddr, amount interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Withdraw", reflect.TypeOf((*MockPaymentKeeper)(nil).Withdraw), ctx, fromAddr, toAddr, amount) -} - // MockPermissionKeeper is a mock of PermissionKeeper interface. type MockPermissionKeeper struct { ctrl *gomock.Controller From c24c59577c995dadb0b3beb204c42565e0930a20 Mon Sep 17 00:00:00 2001 From: dylanhuang Date: Tue, 1 Aug 2023 15:57:25 +0800 Subject: [PATCH 14/24] fix: allow edit-sp by cmd without blskey (#400) --- x/sp/client/cli/tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/sp/client/cli/tx.go b/x/sp/client/cli/tx.go index e02c951ca..7f1ebb6c3 100644 --- a/x/sp/client/cli/tx.go +++ b/x/sp/client/cli/tx.go @@ -212,7 +212,7 @@ func CmdEditStorageProvider() *cobra.Command { if err != nil { return err } - if len(blsPubKey) != 2*sdk.BLSPubKeyLength { + if len(blsPubKey) > 0 && len(blsPubKey) != 2*sdk.BLSPubKeyLength { return fmt.Errorf("invalid bls pubkey") } From 2d969187a0d03107b42ff61835acdb63f5dc770f Mon Sep 17 00:00:00 2001 From: Roshan <48975233+Pythonberg1997@users.noreply.github.com> Date: Thu, 3 Aug 2023 10:02:19 +0800 Subject: [PATCH 15/24] feat: add new query APIs (#399) * feat: add new query APIs * fix wrong error msg * fix lint issue --- .gitignore | 1 + proto/greenfield/storage/query.proto | 38 + swagger/static/swagger.yaml | 163 +++ x/storage/keeper/grpc_query.go | 512 +++++++- x/storage/keeper/grpc_query_test.go | 132 ++- x/storage/keeper/payment_test.go | 14 +- x/storage/keeper/query.go | 460 -------- x/storage/types/query.pb.go | 1633 +++++++++++++++++++++++--- x/storage/types/query.pb.gw.go | 347 ++++++ 9 files changed, 2635 insertions(+), 665 deletions(-) delete mode 100644 x/storage/keeper/query.go diff --git a/.gitignore b/.gitignore index 7a8efdf4b..e1791ccc8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ build/ vendor/ .local .task +coverage.out diff --git a/proto/greenfield/storage/query.proto b/proto/greenfield/storage/query.proto index 411f7f931..bcb7ce708 100644 --- a/proto/greenfield/storage/query.proto +++ b/proto/greenfield/storage/query.proto @@ -128,6 +128,21 @@ service Query { option (google.api.http).get = "/greenfield/storage/is_price_changed/{bucket_name}"; } + // Queries whether some members are in the group. + rpc QueryGroupMembersExist(QueryGroupMembersExistRequest) returns (QueryGroupMembersExistResponse) { + option (google.api.http).get = "/greenfield/storage/group_members_exist/{group_id}/{members}"; + } + + // Queries whether some groups are exist. + rpc QueryGroupsExist(QueryGroupsExistRequest) returns (QueryGroupsExistResponse) { + option (google.api.http).get = "/greenfield/storage/groups_exist/{group_owner}/{group_names}"; + } + + // Queries whether some groups are exist by id. + rpc QueryGroupsExistById(QueryGroupsExistByIdRequest) returns (QueryGroupsExistResponse) { + option (google.api.http).get = "/greenfield/storage/groups_exist_by_id/{group_ids}"; + } + // this line is used by starport scaffolding # 2 } @@ -356,4 +371,27 @@ message QueryIsPriceChangedResponse { (gogoproto.nullable) = false ]; } + +message QueryGroupMembersExistRequest { + string group_id = 1; + repeated string members = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message QueryGroupMembersExistResponse { + map exists = 1; +} + +message QueryGroupsExistRequest { + string group_owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated string group_names = 2; +} + +message QueryGroupsExistByIdRequest { + repeated string group_ids = 1; +} + +message QueryGroupsExistResponse { + map exists = 1; +} + // this line is used by starport scaffolding # 3 diff --git a/swagger/static/swagger.yaml b/swagger/static/swagger.yaml index 9b3a4b440..3dd0ec391 100644 --- a/swagger/static/swagger.yaml +++ b/swagger/static/swagger.yaml @@ -2198,6 +2198,155 @@ paths: type: boolean tags: - Query + /greenfield/storage/group_members_exist/{group_id}/{members}: + get: + summary: Queries whether some members are in the group. + operationId: QueryGroupMembersExist + responses: + '200': + description: A successful response. + schema: + type: object + properties: + exists: + type: object + additionalProperties: + type: boolean + 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: group_id + in: path + required: true + type: string + - name: members + in: path + required: true + type: array + items: + type: string + collectionFormat: csv + minItems: 1 + tags: + - Query + /greenfield/storage/groups_exist/{group_owner}/{group_names}: + get: + summary: Queries whether some groups are exist. + operationId: QueryGroupsExist + responses: + '200': + description: A successful response. + schema: + type: object + properties: + exists: + type: object + additionalProperties: + type: boolean + 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: group_owner + in: path + required: true + type: string + - name: group_names + in: path + required: true + type: array + items: + type: string + collectionFormat: csv + minItems: 1 + tags: + - Query + /greenfield/storage/groups_exist_by_id/{group_ids}: + get: + summary: Queries whether some groups are exist by id. + operationId: QueryGroupsExistById + responses: + '200': + description: A successful response. + schema: + type: object + properties: + exists: + type: object + additionalProperties: + type: boolean + 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: group_ids + in: path + required: true + type: array + items: + type: string + collectionFormat: csv + minItems: 1 + tags: + - Query /greenfield/storage/head_bucket/{bucket_name}: get: summary: Queries a bucket with specify name. @@ -33742,6 +33891,13 @@ definitions: value: type: string title: attributes + greenfield.storage.QueryGroupMembersExistResponse: + type: object + properties: + exists: + type: object + additionalProperties: + type: boolean greenfield.storage.QueryGroupNFTResponse: type: object properties: @@ -33770,6 +33926,13 @@ definitions: value: type: string title: attributes + greenfield.storage.QueryGroupsExistResponse: + type: object + properties: + exists: + type: object + additionalProperties: + type: boolean greenfield.storage.QueryHeadBucketExtraResponse: type: object properties: diff --git a/x/storage/keeper/grpc_query.go b/x/storage/keeper/grpc_query.go index ddcc0e4dd..f4affc3d8 100644 --- a/x/storage/keeper/grpc_query.go +++ b/x/storage/keeper/grpc_query.go @@ -3,12 +3,22 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - types2 "github.com/bnb-chain/greenfield/x/sp/types" + "github.com/bnb-chain/greenfield/internal/sequence" + gnfd "github.com/bnb-chain/greenfield/types" + "github.com/bnb-chain/greenfield/types/errors" + permtypes "github.com/bnb-chain/greenfield/x/permission/types" + sptypes "github.com/bnb-chain/greenfield/x/sp/types" "github.com/bnb-chain/greenfield/x/storage/types" + vgtypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" ) var _ types.QueryServer = Keeper{} @@ -43,6 +53,239 @@ func (k Keeper) QueryParamsByTimestamp(c context.Context, req *types.QueryParams return &types.QueryParamsByTimestampResponse{Params: params}, nil } +func (k Keeper) HeadBucket(goCtx context.Context, req *types.QueryHeadBucketRequest) (*types.QueryHeadBucketResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + bucketInfo, found := k.GetBucketInfo(ctx, req.BucketName) + if found { + return &types.QueryHeadBucketResponse{ + BucketInfo: bucketInfo, + }, nil + } + return nil, types.ErrNoSuchBucket +} + +func (k Keeper) HeadBucketById(goCtx context.Context, req *types.QueryHeadBucketByIdRequest) (*types.QueryHeadBucketResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + id, err := math.ParseUint(req.BucketId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid bucket id") + } + + bucketInfo, found := k.GetBucketInfoById(ctx, id) + if found { + return &types.QueryHeadBucketResponse{ + BucketInfo: bucketInfo, + }, nil + } + return nil, types.ErrNoSuchBucket +} + +func (k Keeper) HeadObject(goCtx context.Context, req *types.QueryHeadObjectRequest) (*types.QueryHeadObjectResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + objectInfo, objectFound := k.GetObjectInfo(ctx, req.BucketName, req.ObjectName) + if !objectFound { + return nil, types.ErrNoSuchObject + } + + bucketInfo, found := k.GetBucketInfo(ctx, req.BucketName) + if !found { + return nil, types.ErrNoSuchBucket + } + var gvg *vgtypes.GlobalVirtualGroup + if objectInfo.ObjectStatus == types.OBJECT_STATUS_SEALED { + gvgFound := false + gvg, gvgFound = k.GetObjectGVG(ctx, bucketInfo.Id, objectInfo.LocalVirtualGroupId) + if !gvgFound { + return nil, types.ErrInvalidGlobalVirtualGroup.Wrapf("gvg not found. objectInfo: %s", objectInfo.String()) + } + } + return &types.QueryHeadObjectResponse{ + ObjectInfo: objectInfo, + GlobalVirtualGroup: gvg, + }, nil +} + +func (k Keeper) HeadObjectById(goCtx context.Context, req *types.QueryHeadObjectByIdRequest) (*types.QueryHeadObjectResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + id, err := math.ParseUint(req.ObjectId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid object id") + } + + objectInfo, found := k.GetObjectInfoById(ctx, id) + if !found { + return nil, types.ErrNoSuchObject + } + + bucketInfo, found := k.GetBucketInfo(ctx, objectInfo.BucketName) + if !found { + return nil, types.ErrNoSuchBucket + } + var gvg *vgtypes.GlobalVirtualGroup + if objectInfo.ObjectStatus == types.OBJECT_STATUS_SEALED { + gvgFound := false + gvg, gvgFound = k.GetObjectGVG(ctx, bucketInfo.Id, objectInfo.LocalVirtualGroupId) + if !gvgFound { + return nil, types.ErrInvalidGlobalVirtualGroup.Wrapf("gvg not found. objectInfo: %s", objectInfo.String()) + } + } + return &types.QueryHeadObjectResponse{ + ObjectInfo: objectInfo, + GlobalVirtualGroup: gvg, + }, nil +} + +func (k Keeper) ListBuckets(goCtx context.Context, req *types.QueryListBucketsRequest) (*types.QueryListBucketsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { + return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + var bucketInfos []*types.BucketInfo + store := ctx.KVStore(k.storeKey) + bucketStore := prefix.NewStore(store, types.BucketByIDPrefix) + + pageRes, err := query.Paginate(bucketStore, req.Pagination, func(key, value []byte) error { + var bucketInfo types.BucketInfo + k.cdc.MustUnmarshal(value, &bucketInfo) + bucketInfos = append(bucketInfos, &bucketInfo) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryListBucketsResponse{BucketInfos: bucketInfos, Pagination: pageRes}, nil +} + +func (k Keeper) ListObjects(goCtx context.Context, req *types.QueryListObjectsRequest) (*types.QueryListObjectsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { + return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) + } + ctx := sdk.UnwrapSDKContext(goCtx) + + var objectInfos []*types.ObjectInfo + store := ctx.KVStore(k.storeKey) + objectPrefixStore := prefix.NewStore(store, types.GetObjectKeyOnlyBucketPrefix(req.BucketName)) + + pageRes, err := query.Paginate(objectPrefixStore, req.Pagination, func(key, value []byte) error { + objectInfo, found := k.GetObjectInfoById(ctx, k.objectSeq.DecodeSequence(value)) + if found { + objectInfos = append(objectInfos, objectInfo) + } + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return &types.QueryListObjectsResponse{ObjectInfos: objectInfos, Pagination: pageRes}, nil +} + +func (k Keeper) ListObjectsByBucketId(goCtx context.Context, req *types.QueryListObjectsByBucketIdRequest) (*types.QueryListObjectsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { + return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + var objectInfos []*types.ObjectInfo + store := ctx.KVStore(k.storeKey) + id, err := math.ParseUint(req.BucketId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid bucket id") + } + bucketInfo, found := k.GetBucketInfoById(ctx, id) + if !found { + return nil, types.ErrNoSuchBucket + } + objectPrefixStore := prefix.NewStore(store, types.GetObjectKeyOnlyBucketPrefix(bucketInfo.BucketName)) + + pageRes, err := query.Paginate(objectPrefixStore, req.Pagination, func(key, value []byte) error { + u256Seq := sequence.Sequence[math.Uint]{} + objectInfo, found := k.GetObjectInfoById(ctx, u256Seq.DecodeSequence(value)) + if found { + objectInfos = append(objectInfos, objectInfo) + } + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return &types.QueryListObjectsResponse{ObjectInfos: objectInfos, Pagination: pageRes}, nil +} + +func (k Keeper) HeadBucketNFT(goCtx context.Context, req *types.QueryNFTRequest) (*types.QueryBucketNFTResponse, error) { + id, err := validateAndGetId(req) + if err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) + bucketInfo, found := k.GetBucketInfoById(ctx, id) + if !found { + return nil, types.ErrNoSuchBucket + } + return &types.QueryBucketNFTResponse{ + MetaData: bucketInfo.ToNFTMetadata(), + }, nil +} + +func (k Keeper) HeadObjectNFT(goCtx context.Context, req *types.QueryNFTRequest) (*types.QueryObjectNFTResponse, error) { + id, err := validateAndGetId(req) + if err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) + objectInfo, found := k.GetObjectInfoById(ctx, id) + if !found { + return nil, types.ErrNoSuchObject + } + return &types.QueryObjectNFTResponse{ + MetaData: objectInfo.ToNFTMetadata(), + }, nil +} + +func (k Keeper) HeadGroupNFT(goCtx context.Context, req *types.QueryNFTRequest) (*types.QueryGroupNFTResponse, error) { + id, err := validateAndGetId(req) + if err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) + groupInfo, found := k.GetGroupInfoById(ctx, id) + if !found { + return nil, types.ErrNoSuchGroup + } + return &types.QueryGroupNFTResponse{ + MetaData: groupInfo.ToNFTMetadata(), + }, nil +} + func (k Keeper) QueryLockFee(c context.Context, req *types.QueryLockFeeRequest) (*types.QueryLockFeeResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") @@ -61,7 +304,7 @@ func (k Keeper) QueryLockFee(c context.Context, req *types.QueryLockFeeRequest) sp, found := k.spKeeper.GetStorageProviderByOperatorAddr(ctx, primaryAcc) if !found { - return nil, types2.ErrStorageProviderNotFound + return nil, sptypes.ErrStorageProviderNotFound } amount, err := k.GetObjectLockFee(ctx, sp.GetId(), createAt, req.PayloadSize) @@ -93,6 +336,7 @@ func (k Keeper) QueryIsPriceChanged(c context.Context, req *types.QueryIsPriceCh if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } + ctx := sdk.UnwrapSDKContext(c) bucketInfo, found := k.GetBucketInfo(ctx, req.BucketName) if !found { @@ -118,3 +362,267 @@ func (k Keeper) QueryIsPriceChanged(c context.Context, req *types.QueryIsPriceCh NewValidatorTaxRate: newTaxRate, }, nil } + +func validateAndGetId(req *types.QueryNFTRequest) (math.Uint, error) { + if req == nil { + return math.ZeroUint(), status.Error(codes.InvalidArgument, "invalid request") + } + id, err := math.ParseUint(req.TokenId) + if err != nil { + return math.ZeroUint(), status.Error(codes.InvalidArgument, "invalid token id") + } + return id, nil +} + +func (k Keeper) QueryPolicyForAccount(goCtx context.Context, req *types.QueryPolicyForAccountRequest) (*types. + QueryPolicyForAccountResponse, + error, +) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + principalAcc, err := sdk.AccAddressFromHexUnsafe(req.PrincipalAddress) + if err != nil { + return nil, err + } + var grn gnfd.GRN + err = grn.ParseFromString(req.Resource, false) + if err != nil { + return nil, err + } + + policy, err := k.GetPolicy(ctx, &grn, permtypes.NewPrincipalWithAccount(principalAcc)) + if err != nil { + return nil, err + } + + return &types.QueryPolicyForAccountResponse{Policy: policy}, nil +} + +func (k Keeper) QueryPolicyForGroup(goCtx context.Context, req *types.QueryPolicyForGroupRequest) (*types. + QueryPolicyForGroupResponse, error, +) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + id, err := math.ParseUint(req.PrincipalGroupId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid group id") + } + + var grn gnfd.GRN + err = grn.ParseFromString(req.Resource, false) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "failed to parse GRN %s: %v", req.Resource, err) + } + + policy, err := k.GetPolicy( + ctx, &grn, permtypes.NewPrincipalWithGroupId(id), + ) + if err != nil { + return nil, err + } + return &types.QueryPolicyForGroupResponse{Policy: policy}, nil +} + +func (k Keeper) VerifyPermission(goCtx context.Context, req *types.QueryVerifyPermissionRequest) (*types.QueryVerifyPermissionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + operator, err := sdk.AccAddressFromHexUnsafe(req.Operator) + if err != nil && err != sdk.ErrEmptyHexAddress { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid operator address (%s)", err) + } + + if req.BucketName == "" { + return nil, errorsmod.Wrapf(errors.ErrInvalidParameter, "No bucket specified") + } + + bucketInfo, found := k.GetBucketInfo(ctx, req.BucketName) + if !found { + return nil, types.ErrNoSuchBucket + } + + var effect permtypes.Effect + if req.ObjectName == "" { + effect = k.VerifyBucketPermission(ctx, bucketInfo, operator, req.ActionType, nil) + } else { + objectInfo, found := k.GetObjectInfo(ctx, req.BucketName, req.ObjectName) + if !found { + return nil, types.ErrNoSuchObject + } + effect = k.VerifyObjectPermission(ctx, bucketInfo, objectInfo, operator, req.ActionType) + } + + return &types.QueryVerifyPermissionResponse{ + Effect: effect, + }, nil +} + +func (k Keeper) HeadGroup(goCtx context.Context, req *types.QueryHeadGroupRequest) (*types.QueryHeadGroupResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) + if err != nil { + return nil, err + } + groupInfo, found := k.GetGroupInfo(ctx, owner, req.GroupName) + if !found { + return nil, types.ErrNoSuchGroup + } + return &types.QueryHeadGroupResponse{GroupInfo: groupInfo}, nil +} + +func (k Keeper) ListGroup(goCtx context.Context, req *types.QueryListGroupRequest) (*types.QueryListGroupResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { + return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) + if err != nil { + return nil, err + } + + var groupInfos []*types.GroupInfo + store := ctx.KVStore(k.storeKey) + groupStore := prefix.NewStore(store, types.GetGroupKeyOnlyOwnerPrefix(owner)) + + pageRes, err := query.Paginate(groupStore, req.Pagination, func(key, value []byte) error { + groupInfo, found := k.GetGroupInfoById(ctx, k.groupSeq.DecodeSequence(value)) + if found { + groupInfos = append(groupInfos, groupInfo) + } + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryListGroupResponse{GroupInfos: groupInfos, Pagination: pageRes}, nil +} + +func (k Keeper) HeadGroupMember(goCtx context.Context, req *types.QueryHeadGroupMemberRequest) (*types.QueryHeadGroupMemberResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + member, err := sdk.AccAddressFromHexUnsafe(req.Member) + if err != nil { + return nil, err + } + owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) + if err != nil { + return nil, err + } + groupInfo, found := k.GetGroupInfo(ctx, owner, req.GroupName) + if !found { + return nil, types.ErrNoSuchGroup + } + groupMember, found := k.permKeeper.GetGroupMember(ctx, groupInfo.Id, member) + if !found { + return nil, types.ErrNoSuchGroupMember + } + return &types.QueryHeadGroupMemberResponse{GroupMember: groupMember}, nil +} + +func (k Keeper) QueryPolicyById(goCtx context.Context, req *types.QueryPolicyByIdRequest) (*types. + QueryPolicyByIdResponse, error, +) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + policyId, err := math.ParseUint(req.PolicyId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid policy id") + } + + policy, found := k.permKeeper.GetPolicyByID(ctx, policyId) + if !found { + return nil, types.ErrNoSuchPolicy + } + return &types.QueryPolicyByIdResponse{Policy: policy}, nil +} + +func (k Keeper) QueryGroupMembersExist(goCtx context.Context, req *types.QueryGroupMembersExistRequest) (*types.QueryGroupMembersExistResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + id, err := math.ParseUint(req.GroupId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid group id") + } + + exists := make(map[string]bool) + for _, member := range req.Members { + addr, err := sdk.AccAddressFromHexUnsafe(member) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid member address") + } + _, found := k.permKeeper.GetGroupMember(ctx, id, addr) + exists[member] = found + } + return &types.QueryGroupMembersExistResponse{Exists: exists}, nil +} + +func (k Keeper) QueryGroupsExist(goCtx context.Context, req *types.QueryGroupsExistRequest) (*types.QueryGroupsExistResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid owner address") + } + + exists := make(map[string]bool) + for _, groupName := range req.GroupNames { + _, found := k.GetGroupInfo(ctx, owner, groupName) + exists[groupName] = found + } + return &types.QueryGroupsExistResponse{Exists: exists}, nil +} + +func (k Keeper) QueryGroupsExistById(goCtx context.Context, req *types.QueryGroupsExistByIdRequest) (*types.QueryGroupsExistResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + exists := make(map[string]bool) + for _, groupId := range req.GroupIds { + id, err := math.ParseUint(groupId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid group id") + } + _, found := k.GetGroupInfoById(ctx, id) + exists[groupId] = found + } + return &types.QueryGroupsExistResponse{Exists: exists}, nil +} diff --git a/x/storage/keeper/grpc_query_test.go b/x/storage/keeper/grpc_query_test.go index 05c911219..79b99b8d2 100644 --- a/x/storage/keeper/grpc_query_test.go +++ b/x/storage/keeper/grpc_query_test.go @@ -1,6 +1,9 @@ package keeper_test import ( + "context" + "math/rand" + "strconv" "testing" "time" @@ -12,6 +15,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/mint" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "github.com/bnb-chain/greenfield/testutil/sample" @@ -42,50 +46,118 @@ func makeKeeper(t *testing.T) (*keeper.Keeper, sdk.Context) { return k, testCtx.Ctx } -func TestParamsQuery(t *testing.T) { - k, ctx := makeKeeper(t) - params := types.DefaultParams() - err := k.SetParams(ctx, params) - require.NoError(t, err) - - response, err := k.Params(ctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +func (s *TestSuite) TestQueryParams() { + res, err := s.queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + s.Require().NoError(err) + s.Require().Equal(s.storageKeeper.GetParams(s.ctx), res.GetParams()) } -func TestVersionedParamsQuery(t *testing.T) { - k, ctx := makeKeeper(t) +func (s *TestSuite) TestQueryVersionedParams() { params := types.DefaultParams() params.VersionedParams.MaxSegmentSize = 1 - blockTimeT1 := ctx.BlockTime().Unix() + blockTimeT1 := s.ctx.BlockTime().Unix() paramsT1 := params - err := k.SetParams(ctx, params) - require.NoError(t, err) + err := s.storageKeeper.SetParams(s.ctx, params) + s.Require().NoError(err) - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(1 * time.Hour)) - blockTimeT2 := ctx.BlockTime().Unix() + s.ctx = s.ctx.WithBlockTime(s.ctx.BlockTime().Add(1 * time.Hour)) + blockTimeT2 := s.ctx.BlockTime().Unix() params.VersionedParams.MaxSegmentSize = 2 paramsT2 := params - err = k.SetParams(ctx, params) - require.NoError(t, err) + err = s.storageKeeper.SetParams(s.ctx, params) + s.Require().NoError(err) - responseT1, err := k.QueryParamsByTimestamp(ctx, &types.QueryParamsByTimestampRequest{Timestamp: blockTimeT1}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsByTimestampResponse{Params: paramsT1}, responseT1) + responseT1, err := s.storageKeeper.QueryParamsByTimestamp(s.ctx, &types.QueryParamsByTimestampRequest{Timestamp: blockTimeT1}) + s.Require().NoError(err) + s.Require().Equal(&types.QueryParamsByTimestampResponse{Params: paramsT1}, responseT1) getParams := responseT1.GetParams() - require.EqualValues(t, getParams.GetMaxSegmentSize(), 1) + s.Require().Equal(getParams.GetMaxSegmentSize(), uint64(1)) - responseT2, err := k.QueryParamsByTimestamp(ctx, &types.QueryParamsByTimestampRequest{Timestamp: blockTimeT2}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsByTimestampResponse{Params: paramsT2}, responseT2) + responseT2, err := s.storageKeeper.QueryParamsByTimestamp(s.ctx, &types.QueryParamsByTimestampRequest{Timestamp: blockTimeT2}) + s.Require().NoError(err) + s.Require().Equal(&types.QueryParamsByTimestampResponse{Params: paramsT2}, responseT2) p := responseT2.GetParams() - require.EqualValues(t, p.GetMaxSegmentSize(), 2) + s.Require().Equal(p.GetMaxSegmentSize(), uint64(2)) - responseT3, err := k.QueryParamsByTimestamp(ctx, &types.QueryParamsByTimestampRequest{Timestamp: 0}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsByTimestampResponse{Params: paramsT2}, responseT3) + responseT3, err := s.storageKeeper.QueryParamsByTimestamp(s.ctx, &types.QueryParamsByTimestampRequest{Timestamp: 0}) + s.Require().NoError(err) + s.Require().Equal(&types.QueryParamsByTimestampResponse{Params: paramsT2}, responseT3) p = responseT2.GetParams() - require.EqualValues(t, p.GetMaxSegmentSize(), 2) + s.Require().Equal(p.GetMaxSegmentSize(), uint64(2)) +} + +func (s *TestSuite) TestQueryGroupMembersExist() { + groupId := rand.Intn(1000) + members := make([]string, 3) + exists := make(map[string]bool) + for i := 0; i < 3; i++ { + members[i] = sample.RandAccAddressHex() + exist := rand.Intn(2) + if exist == 0 { + exists[members[i]] = false + s.permissionKeeper.EXPECT().GetGroupMember(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, false).Times(1) + } else { + exists[members[i]] = true + s.permissionKeeper.EXPECT().GetGroupMember(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, true).Times(1) + } + } + + req := &types.QueryGroupMembersExistRequest{ + GroupId: strconv.Itoa(groupId), + Members: members, + } + res, err := s.queryClient.QueryGroupMembersExist(context.Background(), req) + s.Require().NoError(err) + s.Require().Equal(exists, res.GetExists()) +} + +func (s *TestSuite) TestQueryGroupsExist() { + groupOwner := sample.RandAccAddress() + groupNames := make([]string, 3) + exists := make(map[string]bool) + for i := 0; i < 3; i++ { + groupNames[i] = string(sample.RandStr(10)) + exist := rand.Intn(2) + if exist == 0 { + exists[groupNames[i]] = false + } else { + exists[groupNames[i]] = true + _, err := s.storageKeeper.CreateGroup(s.ctx, groupOwner, groupNames[i], types.CreateGroupOptions{}) + s.Require().NoError(err) + } + } + + req := &types.QueryGroupsExistRequest{ + GroupOwner: groupOwner.String(), + GroupNames: groupNames, + } + res, err := s.queryClient.QueryGroupsExist(context.Background(), req) + s.Require().NoError(err) + s.Require().Equal(exists, res.GetExists()) +} + +func (s *TestSuite) TestQueryGroupsExistById() { + groupIds := make([]string, 3) + exists := make(map[string]bool) + for i := 0; i < 3; i++ { + groupIds[i] = strconv.Itoa(rand.Intn(1000) + 10) // make sure there's no conflict + exist := rand.Intn(2) + if exist == 0 { + exists[groupIds[i]] = false + } else { + id, err := s.storageKeeper.CreateGroup(s.ctx, sample.RandAccAddress(), string(sample.RandStr(10)), types.CreateGroupOptions{}) + s.Require().NoError(err) + groupIds[i] = id.String() + exists[groupIds[i]] = true + } + } + + req := &types.QueryGroupsExistByIdRequest{ + GroupIds: groupIds, + } + res, err := s.queryClient.QueryGroupsExistById(context.Background(), req) + s.Require().NoError(err) + s.Require().Equal(exists, res.GetExists()) } func TestHeadBucket(t *testing.T) { diff --git a/x/storage/keeper/payment_test.go b/x/storage/keeper/payment_test.go index a13db11d6..b58c2a8f7 100644 --- a/x/storage/keeper/payment_test.go +++ b/x/storage/keeper/payment_test.go @@ -33,7 +33,7 @@ type TestSuite struct { accountKeeper *types.MockAccountKeeper spKeeper *types.MockSpKeeper permissionKeeper *types.MockPermissionKeeper - crosschainKeeper *types.MockCrossChainKeeper + crossChainKeeper *types.MockCrossChainKeeper paymentKeeper *types.MockPaymentKeeper virtualGroupKeeper *types.MockVirtualGroupKeeper @@ -60,7 +60,7 @@ func (s *TestSuite) SetupTest() { accountKeeper := types.NewMockAccountKeeper(ctrl) spKeeper := types.NewMockSpKeeper(ctrl) permissionKeeper := types.NewMockPermissionKeeper(ctrl) - crosschainKeeper := types.NewMockCrossChainKeeper(ctrl) + crossChainKeeper := types.NewMockCrossChainKeeper(ctrl) paymentKeeper := types.NewMockPaymentKeeper(ctrl) virtualGroupKeeper := types.NewMockVirtualGroupKeeper(ctrl) @@ -72,7 +72,7 @@ func (s *TestSuite) SetupTest() { spKeeper, paymentKeeper, permissionKeeper, - crosschainKeeper, + crossChainKeeper, virtualGroupKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -81,7 +81,7 @@ func (s *TestSuite) SetupTest() { s.accountKeeper = accountKeeper s.spKeeper = spKeeper s.permissionKeeper = permissionKeeper - s.crosschainKeeper = crosschainKeeper + s.crossChainKeeper = crossChainKeeper s.paymentKeeper = paymentKeeper s.virtualGroupKeeper = virtualGroupKeeper @@ -138,7 +138,8 @@ func (s *TestSuite) TestGetBucketReadBill() { Status: sptypes.STATUS_IN_SERVICE, Id: 100, OperatorAddress: sample.RandAccAddress().String(), - FundingAddress: sample.RandAccAddress().String()} + FundingAddress: sample.RandAccAddress().String(), + } s.spKeeper.EXPECT().GetStorageProvider(gomock.Any(), gomock.Eq(primarySp.Id)). Return(primarySp, true).AnyTimes() @@ -199,7 +200,8 @@ func (s *TestSuite) TestGetBucketReadStoreBill() { Status: sptypes.STATUS_IN_SERVICE, Id: 100, OperatorAddress: sample.RandAccAddress().String(), - FundingAddress: sample.RandAccAddress().String()} + FundingAddress: sample.RandAccAddress().String(), + } s.spKeeper.EXPECT().GetStorageProvider(gomock.Any(), gomock.Eq(primarySp.Id)). Return(primarySp, true).AnyTimes() diff --git a/x/storage/keeper/query.go b/x/storage/keeper/query.go deleted file mode 100644 index 185b60908..000000000 --- a/x/storage/keeper/query.go +++ /dev/null @@ -1,460 +0,0 @@ -package keeper - -import ( - "context" - - "cosmossdk.io/errors" - "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/query" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/bnb-chain/greenfield/internal/sequence" - gnfd "github.com/bnb-chain/greenfield/types" - errors2 "github.com/bnb-chain/greenfield/types/errors" - permtypes "github.com/bnb-chain/greenfield/x/permission/types" - "github.com/bnb-chain/greenfield/x/storage/types" - types2 "github.com/bnb-chain/greenfield/x/virtualgroup/types" -) - -func (k Keeper) HeadBucket(goCtx context.Context, req *types.QueryHeadBucketRequest) (*types.QueryHeadBucketResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - bucketInfo, found := k.GetBucketInfo(ctx, req.BucketName) - if found { - return &types.QueryHeadBucketResponse{ - BucketInfo: bucketInfo, - }, nil - - } - return nil, types.ErrNoSuchBucket -} - -func (k Keeper) HeadBucketById(goCtx context.Context, req *types.QueryHeadBucketByIdRequest) (*types.QueryHeadBucketResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - id, err := math.ParseUint(req.BucketId) - if err != nil { - return nil, status.Error(codes.InvalidArgument, "invalid bucket id") - } - - bucketInfo, found := k.GetBucketInfoById(ctx, id) - if found { - return &types.QueryHeadBucketResponse{ - BucketInfo: bucketInfo, - }, nil - - } - return nil, types.ErrNoSuchBucket -} - -func (k Keeper) HeadObject(goCtx context.Context, req *types.QueryHeadObjectRequest) (*types.QueryHeadObjectResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - objectInfo, objectFound := k.GetObjectInfo(ctx, req.BucketName, req.ObjectName) - if !objectFound { - return nil, types.ErrNoSuchObject - } - - bucketInfo, found := k.GetBucketInfo(ctx, req.BucketName) - if !found { - return nil, types.ErrNoSuchBucket - } - var gvg *types2.GlobalVirtualGroup - if objectInfo.ObjectStatus == types.OBJECT_STATUS_SEALED { - gvgFound := false - gvg, gvgFound = k.GetObjectGVG(ctx, bucketInfo.Id, objectInfo.LocalVirtualGroupId) - if !gvgFound { - return nil, types.ErrInvalidGlobalVirtualGroup.Wrapf("gvg not found. objectInfo: %s", objectInfo.String()) - } - } - return &types.QueryHeadObjectResponse{ - ObjectInfo: objectInfo, - GlobalVirtualGroup: gvg, - }, nil -} - -func (k Keeper) HeadObjectById(goCtx context.Context, req *types.QueryHeadObjectByIdRequest) (*types.QueryHeadObjectResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - id, err := math.ParseUint(req.ObjectId) - if err != nil { - return nil, status.Error(codes.InvalidArgument, "invalid object id") - } - - objectInfo, found := k.GetObjectInfoById(ctx, id) - if !found { - return nil, types.ErrNoSuchObject - } - - bucketInfo, found := k.GetBucketInfo(ctx, objectInfo.BucketName) - if !found { - return nil, types.ErrNoSuchBucket - } - var gvg *types2.GlobalVirtualGroup - if objectInfo.ObjectStatus == types.OBJECT_STATUS_SEALED { - gvgFound := false - gvg, gvgFound = k.GetObjectGVG(ctx, bucketInfo.Id, objectInfo.LocalVirtualGroupId) - if !gvgFound { - return nil, types.ErrInvalidGlobalVirtualGroup.Wrapf("gvg not found. objectInfo: %s", objectInfo.String()) - } - } - return &types.QueryHeadObjectResponse{ - ObjectInfo: objectInfo, - GlobalVirtualGroup: gvg, - }, nil - -} - -func (k Keeper) ListBuckets(goCtx context.Context, req *types.QueryListBucketsRequest) (*types.QueryListBucketsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { - return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - var bucketInfos []*types.BucketInfo - store := ctx.KVStore(k.storeKey) - bucketStore := prefix.NewStore(store, types.BucketByIDPrefix) - - pageRes, err := query.Paginate(bucketStore, req.Pagination, func(key []byte, value []byte) error { - var bucketInfo types.BucketInfo - k.cdc.MustUnmarshal(value, &bucketInfo) - bucketInfos = append(bucketInfos, &bucketInfo) - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryListBucketsResponse{BucketInfos: bucketInfos, Pagination: pageRes}, nil -} - -func (k Keeper) ListObjects(goCtx context.Context, req *types.QueryListObjectsRequest) (*types.QueryListObjectsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { - return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) - } - ctx := sdk.UnwrapSDKContext(goCtx) - - var objectInfos []*types.ObjectInfo - store := ctx.KVStore(k.storeKey) - objectPrefixStore := prefix.NewStore(store, types.GetObjectKeyOnlyBucketPrefix(req.BucketName)) - - pageRes, err := query.Paginate(objectPrefixStore, req.Pagination, func(key []byte, value []byte) error { - objectInfo, found := k.GetObjectInfoById(ctx, k.objectSeq.DecodeSequence(value)) - if found { - objectInfos = append(objectInfos, objectInfo) - } - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - return &types.QueryListObjectsResponse{ObjectInfos: objectInfos, Pagination: pageRes}, nil -} - -func (k Keeper) ListObjectsByBucketId(goCtx context.Context, req *types.QueryListObjectsByBucketIdRequest) (*types.QueryListObjectsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { - return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - var objectInfos []*types.ObjectInfo - store := ctx.KVStore(k.storeKey) - id, err := math.ParseUint(req.BucketId) - if err != nil { - return nil, status.Error(codes.InvalidArgument, "invalid bucket id") - } - bucketInfo, found := k.GetBucketInfoById(ctx, id) - if !found { - return nil, types.ErrNoSuchBucket - } - objectPrefixStore := prefix.NewStore(store, types.GetObjectKeyOnlyBucketPrefix(bucketInfo.BucketName)) - - pageRes, err := query.Paginate(objectPrefixStore, req.Pagination, func(key []byte, value []byte) error { - u256Seq := sequence.Sequence[math.Uint]{} - objectInfo, found := k.GetObjectInfoById(ctx, u256Seq.DecodeSequence(value)) - if found { - objectInfos = append(objectInfos, objectInfo) - } - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - return &types.QueryListObjectsResponse{ObjectInfos: objectInfos, Pagination: pageRes}, nil -} - -func (k Keeper) HeadBucketNFT(goCtx context.Context, req *types.QueryNFTRequest) (*types.QueryBucketNFTResponse, error) { - id, err := validateAndGetId(req) - if err != nil { - return nil, err - } - ctx := sdk.UnwrapSDKContext(goCtx) - bucketInfo, found := k.GetBucketInfoById(ctx, id) - if !found { - return nil, types.ErrNoSuchBucket - } - return &types.QueryBucketNFTResponse{ - MetaData: bucketInfo.ToNFTMetadata(), - }, nil -} - -func (k Keeper) HeadObjectNFT(goCtx context.Context, req *types.QueryNFTRequest) (*types.QueryObjectNFTResponse, error) { - id, err := validateAndGetId(req) - if err != nil { - return nil, err - } - ctx := sdk.UnwrapSDKContext(goCtx) - objectInfo, found := k.GetObjectInfoById(ctx, id) - if !found { - return nil, types.ErrNoSuchObject - } - return &types.QueryObjectNFTResponse{ - MetaData: objectInfo.ToNFTMetadata(), - }, nil -} - -func (k Keeper) HeadGroupNFT(goCtx context.Context, req *types.QueryNFTRequest) (*types.QueryGroupNFTResponse, error) { - id, err := validateAndGetId(req) - if err != nil { - return nil, err - } - ctx := sdk.UnwrapSDKContext(goCtx) - groupInfo, found := k.GetGroupInfoById(ctx, id) - if !found { - return nil, types.ErrNoSuchGroup - } - return &types.QueryGroupNFTResponse{ - MetaData: groupInfo.ToNFTMetadata(), - }, nil -} - -func validateAndGetId(req *types.QueryNFTRequest) (math.Uint, error) { - if req == nil { - return math.ZeroUint(), status.Error(codes.InvalidArgument, "invalid request") - } - id, err := math.ParseUint(req.TokenId) - if err != nil { - return math.ZeroUint(), status.Error(codes.InvalidArgument, "invalid token id") - } - return id, nil -} - -func (k Keeper) QueryPolicyForAccount(goCtx context.Context, req *types.QueryPolicyForAccountRequest) (*types. - QueryPolicyForAccountResponse, - error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - principalAcc, err := sdk.AccAddressFromHexUnsafe(req.PrincipalAddress) - if err != nil { - return nil, err - } - var grn gnfd.GRN - err = grn.ParseFromString(req.Resource, false) - if err != nil { - return nil, err - } - - policy, err := k.GetPolicy(ctx, &grn, permtypes.NewPrincipalWithAccount(principalAcc)) - if err != nil { - return nil, err - } - - return &types.QueryPolicyForAccountResponse{Policy: policy}, nil -} - -func (k Keeper) QueryPolicyForGroup(goCtx context.Context, req *types.QueryPolicyForGroupRequest) (*types. - QueryPolicyForGroupResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - id, err := math.ParseUint(req.PrincipalGroupId) - if err != nil { - return nil, status.Error(codes.InvalidArgument, "invalid group id") - } - - var grn gnfd.GRN - err = grn.ParseFromString(req.Resource, false) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "failed to parse GRN %s: %v", req.Resource, err) - } - - policy, err := k.GetPolicy( - ctx, &grn, permtypes.NewPrincipalWithGroupId(id), - ) - if err != nil { - return nil, err - } - return &types.QueryPolicyForGroupResponse{Policy: policy}, nil -} - -func (k Keeper) VerifyPermission(goCtx context.Context, req *types.QueryVerifyPermissionRequest) (*types.QueryVerifyPermissionResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - operator, err := sdk.AccAddressFromHexUnsafe(req.Operator) - if err != nil && err != sdk.ErrEmptyHexAddress { - return nil, errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid operator address (%s)", err) - } - - if req.BucketName == "" { - return nil, errors.Wrapf(errors2.ErrInvalidParameter, "No bucket specified") - } - - bucketInfo, found := k.GetBucketInfo(ctx, req.BucketName) - if !found { - return nil, types.ErrNoSuchBucket - } - - var effect permtypes.Effect - if req.ObjectName == "" { - effect = k.VerifyBucketPermission(ctx, bucketInfo, operator, req.ActionType, nil) - } else { - objectInfo, found := k.GetObjectInfo(ctx, req.BucketName, req.ObjectName) - if !found { - return nil, types.ErrNoSuchObject - } - effect = k.VerifyObjectPermission(ctx, bucketInfo, objectInfo, operator, req.ActionType) - } - - return &types.QueryVerifyPermissionResponse{ - Effect: effect, - }, nil -} - -func (k Keeper) HeadGroup(goCtx context.Context, req *types.QueryHeadGroupRequest) (*types.QueryHeadGroupResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) - if err != nil { - return nil, err - } - groupInfo, found := k.GetGroupInfo(ctx, owner, req.GroupName) - if !found { - return nil, types.ErrNoSuchGroup - } - return &types.QueryHeadGroupResponse{GroupInfo: groupInfo}, nil -} - -func (k Keeper) ListGroup(goCtx context.Context, req *types.QueryListGroupRequest) (*types.QueryListGroupResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { - return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) - if err != nil { - return nil, err - } - - var groupInfos []*types.GroupInfo - store := ctx.KVStore(k.storeKey) - groupStore := prefix.NewStore(store, types.GetGroupKeyOnlyOwnerPrefix(owner)) - - pageRes, err := query.Paginate(groupStore, req.Pagination, func(key []byte, value []byte) error { - groupInfo, found := k.GetGroupInfoById(ctx, k.groupSeq.DecodeSequence(value)) - if found { - groupInfos = append(groupInfos, groupInfo) - } - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryListGroupResponse{GroupInfos: groupInfos, Pagination: pageRes}, nil -} - -func (k Keeper) HeadGroupMember(goCtx context.Context, req *types.QueryHeadGroupMemberRequest) (*types.QueryHeadGroupMemberResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - member, err := sdk.AccAddressFromHexUnsafe(req.Member) - if err != nil { - return nil, err - } - owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) - if err != nil { - return nil, err - } - groupInfo, found := k.GetGroupInfo(ctx, owner, req.GroupName) - if !found { - return nil, types.ErrNoSuchGroup - } - groupMember, found := k.permKeeper.GetGroupMember(ctx, groupInfo.Id, member) - if !found { - return nil, types.ErrNoSuchGroupMember - } - return &types.QueryHeadGroupMemberResponse{GroupMember: groupMember}, nil -} - -func (k Keeper) QueryPolicyById(goCtx context.Context, req *types.QueryPolicyByIdRequest) (*types. - QueryPolicyByIdResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - policyId, err := math.ParseUint(req.PolicyId) - if err != nil { - return nil, status.Error(codes.InvalidArgument, "invalid policy id") - } - policy, found := k.permKeeper.GetPolicyByID(ctx, policyId) - if !found { - return nil, types.ErrNoSuchPolicy - } - return &types.QueryPolicyByIdResponse{Policy: policy}, nil -} diff --git a/x/storage/types/query.pb.go b/x/storage/types/query.pb.go index 8a84a7bcb..1c5f26ca7 100644 --- a/x/storage/types/query.pb.go +++ b/x/storage/types/query.pb.go @@ -1897,6 +1897,242 @@ func (m *QueryIsPriceChangedResponse) GetChanged() bool { return false } +type QueryGroupMembersExistRequest struct { + GroupId string `protobuf:"bytes,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + Members []string `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` +} + +func (m *QueryGroupMembersExistRequest) Reset() { *m = QueryGroupMembersExistRequest{} } +func (m *QueryGroupMembersExistRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupMembersExistRequest) ProtoMessage() {} +func (*QueryGroupMembersExistRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{39} +} +func (m *QueryGroupMembersExistRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupMembersExistRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupMembersExistRequest.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 *QueryGroupMembersExistRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupMembersExistRequest.Merge(m, src) +} +func (m *QueryGroupMembersExistRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupMembersExistRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupMembersExistRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupMembersExistRequest proto.InternalMessageInfo + +func (m *QueryGroupMembersExistRequest) GetGroupId() string { + if m != nil { + return m.GroupId + } + return "" +} + +func (m *QueryGroupMembersExistRequest) GetMembers() []string { + if m != nil { + return m.Members + } + return nil +} + +type QueryGroupMembersExistResponse struct { + Exists map[string]bool `protobuf:"bytes,1,rep,name=exists,proto3" json:"exists,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` +} + +func (m *QueryGroupMembersExistResponse) Reset() { *m = QueryGroupMembersExistResponse{} } +func (m *QueryGroupMembersExistResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupMembersExistResponse) ProtoMessage() {} +func (*QueryGroupMembersExistResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{40} +} +func (m *QueryGroupMembersExistResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupMembersExistResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupMembersExistResponse.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 *QueryGroupMembersExistResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupMembersExistResponse.Merge(m, src) +} +func (m *QueryGroupMembersExistResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupMembersExistResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupMembersExistResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupMembersExistResponse proto.InternalMessageInfo + +func (m *QueryGroupMembersExistResponse) GetExists() map[string]bool { + if m != nil { + return m.Exists + } + return nil +} + +type QueryGroupsExistRequest struct { + GroupOwner string `protobuf:"bytes,1,opt,name=group_owner,json=groupOwner,proto3" json:"group_owner,omitempty"` + GroupNames []string `protobuf:"bytes,2,rep,name=group_names,json=groupNames,proto3" json:"group_names,omitempty"` +} + +func (m *QueryGroupsExistRequest) Reset() { *m = QueryGroupsExistRequest{} } +func (m *QueryGroupsExistRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupsExistRequest) ProtoMessage() {} +func (*QueryGroupsExistRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{41} +} +func (m *QueryGroupsExistRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupsExistRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupsExistRequest.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 *QueryGroupsExistRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupsExistRequest.Merge(m, src) +} +func (m *QueryGroupsExistRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupsExistRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupsExistRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupsExistRequest proto.InternalMessageInfo + +func (m *QueryGroupsExistRequest) GetGroupOwner() string { + if m != nil { + return m.GroupOwner + } + return "" +} + +func (m *QueryGroupsExistRequest) GetGroupNames() []string { + if m != nil { + return m.GroupNames + } + return nil +} + +type QueryGroupsExistByIdRequest struct { + GroupIds []string `protobuf:"bytes,1,rep,name=group_ids,json=groupIds,proto3" json:"group_ids,omitempty"` +} + +func (m *QueryGroupsExistByIdRequest) Reset() { *m = QueryGroupsExistByIdRequest{} } +func (m *QueryGroupsExistByIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupsExistByIdRequest) ProtoMessage() {} +func (*QueryGroupsExistByIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{42} +} +func (m *QueryGroupsExistByIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupsExistByIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupsExistByIdRequest.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 *QueryGroupsExistByIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupsExistByIdRequest.Merge(m, src) +} +func (m *QueryGroupsExistByIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupsExistByIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupsExistByIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupsExistByIdRequest proto.InternalMessageInfo + +func (m *QueryGroupsExistByIdRequest) GetGroupIds() []string { + if m != nil { + return m.GroupIds + } + return nil +} + +type QueryGroupsExistResponse struct { + Exists map[string]bool `protobuf:"bytes,1,rep,name=exists,proto3" json:"exists,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` +} + +func (m *QueryGroupsExistResponse) Reset() { *m = QueryGroupsExistResponse{} } +func (m *QueryGroupsExistResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupsExistResponse) ProtoMessage() {} +func (*QueryGroupsExistResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{43} +} +func (m *QueryGroupsExistResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupsExistResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupsExistResponse.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 *QueryGroupsExistResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupsExistResponse.Merge(m, src) +} +func (m *QueryGroupsExistResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupsExistResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupsExistResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupsExistResponse proto.InternalMessageInfo + +func (m *QueryGroupsExistResponse) GetExists() map[string]bool { + if m != nil { + return m.Exists + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "greenfield.storage.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "greenfield.storage.QueryParamsResponse") @@ -1937,156 +2173,178 @@ func init() { proto.RegisterType((*QueryHeadBucketExtraResponse)(nil), "greenfield.storage.QueryHeadBucketExtraResponse") proto.RegisterType((*QueryIsPriceChangedRequest)(nil), "greenfield.storage.QueryIsPriceChangedRequest") proto.RegisterType((*QueryIsPriceChangedResponse)(nil), "greenfield.storage.QueryIsPriceChangedResponse") + proto.RegisterType((*QueryGroupMembersExistRequest)(nil), "greenfield.storage.QueryGroupMembersExistRequest") + proto.RegisterType((*QueryGroupMembersExistResponse)(nil), "greenfield.storage.QueryGroupMembersExistResponse") + proto.RegisterMapType((map[string]bool)(nil), "greenfield.storage.QueryGroupMembersExistResponse.ExistsEntry") + proto.RegisterType((*QueryGroupsExistRequest)(nil), "greenfield.storage.QueryGroupsExistRequest") + proto.RegisterType((*QueryGroupsExistByIdRequest)(nil), "greenfield.storage.QueryGroupsExistByIdRequest") + proto.RegisterType((*QueryGroupsExistResponse)(nil), "greenfield.storage.QueryGroupsExistResponse") + proto.RegisterMapType((map[string]bool)(nil), "greenfield.storage.QueryGroupsExistResponse.ExistsEntry") } func init() { proto.RegisterFile("greenfield/storage/query.proto", fileDescriptor_b1b80b580af04cb0) } var fileDescriptor_b1b80b580af04cb0 = []byte{ - // 2290 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 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8, 0xfe, 0xfc, 0x40, 0x42, 0x33, 0x11, 0x77, 0x35, 0x04, 0x67, - 0x9a, 0x7c, 0x1b, 0x82, 0x33, 0x43, 0x85, 0xc9, 0x37, 0x19, 0xce, 0x2a, 0xbe, 0x36, 0x70, 0x17, - 0xe6, 0xe0, 0xc4, 0xbf, 0x95, 0xd0, 0xa9, 0x14, 0x0f, 0x84, 0x95, 0xe2, 0xec, 0x24, 0xc8, 0xad, - 0xf2, 0xf5, 0xd1, 0x15, 0x00, 0xec, 0x12, 0x03, 0x7b, 0x05, 0x7f, 0xb5, 0x60, 0x3b, 0x02, 0x17, - 0xf6, 0x8f, 0x90, 0x03, 0x49, 0x72, 0x3c, 0x43, 0xce, 0xd8, 0x5c, 0xd2, 0xa9, 0xac, 0x8c, 0x2c, - 0x0f, 0x38, 0xef, 0x31, 0x9c, 0x5b, 0xf8, 0x6e, 0xc1, 0x06, 0x84, 0xd4, 0xe6, 0x6e, 0xbf, 0x90, - 0xc0, 0xea, 0x07, 0x47, 0xc9, 0xa9, 0x14, 0x3b, 0x34, 0xe4, 0x5e, 0x93, 0x61, 0x9e, 0x86, 0x5c, - 0x11, 0xb2, 0x74, 0xd3, 0xf0, 0x7e, 0x00, 0xe8, 0x70, 0x3b, 0x88, 0xe8, 0xac, 0x3e, 0xfe, 0x91, - 0x84, 0x66, 0x45, 0x3a, 0x07, 0x0f, 0xfe, 0xd4, 0x48, 0xf2, 0x51, 0xe5, 0xc5, 0x62, 0x41, 0x40, - 0xf6, 0x15, 0x86, 0xac, 0x82, 0xcf, 0xe7, 0x76, 0xaa, 0xad, 0xef, 0x6b, 0x0d, 0x4a, 0xf1, 0x5f, - 0xa0, 0x33, 0x05, 0x96, 0xa6, 0xa0, 0x33, 0xb3, 0x7c, 0x50, 0x41, 0x67, 0xe6, 0x10, 0x40, 0xf2, - 0x2d, 0x06, 0x6e, 0x15, 0xdf, 0x28, 0xba, 0xae, 0x32, 0xb2, 0x27, 0x75, 0x10, 0xff, 0x35, 0xec, - 0xd3, 0x24, 0x6f, 0x33, 0xa4, 0x4f, 0x73, 0x09, 0xa2, 0x21, 0x7d, 0x9a, 0x4f, 0x08, 0xc9, 0xdf, - 0x60, 0xa8, 0x6f, 0xe2, 0x95, 0x3c, 0xd4, 0xa6, 0xc7, 0xbf, 0xa0, 0x35, 0x20, 0x89, 0x92, 0xa0, - 0x37, 0x6a, 0x1f, 0xbd, 0xa8, 0x48, 0x1f, 0xbf, 0xa8, 0x48, 0xff, 0x7d, 0x51, 0x91, 0x7e, 0xf2, - 0xb2, 0x72, 0xec, 0xe3, 0x97, 0x95, 0x63, 0xff, 0x79, 0x59, 0x39, 0xf6, 0x58, 0x11, 0xbe, 0x76, - 0xeb, 0x56, 0x7d, 0x49, 0x7f, 0x42, 0x4c, 0x4b, 0xf4, 0xf0, 0x3c, 0xf9, 0x67, 0x27, 0xf5, 0x29, - 0xf6, 0x27, 0x25, 0x37, 0x3e, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x32, 0xdd, 0xcd, 0x59, 0xb0, 0x23, - 0x00, 0x00, + // 2543 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x5a, 0xdd, 0x6f, 0xdc, 0x58, + 0x15, 0xaf, 0x93, 0x6e, 0x9a, 0xdc, 0x84, 0xb6, 0xdc, 0xcd, 0x6e, 0xd3, 0x69, 0x9b, 0xb6, 0x5e, + 0x68, 0xbb, 0xdd, 0x66, 0xdc, 0xa6, 0x2d, 0x6a, 0xfa, 0x85, 0x92, 0x6d, 0x52, 0x46, 0xea, 0x47, + 0x70, 0xa3, 0x20, 0x2a, 0x21, 0xeb, 0x8e, 0x7d, 0x33, 0xf5, 0x66, 0xc6, 0x9e, 0xda, 0x9e, 0xa6, + 0xb3, 0xa3, 0x11, 0x62, 0x5f, 0xe0, 0x11, 0x81, 0x90, 0x56, 0x08, 0x24, 0x10, 0xe2, 0xf3, 0x05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xba, 0x78, 0xc4, 0xef, 0x20, 0x6c, 0x76, 0x3c, 0x8f, 0x3a, 0x81, 0xe1, 0x51, + 0x62, 0x19, 0xed, 0x50, 0x1c, 0x9a, 0xc7, 0x6e, 0x32, 0x70, 0x87, 0x9a, 0x52, 0x06, 0xee, 0x50, + 0x53, 0x3f, 0x0c, 0x7a, 0x75, 0x4a, 0x2c, 0x06, 0x0a, 0xf7, 0xd0, 0x31, 0x61, 0x2b, 0xaa, 0xc4, + 0xc0, 0xf5, 0x28, 0x18, 0x1d, 0x1f, 0x81, 0xd1, 0x39, 0x30, 0xb0, 0x0e, 0x55, 0x1b, 0xaa, 0xe7, + 0xc6, 0xbf, 0x8d, 0x4e, 0x08, 0xe3, 0x3e, 0x35, 0x5d, 0xc7, 0x4a, 0x9b, 0xdf, 0x3f, 0x02, 0xf3, + 0x15, 0x30, 0xf1, 0x48, 0x58, 0x90, 0x00, 0x74, 0x91, 0x78, 0x6b, 0x3c, 0x23, 0x4d, 0xdb, 0x0a, + 0x07, 0x1e, 0x23, 0x20, 0xcf, 0x0d, 0x8f, 0x04, 0x74, 0xee, 0x95, 0x11, 0x58, 0x3f, 0x02, 0xfa, + 0x37, 0x85, 0xfa, 0x0d, 0xf2, 0x5c, 0x27, 0x01, 0xc5, 0x75, 0x74, 0xd0, 0xa1, 0x3b, 0x72, 0x82, + 0x27, 0x46, 0x60, 0x6e, 0xc6, 0xa1, 0x3b, 0x71, 0x72, 0x7d, 0x74, 0x24, 0xb4, 0x91, 0x97, 0xd8, + 0x03, 0x23, 0x30, 0x36, 0xeb, 0xd0, 0x9d, 0x6c, 0x52, 0x77, 0xd0, 0xd1, 0xd0, 0x68, 0x7e, 0x42, + 0x27, 0x47, 0x60, 0xf6, 0x75, 0x87, 0xee, 0xe4, 0x25, 0xf3, 0x29, 0x0a, 0xdf, 0xe4, 0x25, 0x72, + 0x6a, 0x04, 0x56, 0x5f, 0x75, 0xe8, 0x4e, 0x3a, 0x89, 0xaa, 0x03, 0x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, 0xbe, 0xf7, 0xcf, 0xff, 0xfe, 0x70, 0xec, 0x38, 0xae, 0x68, 0x03, 0xe9, 0x6c, 0xfc, 0x7b, + 0x31, 0xe1, 0x67, 0xe8, 0x5d, 0x7c, 0xa9, 0xc4, 0x4e, 0x96, 0x49, 0xae, 0x2c, 0xee, 0x46, 0x04, + 0x50, 0x56, 0x19, 0xca, 0x73, 0xf8, 0xcc, 0x60, 0x94, 0x5a, 0x2f, 0xa2, 0xa3, 0xfb, 0xf8, 0x27, + 0x0a, 0x42, 0xf1, 0x0c, 0x81, 0xcf, 0x0f, 0x34, 0x99, 0x21, 0x95, 0x2b, 0x6f, 0x0d, 0xb5, 0x17, + 0x70, 0x5d, 0x65, 0xb8, 0x34, 0xbc, 0x90, 0x87, 0xeb, 0x49, 0x78, 0x01, 0xf0, 0xb1, 0x41, 0xeb, + 0x49, 0x13, 0x45, 0x1f, 0xff, 0x46, 0x41, 0x07, 0x93, 0x9c, 0x34, 0xae, 0x0e, 0x61, 0x56, 0xaa, + 0xf1, 0xdd, 0xc1, 0x5c, 0x62, 0x30, 0x2f, 0xe3, 0x4b, 0x25, 0x30, 0x8d, 0x7a, 0x38, 0x35, 0x47, + 0x60, 0x6d, 0xab, 0x8f, 0xdf, 0x57, 0xd0, 0x17, 0x62, 0x8d, 0x0f, 0xd6, 0x36, 0xf0, 0x1b, 0x03, + 0x2d, 0xc7, 0xbc, 0x55, 0x65, 0x70, 0xc4, 0x33, 0x74, 0x95, 0xfa, 0x15, 0x86, 0xee, 0x22, 0xae, + 0x96, 0xa1, 0x73, 0xb6, 0x02, 0xad, 0x27, 0xe8, 0xb0, 0x3e, 0xfe, 0x1d, 0x24, 0x99, 0x73, 0x4d, + 0x25, 0x49, 0x4e, 0xf0, 0xec, 0x25, 0xd1, 0x4b, 0x72, 0xdf, 0xea, 0xdb, 0x0c, 0xdf, 0x2d, 0x7c, + 0x63, 0x20, 0x3e, 0xce, 0x88, 0x24, 0x93, 0xac, 0xf5, 0x24,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0x43, 0xa0, 0x4e, 0xc1, + 0xcd, 0x5e, 0x0d, 0x7e, 0x3f, 0x2c, 0xf3, 0xd9, 0x3c, 0xb6, 0xa3, 0xa0, 0xd6, 0xf3, 0x79, 0x91, + 0x5d, 0xa2, 0x2f, 0xac, 0x18, 0x19, 0xbd, 0x68, 0x12, 0x11, 0xe7, 0xd2, 0x5f, 0xa9, 0x7d, 0xf4, + 0x62, 0x5e, 0xf9, 0xf8, 0xc5, 0xbc, 0xf2, 0xef, 0x17, 0xf3, 0xca, 0xf7, 0x5f, 0xce, 0xef, 0xfb, + 0xf8, 0xe5, 0xfc, 0xbe, 0x7f, 0xbd, 0x9c, 0xdf, 0xf7, 0x58, 0x93, 0x28, 0xba, 0xba, 0x53, 0x5f, + 0x30, 0x9f, 0x10, 0xdb, 0x91, 0x2d, 0x3c, 0x4f, 0xfe, 0x5f, 0xb9, 0xfa, 0x04, 0xfb, 0x7f, 0x70, + 0x97, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0x53, 0xc7, 0xdb, 0xaa, 0x65, 0x28, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2145,6 +2403,12 @@ type QueryClient interface { HeadBucketExtra(ctx context.Context, in *QueryHeadBucketExtraRequest, opts ...grpc.CallOption) (*QueryHeadBucketExtraResponse, error) // Queries whether read and storage prices changed for the bucket. QueryIsPriceChanged(ctx context.Context, in *QueryIsPriceChangedRequest, opts ...grpc.CallOption) (*QueryIsPriceChangedResponse, error) + // Queries whether some members are in the group. + QueryGroupMembersExist(ctx context.Context, in *QueryGroupMembersExistRequest, opts ...grpc.CallOption) (*QueryGroupMembersExistResponse, error) + // Queries whether some groups are exist. + QueryGroupsExist(ctx context.Context, in *QueryGroupsExistRequest, opts ...grpc.CallOption) (*QueryGroupsExistResponse, error) + // Queries whether some groups are exist by id. + QueryGroupsExistById(ctx context.Context, in *QueryGroupsExistByIdRequest, opts ...grpc.CallOption) (*QueryGroupsExistResponse, error) } type queryClient struct { @@ -2353,6 +2617,33 @@ func (c *queryClient) QueryIsPriceChanged(ctx context.Context, in *QueryIsPriceC return out, nil } +func (c *queryClient) QueryGroupMembersExist(ctx context.Context, in *QueryGroupMembersExistRequest, opts ...grpc.CallOption) (*QueryGroupMembersExistResponse, error) { + out := new(QueryGroupMembersExistResponse) + err := c.cc.Invoke(ctx, "/greenfield.storage.Query/QueryGroupMembersExist", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryGroupsExist(ctx context.Context, in *QueryGroupsExistRequest, opts ...grpc.CallOption) (*QueryGroupsExistResponse, error) { + out := new(QueryGroupsExistResponse) + err := c.cc.Invoke(ctx, "/greenfield.storage.Query/QueryGroupsExist", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryGroupsExistById(ctx context.Context, in *QueryGroupsExistByIdRequest, opts ...grpc.CallOption) (*QueryGroupsExistResponse, error) { + out := new(QueryGroupsExistResponse) + err := c.cc.Invoke(ctx, "/greenfield.storage.Query/QueryGroupsExistById", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -2399,6 +2690,12 @@ type QueryServer interface { HeadBucketExtra(context.Context, *QueryHeadBucketExtraRequest) (*QueryHeadBucketExtraResponse, error) // Queries whether read and storage prices changed for the bucket. QueryIsPriceChanged(context.Context, *QueryIsPriceChangedRequest) (*QueryIsPriceChangedResponse, error) + // Queries whether some members are in the group. + QueryGroupMembersExist(context.Context, *QueryGroupMembersExistRequest) (*QueryGroupMembersExistResponse, error) + // Queries whether some groups are exist. + QueryGroupsExist(context.Context, *QueryGroupsExistRequest) (*QueryGroupsExistResponse, error) + // Queries whether some groups are exist by id. + QueryGroupsExistById(context.Context, *QueryGroupsExistByIdRequest) (*QueryGroupsExistResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2471,6 +2768,15 @@ func (*UnimplementedQueryServer) HeadBucketExtra(ctx context.Context, req *Query func (*UnimplementedQueryServer) QueryIsPriceChanged(ctx context.Context, req *QueryIsPriceChangedRequest) (*QueryIsPriceChangedResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryIsPriceChanged not implemented") } +func (*UnimplementedQueryServer) QueryGroupMembersExist(ctx context.Context, req *QueryGroupMembersExistRequest) (*QueryGroupMembersExistResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryGroupMembersExist not implemented") +} +func (*UnimplementedQueryServer) QueryGroupsExist(ctx context.Context, req *QueryGroupsExistRequest) (*QueryGroupsExistResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryGroupsExist not implemented") +} +func (*UnimplementedQueryServer) QueryGroupsExistById(ctx context.Context, req *QueryGroupsExistByIdRequest) (*QueryGroupsExistResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryGroupsExistById not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2872,6 +3178,60 @@ func _Query_QueryIsPriceChanged_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _Query_QueryGroupMembersExist_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupMembersExistRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryGroupMembersExist(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.storage.Query/QueryGroupMembersExist", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryGroupMembersExist(ctx, req.(*QueryGroupMembersExistRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryGroupsExist_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupsExistRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryGroupsExist(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.storage.Query/QueryGroupsExist", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryGroupsExist(ctx, req.(*QueryGroupsExistRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryGroupsExistById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupsExistByIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryGroupsExistById(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.storage.Query/QueryGroupsExistById", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryGroupsExistById(ctx, req.(*QueryGroupsExistByIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "greenfield.storage.Query", HandlerType: (*QueryServer)(nil), @@ -2964,6 +3324,18 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryIsPriceChanged", Handler: _Query_QueryIsPriceChanged_Handler, }, + { + MethodName: "QueryGroupMembersExist", + Handler: _Query_QueryGroupMembersExist_Handler, + }, + { + MethodName: "QueryGroupsExist", + Handler: _Query_QueryGroupsExist_Handler, + }, + { + MethodName: "QueryGroupsExistById", + Handler: _Query_QueryGroupsExistById_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "greenfield/storage/query.proto", @@ -4456,35 +4828,235 @@ func (m *QueryIsPriceChangedResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryGroupMembersExistRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } + +func (m *QueryGroupMembersExistRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupMembersExistRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Members[iNdEx]) + copy(dAtA[i:], m.Members[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Members[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.GroupId) > 0 { + i -= len(m.GroupId) + copy(dAtA[i:], m.GroupId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.GroupId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGroupMembersExistResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + return dAtA[:n], nil +} + +func (m *QueryGroupMembersExistResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupMembersExistResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Exists) > 0 { + for k := range m.Exists { + v := m.Exists[k] + baseI := i + i-- + if v { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintQuery(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupsExistRequest) 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 *QueryGroupsExistRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupsExistRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GroupNames) > 0 { + for iNdEx := len(m.GroupNames) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.GroupNames[iNdEx]) + copy(dAtA[i:], m.GroupNames[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.GroupNames[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.GroupOwner) > 0 { + i -= len(m.GroupOwner) + copy(dAtA[i:], m.GroupOwner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.GroupOwner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupsExistByIdRequest) 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 *QueryGroupsExistByIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupsExistByIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GroupIds) > 0 { + for iNdEx := len(m.GroupIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.GroupIds[iNdEx]) + copy(dAtA[i:], m.GroupIds[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.GroupIds[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupsExistResponse) 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 *QueryGroupsExistResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupsExistResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Exists) > 0 { + for k := range m.Exists { + v := m.Exists[k] + baseI := i + i-- + if v { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintQuery(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } func (m *QueryParamsByTimestampRequest) Size() (n int) { @@ -5052,6 +5624,93 @@ func (m *QueryIsPriceChangedResponse) Size() (n int) { return n } +func (m *QueryGroupMembersExistRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.GroupId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Members) > 0 { + for _, s := range m.Members { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryGroupMembersExistResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Exists) > 0 { + for k, v := range m.Exists { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + 1 + 1 + n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + } + } + return n +} + +func (m *QueryGroupsExistRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.GroupOwner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.GroupNames) > 0 { + for _, s := range m.GroupNames { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryGroupsExistByIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.GroupIds) > 0 { + for _, s := range m.GroupIds { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryGroupsExistResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Exists) > 0 { + for k, v := range m.Exists { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + 1 + 1 + n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -9081,6 +9740,646 @@ func (m *QueryIsPriceChangedResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGroupMembersExistRequest) 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: QueryGroupMembersExistRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupMembersExistRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Members = append(m.Members, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupMembersExistResponse) 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: QueryGroupMembersExistResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupMembersExistResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Exists", 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.Exists == nil { + m.Exists = make(map[string]bool) + } + var mapkey string + var mapvalue bool + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthQuery + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthQuery + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapvaluetemp int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvaluetemp |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + mapvalue = bool(mapvaluetemp != 0) + } else { + iNdEx = entryPreIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Exists[mapkey] = mapvalue + 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 *QueryGroupsExistRequest) 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: QueryGroupsExistRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupsExistRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupOwner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupOwner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupNames", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupNames = append(m.GroupNames, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupsExistByIdRequest) 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: QueryGroupsExistByIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupsExistByIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupIds = append(m.GroupIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupsExistResponse) 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: QueryGroupsExistResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupsExistResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Exists", 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.Exists == nil { + m.Exists = make(map[string]bool) + } + var mapkey string + var mapvalue bool + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthQuery + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthQuery + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapvaluetemp int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvaluetemp |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + mapvalue = bool(mapvaluetemp != 0) + } else { + iNdEx = entryPreIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Exists[mapkey] = mapvalue + 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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/storage/types/query.pb.gw.go b/x/storage/types/query.pb.gw.go index f66bbd84e..6707fddf8 100644 --- a/x/storage/types/query.pb.gw.go +++ b/x/storage/types/query.pb.gw.go @@ -1342,6 +1342,212 @@ func local_request_Query_QueryIsPriceChanged_0(ctx context.Context, marshaler ru } +func request_Query_QueryGroupMembersExist_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGroupMembersExistRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_id") + } + + protoReq.GroupId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_id", err) + } + + val, ok = pathParams["members"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "members") + } + + protoReq.Members, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "members", err) + } + + msg, err := client.QueryGroupMembersExist(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryGroupMembersExist_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGroupMembersExistRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_id") + } + + protoReq.GroupId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_id", err) + } + + val, ok = pathParams["members"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "members") + } + + protoReq.Members, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "members", err) + } + + msg, err := server.QueryGroupMembersExist(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryGroupsExist_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGroupsExistRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_owner") + } + + protoReq.GroupOwner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_owner", err) + } + + val, ok = pathParams["group_names"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_names") + } + + protoReq.GroupNames, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_names", err) + } + + msg, err := client.QueryGroupsExist(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryGroupsExist_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGroupsExistRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_owner") + } + + protoReq.GroupOwner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_owner", err) + } + + val, ok = pathParams["group_names"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_names") + } + + protoReq.GroupNames, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_names", err) + } + + msg, err := server.QueryGroupsExist(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryGroupsExistById_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGroupsExistByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_ids"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_ids") + } + + protoReq.GroupIds, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_ids", err) + } + + msg, err := client.QueryGroupsExistById(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryGroupsExistById_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGroupsExistByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["group_ids"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "group_ids") + } + + protoReq.GroupIds, err = runtime.StringSlice(val, ",") + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "group_ids", err) + } + + msg, err := server.QueryGroupsExistById(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1854,6 +2060,75 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryGroupMembersExist_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_QueryGroupMembersExist_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_QueryGroupMembersExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryGroupsExist_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_QueryGroupsExist_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_QueryGroupsExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryGroupsExistById_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_QueryGroupsExistById_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_QueryGroupsExistById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2335,6 +2610,66 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryGroupMembersExist_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_QueryGroupMembersExist_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_QueryGroupMembersExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryGroupsExist_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_QueryGroupsExist_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_QueryGroupsExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryGroupsExistById_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_QueryGroupsExistById_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_QueryGroupsExistById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2382,6 +2717,12 @@ var ( pattern_Query_HeadBucketExtra_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "storage", "head_bucket_extra", "bucket_name"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryIsPriceChanged_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "storage", "is_price_changed", "bucket_name"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryGroupMembersExist_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"greenfield", "storage", "group_members_exist", "group_id", "members"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryGroupsExist_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"greenfield", "storage", "groups_exist", "group_owner", "group_names"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryGroupsExistById_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "storage", "groups_exist_by_id", "group_ids"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -2428,4 +2769,10 @@ var ( forward_Query_HeadBucketExtra_0 = runtime.ForwardResponseMessage forward_Query_QueryIsPriceChanged_0 = runtime.ForwardResponseMessage + + forward_Query_QueryGroupMembersExist_0 = runtime.ForwardResponseMessage + + forward_Query_QueryGroupsExist_0 = runtime.ForwardResponseMessage + + forward_Query_QueryGroupsExistById_0 = runtime.ForwardResponseMessage ) From af4118b03430ffdec221ad29f1967d17c5aeb2a7 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Thu, 3 Aug 2023 10:41:51 +0800 Subject: [PATCH 16/24] feat: add flag to enable/disable heavy queries and refactor apis (#390) * feat: add flag to enable/disable heavy queries and refactor apis * fix swagger format issue * disable listing objects/groups using offset * fix tests * fix unit tests * update workflows * refactor query * update go mod --- .../workflows/{build-test.yml => build.yml} | 6 +- cmd/gnfd/cmd/root.go | 1 + e2e/tests/payment_test.go | 53 +- e2e/tests/permission_test.go | 4 +- e2e/tests/storage_bill_test.go | 10 +- e2e/tests/storage_test.go | 8 +- go.mod | 2 +- go.sum | 4 +- proto/greenfield/payment/query.proto | 82 +- proto/greenfield/storage/query.proto | 8 +- swagger/static/swagger.yaml | 1010 +++++++-------- x/challenge/client/cli/query.go | 42 +- .../client/cli/query_auto_settle_record.go | 4 +- .../query_get_payment_accounts_by_owner.go | 4 +- x/payment/client/cli/query_payment_account.go | 6 +- .../client/cli/query_payment_account_count.go | 6 +- x/payment/client/cli/query_stream_record.go | 4 +- x/payment/client/cli/query_test.go | 14 +- .../keeper/grpc_query_auto_settle_record.go | 9 +- .../keeper/grpc_query_payment_account.go | 13 +- .../grpc_query_payment_account_count.go | 13 +- ...> grpc_query_payment_accounts_by_owner.go} | 4 +- x/payment/keeper/grpc_query_stream_record.go | 9 +- x/payment/keeper/grpc_query_test.go | 26 +- x/payment/types/query.pb.go | 1124 ++++++++--------- x/payment/types/query.pb.gw.go | 172 +-- x/storage/client/cli/query.go | 12 +- x/storage/client/cli/query_test.go | 6 +- x/storage/keeper/grpc_query.go | 21 +- x/storage/keeper/grpc_query_test.go | 16 +- x/storage/types/query.pb.go | 444 +++---- x/storage/types/query.pb.gw.go | 34 +- x/storage/types/types.go | 2 +- 33 files changed, 1632 insertions(+), 1541 deletions(-) rename .github/workflows/{build-test.yml => build.yml} (94%) rename x/payment/keeper/{grpc_query_get_payment_accounts_by_owner.go => grpc_query_payment_accounts_by_owner.go} (79%) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build.yml similarity index 94% rename from .github/workflows/build-test.yml rename to .github/workflows/build.yml index 40a62c5b1..f70729c29 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Test +name: Build on: push: @@ -51,7 +51,3 @@ jobs: - name: Test Build run: | make build - - - name: Uint Test - run: | - make test diff --git a/cmd/gnfd/cmd/root.go b/cmd/gnfd/cmd/root.go index 8d7b6ba04..521973dcc 100644 --- a/cmd/gnfd/cmd/root.go +++ b/cmd/gnfd/cmd/root.go @@ -369,6 +369,7 @@ func (a appCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))), baseapp.SetChainID(chainID), + baseapp.SetEnableUnsafeQuery(cast.ToBool(appOpts.Get(server.FlagEnableUnsafeQuery))), ) } diff --git a/e2e/tests/payment_test.go b/e2e/tests/payment_test.go index 302d403ed..ea0c8ab30 100644 --- a/e2e/tests/payment_test.go +++ b/e2e/tests/payment_test.go @@ -10,6 +10,8 @@ import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/types/query" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" @@ -55,6 +57,27 @@ func (s *PaymentTestSuite) SetupTest() { s.RefreshGVGFamilies() } +func (s *PaymentTestSuite) TestQueryPaymentAccounts() { + _, err := s.Client.PaymentAccounts(context.Background(), &paymenttypes.QueryPaymentAccountsRequest{ + Pagination: &query.PageRequest{ + Offset: 10, // offset is not allowed + }, + }) + s.Require().Error(err) + + _, err = s.Client.PaymentAccounts(context.Background(), &paymenttypes.QueryPaymentAccountsRequest{ + Pagination: &query.PageRequest{ + CountTotal: true, // count total = true is not allowed + }, + }) + s.Require().Error(err) + + _, err = s.Client.PaymentAccounts(context.Background(), &paymenttypes.QueryPaymentAccountsRequest{ + Pagination: &query.PageRequest{}, + }) + s.Require().NoError(err) +} + func (s *PaymentTestSuite) TestCreatePaymentAccount() { user := s.GenAndChargeAccounts(1, 100)[0] ctx := context.Background() @@ -64,16 +87,16 @@ func (s *PaymentTestSuite) TestCreatePaymentAccount() { } _ = s.SendTxBlock(user, msgCreatePaymentAccount) // query user's payment accounts - queryGetPaymentAccountsByOwnerRequest := paymenttypes.QueryGetPaymentAccountsByOwnerRequest{ + queryGetPaymentAccountsByOwnerRequest := paymenttypes.QueryPaymentAccountsByOwnerRequest{ Owner: user.GetAddr().String(), } - paymentAccounts, err := s.Client.GetPaymentAccountsByOwner(ctx, &queryGetPaymentAccountsByOwnerRequest) + paymentAccounts, err := s.Client.PaymentAccountsByOwner(ctx, &queryGetPaymentAccountsByOwnerRequest) s.Require().NoError(err) s.T().Log(paymentAccounts) s.Require().Equal(1, len(paymentAccounts.PaymentAccounts)) paymentAccountAddr := paymentAccounts.PaymentAccounts[0] // query this payment account - queryGetPaymentAccountRequest := paymenttypes.QueryGetPaymentAccountRequest{ + queryGetPaymentAccountRequest := paymenttypes.QueryPaymentAccountRequest{ Addr: paymentAccountAddr, } paymentAccount, err := s.Client.PaymentAccount(ctx, &queryGetPaymentAccountRequest) @@ -299,8 +322,8 @@ func (s *PaymentTestSuite) TestDeposit_ActiveAccount() { Creator: userAddr, } _ = s.SendTxBlock(user, msgCreatePaymentAccount) - paymentAccountsReq := &paymenttypes.QueryGetPaymentAccountsByOwnerRequest{Owner: userAddr} - paymentAccounts, err := s.Client.PaymentQueryClient.GetPaymentAccountsByOwner(ctx, paymentAccountsReq) + paymentAccountsReq := &paymenttypes.QueryPaymentAccountsByOwnerRequest{Owner: userAddr} + paymentAccounts, err := s.Client.PaymentQueryClient.PaymentAccountsByOwner(ctx, paymentAccountsReq) s.Require().NoError(err) s.T().Logf("paymentAccounts %s", core.YamlString(paymentAccounts)) paymentAddr := paymentAccounts.PaymentAccounts[0] @@ -384,8 +407,8 @@ func (s *PaymentTestSuite) TestDeposit_ResumeInOneBlock() { Creator: userAddr, } _ = s.SendTxBlock(user, msgCreatePaymentAccount) - paymentAccountsReq := &paymenttypes.QueryGetPaymentAccountsByOwnerRequest{Owner: userAddr} - paymentAccounts, err := s.Client.PaymentQueryClient.GetPaymentAccountsByOwner(ctx, paymentAccountsReq) + paymentAccountsReq := &paymenttypes.QueryPaymentAccountsByOwnerRequest{Owner: userAddr} + paymentAccounts, err := s.Client.PaymentQueryClient.PaymentAccountsByOwner(ctx, paymentAccountsReq) s.Require().NoError(err) s.T().Logf("paymentAccounts %s", core.YamlString(paymentAccounts)) paymentAddr := paymentAccounts.PaymentAccounts[0] @@ -501,8 +524,8 @@ func (s *PaymentTestSuite) TestDeposit_ResumeInBlocks() { Creator: userAddr, } _ = s.SendTxBlock(user, msgCreatePaymentAccount) - paymentAccountsReq := &paymenttypes.QueryGetPaymentAccountsByOwnerRequest{Owner: userAddr} - paymentAccounts, err := s.Client.PaymentQueryClient.GetPaymentAccountsByOwner(ctx, paymentAccountsReq) + paymentAccountsReq := &paymenttypes.QueryPaymentAccountsByOwnerRequest{Owner: userAddr} + paymentAccounts, err := s.Client.PaymentQueryClient.PaymentAccountsByOwner(ctx, paymentAccountsReq) s.Require().NoError(err) s.T().Logf("paymentAccounts %s", core.YamlString(paymentAccounts)) paymentAddr := paymentAccounts.PaymentAccounts[0] @@ -636,8 +659,8 @@ func (s *PaymentTestSuite) TestAutoSettle_InOneBlock() { Creator: userAddr, } _ = s.SendTxBlock(user, msgCreatePaymentAccount) - paymentAccountsReq := &paymenttypes.QueryGetPaymentAccountsByOwnerRequest{Owner: userAddr} - paymentAccounts, err := s.Client.PaymentQueryClient.GetPaymentAccountsByOwner(ctx, paymentAccountsReq) + paymentAccountsReq := &paymenttypes.QueryPaymentAccountsByOwnerRequest{Owner: userAddr} + paymentAccounts, err := s.Client.PaymentQueryClient.PaymentAccountsByOwner(ctx, paymentAccountsReq) s.Require().NoError(err) s.T().Logf("paymentAccounts %s", core.YamlString(paymentAccounts)) paymentAddr := paymentAccounts.PaymentAccounts[0] @@ -775,8 +798,8 @@ func (s *PaymentTestSuite) TestAutoSettle_InBlocks() { Creator: userAddr, } _ = s.SendTxBlock(user, msgCreatePaymentAccount) - paymentAccountsReq := &paymenttypes.QueryGetPaymentAccountsByOwnerRequest{Owner: userAddr} - paymentAccounts, err := s.Client.PaymentQueryClient.GetPaymentAccountsByOwner(ctx, paymentAccountsReq) + paymentAccountsReq := &paymenttypes.QueryPaymentAccountsByOwnerRequest{Owner: userAddr} + paymentAccounts, err := s.Client.PaymentQueryClient.PaymentAccountsByOwner(ctx, paymentAccountsReq) s.Require().NoError(err) s.T().Logf("paymentAccounts %s", core.YamlString(paymentAccounts)) paymentAddr := paymentAccounts.PaymentAccounts[0] @@ -872,8 +895,8 @@ func (s *PaymentTestSuite) TestWithdraw() { Creator: userAddr, } _ = s.SendTxBlock(user, msgCreatePaymentAccount) - paymentAccountsReq := &paymenttypes.QueryGetPaymentAccountsByOwnerRequest{Owner: userAddr} - paymentAccounts, err := s.Client.PaymentQueryClient.GetPaymentAccountsByOwner(ctx, paymentAccountsReq) + paymentAccountsReq := &paymenttypes.QueryPaymentAccountsByOwnerRequest{Owner: userAddr} + paymentAccounts, err := s.Client.PaymentQueryClient.PaymentAccountsByOwner(ctx, paymentAccountsReq) s.Require().NoError(err) s.T().Logf("paymentAccounts %s", core.YamlString(paymentAccounts)) paymentAddr := paymentAccounts.PaymentAccounts[0] diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index c11900632..aad76dd6e 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1356,8 +1356,8 @@ func (s *StorageTestSuite) TestGroupMembersAndPolicyGC() { s.Require().Equal(headGroupMemberResponse.GroupMember.GroupId, headGroupResponse.GetGroupInfo().Id) // list group - queryListGroupReq := storagetypes.QueryListGroupRequest{GroupOwner: owner.GetAddr().String()} - queryListGroupResp, err := s.Client.ListGroup(ctx, &queryListGroupReq) + queryListGroupReq := storagetypes.QueryListGroupsRequest{GroupOwner: owner.GetAddr().String()} + queryListGroupResp, err := s.Client.ListGroups(ctx, &queryListGroupReq) s.Require().NoError(err) s.T().Log(queryListGroupResp.String()) diff --git a/e2e/tests/storage_bill_test.go b/e2e/tests/storage_bill_test.go index b55bf930b..031556e14 100644 --- a/e2e/tests/storage_bill_test.go +++ b/e2e/tests/storage_bill_test.go @@ -267,11 +267,11 @@ func (s *PaymentTestSuite) TestStorageBill_Smoke() { s.checkStreamRecordsBeforeAndAfter(streamRecordsBeforeCreateEmptyObject, streamRecordsAfterCreateEmptyObject, readPrice, readChargeRate, primaryStorePrice, secondaryStorePrice, chargeSize, uint64(emptyPayloadSize)) // test query auto settle records - queryAllAutoSettleRecordRequest := paymenttypes.QueryAllAutoSettleRecordRequest{} - queryAllAutoSettleRecordResponse, err := s.Client.AutoSettleRecordAll(ctx, &queryAllAutoSettleRecordRequest) + queryAllAutoSettleRecordRequest := paymenttypes.QueryAutoSettleRecordsRequest{} + queryAllAutoSettleRecordResponse, err := s.Client.AutoSettleRecords(ctx, &queryAllAutoSettleRecordRequest) s.Require().NoError(err) s.T().Logf("queryAllAutoSettleRecordResponse %s", core.YamlString(queryAllAutoSettleRecordResponse)) - s.Require().True(len(queryAllAutoSettleRecordResponse.AutoSettleRecord) >= 1) + s.Require().True(len(queryAllAutoSettleRecordResponse.AutoSettleRecords) >= 1) // simulate delete object, check fee preview deleteObjectMsg := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName) @@ -2107,10 +2107,10 @@ func (s *PaymentTestSuite) CreatePaymentAccount(user keys.KeyManager, amount, de } _ = s.SendTxBlock(user, msgCreatePaymentAccount) // query user's payment accounts - queryGetPaymentAccountsByOwnerRequest := paymenttypes.QueryGetPaymentAccountsByOwnerRequest{ + queryGetPaymentAccountsByOwnerRequest := paymenttypes.QueryPaymentAccountsByOwnerRequest{ Owner: user.GetAddr().String(), } - paymentAccounts, err := s.Client.GetPaymentAccountsByOwner(ctx, &queryGetPaymentAccountsByOwnerRequest) + paymentAccounts, err := s.Client.PaymentAccountsByOwner(ctx, &queryGetPaymentAccountsByOwnerRequest) s.Require().NoError(err) s.T().Log(paymentAccounts) paymentAccountAddr := paymentAccounts.PaymentAccounts[len(paymentAccounts.PaymentAccounts)-1] diff --git a/e2e/tests/storage_test.go b/e2e/tests/storage_test.go index 4aa84e72e..49bb2ab90 100644 --- a/e2e/tests/storage_test.go +++ b/e2e/tests/storage_test.go @@ -295,8 +295,8 @@ func (s *StorageTestSuite) TestCreateGroup() { s.Require().Equal(headGroupNftResponse.MetaData.GroupName, groupName) // 3. ListGroup - queryListGroupReq := storagetypes.QueryListGroupRequest{GroupOwner: owner.GetAddr().String()} - queryListGroupResp, err := s.Client.ListGroup(ctx, &queryListGroupReq) + queryListGroupReq := storagetypes.QueryListGroupsRequest{GroupOwner: owner.GetAddr().String()} + queryListGroupResp, err := s.Client.ListGroups(ctx, &queryListGroupReq) s.Require().NoError(err) s.Require().GreaterOrEqual(len(queryListGroupResp.GroupInfos), 1) @@ -367,8 +367,8 @@ func (s *StorageTestSuite) TestLeaveGroup() { s.Require().Equal(headGroupNftResponse.MetaData.GroupName, groupName) // 3. ListGroup - queryListGroupReq := storagetypes.QueryListGroupRequest{GroupOwner: owner.GetAddr().String()} - queryListGroupResp, err := s.Client.ListGroup(ctx, &queryListGroupReq) + queryListGroupReq := storagetypes.QueryListGroupsRequest{GroupOwner: owner.GetAddr().String()} + queryListGroupResp, err := s.Client.ListGroups(ctx, &queryListGroupReq) s.Require().NoError(err) s.Require().GreaterOrEqual(len(queryListGroupResp.GroupInfos), 1) diff --git a/go.mod b/go.mod index a0fccf520..30740871a 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.5 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230803020148-9216a6aea390 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 14d29202e..82c607fbf 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.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 v0.2.3-alpha.3.0.20230803020148-9216a6aea390 h1:tuXCEm4WHJ/7mhYM9Nqq5z+Qu96xsSZ6pqw0LE0+Fqo= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230803020148-9216a6aea390/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas= 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/payment/query.proto b/proto/greenfield/payment/query.proto index 9df978904..f95869a69 100644 --- a/proto/greenfield/payment/query.proto +++ b/proto/greenfield/payment/query.proto @@ -24,59 +24,59 @@ service Query { option (google.api.http).get = "/greenfield/payment/params"; } - // ParamsByTimestamp queries the parameters of the module. + // ParamsByTimestamp queries the parameter of the module by timestamp. rpc ParamsByTimestamp(QueryParamsByTimestampRequest) returns (QueryParamsByTimestampResponse) { option (google.api.http).get = "/greenfield/payment/params/{timestamp}"; } - // Queries a StreamRecord by index. + // Queries our flows by account. rpc OutFlows(QueryOutFlowsRequest) returns (QueryOutFlowsResponse) { option (google.api.http).get = "/greenfield/payment/out_flows/{account}"; } - // Queries a StreamRecord by index. + // Queries a stream record by account. rpc StreamRecord(QueryGetStreamRecordRequest) returns (QueryGetStreamRecordResponse) { option (google.api.http).get = "/greenfield/payment/stream_record/{account}"; } - // Queries a list of StreamRecord items. - rpc StreamRecordAll(QueryAllStreamRecordRequest) returns (QueryAllStreamRecordResponse) { - option (google.api.http).get = "/greenfield/payment/stream_record"; + // Queries all stream records. + rpc StreamRecords(QueryStreamRecordsRequest) returns (QueryStreamRecordsResponse) { + option (google.api.http).get = "/greenfield/payment/stream_records"; } - // Queries a PaymentAccountCount by index. - rpc PaymentAccountCount(QueryGetPaymentAccountCountRequest) returns (QueryGetPaymentAccountCountResponse) { + // Queries the count of payment account by owner. + rpc PaymentAccountCount(QueryPaymentAccountCountRequest) returns (QueryPaymentAccountCountResponse) { option (google.api.http).get = "/greenfield/payment/payment_account_count/{owner}"; } - // Queries a list of PaymentAccountCount items. - rpc PaymentAccountCountAll(QueryAllPaymentAccountCountRequest) returns (QueryAllPaymentAccountCountResponse) { - option (google.api.http).get = "/greenfield/payment/payment_account_count"; + // Queries all counts of payment account for all owners. + rpc PaymentAccountCounts(QueryPaymentAccountCountsRequest) returns (QueryPaymentAccountCountsResponse) { + option (google.api.http).get = "/greenfield/payment/payment_account_counts"; } - // Queries a PaymentAccount by index. - rpc PaymentAccount(QueryGetPaymentAccountRequest) returns (QueryGetPaymentAccountResponse) { + // Queries a payment account by payment account address. + rpc PaymentAccount(QueryPaymentAccountRequest) returns (QueryPaymentAccountResponse) { option (google.api.http).get = "/greenfield/payment/payment_account/{addr}"; } - // Queries a list of PaymentAccount items. - rpc PaymentAccountAll(QueryAllPaymentAccountRequest) returns (QueryAllPaymentAccountResponse) { - option (google.api.http).get = "/greenfield/payment/payment_account"; + // Queries all payment accounts. + rpc PaymentAccounts(QueryPaymentAccountsRequest) returns (QueryPaymentAccountsResponse) { + option (google.api.http).get = "/greenfield/payment/payment_accounts"; } - // Queries a list of DynamicBalance items. + // Queries dynamic balance of a payment account. rpc DynamicBalance(QueryDynamicBalanceRequest) returns (QueryDynamicBalanceResponse) { option (google.api.http).get = "/greenfield/payment/dynamic_balance/{account}"; } - // Queries a list of GetPaymentAccountsByOwner items. - rpc GetPaymentAccountsByOwner(QueryGetPaymentAccountsByOwnerRequest) returns (QueryGetPaymentAccountsByOwnerResponse) { - option (google.api.http).get = "/greenfield/payment/get_payment_accounts_by_owner/{owner}"; + // Queries all payment accounts by a owner. + rpc PaymentAccountsByOwner(QueryPaymentAccountsByOwnerRequest) returns (QueryPaymentAccountsByOwnerResponse) { + option (google.api.http).get = "/greenfield/payment/payment_accounts_by_owner/{owner}"; } - // Queries a list of AutoSettleRecord items. - rpc AutoSettleRecordAll(QueryAllAutoSettleRecordRequest) returns (QueryAllAutoSettleRecordResponse) { - option (google.api.http).get = "/greenfield/payment/auto_settle_record"; + // Queries all auto settle records. + rpc AutoSettleRecords(QueryAutoSettleRecordsRequest) returns (QueryAutoSettleRecordsResponse) { + option (google.api.http).get = "/greenfield/payment/auto_settle_records"; } } @@ -117,46 +117,46 @@ message QueryGetStreamRecordResponse { StreamRecord stream_record = 1 [(gogoproto.nullable) = false]; } -message QueryAllStreamRecordRequest { +message QueryStreamRecordsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; } -message QueryAllStreamRecordResponse { - repeated StreamRecord stream_record = 1 [(gogoproto.nullable) = false]; +message QueryStreamRecordsResponse { + repeated StreamRecord stream_records = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } -message QueryGetPaymentAccountCountRequest { +message QueryPaymentAccountCountRequest { string owner = 1; } -message QueryGetPaymentAccountCountResponse { +message QueryPaymentAccountCountResponse { PaymentAccountCount payment_account_count = 1 [(gogoproto.nullable) = false]; } -message QueryAllPaymentAccountCountRequest { +message QueryPaymentAccountCountsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; } -message QueryAllPaymentAccountCountResponse { - repeated PaymentAccountCount payment_account_count = 1 [(gogoproto.nullable) = false]; +message QueryPaymentAccountCountsResponse { + repeated PaymentAccountCount payment_account_counts = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } -message QueryGetPaymentAccountRequest { +message QueryPaymentAccountRequest { string addr = 1; } -message QueryGetPaymentAccountResponse { +message QueryPaymentAccountResponse { PaymentAccount payment_account = 1 [(gogoproto.nullable) = false]; } -message QueryAllPaymentAccountRequest { +message QueryPaymentAccountsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; } -message QueryAllPaymentAccountResponse { - repeated PaymentAccount payment_account = 1 [(gogoproto.nullable) = false]; +message QueryPaymentAccountsResponse { + repeated PaymentAccount payment_accounts = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -201,19 +201,19 @@ message QueryDynamicBalanceResponse { ]; } -message QueryGetPaymentAccountsByOwnerRequest { +message QueryPaymentAccountsByOwnerRequest { string owner = 1; } -message QueryGetPaymentAccountsByOwnerResponse { +message QueryPaymentAccountsByOwnerResponse { repeated string paymentAccounts = 1; } -message QueryAllAutoSettleRecordRequest { +message QueryAutoSettleRecordsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; } -message QueryAllAutoSettleRecordResponse { - repeated AutoSettleRecord auto_settle_record = 1 [(gogoproto.nullable) = false]; +message QueryAutoSettleRecordsResponse { + repeated AutoSettleRecord auto_settle_records = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/greenfield/storage/query.proto b/proto/greenfield/storage/query.proto index bcb7ce708..80273e897 100644 --- a/proto/greenfield/storage/query.proto +++ b/proto/greenfield/storage/query.proto @@ -94,8 +94,8 @@ service Query { } // Queries a list of ListGroup items. - rpc ListGroup(QueryListGroupRequest) returns (QueryListGroupResponse) { - option (google.api.http).get = "/greenfield/storage/list_group/{group_owner}"; + rpc ListGroups(QueryListGroupsRequest) returns (QueryListGroupsResponse) { + option (google.api.http).get = "/greenfield/storage/list_groups/{group_owner}"; } // Queries a list of HeadGroupMember items. @@ -262,12 +262,12 @@ message QueryHeadGroupResponse { GroupInfo group_info = 1; } -message QueryListGroupRequest { +message QueryListGroupsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; string group_owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -message QueryListGroupResponse { +message QueryListGroupsResponse { cosmos.base.query.v1beta1.PageResponse pagination = 1; repeated GroupInfo group_infos = 2; } diff --git a/swagger/static/swagger.yaml b/swagger/static/swagger.yaml index 3dd0ec391..3cb9f0a63 100644 --- a/swagger/static/swagger.yaml +++ b/swagger/static/swagger.yaml @@ -329,17 +329,17 @@ paths: format: byte tags: - Query - /greenfield/payment/auto_settle_record: + /greenfield/payment/auto_settle_records: get: - summary: Queries a list of AutoSettleRecord items. - operationId: AutoSettleRecordAll + summary: Queries all auto settle records. + operationId: AutoSettleRecords responses: '200': description: A successful response. schema: type: object properties: - auto_settle_record: + auto_settle_records: type: array items: type: object @@ -473,7 +473,7 @@ paths: - Query /greenfield/payment/dynamic_balance/{account}: get: - summary: Queries a list of DynamicBalance items. + summary: Queries dynamic balance of a payment account. operationId: DynamicBalance responses: '200': @@ -596,52 +596,9 @@ paths: type: string tags: - Query - /greenfield/payment/get_payment_accounts_by_owner/{owner}: - get: - summary: Queries a list of GetPaymentAccountsByOwner items. - operationId: GetPaymentAccountsByOwner - responses: - '200': - description: A successful response. - schema: - type: object - properties: - paymentAccounts: - type: array - items: - type: string - 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: owner - in: path - required: true - type: string - tags: - - Query /greenfield/payment/out_flows/{account}: get: - summary: Queries a StreamRecord by index. + summary: Queries our flows by account. operationId: OutFlows responses: '200': @@ -794,7 +751,7 @@ paths: - Query /greenfield/payment/params/{timestamp}: get: - summary: ParamsByTimestamp queries the parameters of the module. + summary: ParamsByTimestamp queries the parameter of the module by timestamp. operationId: ParamsByTimestamp responses: '200': @@ -886,10 +843,10 @@ paths: format: int64 tags: - Query - /greenfield/payment/payment_account: + /greenfield/payment/payment_account/{addr}: get: - summary: Queries a list of PaymentAccount items. - operationId: PaymentAccountAll + summary: Queries a payment account by payment account address. + operationId: PaymentAccount responses: '200': description: A successful response. @@ -897,48 +854,18 @@ paths: type: object properties: payment_account: - type: array - items: - type: object - properties: - addr: - type: string - title: the address of the payment account - owner: - type: string - title: the owner address of the payment account - refundable: - type: boolean - title: whether the payment account is refundable - title: PaymentAccount defines a payment account - pagination: type: object properties: - next_key: + addr: type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + title: the address of the payment account + owner: type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the - - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } + title: the owner address of the payment account + refundable: + type: boolean + title: whether the payment account is refundable + title: PaymentAccount defines a payment account default: description: An unexpected error response. schema: @@ -962,87 +889,35 @@ paths: type: string format: byte parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false + - name: addr + in: path + required: true type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean tags: - Query - /greenfield/payment/payment_account/{addr}: + /greenfield/payment/payment_account_count/{owner}: get: - summary: Queries a PaymentAccount by index. - operationId: PaymentAccount + summary: Queries the count of payment account by owner. + operationId: PaymentAccountCount responses: '200': description: A successful response. schema: type: object properties: - payment_account: + payment_account_count: type: object properties: - addr: - type: string - title: the address of the payment account owner: type: string - title: the owner address of the payment account - refundable: - type: boolean - title: whether the payment account is refundable - title: PaymentAccount defines a payment account + title: owner is the account address + count: + type: string + format: uint64 + title: count is the number of payment accounts for the account + title: >- + PaymentAccountCount defines the state struct which stores the + number of payment accounts for an account default: description: An unexpected error response. schema: @@ -1066,23 +941,23 @@ paths: type: string format: byte parameters: - - name: addr + - name: owner in: path required: true type: string tags: - Query - /greenfield/payment/payment_account_count: + /greenfield/payment/payment_account_counts: get: - summary: Queries a list of PaymentAccountCount items. - operationId: PaymentAccountCountAll + summary: Queries all counts of payment account for all owners. + operationId: PaymentAccountCounts responses: '200': description: A successful response. schema: type: object properties: - payment_account_count: + payment_account_counts: type: array items: type: object @@ -1206,138 +1081,31 @@ paths: type: boolean tags: - Query - /greenfield/payment/payment_account_count/{owner}: + /greenfield/payment/payment_accounts: get: - summary: Queries a PaymentAccountCount by index. - operationId: PaymentAccountCount + summary: Queries all payment accounts. + operationId: PaymentAccounts responses: '200': description: A successful response. schema: type: object properties: - payment_account_count: - type: object - properties: - owner: - type: string - title: owner is the account address - count: - type: string - format: uint64 - title: count is the number of payment accounts for the account - title: >- - PaymentAccountCount defines the state struct which stores the - number of payment accounts for an account - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: + payment_accounts: type: array items: type: object properties: - type_url: - type: string - value: - type: string - format: byte - parameters: - - name: owner - in: path - required: true - type: string - tags: - - Query - /greenfield/payment/stream_record: - get: - summary: Queries a list of StreamRecord items. - operationId: StreamRecordAll - responses: - '200': - description: A successful response. - schema: - type: object - properties: - stream_record: - type: array - items: - type: object - properties: - account: - type: string - title: account address - crud_timestamp: - type: string - format: int64 - title: latest update timestamp of the stream record - netflow_rate: - type: string - description: >- - The per-second rate that an account's balance is - changing. - - It is the sum of the account's inbound and outbound flow - rates. - static_balance: - type: string - description: >- - The balance of the stream account at the latest CRUD - timestamp. - buffer_balance: - type: string - title: >- - reserved balance of the stream account - - If the netflow rate is negative, the reserved balance is - `netflow_rate * reserve_time` - lock_balance: - type: string - title: >- - the locked balance of the stream account after it puts a - new object and before the object is sealed - status: - title: the status of the stream account - type: string - enum: - - STREAM_ACCOUNT_STATUS_ACTIVE - - STREAM_ACCOUNT_STATUS_FROZEN - default: STREAM_ACCOUNT_STATUS_ACTIVE - description: >- - - STREAM_ACCOUNT_STATUS_ACTIVE: - STREAM_ACCOUNT_STATUS_ACTIVE defines the active status - of a stream account. - - STREAM_ACCOUNT_STATUS_FROZEN: STREAM_ACCOUNT_STATUS_FROZEN defines the frozen status of a stream account. - A frozen stream account cannot be used as payment - address for buckets. - - It can be unfrozen by depositing more BNB to the stream - account. - settle_timestamp: - type: string - format: int64 - title: >- - the unix timestamp when the stream account will be - settled - out_flow_count: + addr: type: string - format: uint64 - title: the count of its out flows - frozen_netflow_rate: + title: the address of the payment account + owner: type: string - title: >- - the frozen netflow rate, which is used when resuming - stream account - title: Stream Payment Record of a stream account + title: the owner address of the payment account + refundable: + type: boolean + title: whether the payment account is refundable + title: PaymentAccount defines a payment account pagination: type: object properties: @@ -1447,9 +1215,52 @@ paths: type: boolean tags: - Query + /greenfield/payment/payment_accounts_by_owner/{owner}: + get: + summary: Queries all payment accounts by a owner. + operationId: PaymentAccountsByOwner + responses: + '200': + description: A successful response. + schema: + type: object + properties: + paymentAccounts: + type: array + items: + type: string + 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: owner + in: path + required: true + type: string + tags: + - Query /greenfield/payment/stream_record/{account}: get: - summary: Queries a StreamRecord by index. + summary: Queries a stream record by account. operationId: StreamRecord responses: '200': @@ -1551,6 +1362,195 @@ paths: type: string tags: - Query + /greenfield/payment/stream_records: + get: + summary: Queries all stream records. + operationId: StreamRecords + responses: + '200': + description: A successful response. + schema: + type: object + properties: + stream_records: + type: array + items: + type: object + properties: + account: + type: string + title: account address + crud_timestamp: + type: string + format: int64 + title: latest update timestamp of the stream record + netflow_rate: + type: string + description: >- + The per-second rate that an account's balance is + changing. + + It is the sum of the account's inbound and outbound flow + rates. + static_balance: + type: string + description: >- + The balance of the stream account at the latest CRUD + timestamp. + buffer_balance: + type: string + title: >- + reserved balance of the stream account + + If the netflow rate is negative, the reserved balance is + `netflow_rate * reserve_time` + lock_balance: + type: string + title: >- + the locked balance of the stream account after it puts a + new object and before the object is sealed + status: + title: the status of the stream account + type: string + enum: + - STREAM_ACCOUNT_STATUS_ACTIVE + - STREAM_ACCOUNT_STATUS_FROZEN + default: STREAM_ACCOUNT_STATUS_ACTIVE + description: >- + - STREAM_ACCOUNT_STATUS_ACTIVE: + STREAM_ACCOUNT_STATUS_ACTIVE defines the active status + of a stream account. + - STREAM_ACCOUNT_STATUS_FROZEN: STREAM_ACCOUNT_STATUS_FROZEN defines the frozen status of a stream account. + A frozen stream account cannot be used as payment + address for buckets. + + It can be unfrozen by depositing more BNB to the stream + account. + settle_timestamp: + type: string + format: int64 + title: >- + the unix timestamp when the stream account will be + settled + out_flow_count: + type: string + format: uint64 + title: the count of its out flows + frozen_netflow_rate: + type: string + title: >- + the frozen netflow rate, which is used when resuming + stream account + title: Stream Payment Record of a stream account + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + 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: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query /greenfield/sp/get_secondary_sp_store_price_by_time/{timestamp}: get: summary: get secondary store price by time @@ -3609,10 +3609,10 @@ paths: type: boolean tags: - Query - /greenfield/storage/list_group/{group_owner}: + /greenfield/storage/list_groups/{group_owner}: get: summary: Queries a list of ListGroup items. - operationId: ListGroup + operationId: ListGroups responses: '200': description: A successful response. @@ -31941,10 +31941,10 @@ definitions: title: >- PaymentAccountCount defines the state struct which stores the number of payment accounts for an account - greenfield.payment.QueryAllAutoSettleRecordResponse: + greenfield.payment.QueryAutoSettleRecordsResponse: type: object properties: - auto_settle_record: + auto_settle_records: type: array items: type: object @@ -31992,184 +31992,6 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - greenfield.payment.QueryAllPaymentAccountCountResponse: - type: object - properties: - payment_account_count: - type: array - items: - type: object - properties: - owner: - type: string - title: owner is the account address - count: - type: string - format: uint64 - title: count is the number of payment accounts for the account - title: >- - PaymentAccountCount defines the state struct which stores the number - of payment accounts for an account - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - greenfield.payment.QueryAllPaymentAccountResponse: - type: object - properties: - payment_account: - type: array - items: - type: object - properties: - addr: - type: string - title: the address of the payment account - owner: - type: string - title: the owner address of the payment account - refundable: - type: boolean - title: whether the payment account is refundable - title: PaymentAccount defines a payment account - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - greenfield.payment.QueryAllStreamRecordResponse: - type: object - properties: - stream_record: - type: array - items: - type: object - properties: - account: - type: string - title: account address - crud_timestamp: - type: string - format: int64 - title: latest update timestamp of the stream record - netflow_rate: - type: string - description: |- - The per-second rate that an account's balance is changing. - It is the sum of the account's inbound and outbound flow rates. - static_balance: - type: string - description: The balance of the stream account at the latest CRUD timestamp. - buffer_balance: - type: string - title: >- - reserved balance of the stream account - - If the netflow rate is negative, the reserved balance is - `netflow_rate * reserve_time` - lock_balance: - type: string - title: >- - the locked balance of the stream account after it puts a new - object and before the object is sealed - status: - title: the status of the stream account - type: string - enum: - - STREAM_ACCOUNT_STATUS_ACTIVE - - STREAM_ACCOUNT_STATUS_FROZEN - default: STREAM_ACCOUNT_STATUS_ACTIVE - description: >- - - STREAM_ACCOUNT_STATUS_ACTIVE: STREAM_ACCOUNT_STATUS_ACTIVE - defines the active status of a stream account. - - STREAM_ACCOUNT_STATUS_FROZEN: STREAM_ACCOUNT_STATUS_FROZEN defines the frozen status of a stream account. - A frozen stream account cannot be used as payment address for - buckets. - - It can be unfrozen by depositing more BNB to the stream account. - settle_timestamp: - type: string - format: int64 - title: the unix timestamp when the stream account will be settled - out_flow_count: - type: string - format: uint64 - title: the count of its out flows - frozen_netflow_rate: - type: string - title: >- - the frozen netflow rate, which is used when resuming stream - account - title: Stream Payment Record of a stream account - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } greenfield.payment.QueryDynamicBalanceResponse: type: object properties: @@ -32253,45 +32075,6 @@ definitions: change_rate: type: string title: change_rate is the netflow rate of the given account - greenfield.payment.QueryGetPaymentAccountCountResponse: - type: object - properties: - payment_account_count: - type: object - properties: - owner: - type: string - title: owner is the account address - count: - type: string - format: uint64 - title: count is the number of payment accounts for the account - title: >- - PaymentAccountCount defines the state struct which stores the number - of payment accounts for an account - greenfield.payment.QueryGetPaymentAccountResponse: - type: object - properties: - payment_account: - type: object - properties: - addr: - type: string - title: the address of the payment account - owner: - type: string - title: the owner address of the payment account - refundable: - type: boolean - title: whether the payment account is refundable - title: PaymentAccount defines a payment account - greenfield.payment.QueryGetPaymentAccountsByOwnerResponse: - type: object - properties: - paymentAccounts: - type: array - items: - type: string greenfield.payment.QueryGetStreamRecordResponse: type: object properties: @@ -32490,6 +32273,223 @@ definitions: type: string title: The denom of fee charged in payment module description: QueryParamsResponse is response type for the Query/Params RPC method. + greenfield.payment.QueryPaymentAccountCountResponse: + type: object + properties: + payment_account_count: + type: object + properties: + owner: + type: string + title: owner is the account address + count: + type: string + format: uint64 + title: count is the number of payment accounts for the account + title: >- + PaymentAccountCount defines the state struct which stores the number + of payment accounts for an account + greenfield.payment.QueryPaymentAccountCountsResponse: + type: object + properties: + payment_account_counts: + type: array + items: + type: object + properties: + owner: + type: string + title: owner is the account address + count: + type: string + format: uint64 + title: count is the number of payment accounts for the account + title: >- + PaymentAccountCount defines the state struct which stores the number + of payment accounts for an account + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + greenfield.payment.QueryPaymentAccountResponse: + type: object + properties: + payment_account: + type: object + properties: + addr: + type: string + title: the address of the payment account + owner: + type: string + title: the owner address of the payment account + refundable: + type: boolean + title: whether the payment account is refundable + title: PaymentAccount defines a payment account + greenfield.payment.QueryPaymentAccountsByOwnerResponse: + type: object + properties: + paymentAccounts: + type: array + items: + type: string + greenfield.payment.QueryPaymentAccountsResponse: + type: object + properties: + payment_accounts: + type: array + items: + type: object + properties: + addr: + type: string + title: the address of the payment account + owner: + type: string + title: the owner address of the payment account + refundable: + type: boolean + title: whether the payment account is refundable + title: PaymentAccount defines a payment account + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + greenfield.payment.QueryStreamRecordsResponse: + type: object + properties: + stream_records: + type: array + items: + type: object + properties: + account: + type: string + title: account address + crud_timestamp: + type: string + format: int64 + title: latest update timestamp of the stream record + netflow_rate: + type: string + description: |- + The per-second rate that an account's balance is changing. + It is the sum of the account's inbound and outbound flow rates. + static_balance: + type: string + description: The balance of the stream account at the latest CRUD timestamp. + buffer_balance: + type: string + title: >- + reserved balance of the stream account + + If the netflow rate is negative, the reserved balance is + `netflow_rate * reserve_time` + lock_balance: + type: string + title: >- + the locked balance of the stream account after it puts a new + object and before the object is sealed + status: + title: the status of the stream account + type: string + enum: + - STREAM_ACCOUNT_STATUS_ACTIVE + - STREAM_ACCOUNT_STATUS_FROZEN + default: STREAM_ACCOUNT_STATUS_ACTIVE + description: >- + - STREAM_ACCOUNT_STATUS_ACTIVE: STREAM_ACCOUNT_STATUS_ACTIVE + defines the active status of a stream account. + - STREAM_ACCOUNT_STATUS_FROZEN: STREAM_ACCOUNT_STATUS_FROZEN defines the frozen status of a stream account. + A frozen stream account cannot be used as payment address for + buckets. + + It can be unfrozen by depositing more BNB to the stream account. + settle_timestamp: + type: string + format: int64 + title: the unix timestamp when the stream account will be settled + out_flow_count: + type: string + format: uint64 + title: the count of its out flows + frozen_netflow_rate: + type: string + title: >- + the frozen netflow rate, which is used when resuming stream + account + title: Stream Payment Record of a stream account + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } greenfield.payment.StreamAccountStatus: type: string enum: @@ -34367,7 +34367,7 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - greenfield.storage.QueryListGroupResponse: + greenfield.storage.QueryListGroupsResponse: type: object properties: pagination: diff --git a/x/challenge/client/cli/query.go b/x/challenge/client/cli/query.go index fc0d8924f..c084f1861 100644 --- a/x/challenge/client/cli/query.go +++ b/x/challenge/client/cli/query.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "strconv" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -23,6 +24,7 @@ func GetQueryCmd() *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdLatestAttestedChallenges()) + cmd.AddCommand(CmdAttestedChallenge()) cmd.AddCommand(CmdInturnChallenger()) // this line is used by starport scaffolding # 1 @@ -54,6 +56,42 @@ func CmdQueryParams() *cobra.Command { return cmd } +func CmdAttestedChallenge() *cobra.Command { + cmd := &cobra.Command{ + Use: "attested-challenge", + Short: "Query result for an attested challenge", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argChallengeId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("challenge-id %s not a valid uint, please input a valid challenge-id", args[0]) + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryAttestedChallengeRequest{ + ChallengeId: argChallengeId, + } + + res, err := queryClient.AttestedChallenge(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + func CmdLatestAttestedChallenges() *cobra.Command { cmd := &cobra.Command{ Use: "latest-attested-challenges", @@ -68,9 +106,9 @@ func CmdLatestAttestedChallenges() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryLatestAttestedChallengesRequest{} + req := &types.QueryLatestAttestedChallengesRequest{} - res, err := queryClient.LatestAttestedChallenges(cmd.Context(), params) + res, err := queryClient.LatestAttestedChallenges(cmd.Context(), req) if err != nil { return err } diff --git a/x/payment/client/cli/query_auto_settle_record.go b/x/payment/client/cli/query_auto_settle_record.go index 259f0e01e..3f82c489a 100644 --- a/x/payment/client/cli/query_auto_settle_record.go +++ b/x/payment/client/cli/query_auto_settle_record.go @@ -24,11 +24,11 @@ func CmdListAutoSettleRecord() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryAllAutoSettleRecordRequest{ + params := &types.QueryAutoSettleRecordsRequest{ Pagination: pageReq, } - res, err := queryClient.AutoSettleRecordAll(context.Background(), params) + res, err := queryClient.AutoSettleRecords(context.Background(), params) if err != nil { return err } diff --git a/x/payment/client/cli/query_get_payment_accounts_by_owner.go b/x/payment/client/cli/query_get_payment_accounts_by_owner.go index 1524fa0ca..216637382 100644 --- a/x/payment/client/cli/query_get_payment_accounts_by_owner.go +++ b/x/payment/client/cli/query_get_payment_accounts_by_owner.go @@ -27,12 +27,12 @@ func CmdGetPaymentAccountsByOwner() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryGetPaymentAccountsByOwnerRequest{ + params := &types.QueryPaymentAccountsByOwnerRequest{ Owner: reqOwner, } - res, err := queryClient.GetPaymentAccountsByOwner(cmd.Context(), params) + res, err := queryClient.PaymentAccountsByOwner(cmd.Context(), params) if err != nil { return err } diff --git a/x/payment/client/cli/query_payment_account.go b/x/payment/client/cli/query_payment_account.go index 3b5d4c5cd..891d57282 100644 --- a/x/payment/client/cli/query_payment_account.go +++ b/x/payment/client/cli/query_payment_account.go @@ -24,11 +24,11 @@ func CmdListPaymentAccount() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryAllPaymentAccountRequest{ + params := &types.QueryPaymentAccountsRequest{ Pagination: pageReq, } - res, err := queryClient.PaymentAccountAll(context.Background(), params) + res, err := queryClient.PaymentAccounts(context.Background(), params) if err != nil { return err } @@ -55,7 +55,7 @@ func CmdShowPaymentAccount() *cobra.Command { argAddr := args[0] - params := &types.QueryGetPaymentAccountRequest{ + params := &types.QueryPaymentAccountRequest{ Addr: argAddr, } diff --git a/x/payment/client/cli/query_payment_account_count.go b/x/payment/client/cli/query_payment_account_count.go index 3fdbb9a3f..8bc6a74e8 100644 --- a/x/payment/client/cli/query_payment_account_count.go +++ b/x/payment/client/cli/query_payment_account_count.go @@ -24,11 +24,11 @@ func CmdListPaymentAccountCount() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryAllPaymentAccountCountRequest{ + params := &types.QueryPaymentAccountCountsRequest{ Pagination: pageReq, } - res, err := queryClient.PaymentAccountCountAll(context.Background(), params) + res, err := queryClient.PaymentAccountCounts(context.Background(), params) if err != nil { return err } @@ -55,7 +55,7 @@ func CmdShowPaymentAccountCount() *cobra.Command { argOwner := args[0] - params := &types.QueryGetPaymentAccountCountRequest{ + params := &types.QueryPaymentAccountCountRequest{ Owner: argOwner, } diff --git a/x/payment/client/cli/query_stream_record.go b/x/payment/client/cli/query_stream_record.go index 227d83274..30c114ac7 100644 --- a/x/payment/client/cli/query_stream_record.go +++ b/x/payment/client/cli/query_stream_record.go @@ -24,11 +24,11 @@ func CmdListStreamRecord() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryAllStreamRecordRequest{ + params := &types.QueryStreamRecordsRequest{ Pagination: pageReq, } - res, err := queryClient.StreamRecordAll(context.Background(), params) + res, err := queryClient.StreamRecords(context.Background(), params) if err != nil { return err } diff --git a/x/payment/client/cli/query_test.go b/x/payment/client/cli/query_test.go index 3428869ee..7d791d968 100644 --- a/x/payment/client/cli/query_test.go +++ b/x/payment/client/cli/query_test.go @@ -54,7 +54,7 @@ func (s *CLITestSuite) TestQueryCmd() { }, commonFlags..., ), - false, "", &types.QueryGetPaymentAccountsByOwnerResponse{}, + false, "", &types.QueryPaymentAccountsByOwnerResponse{}, }, { "query list-auto-settle-record", @@ -64,7 +64,7 @@ func (s *CLITestSuite) TestQueryCmd() { }, commonFlags..., ), - false, "", &types.QueryAllAutoSettleRecordResponse{}, + false, "", &types.QueryAutoSettleRecordsResponse{}, }, { "query list-payment-account", @@ -74,7 +74,7 @@ func (s *CLITestSuite) TestQueryCmd() { }, commonFlags..., ), - false, "", &types.QueryAllPaymentAccountResponse{}, + false, "", &types.QueryPaymentAccountsResponse{}, }, { "query list-payment-account-count", @@ -84,7 +84,7 @@ func (s *CLITestSuite) TestQueryCmd() { }, commonFlags..., ), - false, "", &types.QueryAllPaymentAccountCountResponse{}, + false, "", &types.QueryPaymentAccountCountsResponse{}, }, { "query list-stream-record", @@ -94,7 +94,7 @@ func (s *CLITestSuite) TestQueryCmd() { }, commonFlags..., ), - false, "", &types.QueryAllStreamRecordResponse{}, + false, "", &types.QueryStreamRecordsResponse{}, }, { "query show-payment-account", @@ -105,7 +105,7 @@ func (s *CLITestSuite) TestQueryCmd() { }, commonFlags..., ), - false, "", &types.QueryGetPaymentAccountResponse{}, + false, "", &types.QueryPaymentAccountResponse{}, }, { "query show-payment-account-count", @@ -116,7 +116,7 @@ func (s *CLITestSuite) TestQueryCmd() { }, commonFlags..., ), - false, "", &types.QueryGetPaymentAccountCountResponse{}, + false, "", &types.QueryPaymentAccountCountResponse{}, }, { "query show-stream-record", diff --git a/x/payment/keeper/grpc_query_auto_settle_record.go b/x/payment/keeper/grpc_query_auto_settle_record.go index 19ca00298..25d7161a4 100644 --- a/x/payment/keeper/grpc_query_auto_settle_record.go +++ b/x/payment/keeper/grpc_query_auto_settle_record.go @@ -12,14 +12,17 @@ import ( "github.com/bnb-chain/greenfield/x/payment/types" ) -func (k Keeper) AutoSettleRecordAll(c context.Context, req *types.QueryAllAutoSettleRecordRequest) (*types.QueryAllAutoSettleRecordResponse, error) { +func (k Keeper) AutoSettleRecords(c context.Context, req *types.QueryAutoSettleRecordsRequest) (*types.QueryAutoSettleRecordsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - var autoSettleRecords []types.AutoSettleRecord ctx := sdk.UnwrapSDKContext(c) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } + var autoSettleRecords []types.AutoSettleRecord store := ctx.KVStore(k.storeKey) autoSettleRecordStore := prefix.NewStore(store, types.AutoSettleRecordKeyPrefix) @@ -33,5 +36,5 @@ func (k Keeper) AutoSettleRecordAll(c context.Context, req *types.QueryAllAutoSe return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAllAutoSettleRecordResponse{AutoSettleRecord: autoSettleRecords, Pagination: pageRes}, nil + return &types.QueryAutoSettleRecordsResponse{AutoSettleRecords: autoSettleRecords, Pagination: pageRes}, nil } diff --git a/x/payment/keeper/grpc_query_payment_account.go b/x/payment/keeper/grpc_query_payment_account.go index 30ae28348..b84dbcbbb 100644 --- a/x/payment/keeper/grpc_query_payment_account.go +++ b/x/payment/keeper/grpc_query_payment_account.go @@ -12,14 +12,17 @@ import ( "github.com/bnb-chain/greenfield/x/payment/types" ) -func (k Keeper) PaymentAccountAll(c context.Context, req *types.QueryAllPaymentAccountRequest) (*types.QueryAllPaymentAccountResponse, error) { +func (k Keeper) PaymentAccounts(c context.Context, req *types.QueryPaymentAccountsRequest) (*types.QueryPaymentAccountsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - var paymentAccounts []types.PaymentAccount ctx := sdk.UnwrapSDKContext(c) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } + var paymentAccounts []types.PaymentAccount store := ctx.KVStore(k.storeKey) paymentAccountStore := prefix.NewStore(store, types.PaymentAccountKeyPrefix) @@ -38,10 +41,10 @@ func (k Keeper) PaymentAccountAll(c context.Context, req *types.QueryAllPaymentA return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAllPaymentAccountResponse{PaymentAccount: paymentAccounts, Pagination: pageRes}, nil + return &types.QueryPaymentAccountsResponse{PaymentAccounts: paymentAccounts, Pagination: pageRes}, nil } -func (k Keeper) PaymentAccount(c context.Context, req *types.QueryGetPaymentAccountRequest) (*types.QueryGetPaymentAccountResponse, error) { +func (k Keeper) PaymentAccount(c context.Context, req *types.QueryPaymentAccountRequest) (*types.QueryPaymentAccountResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -59,5 +62,5 @@ func (k Keeper) PaymentAccount(c context.Context, req *types.QueryGetPaymentAcco return nil, status.Error(codes.NotFound, "not found") } - return &types.QueryGetPaymentAccountResponse{PaymentAccount: *val}, nil + return &types.QueryPaymentAccountResponse{PaymentAccount: *val}, nil } diff --git a/x/payment/keeper/grpc_query_payment_account_count.go b/x/payment/keeper/grpc_query_payment_account_count.go index 67bb1a318..66c5b8bfd 100644 --- a/x/payment/keeper/grpc_query_payment_account_count.go +++ b/x/payment/keeper/grpc_query_payment_account_count.go @@ -12,14 +12,17 @@ import ( "github.com/bnb-chain/greenfield/x/payment/types" ) -func (k Keeper) PaymentAccountCountAll(c context.Context, req *types.QueryAllPaymentAccountCountRequest) (*types.QueryAllPaymentAccountCountResponse, error) { +func (k Keeper) PaymentAccountCounts(c context.Context, req *types.QueryPaymentAccountCountsRequest) (*types.QueryPaymentAccountCountsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - var paymentAccountCounts []types.PaymentAccountCount ctx := sdk.UnwrapSDKContext(c) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } + var paymentAccountCounts []types.PaymentAccountCount store := ctx.KVStore(k.storeKey) paymentAccountCountStore := prefix.NewStore(store, types.PaymentAccountCountKeyPrefix) @@ -38,10 +41,10 @@ func (k Keeper) PaymentAccountCountAll(c context.Context, req *types.QueryAllPay return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAllPaymentAccountCountResponse{PaymentAccountCount: paymentAccountCounts, Pagination: pageRes}, nil + return &types.QueryPaymentAccountCountsResponse{PaymentAccountCounts: paymentAccountCounts, Pagination: pageRes}, nil } -func (k Keeper) PaymentAccountCount(c context.Context, req *types.QueryGetPaymentAccountCountRequest) (*types.QueryGetPaymentAccountCountResponse, error) { +func (k Keeper) PaymentAccountCount(c context.Context, req *types.QueryPaymentAccountCountRequest) (*types.QueryPaymentAccountCountResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -59,5 +62,5 @@ func (k Keeper) PaymentAccountCount(c context.Context, req *types.QueryGetPaymen return nil, status.Error(codes.NotFound, "not found") } - return &types.QueryGetPaymentAccountCountResponse{PaymentAccountCount: *val}, nil + return &types.QueryPaymentAccountCountResponse{PaymentAccountCount: *val}, nil } diff --git a/x/payment/keeper/grpc_query_get_payment_accounts_by_owner.go b/x/payment/keeper/grpc_query_payment_accounts_by_owner.go similarity index 79% rename from x/payment/keeper/grpc_query_get_payment_accounts_by_owner.go rename to x/payment/keeper/grpc_query_payment_accounts_by_owner.go index d5c158b1c..e8a561db2 100644 --- a/x/payment/keeper/grpc_query_get_payment_accounts_by_owner.go +++ b/x/payment/keeper/grpc_query_payment_accounts_by_owner.go @@ -10,7 +10,7 @@ import ( "github.com/bnb-chain/greenfield/x/payment/types" ) -func (k Keeper) GetPaymentAccountsByOwner(goCtx context.Context, req *types.QueryGetPaymentAccountsByOwnerRequest) (*types.QueryGetPaymentAccountsByOwnerResponse, error) { +func (k Keeper) PaymentAccountsByOwner(goCtx context.Context, req *types.QueryPaymentAccountsByOwnerRequest) (*types.QueryPaymentAccountsByOwnerResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -33,7 +33,7 @@ func (k Keeper) GetPaymentAccountsByOwner(goCtx context.Context, req *types.Quer paymentAccounts = append(paymentAccounts, paymentAccount.String()) } - return &types.QueryGetPaymentAccountsByOwnerResponse{ + return &types.QueryPaymentAccountsByOwnerResponse{ PaymentAccounts: paymentAccounts, }, nil } diff --git a/x/payment/keeper/grpc_query_stream_record.go b/x/payment/keeper/grpc_query_stream_record.go index a2a223ebb..42cc2fc3d 100644 --- a/x/payment/keeper/grpc_query_stream_record.go +++ b/x/payment/keeper/grpc_query_stream_record.go @@ -12,14 +12,17 @@ import ( "github.com/bnb-chain/greenfield/x/payment/types" ) -func (k Keeper) StreamRecordAll(c context.Context, req *types.QueryAllStreamRecordRequest) (*types.QueryAllStreamRecordResponse, error) { +func (k Keeper) StreamRecords(c context.Context, req *types.QueryStreamRecordsRequest) (*types.QueryStreamRecordsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - var streamRecords []types.StreamRecord ctx := sdk.UnwrapSDKContext(c) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } + var streamRecords []types.StreamRecord store := ctx.KVStore(k.storeKey) streamRecordStore := prefix.NewStore(store, types.StreamRecordKeyPrefix) @@ -38,7 +41,7 @@ func (k Keeper) StreamRecordAll(c context.Context, req *types.QueryAllStreamReco return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAllStreamRecordResponse{StreamRecord: streamRecords, Pagination: pageRes}, nil + return &types.QueryStreamRecordsResponse{StreamRecords: streamRecords, Pagination: pageRes}, nil } func (k Keeper) StreamRecord(c context.Context, req *types.QueryGetStreamRecordRequest) (*types.QueryGetStreamRecordResponse, error) { diff --git a/x/payment/keeper/grpc_query_test.go b/x/payment/keeper/grpc_query_test.go index b7ce3a41f..db2d30d30 100644 --- a/x/payment/keeper/grpc_query_test.go +++ b/x/payment/keeper/grpc_query_test.go @@ -65,9 +65,9 @@ func TestAutoSettleRecordQuery(t *testing.T) { } keeper.SetAutoSettleRecord(ctx, &record) - response, err := keeper.AutoSettleRecordAll(ctx, &types.QueryAllAutoSettleRecordRequest{}) + response, err := keeper.AutoSettleRecords(ctx, &types.QueryAutoSettleRecordsRequest{}) require.NoError(t, err) - require.Equal(t, record, response.AutoSettleRecord[0]) + require.Equal(t, record, response.AutoSettleRecords[0]) } func TestDynamicBalanceQuery(t *testing.T) { @@ -113,9 +113,9 @@ func TestPaymentAccountAllQuery(t *testing.T) { } keeper.SetPaymentAccount(ctx, &record2) - response, err := keeper.PaymentAccountAll(ctx, &types.QueryAllPaymentAccountRequest{}) + response, err := keeper.PaymentAccounts(ctx, &types.QueryPaymentAccountsRequest{}) require.NoError(t, err) - require.Equal(t, 2, len(response.PaymentAccount)) + require.Equal(t, 2, len(response.PaymentAccounts)) } func TestPaymentAccountQuery(t *testing.T) { @@ -140,13 +140,13 @@ func TestPaymentAccountQuery(t *testing.T) { } keeper.SetPaymentAccount(ctx, &record2) - response, err := keeper.PaymentAccount(ctx, &types.QueryGetPaymentAccountRequest{ + response, err := keeper.PaymentAccount(ctx, &types.QueryPaymentAccountRequest{ Addr: addr1, }) require.NoError(t, err) require.Equal(t, owner1.String(), response.PaymentAccount.Owner) - response, err = keeper.PaymentAccount(ctx, &types.QueryGetPaymentAccountRequest{ + response, err = keeper.PaymentAccount(ctx, &types.QueryPaymentAccountRequest{ Addr: addr2, }) require.NoError(t, err) @@ -173,9 +173,9 @@ func TestPaymentAccountCountAllQuery(t *testing.T) { } keeper.SetPaymentAccountCount(ctx, &record2) - response, err := keeper.PaymentAccountCountAll(ctx, &types.QueryAllPaymentAccountCountRequest{}) + response, err := keeper.PaymentAccountCounts(ctx, &types.QueryPaymentAccountCountsRequest{}) require.NoError(t, err) - require.Equal(t, 2, len(response.PaymentAccountCount)) + require.Equal(t, 2, len(response.PaymentAccountCounts)) } func TestPaymentAccountCountQuery(t *testing.T) { @@ -198,13 +198,13 @@ func TestPaymentAccountCountQuery(t *testing.T) { } keeper.SetPaymentAccountCount(ctx, &record2) - response, err := keeper.PaymentAccountCount(ctx, &types.QueryGetPaymentAccountCountRequest{ + response, err := keeper.PaymentAccountCount(ctx, &types.QueryPaymentAccountCountRequest{ Owner: owner1.String(), }) require.NoError(t, err) require.Equal(t, record1.Count, response.PaymentAccountCount.Count) - response, err = keeper.PaymentAccountCount(ctx, &types.QueryGetPaymentAccountCountRequest{ + response, err = keeper.PaymentAccountCount(ctx, &types.QueryPaymentAccountCountRequest{ Owner: owner2.String(), }) require.NoError(t, err) @@ -224,7 +224,7 @@ func TestPaymentAccountsByOwnerQuery(t *testing.T) { } keeper.SetPaymentAccountCount(ctx, &record1) - response, err := keeper.GetPaymentAccountsByOwner(ctx, &types.QueryGetPaymentAccountsByOwnerRequest{ + response, err := keeper.PaymentAccountsByOwner(ctx, &types.QueryPaymentAccountsByOwnerRequest{ Owner: owner1.String(), }) require.NoError(t, err) @@ -245,9 +245,9 @@ func TestStreamRecordAllQuery(t *testing.T) { record2 := types.NewStreamRecord(owner2, ctx.BlockTime().Unix()) keeper.SetStreamRecord(ctx, record2) - response, err := keeper.StreamRecordAll(ctx, &types.QueryAllStreamRecordRequest{}) + response, err := keeper.StreamRecords(ctx, &types.QueryStreamRecordsRequest{}) require.NoError(t, err) - require.Equal(t, 2, len(response.StreamRecord)) + require.Equal(t, 2, len(response.StreamRecords)) } func TestStreamRecordQuery(t *testing.T) { diff --git a/x/payment/types/query.pb.go b/x/payment/types/query.pb.go index ebcbb96ca..f4aba3360 100644 --- a/x/payment/types/query.pb.go +++ b/x/payment/types/query.pb.go @@ -383,22 +383,22 @@ func (m *QueryGetStreamRecordResponse) GetStreamRecord() StreamRecord { return StreamRecord{} } -type QueryAllStreamRecordRequest struct { +type QueryStreamRecordsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllStreamRecordRequest) Reset() { *m = QueryAllStreamRecordRequest{} } -func (m *QueryAllStreamRecordRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllStreamRecordRequest) ProtoMessage() {} -func (*QueryAllStreamRecordRequest) Descriptor() ([]byte, []int) { +func (m *QueryStreamRecordsRequest) Reset() { *m = QueryStreamRecordsRequest{} } +func (m *QueryStreamRecordsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStreamRecordsRequest) ProtoMessage() {} +func (*QueryStreamRecordsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{8} } -func (m *QueryAllStreamRecordRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryStreamRecordsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllStreamRecordRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryStreamRecordsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllStreamRecordRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryStreamRecordsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -408,42 +408,42 @@ func (m *QueryAllStreamRecordRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryAllStreamRecordRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllStreamRecordRequest.Merge(m, src) +func (m *QueryStreamRecordsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStreamRecordsRequest.Merge(m, src) } -func (m *QueryAllStreamRecordRequest) XXX_Size() int { +func (m *QueryStreamRecordsRequest) XXX_Size() int { return m.Size() } -func (m *QueryAllStreamRecordRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllStreamRecordRequest.DiscardUnknown(m) +func (m *QueryStreamRecordsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStreamRecordsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllStreamRecordRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryStreamRecordsRequest proto.InternalMessageInfo -func (m *QueryAllStreamRecordRequest) GetPagination() *query.PageRequest { +func (m *QueryStreamRecordsRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -type QueryAllStreamRecordResponse struct { - StreamRecord []StreamRecord `protobuf:"bytes,1,rep,name=stream_record,json=streamRecord,proto3" json:"stream_record"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +type QueryStreamRecordsResponse struct { + StreamRecords []StreamRecord `protobuf:"bytes,1,rep,name=stream_records,json=streamRecords,proto3" json:"stream_records"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllStreamRecordResponse) Reset() { *m = QueryAllStreamRecordResponse{} } -func (m *QueryAllStreamRecordResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllStreamRecordResponse) ProtoMessage() {} -func (*QueryAllStreamRecordResponse) Descriptor() ([]byte, []int) { +func (m *QueryStreamRecordsResponse) Reset() { *m = QueryStreamRecordsResponse{} } +func (m *QueryStreamRecordsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStreamRecordsResponse) ProtoMessage() {} +func (*QueryStreamRecordsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{9} } -func (m *QueryAllStreamRecordResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryStreamRecordsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllStreamRecordResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryStreamRecordsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllStreamRecordResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryStreamRecordsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -453,48 +453,48 @@ func (m *QueryAllStreamRecordResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryAllStreamRecordResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllStreamRecordResponse.Merge(m, src) +func (m *QueryStreamRecordsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStreamRecordsResponse.Merge(m, src) } -func (m *QueryAllStreamRecordResponse) XXX_Size() int { +func (m *QueryStreamRecordsResponse) XXX_Size() int { return m.Size() } -func (m *QueryAllStreamRecordResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllStreamRecordResponse.DiscardUnknown(m) +func (m *QueryStreamRecordsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStreamRecordsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllStreamRecordResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryStreamRecordsResponse proto.InternalMessageInfo -func (m *QueryAllStreamRecordResponse) GetStreamRecord() []StreamRecord { +func (m *QueryStreamRecordsResponse) GetStreamRecords() []StreamRecord { if m != nil { - return m.StreamRecord + return m.StreamRecords } return nil } -func (m *QueryAllStreamRecordResponse) GetPagination() *query.PageResponse { +func (m *QueryStreamRecordsResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } return nil } -type QueryGetPaymentAccountCountRequest struct { +type QueryPaymentAccountCountRequest struct { Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` } -func (m *QueryGetPaymentAccountCountRequest) Reset() { *m = QueryGetPaymentAccountCountRequest{} } -func (m *QueryGetPaymentAccountCountRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetPaymentAccountCountRequest) ProtoMessage() {} -func (*QueryGetPaymentAccountCountRequest) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountCountRequest) Reset() { *m = QueryPaymentAccountCountRequest{} } +func (m *QueryPaymentAccountCountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountCountRequest) ProtoMessage() {} +func (*QueryPaymentAccountCountRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{10} } -func (m *QueryGetPaymentAccountCountRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetPaymentAccountCountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountCountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetPaymentAccountCountRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountCountRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -504,41 +504,41 @@ func (m *QueryGetPaymentAccountCountRequest) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *QueryGetPaymentAccountCountRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetPaymentAccountCountRequest.Merge(m, src) +func (m *QueryPaymentAccountCountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountCountRequest.Merge(m, src) } -func (m *QueryGetPaymentAccountCountRequest) XXX_Size() int { +func (m *QueryPaymentAccountCountRequest) XXX_Size() int { return m.Size() } -func (m *QueryGetPaymentAccountCountRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetPaymentAccountCountRequest.DiscardUnknown(m) +func (m *QueryPaymentAccountCountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountCountRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetPaymentAccountCountRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountCountRequest proto.InternalMessageInfo -func (m *QueryGetPaymentAccountCountRequest) GetOwner() string { +func (m *QueryPaymentAccountCountRequest) GetOwner() string { if m != nil { return m.Owner } return "" } -type QueryGetPaymentAccountCountResponse struct { +type QueryPaymentAccountCountResponse struct { PaymentAccountCount PaymentAccountCount `protobuf:"bytes,1,opt,name=payment_account_count,json=paymentAccountCount,proto3" json:"payment_account_count"` } -func (m *QueryGetPaymentAccountCountResponse) Reset() { *m = QueryGetPaymentAccountCountResponse{} } -func (m *QueryGetPaymentAccountCountResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetPaymentAccountCountResponse) ProtoMessage() {} -func (*QueryGetPaymentAccountCountResponse) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountCountResponse) Reset() { *m = QueryPaymentAccountCountResponse{} } +func (m *QueryPaymentAccountCountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountCountResponse) ProtoMessage() {} +func (*QueryPaymentAccountCountResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{11} } -func (m *QueryGetPaymentAccountCountResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetPaymentAccountCountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountCountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetPaymentAccountCountResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountCountResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -548,41 +548,41 @@ func (m *QueryGetPaymentAccountCountResponse) XXX_Marshal(b []byte, deterministi return b[:n], nil } } -func (m *QueryGetPaymentAccountCountResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetPaymentAccountCountResponse.Merge(m, src) +func (m *QueryPaymentAccountCountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountCountResponse.Merge(m, src) } -func (m *QueryGetPaymentAccountCountResponse) XXX_Size() int { +func (m *QueryPaymentAccountCountResponse) XXX_Size() int { return m.Size() } -func (m *QueryGetPaymentAccountCountResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetPaymentAccountCountResponse.DiscardUnknown(m) +func (m *QueryPaymentAccountCountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountCountResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetPaymentAccountCountResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountCountResponse proto.InternalMessageInfo -func (m *QueryGetPaymentAccountCountResponse) GetPaymentAccountCount() PaymentAccountCount { +func (m *QueryPaymentAccountCountResponse) GetPaymentAccountCount() PaymentAccountCount { if m != nil { return m.PaymentAccountCount } return PaymentAccountCount{} } -type QueryAllPaymentAccountCountRequest struct { +type QueryPaymentAccountCountsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllPaymentAccountCountRequest) Reset() { *m = QueryAllPaymentAccountCountRequest{} } -func (m *QueryAllPaymentAccountCountRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllPaymentAccountCountRequest) ProtoMessage() {} -func (*QueryAllPaymentAccountCountRequest) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountCountsRequest) Reset() { *m = QueryPaymentAccountCountsRequest{} } +func (m *QueryPaymentAccountCountsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountCountsRequest) ProtoMessage() {} +func (*QueryPaymentAccountCountsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{12} } -func (m *QueryAllPaymentAccountCountRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountCountsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllPaymentAccountCountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountCountsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllPaymentAccountCountRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountCountsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -592,42 +592,42 @@ func (m *QueryAllPaymentAccountCountRequest) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *QueryAllPaymentAccountCountRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllPaymentAccountCountRequest.Merge(m, src) +func (m *QueryPaymentAccountCountsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountCountsRequest.Merge(m, src) } -func (m *QueryAllPaymentAccountCountRequest) XXX_Size() int { +func (m *QueryPaymentAccountCountsRequest) XXX_Size() int { return m.Size() } -func (m *QueryAllPaymentAccountCountRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllPaymentAccountCountRequest.DiscardUnknown(m) +func (m *QueryPaymentAccountCountsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountCountsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllPaymentAccountCountRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountCountsRequest proto.InternalMessageInfo -func (m *QueryAllPaymentAccountCountRequest) GetPagination() *query.PageRequest { +func (m *QueryPaymentAccountCountsRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -type QueryAllPaymentAccountCountResponse struct { - PaymentAccountCount []PaymentAccountCount `protobuf:"bytes,1,rep,name=payment_account_count,json=paymentAccountCount,proto3" json:"payment_account_count"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +type QueryPaymentAccountCountsResponse struct { + PaymentAccountCounts []PaymentAccountCount `protobuf:"bytes,1,rep,name=payment_account_counts,json=paymentAccountCounts,proto3" json:"payment_account_counts"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllPaymentAccountCountResponse) Reset() { *m = QueryAllPaymentAccountCountResponse{} } -func (m *QueryAllPaymentAccountCountResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllPaymentAccountCountResponse) ProtoMessage() {} -func (*QueryAllPaymentAccountCountResponse) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountCountsResponse) Reset() { *m = QueryPaymentAccountCountsResponse{} } +func (m *QueryPaymentAccountCountsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountCountsResponse) ProtoMessage() {} +func (*QueryPaymentAccountCountsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{13} } -func (m *QueryAllPaymentAccountCountResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountCountsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllPaymentAccountCountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountCountsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllPaymentAccountCountResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountCountsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -637,48 +637,48 @@ func (m *QueryAllPaymentAccountCountResponse) XXX_Marshal(b []byte, deterministi return b[:n], nil } } -func (m *QueryAllPaymentAccountCountResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllPaymentAccountCountResponse.Merge(m, src) +func (m *QueryPaymentAccountCountsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountCountsResponse.Merge(m, src) } -func (m *QueryAllPaymentAccountCountResponse) XXX_Size() int { +func (m *QueryPaymentAccountCountsResponse) XXX_Size() int { return m.Size() } -func (m *QueryAllPaymentAccountCountResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllPaymentAccountCountResponse.DiscardUnknown(m) +func (m *QueryPaymentAccountCountsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountCountsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllPaymentAccountCountResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountCountsResponse proto.InternalMessageInfo -func (m *QueryAllPaymentAccountCountResponse) GetPaymentAccountCount() []PaymentAccountCount { +func (m *QueryPaymentAccountCountsResponse) GetPaymentAccountCounts() []PaymentAccountCount { if m != nil { - return m.PaymentAccountCount + return m.PaymentAccountCounts } return nil } -func (m *QueryAllPaymentAccountCountResponse) GetPagination() *query.PageResponse { +func (m *QueryPaymentAccountCountsResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } return nil } -type QueryGetPaymentAccountRequest struct { +type QueryPaymentAccountRequest struct { Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` } -func (m *QueryGetPaymentAccountRequest) Reset() { *m = QueryGetPaymentAccountRequest{} } -func (m *QueryGetPaymentAccountRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetPaymentAccountRequest) ProtoMessage() {} -func (*QueryGetPaymentAccountRequest) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountRequest) Reset() { *m = QueryPaymentAccountRequest{} } +func (m *QueryPaymentAccountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountRequest) ProtoMessage() {} +func (*QueryPaymentAccountRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{14} } -func (m *QueryGetPaymentAccountRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetPaymentAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetPaymentAccountRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -688,41 +688,41 @@ func (m *QueryGetPaymentAccountRequest) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryGetPaymentAccountRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetPaymentAccountRequest.Merge(m, src) +func (m *QueryPaymentAccountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountRequest.Merge(m, src) } -func (m *QueryGetPaymentAccountRequest) XXX_Size() int { +func (m *QueryPaymentAccountRequest) XXX_Size() int { return m.Size() } -func (m *QueryGetPaymentAccountRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetPaymentAccountRequest.DiscardUnknown(m) +func (m *QueryPaymentAccountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetPaymentAccountRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountRequest proto.InternalMessageInfo -func (m *QueryGetPaymentAccountRequest) GetAddr() string { +func (m *QueryPaymentAccountRequest) GetAddr() string { if m != nil { return m.Addr } return "" } -type QueryGetPaymentAccountResponse struct { +type QueryPaymentAccountResponse struct { PaymentAccount PaymentAccount `protobuf:"bytes,1,opt,name=payment_account,json=paymentAccount,proto3" json:"payment_account"` } -func (m *QueryGetPaymentAccountResponse) Reset() { *m = QueryGetPaymentAccountResponse{} } -func (m *QueryGetPaymentAccountResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetPaymentAccountResponse) ProtoMessage() {} -func (*QueryGetPaymentAccountResponse) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountResponse) Reset() { *m = QueryPaymentAccountResponse{} } +func (m *QueryPaymentAccountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountResponse) ProtoMessage() {} +func (*QueryPaymentAccountResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{15} } -func (m *QueryGetPaymentAccountResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetPaymentAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetPaymentAccountResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -732,41 +732,41 @@ func (m *QueryGetPaymentAccountResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *QueryGetPaymentAccountResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetPaymentAccountResponse.Merge(m, src) +func (m *QueryPaymentAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountResponse.Merge(m, src) } -func (m *QueryGetPaymentAccountResponse) XXX_Size() int { +func (m *QueryPaymentAccountResponse) XXX_Size() int { return m.Size() } -func (m *QueryGetPaymentAccountResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetPaymentAccountResponse.DiscardUnknown(m) +func (m *QueryPaymentAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetPaymentAccountResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountResponse proto.InternalMessageInfo -func (m *QueryGetPaymentAccountResponse) GetPaymentAccount() PaymentAccount { +func (m *QueryPaymentAccountResponse) GetPaymentAccount() PaymentAccount { if m != nil { return m.PaymentAccount } return PaymentAccount{} } -type QueryAllPaymentAccountRequest struct { +type QueryPaymentAccountsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllPaymentAccountRequest) Reset() { *m = QueryAllPaymentAccountRequest{} } -func (m *QueryAllPaymentAccountRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllPaymentAccountRequest) ProtoMessage() {} -func (*QueryAllPaymentAccountRequest) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountsRequest) Reset() { *m = QueryPaymentAccountsRequest{} } +func (m *QueryPaymentAccountsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountsRequest) ProtoMessage() {} +func (*QueryPaymentAccountsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{16} } -func (m *QueryAllPaymentAccountRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllPaymentAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllPaymentAccountRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -776,42 +776,42 @@ func (m *QueryAllPaymentAccountRequest) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryAllPaymentAccountRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllPaymentAccountRequest.Merge(m, src) +func (m *QueryPaymentAccountsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountsRequest.Merge(m, src) } -func (m *QueryAllPaymentAccountRequest) XXX_Size() int { +func (m *QueryPaymentAccountsRequest) XXX_Size() int { return m.Size() } -func (m *QueryAllPaymentAccountRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllPaymentAccountRequest.DiscardUnknown(m) +func (m *QueryPaymentAccountsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllPaymentAccountRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountsRequest proto.InternalMessageInfo -func (m *QueryAllPaymentAccountRequest) GetPagination() *query.PageRequest { +func (m *QueryPaymentAccountsRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -type QueryAllPaymentAccountResponse struct { - PaymentAccount []PaymentAccount `protobuf:"bytes,1,rep,name=payment_account,json=paymentAccount,proto3" json:"payment_account"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +type QueryPaymentAccountsResponse struct { + PaymentAccounts []PaymentAccount `protobuf:"bytes,1,rep,name=payment_accounts,json=paymentAccounts,proto3" json:"payment_accounts"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllPaymentAccountResponse) Reset() { *m = QueryAllPaymentAccountResponse{} } -func (m *QueryAllPaymentAccountResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllPaymentAccountResponse) ProtoMessage() {} -func (*QueryAllPaymentAccountResponse) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountsResponse) Reset() { *m = QueryPaymentAccountsResponse{} } +func (m *QueryPaymentAccountsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountsResponse) ProtoMessage() {} +func (*QueryPaymentAccountsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{17} } -func (m *QueryAllPaymentAccountResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllPaymentAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllPaymentAccountResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -821,26 +821,26 @@ func (m *QueryAllPaymentAccountResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *QueryAllPaymentAccountResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllPaymentAccountResponse.Merge(m, src) +func (m *QueryPaymentAccountsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountsResponse.Merge(m, src) } -func (m *QueryAllPaymentAccountResponse) XXX_Size() int { +func (m *QueryPaymentAccountsResponse) XXX_Size() int { return m.Size() } -func (m *QueryAllPaymentAccountResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllPaymentAccountResponse.DiscardUnknown(m) +func (m *QueryPaymentAccountsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllPaymentAccountResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountsResponse proto.InternalMessageInfo -func (m *QueryAllPaymentAccountResponse) GetPaymentAccount() []PaymentAccount { +func (m *QueryPaymentAccountsResponse) GetPaymentAccounts() []PaymentAccount { if m != nil { - return m.PaymentAccount + return m.PaymentAccounts } return nil } -func (m *QueryAllPaymentAccountResponse) GetPagination() *query.PageResponse { +func (m *QueryPaymentAccountsResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } @@ -955,22 +955,22 @@ func (m *QueryDynamicBalanceResponse) GetCurrentTimestamp() int64 { return 0 } -type QueryGetPaymentAccountsByOwnerRequest struct { +type QueryPaymentAccountsByOwnerRequest struct { Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` } -func (m *QueryGetPaymentAccountsByOwnerRequest) Reset() { *m = QueryGetPaymentAccountsByOwnerRequest{} } -func (m *QueryGetPaymentAccountsByOwnerRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetPaymentAccountsByOwnerRequest) ProtoMessage() {} -func (*QueryGetPaymentAccountsByOwnerRequest) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountsByOwnerRequest) Reset() { *m = QueryPaymentAccountsByOwnerRequest{} } +func (m *QueryPaymentAccountsByOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountsByOwnerRequest) ProtoMessage() {} +func (*QueryPaymentAccountsByOwnerRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{20} } -func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountsByOwnerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountsByOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetPaymentAccountsByOwnerRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountsByOwnerRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -980,43 +980,41 @@ func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_Marshal(b []byte, determinis return b[:n], nil } } -func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetPaymentAccountsByOwnerRequest.Merge(m, src) +func (m *QueryPaymentAccountsByOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountsByOwnerRequest.Merge(m, src) } -func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_Size() int { +func (m *QueryPaymentAccountsByOwnerRequest) XXX_Size() int { return m.Size() } -func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetPaymentAccountsByOwnerRequest.DiscardUnknown(m) +func (m *QueryPaymentAccountsByOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountsByOwnerRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetPaymentAccountsByOwnerRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountsByOwnerRequest proto.InternalMessageInfo -func (m *QueryGetPaymentAccountsByOwnerRequest) GetOwner() string { +func (m *QueryPaymentAccountsByOwnerRequest) GetOwner() string { if m != nil { return m.Owner } return "" } -type QueryGetPaymentAccountsByOwnerResponse struct { +type QueryPaymentAccountsByOwnerResponse struct { PaymentAccounts []string `protobuf:"bytes,1,rep,name=paymentAccounts,proto3" json:"paymentAccounts,omitempty"` } -func (m *QueryGetPaymentAccountsByOwnerResponse) Reset() { - *m = QueryGetPaymentAccountsByOwnerResponse{} -} -func (m *QueryGetPaymentAccountsByOwnerResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetPaymentAccountsByOwnerResponse) ProtoMessage() {} -func (*QueryGetPaymentAccountsByOwnerResponse) Descriptor() ([]byte, []int) { +func (m *QueryPaymentAccountsByOwnerResponse) Reset() { *m = QueryPaymentAccountsByOwnerResponse{} } +func (m *QueryPaymentAccountsByOwnerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPaymentAccountsByOwnerResponse) ProtoMessage() {} +func (*QueryPaymentAccountsByOwnerResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{21} } -func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPaymentAccountsByOwnerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPaymentAccountsByOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetPaymentAccountsByOwnerResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPaymentAccountsByOwnerResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1026,41 +1024,41 @@ func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_Marshal(b []byte, determini return b[:n], nil } } -func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetPaymentAccountsByOwnerResponse.Merge(m, src) +func (m *QueryPaymentAccountsByOwnerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPaymentAccountsByOwnerResponse.Merge(m, src) } -func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_Size() int { +func (m *QueryPaymentAccountsByOwnerResponse) XXX_Size() int { return m.Size() } -func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetPaymentAccountsByOwnerResponse.DiscardUnknown(m) +func (m *QueryPaymentAccountsByOwnerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPaymentAccountsByOwnerResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetPaymentAccountsByOwnerResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPaymentAccountsByOwnerResponse proto.InternalMessageInfo -func (m *QueryGetPaymentAccountsByOwnerResponse) GetPaymentAccounts() []string { +func (m *QueryPaymentAccountsByOwnerResponse) GetPaymentAccounts() []string { if m != nil { return m.PaymentAccounts } return nil } -type QueryAllAutoSettleRecordRequest struct { +type QueryAutoSettleRecordsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllAutoSettleRecordRequest) Reset() { *m = QueryAllAutoSettleRecordRequest{} } -func (m *QueryAllAutoSettleRecordRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllAutoSettleRecordRequest) ProtoMessage() {} -func (*QueryAllAutoSettleRecordRequest) Descriptor() ([]byte, []int) { +func (m *QueryAutoSettleRecordsRequest) Reset() { *m = QueryAutoSettleRecordsRequest{} } +func (m *QueryAutoSettleRecordsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAutoSettleRecordsRequest) ProtoMessage() {} +func (*QueryAutoSettleRecordsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{22} } -func (m *QueryAllAutoSettleRecordRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryAutoSettleRecordsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllAutoSettleRecordRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAutoSettleRecordsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllAutoSettleRecordRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAutoSettleRecordsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1070,42 +1068,42 @@ func (m *QueryAllAutoSettleRecordRequest) XXX_Marshal(b []byte, deterministic bo return b[:n], nil } } -func (m *QueryAllAutoSettleRecordRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllAutoSettleRecordRequest.Merge(m, src) +func (m *QueryAutoSettleRecordsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAutoSettleRecordsRequest.Merge(m, src) } -func (m *QueryAllAutoSettleRecordRequest) XXX_Size() int { +func (m *QueryAutoSettleRecordsRequest) XXX_Size() int { return m.Size() } -func (m *QueryAllAutoSettleRecordRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllAutoSettleRecordRequest.DiscardUnknown(m) +func (m *QueryAutoSettleRecordsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAutoSettleRecordsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllAutoSettleRecordRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryAutoSettleRecordsRequest proto.InternalMessageInfo -func (m *QueryAllAutoSettleRecordRequest) GetPagination() *query.PageRequest { +func (m *QueryAutoSettleRecordsRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -type QueryAllAutoSettleRecordResponse struct { - AutoSettleRecord []AutoSettleRecord `protobuf:"bytes,1,rep,name=auto_settle_record,json=autoSettleRecord,proto3" json:"auto_settle_record"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +type QueryAutoSettleRecordsResponse struct { + AutoSettleRecords []AutoSettleRecord `protobuf:"bytes,1,rep,name=auto_settle_records,json=autoSettleRecords,proto3" json:"auto_settle_records"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryAllAutoSettleRecordResponse) Reset() { *m = QueryAllAutoSettleRecordResponse{} } -func (m *QueryAllAutoSettleRecordResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllAutoSettleRecordResponse) ProtoMessage() {} -func (*QueryAllAutoSettleRecordResponse) Descriptor() ([]byte, []int) { +func (m *QueryAutoSettleRecordsResponse) Reset() { *m = QueryAutoSettleRecordsResponse{} } +func (m *QueryAutoSettleRecordsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAutoSettleRecordsResponse) ProtoMessage() {} +func (*QueryAutoSettleRecordsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f62e6684473ccf4a, []int{23} } -func (m *QueryAllAutoSettleRecordResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryAutoSettleRecordsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllAutoSettleRecordResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAutoSettleRecordsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllAutoSettleRecordResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAutoSettleRecordsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1115,26 +1113,26 @@ func (m *QueryAllAutoSettleRecordResponse) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *QueryAllAutoSettleRecordResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllAutoSettleRecordResponse.Merge(m, src) +func (m *QueryAutoSettleRecordsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAutoSettleRecordsResponse.Merge(m, src) } -func (m *QueryAllAutoSettleRecordResponse) XXX_Size() int { +func (m *QueryAutoSettleRecordsResponse) XXX_Size() int { return m.Size() } -func (m *QueryAllAutoSettleRecordResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllAutoSettleRecordResponse.DiscardUnknown(m) +func (m *QueryAutoSettleRecordsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAutoSettleRecordsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllAutoSettleRecordResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryAutoSettleRecordsResponse proto.InternalMessageInfo -func (m *QueryAllAutoSettleRecordResponse) GetAutoSettleRecord() []AutoSettleRecord { +func (m *QueryAutoSettleRecordsResponse) GetAutoSettleRecords() []AutoSettleRecord { if m != nil { - return m.AutoSettleRecord + return m.AutoSettleRecords } return nil } -func (m *QueryAllAutoSettleRecordResponse) GetPagination() *query.PageResponse { +func (m *QueryAutoSettleRecordsResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } @@ -1150,112 +1148,112 @@ func init() { proto.RegisterType((*QueryOutFlowsResponse)(nil), "greenfield.payment.QueryOutFlowsResponse") proto.RegisterType((*QueryGetStreamRecordRequest)(nil), "greenfield.payment.QueryGetStreamRecordRequest") proto.RegisterType((*QueryGetStreamRecordResponse)(nil), "greenfield.payment.QueryGetStreamRecordResponse") - proto.RegisterType((*QueryAllStreamRecordRequest)(nil), "greenfield.payment.QueryAllStreamRecordRequest") - proto.RegisterType((*QueryAllStreamRecordResponse)(nil), "greenfield.payment.QueryAllStreamRecordResponse") - proto.RegisterType((*QueryGetPaymentAccountCountRequest)(nil), "greenfield.payment.QueryGetPaymentAccountCountRequest") - proto.RegisterType((*QueryGetPaymentAccountCountResponse)(nil), "greenfield.payment.QueryGetPaymentAccountCountResponse") - proto.RegisterType((*QueryAllPaymentAccountCountRequest)(nil), "greenfield.payment.QueryAllPaymentAccountCountRequest") - proto.RegisterType((*QueryAllPaymentAccountCountResponse)(nil), "greenfield.payment.QueryAllPaymentAccountCountResponse") - proto.RegisterType((*QueryGetPaymentAccountRequest)(nil), "greenfield.payment.QueryGetPaymentAccountRequest") - proto.RegisterType((*QueryGetPaymentAccountResponse)(nil), "greenfield.payment.QueryGetPaymentAccountResponse") - proto.RegisterType((*QueryAllPaymentAccountRequest)(nil), "greenfield.payment.QueryAllPaymentAccountRequest") - proto.RegisterType((*QueryAllPaymentAccountResponse)(nil), "greenfield.payment.QueryAllPaymentAccountResponse") + proto.RegisterType((*QueryStreamRecordsRequest)(nil), "greenfield.payment.QueryStreamRecordsRequest") + proto.RegisterType((*QueryStreamRecordsResponse)(nil), "greenfield.payment.QueryStreamRecordsResponse") + proto.RegisterType((*QueryPaymentAccountCountRequest)(nil), "greenfield.payment.QueryPaymentAccountCountRequest") + proto.RegisterType((*QueryPaymentAccountCountResponse)(nil), "greenfield.payment.QueryPaymentAccountCountResponse") + proto.RegisterType((*QueryPaymentAccountCountsRequest)(nil), "greenfield.payment.QueryPaymentAccountCountsRequest") + proto.RegisterType((*QueryPaymentAccountCountsResponse)(nil), "greenfield.payment.QueryPaymentAccountCountsResponse") + proto.RegisterType((*QueryPaymentAccountRequest)(nil), "greenfield.payment.QueryPaymentAccountRequest") + proto.RegisterType((*QueryPaymentAccountResponse)(nil), "greenfield.payment.QueryPaymentAccountResponse") + proto.RegisterType((*QueryPaymentAccountsRequest)(nil), "greenfield.payment.QueryPaymentAccountsRequest") + proto.RegisterType((*QueryPaymentAccountsResponse)(nil), "greenfield.payment.QueryPaymentAccountsResponse") proto.RegisterType((*QueryDynamicBalanceRequest)(nil), "greenfield.payment.QueryDynamicBalanceRequest") proto.RegisterType((*QueryDynamicBalanceResponse)(nil), "greenfield.payment.QueryDynamicBalanceResponse") - proto.RegisterType((*QueryGetPaymentAccountsByOwnerRequest)(nil), "greenfield.payment.QueryGetPaymentAccountsByOwnerRequest") - proto.RegisterType((*QueryGetPaymentAccountsByOwnerResponse)(nil), "greenfield.payment.QueryGetPaymentAccountsByOwnerResponse") - proto.RegisterType((*QueryAllAutoSettleRecordRequest)(nil), "greenfield.payment.QueryAllAutoSettleRecordRequest") - proto.RegisterType((*QueryAllAutoSettleRecordResponse)(nil), "greenfield.payment.QueryAllAutoSettleRecordResponse") + proto.RegisterType((*QueryPaymentAccountsByOwnerRequest)(nil), "greenfield.payment.QueryPaymentAccountsByOwnerRequest") + proto.RegisterType((*QueryPaymentAccountsByOwnerResponse)(nil), "greenfield.payment.QueryPaymentAccountsByOwnerResponse") + proto.RegisterType((*QueryAutoSettleRecordsRequest)(nil), "greenfield.payment.QueryAutoSettleRecordsRequest") + proto.RegisterType((*QueryAutoSettleRecordsResponse)(nil), "greenfield.payment.QueryAutoSettleRecordsResponse") } func init() { proto.RegisterFile("greenfield/payment/query.proto", fileDescriptor_f62e6684473ccf4a) } var fileDescriptor_f62e6684473ccf4a = []byte{ - // 1341 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xd6, 0x4d, 0xda, 0xbc, 0x94, 0x34, 0x9d, 0xa4, 0x28, 0xdd, 0x06, 0xa7, 0xdd, 0x52, - 0xc7, 0x69, 0x88, 0xb7, 0x4e, 0x20, 0x25, 0x85, 0x22, 0xd9, 0xa0, 0x54, 0x11, 0x87, 0xa4, 0x2e, - 0x12, 0xa8, 0x08, 0xad, 0xc6, 0xf6, 0xc4, 0xb1, 0xb2, 0xde, 0x75, 0xbd, 0xe3, 0x06, 0x2b, 0xca, - 0x85, 0x03, 0xe2, 0x58, 0x89, 0x3f, 0x00, 0x89, 0x03, 0x20, 0xb8, 0x70, 0xe8, 0xb1, 0x17, 0x0e, - 0x48, 0x3d, 0x16, 0x10, 0x12, 0xe2, 0x50, 0xa1, 0x84, 0x3f, 0x04, 0xed, 0xec, 0x5b, 0x67, 0x6d, - 0xcf, 0xee, 0x3a, 0xa9, 0xb9, 0x34, 0xde, 0xd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xc0, 0xb7, 0x04, - 0x40, 0x9d, 0x2c, 0xca, 0x00, 0x76, 0x69, 0xd5, 0xc0, 0x9c, 0xf8, 0x53, 0x81, 0x4b, 0xa1, 0xe2, - 0x80, 0xac, 0xf6, 0xdf, 0xda, 0x2e, 0x3d, 0xa2, 0xde, 0x3e, 0x89, 0x2b, 0x72, 0xc9, 0x09, 0x2e, - 0xef, 0x90, 0x55, 0x19, 0x97, 0x0a, 0xe3, 0x46, 0x57, 0xc1, 0x1d, 0xa3, 0xd8, 0x32, 0xc4, 0x96, - 0x6c, 0xef, 0xcc, 0x9f, 0x15, 0x98, 0xec, 0x3e, 0xe7, 0xdd, 0xcf, 0x65, 0x39, 0xaa, 0xf7, 0x21, - 0x72, 0x46, 0x7d, 0xf3, 0x78, 0x4e, 0xfd, 0x1c, 0x77, 0xbd, 0x8a, 0x25, 0xbf, 0xfe, 0xec, 0x20, - 0xa9, 0x3c, 0x3f, 0x48, 0x2a, 0xff, 0x1c, 0x24, 0x95, 0xc7, 0x87, 0xc9, 0xa1, 0xe7, 0x87, 0xc9, - 0xa1, 0xbf, 0x0e, 0x93, 0x43, 0x0f, 0xf4, 0x80, 0x8c, 0x2c, 0x5a, 0xc5, 0xc5, 0xd2, 0x36, 0xad, - 0x5a, 0xc1, 0xa8, 0x9f, 0xb7, 0xe3, 0x0a, 0x4d, 0x59, 0x1c, 0x11, 0xff, 0x53, 0xb8, 0xfc, 0x5f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0x26, 0x77, 0xa3, 0xcd, 0x15, 0x00, 0x00, + // 1334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xb6, 0x4d, 0xda, 0xbc, 0x34, 0x5f, 0x13, 0xb7, 0x4a, 0xdd, 0xe0, 0xa4, 0x4b, 0xe4, + 0xb8, 0x49, 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, 0x41, 0xe0, 0x0e, 0x59, 0x8c, 0x4c, 0xc0, + 0x21, 0xdf, 0x28, 0x30, 0x16, 0x0c, 0x4a, 0xb4, 0x88, 0xd9, 0x3d, 0xb4, 0x7a, 0x64, 0xfb, 0x97, + 0xc0, 0xa9, 0x1f, 0x35, 0x44, 0xf4, 0x31, 0xf9, 0x5a, 0x81, 0xf1, 0x96, 0xcb, 0x8a, 0x44, 0x4d, + 0xec, 0x74, 0x1f, 0xb4, 0x10, 0x09, 0xab, 0xde, 0x11, 0x50, 0x93, 0x64, 0x3e, 0x02, 0x54, 0x87, + 0x7c, 0xa7, 0xc0, 0x58, 0x50, 0x15, 0x76, 0x28, 0xa6, 0x54, 0x77, 0x76, 0x28, 0xa6, 0x5c, 0x6e, + 0xaa, 0xeb, 0x02, 0xa1, 0x4e, 0xd2, 0x32, 0x84, 0x2d, 0x42, 0xd4, 0x77, 0x18, 0x9c, 0x28, 0x70, + 0x5d, 0x7e, 0xf9, 0x93, 0xbb, 0x51, 0xab, 0x14, 0x54, 0x1a, 0xf1, 0x8d, 0x9e, 0xfd, 0x90, 0xc2, + 0x3d, 0x41, 0x61, 0x83, 0xac, 0x47, 0x29, 0xb2, 0x91, 0xab, 0x1b, 0x62, 0xea, 0x9a, 0xc3, 0xf7, + 0x83, 0x02, 0x93, 0x6d, 0x62, 0xa0, 0xc3, 0x05, 0x16, 0x26, 0x51, 0x3a, 0x5c, 0x60, 0xa1, 0x5a, + 0xa3, 0xf3, 0x75, 0x21, 0x51, 0x21, 0x99, 0xad, 0x93, 0xd3, 0x84, 0xf2, 0xfc, 0x34, 0xa1, 0xfc, + 0x75, 0x9a, 0x50, 0x9e, 0x9e, 0x25, 0x06, 0x9e, 0x9f, 0x25, 0x06, 0xfe, 0x38, 0x4b, 0x0c, 0xec, + 0xea, 0x3e, 0x45, 0x98, 0xb3, 0x72, 0x69, 0x73, 0x9f, 0x16, 0x2d, 0x7f, 0xd8, 0x4f, 0x9b, 0x81, + 0x85, 0x3c, 0xcc, 0x0d, 0x89, 0xff, 0xe2, 0x5b, 0xfb, 0x37, 0x00, 0x00, 0xff, 0xff, 0x83, 0x93, + 0xf5, 0x73, 0x86, 0x15, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1272,28 +1270,28 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // ParamsByTimestamp queries the parameters of the module. + // ParamsByTimestamp queries the parameter of the module by timestamp. ParamsByTimestamp(ctx context.Context, in *QueryParamsByTimestampRequest, opts ...grpc.CallOption) (*QueryParamsByTimestampResponse, error) - // Queries a StreamRecord by index. + // Queries our flows by account. OutFlows(ctx context.Context, in *QueryOutFlowsRequest, opts ...grpc.CallOption) (*QueryOutFlowsResponse, error) - // Queries a StreamRecord by index. + // Queries a stream record by account. StreamRecord(ctx context.Context, in *QueryGetStreamRecordRequest, opts ...grpc.CallOption) (*QueryGetStreamRecordResponse, error) - // Queries a list of StreamRecord items. - StreamRecordAll(ctx context.Context, in *QueryAllStreamRecordRequest, opts ...grpc.CallOption) (*QueryAllStreamRecordResponse, error) - // Queries a PaymentAccountCount by index. - PaymentAccountCount(ctx context.Context, in *QueryGetPaymentAccountCountRequest, opts ...grpc.CallOption) (*QueryGetPaymentAccountCountResponse, error) - // Queries a list of PaymentAccountCount items. - PaymentAccountCountAll(ctx context.Context, in *QueryAllPaymentAccountCountRequest, opts ...grpc.CallOption) (*QueryAllPaymentAccountCountResponse, error) - // Queries a PaymentAccount by index. - PaymentAccount(ctx context.Context, in *QueryGetPaymentAccountRequest, opts ...grpc.CallOption) (*QueryGetPaymentAccountResponse, error) - // Queries a list of PaymentAccount items. - PaymentAccountAll(ctx context.Context, in *QueryAllPaymentAccountRequest, opts ...grpc.CallOption) (*QueryAllPaymentAccountResponse, error) - // Queries a list of DynamicBalance items. + // Queries all stream records. + StreamRecords(ctx context.Context, in *QueryStreamRecordsRequest, opts ...grpc.CallOption) (*QueryStreamRecordsResponse, error) + // Queries the count of payment account by owner. + PaymentAccountCount(ctx context.Context, in *QueryPaymentAccountCountRequest, opts ...grpc.CallOption) (*QueryPaymentAccountCountResponse, error) + // Queries all counts of payment account for all owners. + PaymentAccountCounts(ctx context.Context, in *QueryPaymentAccountCountsRequest, opts ...grpc.CallOption) (*QueryPaymentAccountCountsResponse, error) + // Queries a payment account by payment account address. + PaymentAccount(ctx context.Context, in *QueryPaymentAccountRequest, opts ...grpc.CallOption) (*QueryPaymentAccountResponse, error) + // Queries all payment accounts. + PaymentAccounts(ctx context.Context, in *QueryPaymentAccountsRequest, opts ...grpc.CallOption) (*QueryPaymentAccountsResponse, error) + // Queries dynamic balance of a payment account. DynamicBalance(ctx context.Context, in *QueryDynamicBalanceRequest, opts ...grpc.CallOption) (*QueryDynamicBalanceResponse, error) - // Queries a list of GetPaymentAccountsByOwner items. - GetPaymentAccountsByOwner(ctx context.Context, in *QueryGetPaymentAccountsByOwnerRequest, opts ...grpc.CallOption) (*QueryGetPaymentAccountsByOwnerResponse, error) - // Queries a list of AutoSettleRecord items. - AutoSettleRecordAll(ctx context.Context, in *QueryAllAutoSettleRecordRequest, opts ...grpc.CallOption) (*QueryAllAutoSettleRecordResponse, error) + // Queries all payment accounts by a owner. + PaymentAccountsByOwner(ctx context.Context, in *QueryPaymentAccountsByOwnerRequest, opts ...grpc.CallOption) (*QueryPaymentAccountsByOwnerResponse, error) + // Queries all auto settle records. + AutoSettleRecords(ctx context.Context, in *QueryAutoSettleRecordsRequest, opts ...grpc.CallOption) (*QueryAutoSettleRecordsResponse, error) } type queryClient struct { @@ -1340,17 +1338,17 @@ func (c *queryClient) StreamRecord(ctx context.Context, in *QueryGetStreamRecord return out, nil } -func (c *queryClient) StreamRecordAll(ctx context.Context, in *QueryAllStreamRecordRequest, opts ...grpc.CallOption) (*QueryAllStreamRecordResponse, error) { - out := new(QueryAllStreamRecordResponse) - err := c.cc.Invoke(ctx, "/greenfield.payment.Query/StreamRecordAll", in, out, opts...) +func (c *queryClient) StreamRecords(ctx context.Context, in *QueryStreamRecordsRequest, opts ...grpc.CallOption) (*QueryStreamRecordsResponse, error) { + out := new(QueryStreamRecordsResponse) + err := c.cc.Invoke(ctx, "/greenfield.payment.Query/StreamRecords", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) PaymentAccountCount(ctx context.Context, in *QueryGetPaymentAccountCountRequest, opts ...grpc.CallOption) (*QueryGetPaymentAccountCountResponse, error) { - out := new(QueryGetPaymentAccountCountResponse) +func (c *queryClient) PaymentAccountCount(ctx context.Context, in *QueryPaymentAccountCountRequest, opts ...grpc.CallOption) (*QueryPaymentAccountCountResponse, error) { + out := new(QueryPaymentAccountCountResponse) err := c.cc.Invoke(ctx, "/greenfield.payment.Query/PaymentAccountCount", in, out, opts...) if err != nil { return nil, err @@ -1358,17 +1356,17 @@ func (c *queryClient) PaymentAccountCount(ctx context.Context, in *QueryGetPayme return out, nil } -func (c *queryClient) PaymentAccountCountAll(ctx context.Context, in *QueryAllPaymentAccountCountRequest, opts ...grpc.CallOption) (*QueryAllPaymentAccountCountResponse, error) { - out := new(QueryAllPaymentAccountCountResponse) - err := c.cc.Invoke(ctx, "/greenfield.payment.Query/PaymentAccountCountAll", in, out, opts...) +func (c *queryClient) PaymentAccountCounts(ctx context.Context, in *QueryPaymentAccountCountsRequest, opts ...grpc.CallOption) (*QueryPaymentAccountCountsResponse, error) { + out := new(QueryPaymentAccountCountsResponse) + err := c.cc.Invoke(ctx, "/greenfield.payment.Query/PaymentAccountCounts", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) PaymentAccount(ctx context.Context, in *QueryGetPaymentAccountRequest, opts ...grpc.CallOption) (*QueryGetPaymentAccountResponse, error) { - out := new(QueryGetPaymentAccountResponse) +func (c *queryClient) PaymentAccount(ctx context.Context, in *QueryPaymentAccountRequest, opts ...grpc.CallOption) (*QueryPaymentAccountResponse, error) { + out := new(QueryPaymentAccountResponse) err := c.cc.Invoke(ctx, "/greenfield.payment.Query/PaymentAccount", in, out, opts...) if err != nil { return nil, err @@ -1376,9 +1374,9 @@ func (c *queryClient) PaymentAccount(ctx context.Context, in *QueryGetPaymentAcc return out, nil } -func (c *queryClient) PaymentAccountAll(ctx context.Context, in *QueryAllPaymentAccountRequest, opts ...grpc.CallOption) (*QueryAllPaymentAccountResponse, error) { - out := new(QueryAllPaymentAccountResponse) - err := c.cc.Invoke(ctx, "/greenfield.payment.Query/PaymentAccountAll", in, out, opts...) +func (c *queryClient) PaymentAccounts(ctx context.Context, in *QueryPaymentAccountsRequest, opts ...grpc.CallOption) (*QueryPaymentAccountsResponse, error) { + out := new(QueryPaymentAccountsResponse) + err := c.cc.Invoke(ctx, "/greenfield.payment.Query/PaymentAccounts", in, out, opts...) if err != nil { return nil, err } @@ -1394,18 +1392,18 @@ func (c *queryClient) DynamicBalance(ctx context.Context, in *QueryDynamicBalanc return out, nil } -func (c *queryClient) GetPaymentAccountsByOwner(ctx context.Context, in *QueryGetPaymentAccountsByOwnerRequest, opts ...grpc.CallOption) (*QueryGetPaymentAccountsByOwnerResponse, error) { - out := new(QueryGetPaymentAccountsByOwnerResponse) - err := c.cc.Invoke(ctx, "/greenfield.payment.Query/GetPaymentAccountsByOwner", in, out, opts...) +func (c *queryClient) PaymentAccountsByOwner(ctx context.Context, in *QueryPaymentAccountsByOwnerRequest, opts ...grpc.CallOption) (*QueryPaymentAccountsByOwnerResponse, error) { + out := new(QueryPaymentAccountsByOwnerResponse) + err := c.cc.Invoke(ctx, "/greenfield.payment.Query/PaymentAccountsByOwner", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) AutoSettleRecordAll(ctx context.Context, in *QueryAllAutoSettleRecordRequest, opts ...grpc.CallOption) (*QueryAllAutoSettleRecordResponse, error) { - out := new(QueryAllAutoSettleRecordResponse) - err := c.cc.Invoke(ctx, "/greenfield.payment.Query/AutoSettleRecordAll", in, out, opts...) +func (c *queryClient) AutoSettleRecords(ctx context.Context, in *QueryAutoSettleRecordsRequest, opts ...grpc.CallOption) (*QueryAutoSettleRecordsResponse, error) { + out := new(QueryAutoSettleRecordsResponse) + err := c.cc.Invoke(ctx, "/greenfield.payment.Query/AutoSettleRecords", in, out, opts...) if err != nil { return nil, err } @@ -1416,28 +1414,28 @@ func (c *queryClient) AutoSettleRecordAll(ctx context.Context, in *QueryAllAutoS type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // ParamsByTimestamp queries the parameters of the module. + // ParamsByTimestamp queries the parameter of the module by timestamp. ParamsByTimestamp(context.Context, *QueryParamsByTimestampRequest) (*QueryParamsByTimestampResponse, error) - // Queries a StreamRecord by index. + // Queries our flows by account. OutFlows(context.Context, *QueryOutFlowsRequest) (*QueryOutFlowsResponse, error) - // Queries a StreamRecord by index. + // Queries a stream record by account. StreamRecord(context.Context, *QueryGetStreamRecordRequest) (*QueryGetStreamRecordResponse, error) - // Queries a list of StreamRecord items. - StreamRecordAll(context.Context, *QueryAllStreamRecordRequest) (*QueryAllStreamRecordResponse, error) - // Queries a PaymentAccountCount by index. - PaymentAccountCount(context.Context, *QueryGetPaymentAccountCountRequest) (*QueryGetPaymentAccountCountResponse, error) - // Queries a list of PaymentAccountCount items. - PaymentAccountCountAll(context.Context, *QueryAllPaymentAccountCountRequest) (*QueryAllPaymentAccountCountResponse, error) - // Queries a PaymentAccount by index. - PaymentAccount(context.Context, *QueryGetPaymentAccountRequest) (*QueryGetPaymentAccountResponse, error) - // Queries a list of PaymentAccount items. - PaymentAccountAll(context.Context, *QueryAllPaymentAccountRequest) (*QueryAllPaymentAccountResponse, error) - // Queries a list of DynamicBalance items. + // Queries all stream records. + StreamRecords(context.Context, *QueryStreamRecordsRequest) (*QueryStreamRecordsResponse, error) + // Queries the count of payment account by owner. + PaymentAccountCount(context.Context, *QueryPaymentAccountCountRequest) (*QueryPaymentAccountCountResponse, error) + // Queries all counts of payment account for all owners. + PaymentAccountCounts(context.Context, *QueryPaymentAccountCountsRequest) (*QueryPaymentAccountCountsResponse, error) + // Queries a payment account by payment account address. + PaymentAccount(context.Context, *QueryPaymentAccountRequest) (*QueryPaymentAccountResponse, error) + // Queries all payment accounts. + PaymentAccounts(context.Context, *QueryPaymentAccountsRequest) (*QueryPaymentAccountsResponse, error) + // Queries dynamic balance of a payment account. DynamicBalance(context.Context, *QueryDynamicBalanceRequest) (*QueryDynamicBalanceResponse, error) - // Queries a list of GetPaymentAccountsByOwner items. - GetPaymentAccountsByOwner(context.Context, *QueryGetPaymentAccountsByOwnerRequest) (*QueryGetPaymentAccountsByOwnerResponse, error) - // Queries a list of AutoSettleRecord items. - AutoSettleRecordAll(context.Context, *QueryAllAutoSettleRecordRequest) (*QueryAllAutoSettleRecordResponse, error) + // Queries all payment accounts by a owner. + PaymentAccountsByOwner(context.Context, *QueryPaymentAccountsByOwnerRequest) (*QueryPaymentAccountsByOwnerResponse, error) + // Queries all auto settle records. + AutoSettleRecords(context.Context, *QueryAutoSettleRecordsRequest) (*QueryAutoSettleRecordsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1456,29 +1454,29 @@ func (*UnimplementedQueryServer) OutFlows(ctx context.Context, req *QueryOutFlow func (*UnimplementedQueryServer) StreamRecord(ctx context.Context, req *QueryGetStreamRecordRequest) (*QueryGetStreamRecordResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StreamRecord not implemented") } -func (*UnimplementedQueryServer) StreamRecordAll(ctx context.Context, req *QueryAllStreamRecordRequest) (*QueryAllStreamRecordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method StreamRecordAll not implemented") +func (*UnimplementedQueryServer) StreamRecords(ctx context.Context, req *QueryStreamRecordsRequest) (*QueryStreamRecordsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StreamRecords not implemented") } -func (*UnimplementedQueryServer) PaymentAccountCount(ctx context.Context, req *QueryGetPaymentAccountCountRequest) (*QueryGetPaymentAccountCountResponse, error) { +func (*UnimplementedQueryServer) PaymentAccountCount(ctx context.Context, req *QueryPaymentAccountCountRequest) (*QueryPaymentAccountCountResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PaymentAccountCount not implemented") } -func (*UnimplementedQueryServer) PaymentAccountCountAll(ctx context.Context, req *QueryAllPaymentAccountCountRequest) (*QueryAllPaymentAccountCountResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PaymentAccountCountAll not implemented") +func (*UnimplementedQueryServer) PaymentAccountCounts(ctx context.Context, req *QueryPaymentAccountCountsRequest) (*QueryPaymentAccountCountsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PaymentAccountCounts not implemented") } -func (*UnimplementedQueryServer) PaymentAccount(ctx context.Context, req *QueryGetPaymentAccountRequest) (*QueryGetPaymentAccountResponse, error) { +func (*UnimplementedQueryServer) PaymentAccount(ctx context.Context, req *QueryPaymentAccountRequest) (*QueryPaymentAccountResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PaymentAccount not implemented") } -func (*UnimplementedQueryServer) PaymentAccountAll(ctx context.Context, req *QueryAllPaymentAccountRequest) (*QueryAllPaymentAccountResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PaymentAccountAll not implemented") +func (*UnimplementedQueryServer) PaymentAccounts(ctx context.Context, req *QueryPaymentAccountsRequest) (*QueryPaymentAccountsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PaymentAccounts not implemented") } func (*UnimplementedQueryServer) DynamicBalance(ctx context.Context, req *QueryDynamicBalanceRequest) (*QueryDynamicBalanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DynamicBalance not implemented") } -func (*UnimplementedQueryServer) GetPaymentAccountsByOwner(ctx context.Context, req *QueryGetPaymentAccountsByOwnerRequest) (*QueryGetPaymentAccountsByOwnerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPaymentAccountsByOwner not implemented") +func (*UnimplementedQueryServer) PaymentAccountsByOwner(ctx context.Context, req *QueryPaymentAccountsByOwnerRequest) (*QueryPaymentAccountsByOwnerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PaymentAccountsByOwner not implemented") } -func (*UnimplementedQueryServer) AutoSettleRecordAll(ctx context.Context, req *QueryAllAutoSettleRecordRequest) (*QueryAllAutoSettleRecordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AutoSettleRecordAll not implemented") +func (*UnimplementedQueryServer) AutoSettleRecords(ctx context.Context, req *QueryAutoSettleRecordsRequest) (*QueryAutoSettleRecordsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AutoSettleRecords not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -1557,26 +1555,26 @@ func _Query_StreamRecord_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } -func _Query_StreamRecordAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllStreamRecordRequest) +func _Query_StreamRecords_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStreamRecordsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).StreamRecordAll(ctx, in) + return srv.(QueryServer).StreamRecords(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/greenfield.payment.Query/StreamRecordAll", + FullMethod: "/greenfield.payment.Query/StreamRecords", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).StreamRecordAll(ctx, req.(*QueryAllStreamRecordRequest)) + return srv.(QueryServer).StreamRecords(ctx, req.(*QueryStreamRecordsRequest)) } return interceptor(ctx, in, info, handler) } func _Query_PaymentAccountCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetPaymentAccountCountRequest) + in := new(QueryPaymentAccountCountRequest) if err := dec(in); err != nil { return nil, err } @@ -1588,31 +1586,31 @@ func _Query_PaymentAccountCount_Handler(srv interface{}, ctx context.Context, de FullMethod: "/greenfield.payment.Query/PaymentAccountCount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PaymentAccountCount(ctx, req.(*QueryGetPaymentAccountCountRequest)) + return srv.(QueryServer).PaymentAccountCount(ctx, req.(*QueryPaymentAccountCountRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_PaymentAccountCountAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllPaymentAccountCountRequest) +func _Query_PaymentAccountCounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPaymentAccountCountsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).PaymentAccountCountAll(ctx, in) + return srv.(QueryServer).PaymentAccountCounts(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/greenfield.payment.Query/PaymentAccountCountAll", + FullMethod: "/greenfield.payment.Query/PaymentAccountCounts", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PaymentAccountCountAll(ctx, req.(*QueryAllPaymentAccountCountRequest)) + return srv.(QueryServer).PaymentAccountCounts(ctx, req.(*QueryPaymentAccountCountsRequest)) } return interceptor(ctx, in, info, handler) } func _Query_PaymentAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetPaymentAccountRequest) + in := new(QueryPaymentAccountRequest) if err := dec(in); err != nil { return nil, err } @@ -1624,25 +1622,25 @@ func _Query_PaymentAccount_Handler(srv interface{}, ctx context.Context, dec fun FullMethod: "/greenfield.payment.Query/PaymentAccount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PaymentAccount(ctx, req.(*QueryGetPaymentAccountRequest)) + return srv.(QueryServer).PaymentAccount(ctx, req.(*QueryPaymentAccountRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_PaymentAccountAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllPaymentAccountRequest) +func _Query_PaymentAccounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPaymentAccountsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).PaymentAccountAll(ctx, in) + return srv.(QueryServer).PaymentAccounts(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/greenfield.payment.Query/PaymentAccountAll", + FullMethod: "/greenfield.payment.Query/PaymentAccounts", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PaymentAccountAll(ctx, req.(*QueryAllPaymentAccountRequest)) + return srv.(QueryServer).PaymentAccounts(ctx, req.(*QueryPaymentAccountsRequest)) } return interceptor(ctx, in, info, handler) } @@ -1665,38 +1663,38 @@ func _Query_DynamicBalance_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Query_GetPaymentAccountsByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetPaymentAccountsByOwnerRequest) +func _Query_PaymentAccountsByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPaymentAccountsByOwnerRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).GetPaymentAccountsByOwner(ctx, in) + return srv.(QueryServer).PaymentAccountsByOwner(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/greenfield.payment.Query/GetPaymentAccountsByOwner", + FullMethod: "/greenfield.payment.Query/PaymentAccountsByOwner", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetPaymentAccountsByOwner(ctx, req.(*QueryGetPaymentAccountsByOwnerRequest)) + return srv.(QueryServer).PaymentAccountsByOwner(ctx, req.(*QueryPaymentAccountsByOwnerRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_AutoSettleRecordAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllAutoSettleRecordRequest) +func _Query_AutoSettleRecords_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAutoSettleRecordsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).AutoSettleRecordAll(ctx, in) + return srv.(QueryServer).AutoSettleRecords(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/greenfield.payment.Query/AutoSettleRecordAll", + FullMethod: "/greenfield.payment.Query/AutoSettleRecords", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AutoSettleRecordAll(ctx, req.(*QueryAllAutoSettleRecordRequest)) + return srv.(QueryServer).AutoSettleRecords(ctx, req.(*QueryAutoSettleRecordsRequest)) } return interceptor(ctx, in, info, handler) } @@ -1722,36 +1720,36 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_StreamRecord_Handler, }, { - MethodName: "StreamRecordAll", - Handler: _Query_StreamRecordAll_Handler, + MethodName: "StreamRecords", + Handler: _Query_StreamRecords_Handler, }, { MethodName: "PaymentAccountCount", Handler: _Query_PaymentAccountCount_Handler, }, { - MethodName: "PaymentAccountCountAll", - Handler: _Query_PaymentAccountCountAll_Handler, + MethodName: "PaymentAccountCounts", + Handler: _Query_PaymentAccountCounts_Handler, }, { MethodName: "PaymentAccount", Handler: _Query_PaymentAccount_Handler, }, { - MethodName: "PaymentAccountAll", - Handler: _Query_PaymentAccountAll_Handler, + MethodName: "PaymentAccounts", + Handler: _Query_PaymentAccounts_Handler, }, { MethodName: "DynamicBalance", Handler: _Query_DynamicBalance_Handler, }, { - MethodName: "GetPaymentAccountsByOwner", - Handler: _Query_GetPaymentAccountsByOwner_Handler, + MethodName: "PaymentAccountsByOwner", + Handler: _Query_PaymentAccountsByOwner_Handler, }, { - MethodName: "AutoSettleRecordAll", - Handler: _Query_AutoSettleRecordAll_Handler, + MethodName: "AutoSettleRecords", + Handler: _Query_AutoSettleRecords_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -2005,7 +2003,7 @@ func (m *QueryGetStreamRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryAllStreamRecordRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryStreamRecordsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2015,12 +2013,12 @@ func (m *QueryAllStreamRecordRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllStreamRecordRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryStreamRecordsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllStreamRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryStreamRecordsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2040,7 +2038,7 @@ func (m *QueryAllStreamRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryAllStreamRecordResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryStreamRecordsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2050,12 +2048,12 @@ func (m *QueryAllStreamRecordResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllStreamRecordResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryStreamRecordsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllStreamRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryStreamRecordsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2072,10 +2070,10 @@ func (m *QueryAllStreamRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, e i-- dAtA[i] = 0x12 } - if len(m.StreamRecord) > 0 { - for iNdEx := len(m.StreamRecord) - 1; iNdEx >= 0; iNdEx-- { + if len(m.StreamRecords) > 0 { + for iNdEx := len(m.StreamRecords) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.StreamRecord[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.StreamRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2089,7 +2087,7 @@ func (m *QueryAllStreamRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryGetPaymentAccountCountRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountCountRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2099,12 +2097,12 @@ func (m *QueryGetPaymentAccountCountRequest) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryGetPaymentAccountCountRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetPaymentAccountCountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2119,7 +2117,7 @@ func (m *QueryGetPaymentAccountCountRequest) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } -func (m *QueryGetPaymentAccountCountResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountCountResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2129,12 +2127,12 @@ func (m *QueryGetPaymentAccountCountResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryGetPaymentAccountCountResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetPaymentAccountCountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2152,7 +2150,7 @@ func (m *QueryGetPaymentAccountCountResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *QueryAllPaymentAccountCountRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountCountsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2162,12 +2160,12 @@ func (m *QueryAllPaymentAccountCountRequest) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryAllPaymentAccountCountRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllPaymentAccountCountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2187,7 +2185,7 @@ func (m *QueryAllPaymentAccountCountRequest) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } -func (m *QueryAllPaymentAccountCountResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountCountsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2197,12 +2195,12 @@ func (m *QueryAllPaymentAccountCountResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryAllPaymentAccountCountResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllPaymentAccountCountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountCountsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2219,10 +2217,10 @@ func (m *QueryAllPaymentAccountCountResponse) MarshalToSizedBuffer(dAtA []byte) i-- dAtA[i] = 0x12 } - if len(m.PaymentAccountCount) > 0 { - for iNdEx := len(m.PaymentAccountCount) - 1; iNdEx >= 0; iNdEx-- { + if len(m.PaymentAccountCounts) > 0 { + for iNdEx := len(m.PaymentAccountCounts) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.PaymentAccountCount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.PaymentAccountCounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2236,7 +2234,7 @@ func (m *QueryAllPaymentAccountCountResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *QueryGetPaymentAccountRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2246,12 +2244,12 @@ func (m *QueryGetPaymentAccountRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryGetPaymentAccountRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetPaymentAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2266,7 +2264,7 @@ func (m *QueryGetPaymentAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryGetPaymentAccountResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2276,12 +2274,12 @@ func (m *QueryGetPaymentAccountResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryGetPaymentAccountResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetPaymentAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2299,7 +2297,7 @@ func (m *QueryGetPaymentAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryAllPaymentAccountRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2309,12 +2307,12 @@ func (m *QueryAllPaymentAccountRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllPaymentAccountRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllPaymentAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2334,7 +2332,7 @@ func (m *QueryAllPaymentAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryAllPaymentAccountResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2344,12 +2342,12 @@ func (m *QueryAllPaymentAccountResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllPaymentAccountResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllPaymentAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2366,10 +2364,10 @@ func (m *QueryAllPaymentAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 } - if len(m.PaymentAccount) > 0 { - for iNdEx := len(m.PaymentAccount) - 1; iNdEx >= 0; iNdEx-- { + if len(m.PaymentAccounts) > 0 { + for iNdEx := len(m.PaymentAccounts) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.PaymentAccount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.PaymentAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2501,7 +2499,7 @@ func (m *QueryDynamicBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryGetPaymentAccountsByOwnerRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountsByOwnerRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2511,12 +2509,12 @@ func (m *QueryGetPaymentAccountsByOwnerRequest) Marshal() (dAtA []byte, err erro return dAtA[:n], nil } -func (m *QueryGetPaymentAccountsByOwnerRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsByOwnerRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetPaymentAccountsByOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsByOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2531,7 +2529,7 @@ func (m *QueryGetPaymentAccountsByOwnerRequest) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } -func (m *QueryGetPaymentAccountsByOwnerResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPaymentAccountsByOwnerResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2541,12 +2539,12 @@ func (m *QueryGetPaymentAccountsByOwnerResponse) Marshal() (dAtA []byte, err err return dAtA[:n], nil } -func (m *QueryGetPaymentAccountsByOwnerResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsByOwnerResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetPaymentAccountsByOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPaymentAccountsByOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2563,7 +2561,7 @@ func (m *QueryGetPaymentAccountsByOwnerResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } -func (m *QueryAllAutoSettleRecordRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAutoSettleRecordsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2573,12 +2571,12 @@ func (m *QueryAllAutoSettleRecordRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllAutoSettleRecordRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAutoSettleRecordsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllAutoSettleRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAutoSettleRecordsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2598,7 +2596,7 @@ func (m *QueryAllAutoSettleRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } -func (m *QueryAllAutoSettleRecordResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAutoSettleRecordsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2608,12 +2606,12 @@ func (m *QueryAllAutoSettleRecordResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAllAutoSettleRecordResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAutoSettleRecordsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllAutoSettleRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAutoSettleRecordsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2630,10 +2628,10 @@ func (m *QueryAllAutoSettleRecordResponse) MarshalToSizedBuffer(dAtA []byte) (in i-- dAtA[i] = 0x12 } - if len(m.AutoSettleRecord) > 0 { - for iNdEx := len(m.AutoSettleRecord) - 1; iNdEx >= 0; iNdEx-- { + if len(m.AutoSettleRecords) > 0 { + for iNdEx := len(m.AutoSettleRecords) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.AutoSettleRecord[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.AutoSettleRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2753,7 +2751,7 @@ func (m *QueryGetStreamRecordResponse) Size() (n int) { return n } -func (m *QueryAllStreamRecordRequest) Size() (n int) { +func (m *QueryStreamRecordsRequest) Size() (n int) { if m == nil { return 0 } @@ -2766,14 +2764,14 @@ func (m *QueryAllStreamRecordRequest) Size() (n int) { return n } -func (m *QueryAllStreamRecordResponse) Size() (n int) { +func (m *QueryStreamRecordsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.StreamRecord) > 0 { - for _, e := range m.StreamRecord { + if len(m.StreamRecords) > 0 { + for _, e := range m.StreamRecords { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -2785,7 +2783,7 @@ func (m *QueryAllStreamRecordResponse) Size() (n int) { return n } -func (m *QueryGetPaymentAccountCountRequest) Size() (n int) { +func (m *QueryPaymentAccountCountRequest) Size() (n int) { if m == nil { return 0 } @@ -2798,7 +2796,7 @@ func (m *QueryGetPaymentAccountCountRequest) Size() (n int) { return n } -func (m *QueryGetPaymentAccountCountResponse) Size() (n int) { +func (m *QueryPaymentAccountCountResponse) Size() (n int) { if m == nil { return 0 } @@ -2809,7 +2807,7 @@ func (m *QueryGetPaymentAccountCountResponse) Size() (n int) { return n } -func (m *QueryAllPaymentAccountCountRequest) Size() (n int) { +func (m *QueryPaymentAccountCountsRequest) Size() (n int) { if m == nil { return 0 } @@ -2822,14 +2820,14 @@ func (m *QueryAllPaymentAccountCountRequest) Size() (n int) { return n } -func (m *QueryAllPaymentAccountCountResponse) Size() (n int) { +func (m *QueryPaymentAccountCountsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.PaymentAccountCount) > 0 { - for _, e := range m.PaymentAccountCount { + if len(m.PaymentAccountCounts) > 0 { + for _, e := range m.PaymentAccountCounts { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -2841,7 +2839,7 @@ func (m *QueryAllPaymentAccountCountResponse) Size() (n int) { return n } -func (m *QueryGetPaymentAccountRequest) Size() (n int) { +func (m *QueryPaymentAccountRequest) Size() (n int) { if m == nil { return 0 } @@ -2854,7 +2852,7 @@ func (m *QueryGetPaymentAccountRequest) Size() (n int) { return n } -func (m *QueryGetPaymentAccountResponse) Size() (n int) { +func (m *QueryPaymentAccountResponse) Size() (n int) { if m == nil { return 0 } @@ -2865,7 +2863,7 @@ func (m *QueryGetPaymentAccountResponse) Size() (n int) { return n } -func (m *QueryAllPaymentAccountRequest) Size() (n int) { +func (m *QueryPaymentAccountsRequest) Size() (n int) { if m == nil { return 0 } @@ -2878,14 +2876,14 @@ func (m *QueryAllPaymentAccountRequest) Size() (n int) { return n } -func (m *QueryAllPaymentAccountResponse) Size() (n int) { +func (m *QueryPaymentAccountsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.PaymentAccount) > 0 { - for _, e := range m.PaymentAccount { + if len(m.PaymentAccounts) > 0 { + for _, e := range m.PaymentAccounts { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -2934,7 +2932,7 @@ func (m *QueryDynamicBalanceResponse) Size() (n int) { return n } -func (m *QueryGetPaymentAccountsByOwnerRequest) Size() (n int) { +func (m *QueryPaymentAccountsByOwnerRequest) Size() (n int) { if m == nil { return 0 } @@ -2947,7 +2945,7 @@ func (m *QueryGetPaymentAccountsByOwnerRequest) Size() (n int) { return n } -func (m *QueryGetPaymentAccountsByOwnerResponse) Size() (n int) { +func (m *QueryPaymentAccountsByOwnerResponse) Size() (n int) { if m == nil { return 0 } @@ -2962,7 +2960,7 @@ func (m *QueryGetPaymentAccountsByOwnerResponse) Size() (n int) { return n } -func (m *QueryAllAutoSettleRecordRequest) Size() (n int) { +func (m *QueryAutoSettleRecordsRequest) Size() (n int) { if m == nil { return 0 } @@ -2975,14 +2973,14 @@ func (m *QueryAllAutoSettleRecordRequest) Size() (n int) { return n } -func (m *QueryAllAutoSettleRecordResponse) Size() (n int) { +func (m *QueryAutoSettleRecordsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.AutoSettleRecord) > 0 { - for _, e := range m.AutoSettleRecord { + if len(m.AutoSettleRecords) > 0 { + for _, e := range m.AutoSettleRecords { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -3616,7 +3614,7 @@ func (m *QueryGetStreamRecordResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllStreamRecordRequest) Unmarshal(dAtA []byte) error { +func (m *QueryStreamRecordsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3639,10 +3637,10 @@ func (m *QueryAllStreamRecordRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllStreamRecordRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryStreamRecordsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllStreamRecordRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryStreamRecordsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3702,7 +3700,7 @@ func (m *QueryAllStreamRecordRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllStreamRecordResponse) Unmarshal(dAtA []byte) error { +func (m *QueryStreamRecordsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3725,15 +3723,15 @@ func (m *QueryAllStreamRecordResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllStreamRecordResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryStreamRecordsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllStreamRecordResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryStreamRecordsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StreamRecord", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StreamRecords", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3760,8 +3758,8 @@ func (m *QueryAllStreamRecordResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StreamRecord = append(m.StreamRecord, StreamRecord{}) - if err := m.StreamRecord[len(m.StreamRecord)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.StreamRecords = append(m.StreamRecords, StreamRecord{}) + if err := m.StreamRecords[len(m.StreamRecords)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3822,7 +3820,7 @@ func (m *QueryAllStreamRecordResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPaymentAccountCountRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountCountRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3845,10 +3843,10 @@ func (m *QueryGetPaymentAccountCountRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPaymentAccountCountRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountCountRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPaymentAccountCountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountCountRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3904,7 +3902,7 @@ func (m *QueryGetPaymentAccountCountRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3927,10 +3925,10 @@ func (m *QueryGetPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPaymentAccountCountResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountCountResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPaymentAccountCountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountCountResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3987,7 +3985,7 @@ func (m *QueryGetPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPaymentAccountCountRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountCountsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4010,10 +4008,10 @@ func (m *QueryAllPaymentAccountCountRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPaymentAccountCountRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountCountsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPaymentAccountCountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountCountsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4073,7 +4071,7 @@ func (m *QueryAllPaymentAccountCountRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountCountsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4096,15 +4094,15 @@ func (m *QueryAllPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPaymentAccountCountResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountCountsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPaymentAccountCountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountCountsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PaymentAccountCount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PaymentAccountCounts", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4131,8 +4129,8 @@ func (m *QueryAllPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PaymentAccountCount = append(m.PaymentAccountCount, PaymentAccountCount{}) - if err := m.PaymentAccountCount[len(m.PaymentAccountCount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.PaymentAccountCounts = append(m.PaymentAccountCounts, PaymentAccountCount{}) + if err := m.PaymentAccountCounts[len(m.PaymentAccountCounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4193,7 +4191,7 @@ func (m *QueryAllPaymentAccountCountResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPaymentAccountRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4216,10 +4214,10 @@ func (m *QueryGetPaymentAccountRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPaymentAccountRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPaymentAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4275,7 +4273,7 @@ func (m *QueryGetPaymentAccountRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPaymentAccountResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4298,10 +4296,10 @@ func (m *QueryGetPaymentAccountResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPaymentAccountResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPaymentAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4358,7 +4356,7 @@ func (m *QueryGetPaymentAccountResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPaymentAccountRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4381,10 +4379,10 @@ func (m *QueryAllPaymentAccountRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPaymentAccountRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPaymentAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4444,7 +4442,7 @@ func (m *QueryAllPaymentAccountRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPaymentAccountResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4467,15 +4465,15 @@ func (m *QueryAllPaymentAccountResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPaymentAccountResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPaymentAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PaymentAccount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PaymentAccounts", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4502,8 +4500,8 @@ func (m *QueryAllPaymentAccountResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PaymentAccount = append(m.PaymentAccount, PaymentAccount{}) - if err := m.PaymentAccount[len(m.PaymentAccount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.PaymentAccounts = append(m.PaymentAccounts, PaymentAccount{}) + if err := m.PaymentAccounts[len(m.PaymentAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4918,7 +4916,7 @@ func (m *QueryDynamicBalanceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPaymentAccountsByOwnerRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountsByOwnerRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4941,10 +4939,10 @@ func (m *QueryGetPaymentAccountsByOwnerRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPaymentAccountsByOwnerRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountsByOwnerRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPaymentAccountsByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountsByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5000,7 +4998,7 @@ func (m *QueryGetPaymentAccountsByOwnerRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPaymentAccountsByOwnerResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPaymentAccountsByOwnerResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5023,10 +5021,10 @@ func (m *QueryGetPaymentAccountsByOwnerResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPaymentAccountsByOwnerResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPaymentAccountsByOwnerResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPaymentAccountsByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPaymentAccountsByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5082,7 +5080,7 @@ func (m *QueryGetPaymentAccountsByOwnerResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllAutoSettleRecordRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAutoSettleRecordsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5105,10 +5103,10 @@ func (m *QueryAllAutoSettleRecordRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllAutoSettleRecordRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAutoSettleRecordsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllAutoSettleRecordRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAutoSettleRecordsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5168,7 +5166,7 @@ func (m *QueryAllAutoSettleRecordRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllAutoSettleRecordResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAutoSettleRecordsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5191,15 +5189,15 @@ func (m *QueryAllAutoSettleRecordResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllAutoSettleRecordResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAutoSettleRecordsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllAutoSettleRecordResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAutoSettleRecordsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AutoSettleRecord", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AutoSettleRecords", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -5226,8 +5224,8 @@ func (m *QueryAllAutoSettleRecordResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AutoSettleRecord = append(m.AutoSettleRecord, AutoSettleRecord{}) - if err := m.AutoSettleRecord[len(m.AutoSettleRecord)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.AutoSettleRecords = append(m.AutoSettleRecords, AutoSettleRecord{}) + if err := m.AutoSettleRecords[len(m.AutoSettleRecords)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/payment/types/query.pb.gw.go b/x/payment/types/query.pb.gw.go index 3b840a38b..024c80877 100644 --- a/x/payment/types/query.pb.gw.go +++ b/x/payment/types/query.pb.gw.go @@ -214,43 +214,43 @@ func local_request_Query_StreamRecord_0(ctx context.Context, marshaler runtime.M } var ( - filter_Query_StreamRecordAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_StreamRecords_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_StreamRecordAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllStreamRecordRequest +func request_Query_StreamRecords_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStreamRecordsRequest 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_StreamRecordAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StreamRecords_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.StreamRecordAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.StreamRecords(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_StreamRecordAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllStreamRecordRequest +func local_request_Query_StreamRecords_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStreamRecordsRequest 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_StreamRecordAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StreamRecords_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.StreamRecordAll(ctx, &protoReq) + msg, err := server.StreamRecords(ctx, &protoReq) return msg, metadata, err } func request_Query_PaymentAccountCount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetPaymentAccountCountRequest + var protoReq QueryPaymentAccountCountRequest var metadata runtime.ServerMetadata var ( @@ -277,7 +277,7 @@ func request_Query_PaymentAccountCount_0(ctx context.Context, marshaler runtime. } func local_request_Query_PaymentAccountCount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetPaymentAccountCountRequest + var protoReq QueryPaymentAccountCountRequest var metadata runtime.ServerMetadata var ( @@ -304,43 +304,43 @@ func local_request_Query_PaymentAccountCount_0(ctx context.Context, marshaler ru } var ( - filter_Query_PaymentAccountCountAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_PaymentAccountCounts_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_PaymentAccountCountAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPaymentAccountCountRequest +func request_Query_PaymentAccountCounts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPaymentAccountCountsRequest 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_PaymentAccountCountAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PaymentAccountCounts_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.PaymentAccountCountAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.PaymentAccountCounts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_PaymentAccountCountAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPaymentAccountCountRequest +func local_request_Query_PaymentAccountCounts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPaymentAccountCountsRequest 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_PaymentAccountCountAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PaymentAccountCounts_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.PaymentAccountCountAll(ctx, &protoReq) + msg, err := server.PaymentAccountCounts(ctx, &protoReq) return msg, metadata, err } func request_Query_PaymentAccount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetPaymentAccountRequest + var protoReq QueryPaymentAccountRequest var metadata runtime.ServerMetadata var ( @@ -367,7 +367,7 @@ func request_Query_PaymentAccount_0(ctx context.Context, marshaler runtime.Marsh } func local_request_Query_PaymentAccount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetPaymentAccountRequest + var protoReq QueryPaymentAccountRequest var metadata runtime.ServerMetadata var ( @@ -394,37 +394,37 @@ func local_request_Query_PaymentAccount_0(ctx context.Context, marshaler runtime } var ( - filter_Query_PaymentAccountAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_PaymentAccounts_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_PaymentAccountAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPaymentAccountRequest +func request_Query_PaymentAccounts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPaymentAccountsRequest 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_PaymentAccountAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PaymentAccounts_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.PaymentAccountAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.PaymentAccounts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_PaymentAccountAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPaymentAccountRequest +func local_request_Query_PaymentAccounts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPaymentAccountsRequest 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_PaymentAccountAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PaymentAccounts_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.PaymentAccountAll(ctx, &protoReq) + msg, err := server.PaymentAccounts(ctx, &protoReq) return msg, metadata, err } @@ -483,8 +483,8 @@ func local_request_Query_DynamicBalance_0(ctx context.Context, marshaler runtime } -func request_Query_GetPaymentAccountsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetPaymentAccountsByOwnerRequest +func request_Query_PaymentAccountsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPaymentAccountsByOwnerRequest var metadata runtime.ServerMetadata var ( @@ -505,13 +505,13 @@ func request_Query_GetPaymentAccountsByOwner_0(ctx context.Context, marshaler ru return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) } - msg, err := client.GetPaymentAccountsByOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.PaymentAccountsByOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_GetPaymentAccountsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetPaymentAccountsByOwnerRequest +func local_request_Query_PaymentAccountsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPaymentAccountsByOwnerRequest var metadata runtime.ServerMetadata var ( @@ -532,43 +532,43 @@ func local_request_Query_GetPaymentAccountsByOwner_0(ctx context.Context, marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) } - msg, err := server.GetPaymentAccountsByOwner(ctx, &protoReq) + msg, err := server.PaymentAccountsByOwner(ctx, &protoReq) return msg, metadata, err } var ( - filter_Query_AutoSettleRecordAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_AutoSettleRecords_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_AutoSettleRecordAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllAutoSettleRecordRequest +func request_Query_AutoSettleRecords_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAutoSettleRecordsRequest 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_AutoSettleRecordAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AutoSettleRecords_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.AutoSettleRecordAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.AutoSettleRecords(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_AutoSettleRecordAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllAutoSettleRecordRequest +func local_request_Query_AutoSettleRecords_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAutoSettleRecordsRequest 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_AutoSettleRecordAll_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AutoSettleRecords_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.AutoSettleRecordAll(ctx, &protoReq) + msg, err := server.AutoSettleRecords(ctx, &protoReq) return msg, metadata, err } @@ -671,7 +671,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_StreamRecordAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_StreamRecords_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -682,7 +682,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_StreamRecordAll_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_StreamRecords_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 { @@ -690,7 +690,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_StreamRecordAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_StreamRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -717,7 +717,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_PaymentAccountCountAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PaymentAccountCounts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -728,7 +728,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_PaymentAccountCountAll_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_PaymentAccountCounts_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 { @@ -736,7 +736,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_PaymentAccountCountAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PaymentAccountCounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -763,7 +763,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_PaymentAccountAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PaymentAccounts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -774,7 +774,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_PaymentAccountAll_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_PaymentAccounts_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 { @@ -782,7 +782,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_PaymentAccountAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PaymentAccounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -809,7 +809,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_GetPaymentAccountsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PaymentAccountsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -820,7 +820,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_GetPaymentAccountsByOwner_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_PaymentAccountsByOwner_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 { @@ -828,11 +828,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_GetPaymentAccountsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PaymentAccountsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_AutoSettleRecordAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AutoSettleRecords_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -843,7 +843,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_AutoSettleRecordAll_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_AutoSettleRecords_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 { @@ -851,7 +851,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_AutoSettleRecordAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AutoSettleRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -976,7 +976,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_StreamRecordAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_StreamRecords_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) @@ -985,14 +985,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_StreamRecordAll_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_StreamRecords_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_StreamRecordAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_StreamRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1016,7 +1016,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_PaymentAccountCountAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PaymentAccountCounts_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) @@ -1025,14 +1025,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_PaymentAccountCountAll_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_PaymentAccountCounts_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_PaymentAccountCountAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PaymentAccountCounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1056,7 +1056,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_PaymentAccountAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PaymentAccounts_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) @@ -1065,14 +1065,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_PaymentAccountAll_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_PaymentAccounts_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_PaymentAccountAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PaymentAccounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1096,7 +1096,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_GetPaymentAccountsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PaymentAccountsByOwner_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) @@ -1105,18 +1105,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_GetPaymentAccountsByOwner_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_PaymentAccountsByOwner_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_GetPaymentAccountsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PaymentAccountsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_AutoSettleRecordAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AutoSettleRecords_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) @@ -1125,14 +1125,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_AutoSettleRecordAll_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_AutoSettleRecords_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_AutoSettleRecordAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AutoSettleRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1148,21 +1148,21 @@ var ( pattern_Query_StreamRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "stream_record", "account"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_StreamRecordAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "stream_record"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_StreamRecords_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "stream_records"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PaymentAccountCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "payment_account_count", "owner"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PaymentAccountCountAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "payment_account_count"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PaymentAccountCounts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "payment_account_counts"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_PaymentAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "payment_account", "addr"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PaymentAccountAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "payment_account"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PaymentAccounts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "payment_accounts"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_DynamicBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "dynamic_balance", "account"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_GetPaymentAccountsByOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "get_payment_accounts_by_owner", "owner"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PaymentAccountsByOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "payment_accounts_by_owner", "owner"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_AutoSettleRecordAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "auto_settle_record"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_AutoSettleRecords_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "auto_settle_records"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1174,19 +1174,19 @@ var ( forward_Query_StreamRecord_0 = runtime.ForwardResponseMessage - forward_Query_StreamRecordAll_0 = runtime.ForwardResponseMessage + forward_Query_StreamRecords_0 = runtime.ForwardResponseMessage forward_Query_PaymentAccountCount_0 = runtime.ForwardResponseMessage - forward_Query_PaymentAccountCountAll_0 = runtime.ForwardResponseMessage + forward_Query_PaymentAccountCounts_0 = runtime.ForwardResponseMessage forward_Query_PaymentAccount_0 = runtime.ForwardResponseMessage - forward_Query_PaymentAccountAll_0 = runtime.ForwardResponseMessage + forward_Query_PaymentAccounts_0 = runtime.ForwardResponseMessage forward_Query_DynamicBalance_0 = runtime.ForwardResponseMessage - forward_Query_GetPaymentAccountsByOwner_0 = runtime.ForwardResponseMessage + forward_Query_PaymentAccountsByOwner_0 = runtime.ForwardResponseMessage - forward_Query_AutoSettleRecordAll_0 = runtime.ForwardResponseMessage + forward_Query_AutoSettleRecords_0 = runtime.ForwardResponseMessage ) diff --git a/x/storage/client/cli/query.go b/x/storage/client/cli/query.go index 6d8075541..1da91bc8e 100644 --- a/x/storage/client/cli/query.go +++ b/x/storage/client/cli/query.go @@ -30,7 +30,7 @@ func GetQueryCmd() *cobra.Command { CmdListObjects(), CmdVerifyPermission(), CmdHeadGroup(), - CmdListGroup(), + CmdListGroups(), CmdHeadGroupMember()) // this line is used by starport scaffolding # 1 @@ -249,10 +249,10 @@ func CmdHeadGroup() *cobra.Command { return cmd } -func CmdListGroup() *cobra.Command { +func CmdListGroups() *cobra.Command { cmd := &cobra.Command{ - Use: "list-group [group-owner]", - Short: "Query list group of owner", + Use: "list-groups [group-owner]", + Short: "Query list groups of owner", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { reqGroupOwner := args[0] @@ -264,11 +264,11 @@ func CmdListGroup() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryListGroupRequest{ + params := &types.QueryListGroupsRequest{ GroupOwner: reqGroupOwner, } - res, err := queryClient.ListGroup(cmd.Context(), params) + res, err := queryClient.ListGroups(cmd.Context(), params) if err != nil { return err } diff --git a/x/storage/client/cli/query_test.go b/x/storage/client/cli/query_test.go index ff984294c..36141b89b 100644 --- a/x/storage/client/cli/query_test.go +++ b/x/storage/client/cli/query_test.go @@ -93,15 +93,15 @@ func (s *CLITestSuite) TestQueryCmd() { false, "", &types.QueryListBucketsResponse{}, }, { - "query list-group", + "query list-groups", append( []string{ - "list-group", + "list-groups", sample.RandAccAddressHex(), }, commonFlags..., ), - false, "", &types.QueryListGroupResponse{}, + false, "", &types.QueryListGroupsResponse{}, }, { "query list-objects", diff --git a/x/storage/keeper/grpc_query.go b/x/storage/keeper/grpc_query.go index f4affc3d8..ea2aa50a7 100644 --- a/x/storage/keeper/grpc_query.go +++ b/x/storage/keeper/grpc_query.go @@ -161,6 +161,9 @@ func (k Keeper) ListBuckets(goCtx context.Context, req *types.QueryListBucketsRe } ctx := sdk.UnwrapSDKContext(goCtx) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } var bucketInfos []*types.BucketInfo store := ctx.KVStore(k.storeKey) @@ -183,10 +186,17 @@ func (k Keeper) ListObjects(goCtx context.Context, req *types.QueryListObjectsRe if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } + if req.BucketName == "" { + return nil, status.Error(codes.InvalidArgument, "bucket name should not be empty") + } if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) } + ctx := sdk.UnwrapSDKContext(goCtx) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } var objectInfos []*types.ObjectInfo store := ctx.KVStore(k.storeKey) @@ -214,6 +224,9 @@ func (k Keeper) ListObjectsByBucketId(goCtx context.Context, req *types.QueryLis } ctx := sdk.UnwrapSDKContext(goCtx) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } var objectInfos []*types.ObjectInfo store := ctx.KVStore(k.storeKey) @@ -486,16 +499,18 @@ func (k Keeper) HeadGroup(goCtx context.Context, req *types.QueryHeadGroupReques return &types.QueryHeadGroupResponse{GroupInfo: groupInfo}, nil } -func (k Keeper) ListGroup(goCtx context.Context, req *types.QueryListGroupRequest) (*types.QueryListGroupResponse, error) { +func (k Keeper) ListGroups(goCtx context.Context, req *types.QueryListGroupsRequest) (*types.QueryListGroupsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - if req.Pagination != nil && req.Pagination.Limit > types.MaxPaginationLimit { return nil, status.Errorf(codes.InvalidArgument, "exceed pagination limit %d", types.MaxPaginationLimit) } ctx := sdk.UnwrapSDKContext(goCtx) + if err := query.CheckOffsetQueryNotAllowed(ctx, req.Pagination); err != nil { + return nil, err + } owner, err := sdk.AccAddressFromHexUnsafe(req.GroupOwner) if err != nil { @@ -517,7 +532,7 @@ func (k Keeper) ListGroup(goCtx context.Context, req *types.QueryListGroupReques return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryListGroupResponse{GroupInfos: groupInfos, Pagination: pageRes}, nil + return &types.QueryListGroupsResponse{GroupInfos: groupInfos, Pagination: pageRes}, nil } func (k Keeper) HeadGroupMember(goCtx context.Context, req *types.QueryHeadGroupMemberRequest) (*types.QueryHeadGroupMemberResponse, error) { diff --git a/x/storage/keeper/grpc_query_test.go b/x/storage/keeper/grpc_query_test.go index 79b99b8d2..dc2f9ccb9 100644 --- a/x/storage/keeper/grpc_query_test.go +++ b/x/storage/keeper/grpc_query_test.go @@ -297,6 +297,14 @@ func TestListObjects(t *testing.T) { require.ErrorContains(t, err, "invalid request") _, err = k.ListObjects(ctx, &types.QueryListObjectsRequest{ + Pagination: &query.PageRequest{ + Limit: types.MaxPaginationLimit, + }, + }) + require.ErrorContains(t, err, "bucket name should not be empty") + + _, err = k.ListObjects(ctx, &types.QueryListObjectsRequest{ + BucketName: "abc", Pagination: &query.PageRequest{ Limit: types.MaxPaginationLimit + 1, }, @@ -409,17 +417,17 @@ func TestHeadGroup(t *testing.T) { func TestListGroup(t *testing.T) { // invalid argument k, ctx := makeKeeper(t) - _, err := k.ListGroup(ctx, nil) + _, err := k.ListGroups(ctx, nil) require.ErrorContains(t, err, "invalid request") - _, err = k.ListGroup(ctx, &types.QueryListGroupRequest{ + _, err = k.ListGroups(ctx, &types.QueryListGroupsRequest{ Pagination: &query.PageRequest{ Limit: types.MaxPaginationLimit + 1, }, }) require.ErrorContains(t, err, "exceed pagination limit") - _, err = k.ListGroup(ctx, &types.QueryListGroupRequest{ + _, err = k.ListGroups(ctx, &types.QueryListGroupsRequest{ GroupOwner: "xxx", }) require.ErrorContains(t, err, "invalid address hex length") @@ -428,7 +436,7 @@ func TestListGroup(t *testing.T) { func TestHeadGroupMember(t *testing.T) { // invalid argument k, ctx := makeKeeper(t) - _, err := k.ListGroup(ctx, nil) + _, err := k.ListGroups(ctx, nil) require.ErrorContains(t, err, "invalid request") _, err = k.HeadGroupMember(ctx, &types.QueryHeadGroupMemberRequest{ diff --git a/x/storage/types/query.pb.go b/x/storage/types/query.pb.go index 1c5f26ca7..44a18846d 100644 --- a/x/storage/types/query.pb.go +++ b/x/storage/types/query.pb.go @@ -1221,23 +1221,23 @@ func (m *QueryHeadGroupResponse) GetGroupInfo() *GroupInfo { return nil } -type QueryListGroupRequest struct { +type QueryListGroupsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` GroupOwner string `protobuf:"bytes,2,opt,name=group_owner,json=groupOwner,proto3" json:"group_owner,omitempty"` } -func (m *QueryListGroupRequest) Reset() { *m = QueryListGroupRequest{} } -func (m *QueryListGroupRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListGroupRequest) ProtoMessage() {} -func (*QueryListGroupRequest) Descriptor() ([]byte, []int) { +func (m *QueryListGroupsRequest) Reset() { *m = QueryListGroupsRequest{} } +func (m *QueryListGroupsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListGroupsRequest) ProtoMessage() {} +func (*QueryListGroupsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b1b80b580af04cb0, []int{25} } -func (m *QueryListGroupRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryListGroupsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListGroupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListGroupsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListGroupRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListGroupsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1247,49 +1247,49 @@ func (m *QueryListGroupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *QueryListGroupRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListGroupRequest.Merge(m, src) +func (m *QueryListGroupsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListGroupsRequest.Merge(m, src) } -func (m *QueryListGroupRequest) XXX_Size() int { +func (m *QueryListGroupsRequest) XXX_Size() int { return m.Size() } -func (m *QueryListGroupRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListGroupRequest.DiscardUnknown(m) +func (m *QueryListGroupsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListGroupsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListGroupRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryListGroupsRequest proto.InternalMessageInfo -func (m *QueryListGroupRequest) GetPagination() *query.PageRequest { +func (m *QueryListGroupsRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -func (m *QueryListGroupRequest) GetGroupOwner() string { +func (m *QueryListGroupsRequest) GetGroupOwner() string { if m != nil { return m.GroupOwner } return "" } -type QueryListGroupResponse struct { +type QueryListGroupsResponse struct { Pagination *query.PageResponse `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` GroupInfos []*GroupInfo `protobuf:"bytes,2,rep,name=group_infos,json=groupInfos,proto3" json:"group_infos,omitempty"` } -func (m *QueryListGroupResponse) Reset() { *m = QueryListGroupResponse{} } -func (m *QueryListGroupResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListGroupResponse) ProtoMessage() {} -func (*QueryListGroupResponse) Descriptor() ([]byte, []int) { +func (m *QueryListGroupsResponse) Reset() { *m = QueryListGroupsResponse{} } +func (m *QueryListGroupsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListGroupsResponse) ProtoMessage() {} +func (*QueryListGroupsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b1b80b580af04cb0, []int{26} } -func (m *QueryListGroupResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListGroupsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListGroupsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListGroupResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListGroupsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1299,26 +1299,26 @@ func (m *QueryListGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *QueryListGroupResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListGroupResponse.Merge(m, src) +func (m *QueryListGroupsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListGroupsResponse.Merge(m, src) } -func (m *QueryListGroupResponse) XXX_Size() int { +func (m *QueryListGroupsResponse) XXX_Size() int { return m.Size() } -func (m *QueryListGroupResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListGroupResponse.DiscardUnknown(m) +func (m *QueryListGroupsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListGroupsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListGroupResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListGroupsResponse proto.InternalMessageInfo -func (m *QueryListGroupResponse) GetPagination() *query.PageResponse { +func (m *QueryListGroupsResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } return nil } -func (m *QueryListGroupResponse) GetGroupInfos() []*GroupInfo { +func (m *QueryListGroupsResponse) GetGroupInfos() []*GroupInfo { if m != nil { return m.GroupInfos } @@ -2159,8 +2159,8 @@ func init() { proto.RegisterType((*QueryVerifyPermissionResponse)(nil), "greenfield.storage.QueryVerifyPermissionResponse") proto.RegisterType((*QueryHeadGroupRequest)(nil), "greenfield.storage.QueryHeadGroupRequest") proto.RegisterType((*QueryHeadGroupResponse)(nil), "greenfield.storage.QueryHeadGroupResponse") - proto.RegisterType((*QueryListGroupRequest)(nil), "greenfield.storage.QueryListGroupRequest") - proto.RegisterType((*QueryListGroupResponse)(nil), "greenfield.storage.QueryListGroupResponse") + proto.RegisterType((*QueryListGroupsRequest)(nil), "greenfield.storage.QueryListGroupsRequest") + proto.RegisterType((*QueryListGroupsResponse)(nil), "greenfield.storage.QueryListGroupsResponse") proto.RegisterType((*QueryHeadGroupMemberRequest)(nil), "greenfield.storage.QueryHeadGroupMemberRequest") proto.RegisterType((*QueryHeadGroupMemberResponse)(nil), "greenfield.storage.QueryHeadGroupMemberResponse") proto.RegisterType((*QueryPolicyForGroupRequest)(nil), "greenfield.storage.QueryPolicyForGroupRequest") @@ -2185,166 +2185,166 @@ func init() { func init() { proto.RegisterFile("greenfield/storage/query.proto", fileDescriptor_b1b80b580af04cb0) } var fileDescriptor_b1b80b580af04cb0 = []byte{ - // 2543 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0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x38, 0x35, 0x47, - 0x60, 0x6d, 0xab, 0x8f, 0xdf, 0x57, 0xd0, 0x17, 0x62, 0x8d, 0x0f, 0xd6, 0x36, 0xf0, 0x1b, 0x03, - 0x2d, 0xc7, 0xbc, 0x55, 0x65, 0x70, 0xc4, 0x33, 0x74, 0x95, 0xfa, 0x15, 0x86, 0xee, 0x22, 0xae, - 0x96, 0xa1, 0x73, 0xb6, 0x02, 0xad, 0x27, 0xe8, 0xb0, 0x3e, 0xfe, 0x1d, 0x24, 0x99, 0x73, 0x4d, - 0x25, 0x49, 0x4e, 0xf0, 0xec, 0x25, 0xd1, 0x4b, 0x72, 0xdf, 0xea, 0xdb, 0x0c, 0xdf, 0x2d, 0x7c, - 0x63, 0x20, 0x3e, 0xce, 0x88, 0x24, 0x93, 0xac, 0xf5, 0x24, 0xea, 0x24, 0x4e, 0x79, 0xcc, 0xc9, - 0x97, 0xa4, 0x3c, 0x43, 0xde, 0xef, 0x0e, 0x74, 0x79, 0xca, 0x01, 0x1e, 0xa4, 0x3c, 0xfa, 0xb3, - 0x40, 0x9c, 0xf2, 0x88, 0xfd, 0xdb, 0x6b, 0xca, 0x33, 0x34, 0xe2, 0x10, 0x29, 0x17, 0xc1, 0x4b, - 0xa6, 0xfc, 0x07, 0x0a, 0x9a, 0x96, 0xe8, 0x77, 0x3c, 0x38, 0x24, 0xd9, 0x3f, 0x04, 0x54, 0x2e, - 0x0c, 0xb7, 0x19, 0x20, 0x9e, 0x63, 0x10, 0x55, 0x7c, 0x2a, 0x0f, 0x62, 0xd3, 0xf6, 0x03, 0xa8, - 0x4a, 0x1f, 0xff, 0x0c, 0x40, 0x01, 0xb5, 0x5c, 0x02, 0x2a, 0x49, 0xc8, 0x97, 0x80, 0x4a, 0xb1, - 0xd5, 0xc5, 0x71, 0x63, 0xa0, 0x78, 0xdc, 0xfc, 0x54, 0xc3, 0xf9, 0x8b, 0x82, 0x5e, 0xcb, 0x25, - 0xe2, 0xf1, 0xd5, 0x61, 0xec, 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xea, 0x2b, 0x78, 0x31, 0x0f, 0xb5, 0xed, 0x73, 0x12, 0xc7, 0x00, 0x9e, 0x32, 0x05, 0xfa, - 0x6f, 0xe2, 0xfb, 0x2f, 0xc3, 0x2b, 0x14, 0x7c, 0xff, 0x0d, 0x22, 0x4e, 0x0a, 0xbe, 0xff, 0x06, - 0xd2, 0x16, 0xea, 0x1d, 0x86, 0xfe, 0x36, 0xbe, 0x99, 0x87, 0x5e, 0x6e, 0x04, 0xbe, 0xc1, 0xbe, - 0xbb, 0x45, 0x0f, 0xb3, 0xad, 0xbe, 0xd6, 0x83, 0x37, 0x7d, 0xfc, 0x81, 0x82, 0x0e, 0xa7, 0x3f, - 0xde, 0x0b, 0xa6, 0xb5, 0x2c, 0xa9, 0x51, 0x30, 0xf6, 0xe4, 0xf0, 0x01, 0x43, 0xa0, 0x4e, 0xc1, - 0xcd, 0x5e, 0x0d, 0x7e, 0x3f, 0x2c, 0xf3, 0xd9, 0x3c, 0xb6, 0xa3, 0xa0, 0xd6, 0xf3, 0x79, 0x91, - 0x5d, 0xa2, 0x2f, 0xac, 0x18, 0x19, 0xbd, 0x68, 0x12, 0x11, 0xe7, 0xd2, 0x5f, 0xa9, 0x7d, 0xf4, - 0x62, 0x5e, 0xf9, 0xf8, 0xc5, 0xbc, 0xf2, 0xef, 0x17, 0xf3, 0xca, 0xf7, 0x5f, 0xce, 0xef, 0xfb, - 0xf8, 0xe5, 0xfc, 0xbe, 0x7f, 0xbd, 0x9c, 0xdf, 0xf7, 0x58, 0x93, 0x28, 0xba, 0xba, 0x53, 0x5f, - 0x30, 0x9f, 0x10, 0xdb, 0x91, 0x2d, 0x3c, 0x4f, 0xfe, 0x5f, 0xb9, 0xfa, 0x04, 0xfb, 0x7f, 0x70, - 0x97, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0x53, 0xc7, 0xdb, 0xaa, 0x65, 0x28, 0x00, 0x00, + // 2544 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08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to suppress errors if they are not otherwise used. @@ -2390,7 +2390,7 @@ type QueryClient interface { // Queries a group with specify owner and name . HeadGroup(ctx context.Context, in *QueryHeadGroupRequest, opts ...grpc.CallOption) (*QueryHeadGroupResponse, error) // Queries a list of ListGroup items. - ListGroup(ctx context.Context, in *QueryListGroupRequest, opts ...grpc.CallOption) (*QueryListGroupResponse, error) + ListGroups(ctx context.Context, in *QueryListGroupsRequest, opts ...grpc.CallOption) (*QueryListGroupsResponse, error) // Queries a list of HeadGroupMember items. HeadGroupMember(ctx context.Context, in *QueryHeadGroupMemberRequest, opts ...grpc.CallOption) (*QueryHeadGroupMemberResponse, error) // Queries a policy that grants permission to a group @@ -2554,9 +2554,9 @@ func (c *queryClient) HeadGroup(ctx context.Context, in *QueryHeadGroupRequest, return out, nil } -func (c *queryClient) ListGroup(ctx context.Context, in *QueryListGroupRequest, opts ...grpc.CallOption) (*QueryListGroupResponse, error) { - out := new(QueryListGroupResponse) - err := c.cc.Invoke(ctx, "/greenfield.storage.Query/ListGroup", in, out, opts...) +func (c *queryClient) ListGroups(ctx context.Context, in *QueryListGroupsRequest, opts ...grpc.CallOption) (*QueryListGroupsResponse, error) { + out := new(QueryListGroupsResponse) + err := c.cc.Invoke(ctx, "/greenfield.storage.Query/ListGroups", in, out, opts...) if err != nil { return nil, err } @@ -2677,7 +2677,7 @@ type QueryServer interface { // Queries a group with specify owner and name . HeadGroup(context.Context, *QueryHeadGroupRequest) (*QueryHeadGroupResponse, error) // Queries a list of ListGroup items. - ListGroup(context.Context, *QueryListGroupRequest) (*QueryListGroupResponse, error) + ListGroups(context.Context, *QueryListGroupsRequest) (*QueryListGroupsResponse, error) // Queries a list of HeadGroupMember items. HeadGroupMember(context.Context, *QueryHeadGroupMemberRequest) (*QueryHeadGroupMemberResponse, error) // Queries a policy that grants permission to a group @@ -2747,8 +2747,8 @@ func (*UnimplementedQueryServer) VerifyPermission(ctx context.Context, req *Quer func (*UnimplementedQueryServer) HeadGroup(ctx context.Context, req *QueryHeadGroupRequest) (*QueryHeadGroupResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method HeadGroup not implemented") } -func (*UnimplementedQueryServer) ListGroup(ctx context.Context, req *QueryListGroupRequest) (*QueryListGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListGroup not implemented") +func (*UnimplementedQueryServer) ListGroups(ctx context.Context, req *QueryListGroupsRequest) (*QueryListGroupsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListGroups not implemented") } func (*UnimplementedQueryServer) HeadGroupMember(ctx context.Context, req *QueryHeadGroupMemberRequest) (*QueryHeadGroupMemberResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method HeadGroupMember not implemented") @@ -3052,20 +3052,20 @@ func _Query_HeadGroup_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } -func _Query_ListGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListGroupRequest) +func _Query_ListGroups_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListGroupsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).ListGroup(ctx, in) + return srv.(QueryServer).ListGroups(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/greenfield.storage.Query/ListGroup", + FullMethod: "/greenfield.storage.Query/ListGroups", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListGroup(ctx, req.(*QueryListGroupRequest)) + return srv.(QueryServer).ListGroups(ctx, req.(*QueryListGroupsRequest)) } return interceptor(ctx, in, info, handler) } @@ -3297,8 +3297,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_HeadGroup_Handler, }, { - MethodName: "ListGroup", - Handler: _Query_ListGroup_Handler, + MethodName: "ListGroups", + Handler: _Query_ListGroups_Handler, }, { MethodName: "HeadGroupMember", @@ -4240,7 +4240,7 @@ func (m *QueryHeadGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryListGroupRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryListGroupsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4250,12 +4250,12 @@ func (m *QueryListGroupRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryListGroupRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryListGroupsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListGroupRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryListGroupsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -4282,7 +4282,7 @@ func (m *QueryListGroupRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryListGroupResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryListGroupsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4292,12 +4292,12 @@ func (m *QueryListGroupResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryListGroupResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryListGroupsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryListGroupsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -5401,7 +5401,7 @@ func (m *QueryHeadGroupResponse) Size() (n int) { return n } -func (m *QueryListGroupRequest) Size() (n int) { +func (m *QueryListGroupsRequest) Size() (n int) { if m == nil { return 0 } @@ -5418,7 +5418,7 @@ func (m *QueryListGroupRequest) Size() (n int) { return n } -func (m *QueryListGroupResponse) Size() (n int) { +func (m *QueryListGroupsResponse) Size() (n int) { if m == nil { return 0 } @@ -8106,7 +8106,7 @@ func (m *QueryHeadGroupResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListGroupRequest) Unmarshal(dAtA []byte) error { +func (m *QueryListGroupsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8129,10 +8129,10 @@ func (m *QueryListGroupRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListGroupRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListGroupsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListGroupsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8224,7 +8224,7 @@ func (m *QueryListGroupRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListGroupResponse) Unmarshal(dAtA []byte) error { +func (m *QueryListGroupsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8247,10 +8247,10 @@ func (m *QueryListGroupResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListGroupResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListGroupsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListGroupsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/storage/types/query.pb.gw.go b/x/storage/types/query.pb.gw.go index 6707fddf8..5e5667fad 100644 --- a/x/storage/types/query.pb.gw.go +++ b/x/storage/types/query.pb.gw.go @@ -961,11 +961,11 @@ func local_request_Query_HeadGroup_0(ctx context.Context, marshaler runtime.Mars } var ( - filter_Query_ListGroup_0 = &utilities.DoubleArray{Encoding: map[string]int{"group_owner": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_ListGroups_0 = &utilities.DoubleArray{Encoding: map[string]int{"group_owner": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) -func request_Query_ListGroup_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryListGroupRequest +func request_Query_ListGroups_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListGroupsRequest var metadata runtime.ServerMetadata var ( @@ -989,17 +989,17 @@ func request_Query_ListGroup_0(ctx context.Context, marshaler runtime.Marshaler, if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListGroup_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListGroups_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.ListGroup(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.ListGroups(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_ListGroup_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryListGroupRequest +func local_request_Query_ListGroups_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListGroupsRequest var metadata runtime.ServerMetadata var ( @@ -1023,11 +1023,11 @@ func local_request_Query_ListGroup_0(ctx context.Context, marshaler runtime.Mars if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListGroup_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListGroups_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.ListGroup(ctx, &protoReq) + msg, err := server.ListGroups(ctx, &protoReq) return msg, metadata, err } @@ -1899,7 +1899,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_ListGroup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_ListGroups_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -1910,7 +1910,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_ListGroup_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_ListGroups_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 { @@ -1918,7 +1918,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_ListGroup_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_ListGroups_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -2470,7 +2470,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_ListGroup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_ListGroups_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) @@ -2479,14 +2479,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_ListGroup_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_ListGroups_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_ListGroup_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_ListGroups_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -2704,7 +2704,7 @@ var ( pattern_Query_HeadGroup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"greenfield", "storage", "head_group", "group_owner", "group_name"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_ListGroup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "storage", "list_group", "group_owner"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ListGroups_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "storage", "list_groups", "group_owner"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_HeadGroupMember_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "storage", "head_group_member"}, "", runtime.AssumeColonVerbOpt(false))) @@ -2756,7 +2756,7 @@ var ( forward_Query_HeadGroup_0 = runtime.ForwardResponseMessage - forward_Query_ListGroup_0 = runtime.ForwardResponseMessage + forward_Query_ListGroups_0 = runtime.ForwardResponseMessage forward_Query_HeadGroupMember_0 = runtime.ForwardResponseMessage diff --git a/x/storage/types/types.go b/x/storage/types/types.go index 8a69491a6..8d2136a71 100644 --- a/x/storage/types/types.go +++ b/x/storage/types/types.go @@ -15,7 +15,7 @@ type ( const ( TagKeyTraits = "traits" TagValueOmit = "omit" - MaxPaginationLimit = 200 // the default limit is 100 if pagination parameters is not provided + MaxPaginationLimit = 200 // the default limit is 200 if pagination parameters is not provided ) func (m *BucketInfo) ToNFTMetadata() *BucketMetaData { From 3f580f783d955886c15a252423a58b7f2cbcede6 Mon Sep 17 00:00:00 2001 From: dylanhuang Date: Thu, 3 Aug 2023 13:37:36 +0800 Subject: [PATCH 17/24] docs: update testnet asset to v0.2.3 (#402) --- asset/configs/testnet_config/app.toml | 2 +- asset/configs/testnet_config/config.toml | 12 +- asset/configs/testnet_config/genesis.json | 1048 ++++++++++++++------- 3 files changed, 690 insertions(+), 372 deletions(-) diff --git a/asset/configs/testnet_config/app.toml b/asset/configs/testnet_config/app.toml index 30e9017a0..d5cd42866 100644 --- a/asset/configs/testnet_config/app.toml +++ b/asset/configs/testnet_config/app.toml @@ -283,4 +283,4 @@ max-txs = "5000" # chain-id for current chain src-chain-id = 5600 # chain-id for destination chain(bsc) -dest-chain-id = 97 +dest-bsc-chain-id = 97 diff --git a/asset/configs/testnet_config/config.toml b/asset/configs/testnet_config/config.toml index b6b4a69cc..f3292a478 100644 --- a/asset/configs/testnet_config/config.toml +++ b/asset/configs/testnet_config/config.toml @@ -215,7 +215,7 @@ external_address = "" seeds = "" # Comma separated list of nodes to keep persistent connections to -persistent_peers = "f35d1c0920d3b42f313f682907ff996f3ab08cd9@k8s-gnfdfull-gnfdfull-5caecaf140-3641960911e9b27b.elb.ap-northeast-1.amazonaws.com:26656,071fc182cda17d93d1a086060898bfb405418dc7@k8s-gnfdfull-gnfdfull-915e53c8f7-bca52664efa2d3fe.elb.us-east-1.amazonaws.com:26656" +persistent_peers = "7a635c262955a2e85c654615f390f3a3e9c71328@k8s-gnfdfull-gnfdfull-514c3179cd-d1c316adcbfbfd3c.elb.us-east-1.amazonaws.com:26656,f811d0f87415bcc5daba37ec925b137a1b403372@k8s-gnfdfull-gnfdfull-92f4e91ef7-3d981d8d310e48f1.elb.ap-northeast-1.amazonaws.com:26656" # UPNP port forwarding upnp = false @@ -334,7 +334,7 @@ ttl-num-blocks = 0 # the network to take and serve state machine snapshots. State sync is not attempted if the node # has any local state (LastBlockHeight > 0). The node will have a truncated block history, # starting from the height of the snapshot. -enable = false +enable = true # RPC servers (comma-separated) for light client verification of the synced state machine and # retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding @@ -342,10 +342,10 @@ enable = false # # For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 # weeks) during which they can be financially punished (slashed) for misbehavior. -rpc_servers = "" -trust_height = 0 -trust_hash = "" -trust_period = "168h0m0s" +rpc_servers = "https://gnfd-testnet-fullnode-tendermint-ap.bnbchain.org:443,https://gnfd-testnet-fullnode-tendermint-ap.bnbchain.org:443" +trust_height = 65000 +trust_hash = "AC28AB55C96AFC73BC8313C5C99E4028A6FDBBCD22C02A95EFAC743B220F083A" +trust_period = "999999h0m0s" # Time to spend discovering snapshots before initiating a restore. discovery_time = "15s" diff --git a/asset/configs/testnet_config/genesis.json b/asset/configs/testnet_config/genesis.json index aa0f62c21..d737309f5 100644 --- a/asset/configs/testnet_config/genesis.json +++ b/asset/configs/testnet_config/genesis.json @@ -1,10 +1,11 @@ { - "genesis_time": "2023-06-25T02:42:08.762425Z", + "genesis_time": "2023-07-31T09:54:56.764005Z", "chain_id": "greenfield_5600-1", "initial_height": "1", "consensus_params": { "block": { - "max_bytes": "22020096", + "max_txs": "500", + "max_bytes": "1048576", "max_gas": "-1" }, "evidence": { @@ -34,444 +35,486 @@ "accounts": [ { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x89b7f5dBAde74CB8c2c78Af26B3841cFF8182945", + "address": "0x30C9eaD1aafc7ACeD3dF6EE5868f10766485c5B5", "pub_key": null, "account_number": "0", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x1CA8e333a58b292d0e12Dd01F3314cAbB52e3975", + "address": "0x2c29c11069Ad404D8CE0d04d1EA646310a300306", "pub_key": null, "account_number": "1", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x9D37729D08A346A5548a58Bf69Ec629d5B51A9b5", + "address": "0xeC09d6E7D8B3F4ddE3D4Ec684172e325fA1af852", "pub_key": null, "account_number": "2", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xcA3168c36ceaC3ED7eE7C6097B031f94A2C62094", + "address": "0xa258eb261Ccd5Ae0AAbc757bDc4f40634FF7b5eA", "pub_key": null, "account_number": "3", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x14ed904094a90cE2E8274E64a8D70F59cEDAdBdF", + "address": "0xEeeE317f27dD698C8F0Eb06Cc331f37129eC351B", "pub_key": null, "account_number": "4", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x3a1422D7d1466aA95302F20eE45236258b8C2472", + "address": "0x41F3B0C665D0b1a918B4AA48FB691561BeC05E47", "pub_key": null, "account_number": "5", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xcB22c3FcdDd5Ee57639b0f053ce50C7516eC1fBF", + "address": "0xA7F5CE47701CB1988c92958d5B94583fa3AFCee4", "pub_key": null, "account_number": "6", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x5fd2786474F9785725CfD617B733ecfCB1A09142", + "address": "0x748d9CAAEE996f793612ad9d21Fe4F06B638C1a4", "pub_key": null, "account_number": "7", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xd232339d21D20673CAb8c7EA2b7e96B1Ceb702C5", + "address": "0xe5B0A517809D0980582722Ae7505f19A5592cB25", "pub_key": null, "account_number": "8", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x19FC305a8C2107125e3eC6Ee05C5a47894B70392", + "address": "0xa661b6eE4970713EA38962a37b9DC6fF24a203c5", "pub_key": null, "account_number": "9", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x317AF415a8964509014160C8d255fa1d23B87768", + "address": "0x5dB332dB5e312223c0Ae2bb7305453814D1AF182", "pub_key": null, "account_number": "10", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xE2100FE4575C4bC9A87e4D0f16d4359e2d65a0A3", + "address": "0x94e5Ca4349df395bFBc1c933b007Cf79Df545A19", "pub_key": null, "account_number": "11", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xe12692932eF227EbCbF73C20e8ec8F9FA5333715", + "address": "0x9Ed0F2B0Ca585D7728966421db19A97C83a879D4", "pub_key": null, "account_number": "12", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x530750b734A59b7762d28F4440d370CFb2b14C46", + "address": "0xAd0d91320117DDdec10e7Cba66e393B1AaC0D8f6", "pub_key": null, "account_number": "13", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x149Cb630Bc5BC853Aa72C1B2fEb0f4E1A0CFFe6A", + "address": "0x08D2F2FE8dc0B9E0aE4DCD1b6D8aA46f9C71dbE0", "pub_key": null, "account_number": "14", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xF543641BCdc9C8C5d993473376eE1B40A2b0780b", + "address": "0x3364A7ccBBFc623AcAC3d8691450218Ff5e8d5Ea", "pub_key": null, "account_number": "15", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x7051943E02fbABdAB53C7b0Ea3890bF375517FaB", + "address": "0x67d3Fe3A13CE1f7AcB683278164CA5abC854efa1", "pub_key": null, "account_number": "16", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x2283a68aa25e372eAdfE76adF604388C7b8EE10d", + "address": "0xCd9122341c22A89901c9Fd87F84Bd5B8A32ac90a", "pub_key": null, "account_number": "17", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x552680552d2F2B9342AC9cA55eB7a173F7C51bda", + "address": "0x7E64d4676fcEFE17BC2dd01182992987D63B6205", "pub_key": null, "account_number": "18", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x045f487b6070E8D6D3a60Cd932e0f9E8BA53B4e7", + "address": "0x878427DDDd2b65985D36A82D527b0273cd86BFAC", "pub_key": null, "account_number": "19", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x53CF9745E01dDd6C4217ddBb9a73b57Af9E977f9", + "address": "0x4EFF7B03d1bF18Aa22f197aec96CF37b551B4176", "pub_key": null, "account_number": "20", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xe630C94958220B8a7BD6c7438BFD273009047306", + "address": "0x48A1aae6aB9FA8FE9d5F0A24f1b075ef48F2a6F5", "pub_key": null, "account_number": "21", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xd8EF56759FB89A23a88795841a2857Cf705B33A5", + "address": "0x04610ac4921dA11F230deFc3F5f4d7bF382c843A", "pub_key": null, "account_number": "22", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xC80e147fBF307b97B0553a6359A50b70025eb0C7", + "address": "0xfABDd8b607201667fE54054CB4AD9068Afa2993e", "pub_key": null, "account_number": "23", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x7258A423040087004037260Ab2BB7dD0f15F42c9", + "address": "0x634AafEf507e28a907815Aa8025C7850A2945120", "pub_key": null, "account_number": "24", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x57647B3324D03A95Bb710b3cb2e8af1FF15653FA", + "address": "0x0dFA33E3260986f4Bf3A2C515fCeCD3b4e8D1DAe", "pub_key": null, "account_number": "25", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x65460A347cD5244350B46343D3F961f0fC3B3Bfa", + "address": "0x171cDB9420a990c1E0c1711C67d9218686823CF6", "pub_key": null, "account_number": "26", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xc6c47b723a00cFa0FDA7759a8c75a433b01887fe", + "address": "0x2697e8FfFf3B4cBc2927fD69a8b70CEc6eDf33d4", "pub_key": null, "account_number": "27", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x7715d0680fE84cA6d7eaEF6e8A7CAcE29a4C0064", + "address": "0xfeb17aDA5076B13C68b4CD83aA8918c2931d66f0", "pub_key": null, "account_number": "28", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x34C78a5BCC1b0fD7F58E4f36393d29A356603698", + "address": "0x307E33532E039440134d29C00b5F73ea85A6430e", "pub_key": null, "account_number": "29", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x735851c190f6999826f2a128dD53b9cA02F32C25", + "address": "0x1f0b30996a0a91091a34Af953876a318cB10dF8e", "pub_key": null, "account_number": "30", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x2489613b7AA789e7e6f5f6713D95154AEdF4A9DC", + "address": "0xaf73d3E602B84309c292f05b27B29c00d76E9134", "pub_key": null, "account_number": "31", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x35Bb57d2b84E363a293F918f273975B8dfAE8201", + "address": "0xC6D661d5Ee633eA3DfD4D86f368cdd839D682D18", "pub_key": null, "account_number": "32", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x22804504786F44289D4156E7317142e25B92c00e", + "address": "0xc6c47b723a00cFa0FDA7759a8c75a433b01887fe", "pub_key": null, "account_number": "33", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xd641C35f947Eb60676f0e0793691bB174256C651", + "address": "0xCE5FC4786fbbFEf97841B2CB3c3F1C3A03C3ba13", "pub_key": null, "account_number": "34", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xE4F1Ac4B9312724D2819347c5c91252b650C4AEb", + "address": "0x3146305eB4fA7C069c873f8D01e93909703e2389", "pub_key": null, "account_number": "35", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xaF07AdBb21029adf12FB6E4515Ed8dA0A7e252a2", + "address": "0xEA0FB8E8341C287805d1204b0b7E88DdbB6F7192", "pub_key": null, "account_number": "36", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xfF755134416a0Ebc4A614f951163a2Ecf48C069b", + "address": "0xBf94803A169D34f3F8f67F243be4288866C8B08b", "pub_key": null, "account_number": "37", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xE42B5AD90AfF1e8Ad90F76e02541A71Ca9D41A11", + "address": "0xDC6Aa552aae06EE8b5F78bA849D6e29675C38D04", "pub_key": null, "account_number": "38", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x05e10816F92aB9aE545733db2f73bB858F9DC1fa", + "address": "0x8A26E3752031A08cBf791f45f09dee66579a8A9d", "pub_key": null, "account_number": "39", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x47B07B9dBA6117F800b4f7D2e31B0C4b32127A90", + "address": "0x1Bba5f483efADc5ECecD372A7326beE90bc3F865", "pub_key": null, "account_number": "40", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xAe51dE302F70A7a2ff9d04B3c372e90de1518329", + "address": "0xf7ddEE80B3710ad1926d784571feF70B15493D92", "pub_key": null, "account_number": "41", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xC0B4285E54981011853197b535DF27Dfb24eEde5", + "address": "0x36a088954a587eEc93b58eBbA552aa20d5d7E698", "pub_key": null, "account_number": "42", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x5E340C0721bD5f49627e7E34eb94bedfA575E993", + "address": "0x3d7aa60c7F8bf5A9bF9CafAf075DE348845C515F", "pub_key": null, "account_number": "43", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xD3af86C62D53dA3aD7FD3eaF867D91E1Ba9c61AC", + "address": "0x9E49844DB47f07c7059131F9635fa56Cb3CE8c57", "pub_key": null, "account_number": "44", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xFCE3084e2AC67E1f698926b7FbcbD2204bFa7F92", + "address": "0x9770a28871268f62F0aDc37D14eBED5B7C4dFc95", "pub_key": null, "account_number": "45", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xbc01dE0Cc6D7F23822De6352c570d7E4798070f7", + "address": "0x26e38923b66dFdf25575377AA8521Db5287421aE", "pub_key": null, "account_number": "46", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x61FcD913b09894fa53d926bEFc2ED92EF3F014b2", + "address": "0x0e4E6325307c80eaBFE1F9fe8Ca54504d7e26cB4", "pub_key": null, "account_number": "47", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xC6fA3F3640e3b594335efAb349abdD4A82C83736", + "address": "0xC2fCA75950fD6bbE9E67f441E7B2f1B1a197C3c3", "pub_key": null, "account_number": "48", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x8FeD9Ba853B685c2e482DEba08cE30F6942A9F2f", + "address": "0xcf8351B881D578DaCEeb7fc55B0b4fB0971070f6", "pub_key": null, "account_number": "49", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x3f92219ef03F8aF218F9DA601Eaf254DB022f13D", + "address": "0x02EA1f2f26D09fb771D4BDCEcF47eF4Fa0444765", "pub_key": null, "account_number": "50", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x4ea8378e4c64a41e417750E8f7fBa0F264AD379A", + "address": "0x169F5002cdE1bC58d130edCeE40818DD7e862aF9", "pub_key": null, "account_number": "51", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x431EA58C86Abd737e0606cEa0f332115a4E1F5c1", + "address": "0x6508D5Ec804Bf96F8367eB09b5C6218D81E64c68", "pub_key": null, "account_number": "52", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x3CFC8b2095DA8F0722412Dc16f8A067942d2c697", + "address": "0x5C1Af1bC9F751616145BC7f521bE3E5571332152", "pub_key": null, "account_number": "53", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xE44c4e725598CCa7Da3c506869d658a84e599983", + "address": "0xb27457Bb90C902B690c276A470A5fA393FD7BD4F", "pub_key": null, "account_number": "54", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x43416fd2Dd08Bc6F2004B9a5fA53686B7F541d58", + "address": "0x4C54914cc75DB4851F461b10a11429C33C817bBb", "pub_key": null, "account_number": "55", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x0DC08D602aaAAAA7e2fD604f9f96DdD2cD67FE51", + "address": "0xc748C39C96e708218e54971231F795391FCB690C", "pub_key": null, "account_number": "56", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xD27faC13b0C38f57ce1840Fc55e7B8b66dEBB342", + "address": "0x5944ffdA31A929510fD9842adE32B0cf5aFb402b", "pub_key": null, "account_number": "57", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xB573F5c174f33aF0CA033c8A287061C1538fb130", + "address": "0x30fD9d9dD53dddda51A90B97D31ad186702aC31F", "pub_key": null, "account_number": "58", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x4B956d53E466a53d5FdE86781F1f547B44a19260", + "address": "0x7df63379274A445AA4eFa6cc2bFb574B41B7D859", "pub_key": null, "account_number": "59", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x674d969927AbA4eE9Cd05e5079655BB099D83d85", + "address": "0x49F4236Da953c2CEa8904CC0Cc71F562c5AAa1fE", "pub_key": null, "account_number": "60", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0x648848d33938Ab930Da70cC71eda2Bd0175f7150", + "address": "0xBce1030CF99c6a5b55cAf461ba4349acebaB89B4", "pub_key": null, "account_number": "61", "sequence": "0" }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", - "address": "0xc5f1910AF4771720395f33f2FBBe782233215b4B", + "address": "0xF5E274F603B79312e575d90B1F09b0d784AB171D", "pub_key": null, "account_number": "62", "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "0x229ECf480a25469d924cfF7B8eFAbac6ab0baEca", + "pub_key": null, + "account_number": "63", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "0x3ae3A9670D85B7F80aF823Ac2Ca72415d0975D0b", + "pub_key": null, + "account_number": "64", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "0x6128C0850864783C668a9c906295Fb7c16a0e9fb", + "pub_key": null, + "account_number": "65", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "0x46c091B03728df63b3D53ADd1f40A87A27Ff5b50", + "pub_key": null, + "account_number": "66", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "0x6ecDEDB0a6D42B268D222e5DaFBF686Ad6f4CD6e", + "pub_key": null, + "account_number": "67", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "0x37E728443fa75b1dF65214033EBa15aD9840b544", + "pub_key": null, + "account_number": "68", + "sequence": "0" } ] }, @@ -485,7 +528,7 @@ }, "balances": [ { - "address": "0x045f487b6070E8D6D3a60Cd932e0f9E8BA53B4e7", + "address": "0x02EA1f2f26D09fb771D4BDCEcF47eF4Fa0444765", "coins": [ { "denom": "BNB", @@ -494,7 +537,7 @@ ] }, { - "address": "0x05e10816F92aB9aE545733db2f73bB858F9DC1fa", + "address": "0x04610ac4921dA11F230deFc3F5f4d7bF382c843A", "coins": [ { "denom": "BNB", @@ -503,7 +546,7 @@ ] }, { - "address": "0x0DC08D602aaAAAA7e2fD604f9f96DdD2cD67FE51", + "address": "0x08D2F2FE8dc0B9E0aE4DCD1b6D8aA46f9C71dbE0", "coins": [ { "denom": "BNB", @@ -512,7 +555,7 @@ ] }, { - "address": "0x149Cb630Bc5BC853Aa72C1B2fEb0f4E1A0CFFe6A", + "address": "0x0dFA33E3260986f4Bf3A2C515fCeCD3b4e8D1DAe", "coins": [ { "denom": "BNB", @@ -521,16 +564,16 @@ ] }, { - "address": "0x14ed904094a90cE2E8274E64a8D70F59cEDAdBdF", + "address": "0x0e4E6325307c80eaBFE1F9fe8Ca54504d7e26cB4", "coins": [ { "denom": "BNB", - "amount": "3000000000000000000000" + "amount": "2000000000000000000000" } ] }, { - "address": "0x19FC305a8C2107125e3eC6Ee05C5a47894B70392", + "address": "0x169F5002cdE1bC58d130edCeE40818DD7e862aF9", "coins": [ { "denom": "BNB", @@ -539,16 +582,16 @@ ] }, { - "address": "0x1CA8e333a58b292d0e12Dd01F3314cAbB52e3975", + "address": "0x171cDB9420a990c1E0c1711C67d9218686823CF6", "coins": [ { "denom": "BNB", - "amount": "3000000000000000000000" + "amount": "2000000000000000000000" } ] }, { - "address": "0x22804504786F44289D4156E7317142e25B92c00e", + "address": "0x1Bba5f483efADc5ECecD372A7326beE90bc3F865", "coins": [ { "denom": "BNB", @@ -557,7 +600,7 @@ ] }, { - "address": "0x2283a68aa25e372eAdfE76adF604388C7b8EE10d", + "address": "0x1f0b30996a0a91091a34Af953876a318cB10dF8e", "coins": [ { "denom": "BNB", @@ -566,7 +609,7 @@ ] }, { - "address": "0x2489613b7AA789e7e6f5f6713D95154AEdF4A9DC", + "address": "0x229ECf480a25469d924cfF7B8eFAbac6ab0baEca", "coins": [ { "denom": "BNB", @@ -575,7 +618,7 @@ ] }, { - "address": "0x317AF415a8964509014160C8d255fa1d23B87768", + "address": "0x2697e8FfFf3B4cBc2927fD69a8b70CEc6eDf33d4", "coins": [ { "denom": "BNB", @@ -584,7 +627,7 @@ ] }, { - "address": "0x34C78a5BCC1b0fD7F58E4f36393d29A356603698", + "address": "0x26e38923b66dFdf25575377AA8521Db5287421aE", "coins": [ { "denom": "BNB", @@ -593,7 +636,16 @@ ] }, { - "address": "0x35Bb57d2b84E363a293F918f273975B8dfAE8201", + "address": "0x2c29c11069Ad404D8CE0d04d1EA646310a300306", + "coins": [ + { + "denom": "BNB", + "amount": "3000000000000000000000" + } + ] + }, + { + "address": "0x307E33532E039440134d29C00b5F73ea85A6430e", "coins": [ { "denom": "BNB", @@ -602,7 +654,7 @@ ] }, { - "address": "0x3a1422D7d1466aA95302F20eE45236258b8C2472", + "address": "0x30C9eaD1aafc7ACeD3dF6EE5868f10766485c5B5", "coins": [ { "denom": "BNB", @@ -611,7 +663,7 @@ ] }, { - "address": "0x3CFC8b2095DA8F0722412Dc16f8A067942d2c697", + "address": "0x30fD9d9dD53dddda51A90B97D31ad186702aC31F", "coins": [ { "denom": "BNB", @@ -620,7 +672,7 @@ ] }, { - "address": "0x3f92219ef03F8aF218F9DA601Eaf254DB022f13D", + "address": "0x3146305eB4fA7C069c873f8D01e93909703e2389", "coins": [ { "denom": "BNB", @@ -629,7 +681,7 @@ ] }, { - "address": "0x431EA58C86Abd737e0606cEa0f332115a4E1F5c1", + "address": "0x3364A7ccBBFc623AcAC3d8691450218Ff5e8d5Ea", "coins": [ { "denom": "BNB", @@ -638,7 +690,7 @@ ] }, { - "address": "0x43416fd2Dd08Bc6F2004B9a5fA53686B7F541d58", + "address": "0x36a088954a587eEc93b58eBbA552aa20d5d7E698", "coins": [ { "denom": "BNB", @@ -647,7 +699,7 @@ ] }, { - "address": "0x47B07B9dBA6117F800b4f7D2e31B0C4b32127A90", + "address": "0x37E728443fa75b1dF65214033EBa15aD9840b544", "coins": [ { "denom": "BNB", @@ -656,7 +708,7 @@ ] }, { - "address": "0x4B956d53E466a53d5FdE86781F1f547B44a19260", + "address": "0x3ae3A9670D85B7F80aF823Ac2Ca72415d0975D0b", "coins": [ { "denom": "BNB", @@ -665,7 +717,7 @@ ] }, { - "address": "0x4ea8378e4c64a41e417750E8f7fBa0F264AD379A", + "address": "0x3d7aa60c7F8bf5A9bF9CafAf075DE348845C515F", "coins": [ { "denom": "BNB", @@ -674,16 +726,16 @@ ] }, { - "address": "0x530750b734A59b7762d28F4440d370CFb2b14C46", + "address": "0x41F3B0C665D0b1a918B4AA48FB691561BeC05E47", "coins": [ { "denom": "BNB", - "amount": "2000000000000000000000" + "amount": "3000000000000000000000" } ] }, { - "address": "0x53CF9745E01dDd6C4217ddBb9a73b57Af9E977f9", + "address": "0x46c091B03728df63b3D53ADd1f40A87A27Ff5b50", "coins": [ { "denom": "BNB", @@ -692,7 +744,7 @@ ] }, { - "address": "0x552680552d2F2B9342AC9cA55eB7a173F7C51bda", + "address": "0x48A1aae6aB9FA8FE9d5F0A24f1b075ef48F2a6F5", "coins": [ { "denom": "BNB", @@ -701,7 +753,7 @@ ] }, { - "address": "0x57647B3324D03A95Bb710b3cb2e8af1FF15653FA", + "address": "0x49F4236Da953c2CEa8904CC0Cc71F562c5AAa1fE", "coins": [ { "denom": "BNB", @@ -710,7 +762,7 @@ ] }, { - "address": "0x5E340C0721bD5f49627e7E34eb94bedfA575E993", + "address": "0x4C54914cc75DB4851F461b10a11429C33C817bBb", "coins": [ { "denom": "BNB", @@ -719,16 +771,16 @@ ] }, { - "address": "0x5fd2786474F9785725CfD617B733ecfCB1A09142", + "address": "0x4EFF7B03d1bF18Aa22f197aec96CF37b551B4176", "coins": [ { "denom": "BNB", - "amount": "3000000000000000000000" + "amount": "2000000000000000000000" } ] }, { - "address": "0x61FcD913b09894fa53d926bEFc2ED92EF3F014b2", + "address": "0x5944ffdA31A929510fD9842adE32B0cf5aFb402b", "coins": [ { "denom": "BNB", @@ -737,7 +789,7 @@ ] }, { - "address": "0x648848d33938Ab930Da70cC71eda2Bd0175f7150", + "address": "0x5C1Af1bC9F751616145BC7f521bE3E5571332152", "coins": [ { "denom": "BNB", @@ -746,16 +798,16 @@ ] }, { - "address": "0x65460A347cD5244350B46343D3F961f0fC3B3Bfa", + "address": "0x5dB332dB5e312223c0Ae2bb7305453814D1AF182", "coins": [ { "denom": "BNB", - "amount": "2000000000000000000000" + "amount": "3000000000000000000000" } ] }, { - "address": "0x674d969927AbA4eE9Cd05e5079655BB099D83d85", + "address": "0x6128C0850864783C668a9c906295Fb7c16a0e9fb", "coins": [ { "denom": "BNB", @@ -764,7 +816,7 @@ ] }, { - "address": "0x7051943E02fbABdAB53C7b0Ea3890bF375517FaB", + "address": "0x634AafEf507e28a907815Aa8025C7850A2945120", "coins": [ { "denom": "BNB", @@ -773,7 +825,7 @@ ] }, { - "address": "0x7258A423040087004037260Ab2BB7dD0f15F42c9", + "address": "0x6508D5Ec804Bf96F8367eB09b5C6218D81E64c68", "coins": [ { "denom": "BNB", @@ -782,7 +834,7 @@ ] }, { - "address": "0x735851c190f6999826f2a128dD53b9cA02F32C25", + "address": "0x67d3Fe3A13CE1f7AcB683278164CA5abC854efa1", "coins": [ { "denom": "BNB", @@ -791,7 +843,7 @@ ] }, { - "address": "0x7715d0680fE84cA6d7eaEF6e8A7CAcE29a4C0064", + "address": "0x6ecDEDB0a6D42B268D222e5DaFBF686Ad6f4CD6e", "coins": [ { "denom": "BNB", @@ -800,7 +852,7 @@ ] }, { - "address": "0x89b7f5dBAde74CB8c2c78Af26B3841cFF8182945", + "address": "0x748d9CAAEE996f793612ad9d21Fe4F06B638C1a4", "coins": [ { "denom": "BNB", @@ -809,7 +861,7 @@ ] }, { - "address": "0x8FeD9Ba853B685c2e482DEba08cE30F6942A9F2f", + "address": "0x7df63379274A445AA4eFa6cc2bFb574B41B7D859", "coins": [ { "denom": "BNB", @@ -818,16 +870,16 @@ ] }, { - "address": "0x9D37729D08A346A5548a58Bf69Ec629d5B51A9b5", + "address": "0x7E64d4676fcEFE17BC2dd01182992987D63B6205", "coins": [ { "denom": "BNB", - "amount": "3000000000000000000000" + "amount": "2000000000000000000000" } ] }, { - "address": "0xAe51dE302F70A7a2ff9d04B3c372e90de1518329", + "address": "0x878427DDDd2b65985D36A82D527b0273cd86BFAC", "coins": [ { "denom": "BNB", @@ -836,7 +888,7 @@ ] }, { - "address": "0xaF07AdBb21029adf12FB6E4515Ed8dA0A7e252a2", + "address": "0x8A26E3752031A08cBf791f45f09dee66579a8A9d", "coins": [ { "denom": "BNB", @@ -845,7 +897,7 @@ ] }, { - "address": "0xB573F5c174f33aF0CA033c8A287061C1538fb130", + "address": "0x94e5Ca4349df395bFBc1c933b007Cf79Df545A19", "coins": [ { "denom": "BNB", @@ -854,7 +906,7 @@ ] }, { - "address": "0xbc01dE0Cc6D7F23822De6352c570d7E4798070f7", + "address": "0x9770a28871268f62F0aDc37D14eBED5B7C4dFc95", "coins": [ { "denom": "BNB", @@ -863,7 +915,7 @@ ] }, { - "address": "0xC0B4285E54981011853197b535DF27Dfb24eEde5", + "address": "0x9E49844DB47f07c7059131F9635fa56Cb3CE8c57", "coins": [ { "denom": "BNB", @@ -872,7 +924,7 @@ ] }, { - "address": "0xc5f1910AF4771720395f33f2FBBe782233215b4B", + "address": "0x9Ed0F2B0Ca585D7728966421db19A97C83a879D4", "coins": [ { "denom": "BNB", @@ -881,25 +933,34 @@ ] }, { - "address": "0xc6c47b723a00cFa0FDA7759a8c75a433b01887fe", + "address": "0xa258eb261Ccd5Ae0AAbc757bDc4f40634FF7b5eA", "coins": [ { "denom": "BNB", - "amount": "1867000000000000000000000" + "amount": "3000000000000000000000" } ] }, { - "address": "0xC6fA3F3640e3b594335efAb349abdD4A82C83736", + "address": "0xa661b6eE4970713EA38962a37b9DC6fF24a203c5", "coins": [ { "denom": "BNB", - "amount": "2000000000000000000000" + "amount": "3000000000000000000000" + } + ] + }, + { + "address": "0xA7F5CE47701CB1988c92958d5B94583fa3AFCee4", + "coins": [ + { + "denom": "BNB", + "amount": "3000000000000000000000" } ] }, { - "address": "0xC80e147fBF307b97B0553a6359A50b70025eb0C7", + "address": "0xAd0d91320117DDdec10e7Cba66e393B1AaC0D8f6", "coins": [ { "denom": "BNB", @@ -908,34 +969,34 @@ ] }, { - "address": "0xcA3168c36ceaC3ED7eE7C6097B031f94A2C62094", + "address": "0xaf73d3E602B84309c292f05b27B29c00d76E9134", "coins": [ { "denom": "BNB", - "amount": "3000000000000000000000" + "amount": "2000000000000000000000" } ] }, { - "address": "0xcB22c3FcdDd5Ee57639b0f053ce50C7516eC1fBF", + "address": "0xb27457Bb90C902B690c276A470A5fA393FD7BD4F", "coins": [ { "denom": "BNB", - "amount": "3000000000000000000000" + "amount": "2000000000000000000000" } ] }, { - "address": "0xd232339d21D20673CAb8c7EA2b7e96B1Ceb702C5", + "address": "0xBce1030CF99c6a5b55cAf461ba4349acebaB89B4", "coins": [ { "denom": "BNB", - "amount": "3000000000000000000000" + "amount": "2000000000000000000000" } ] }, { - "address": "0xD27faC13b0C38f57ce1840Fc55e7B8b66dEBB342", + "address": "0xBf94803A169D34f3F8f67F243be4288866C8B08b", "coins": [ { "denom": "BNB", @@ -944,7 +1005,7 @@ ] }, { - "address": "0xD3af86C62D53dA3aD7FD3eaF867D91E1Ba9c61AC", + "address": "0xC2fCA75950fD6bbE9E67f441E7B2f1B1a197C3c3", "coins": [ { "denom": "BNB", @@ -953,7 +1014,16 @@ ] }, { - "address": "0xd641C35f947Eb60676f0e0793691bB174256C651", + "address": "0xc6c47b723a00cFa0FDA7759a8c75a433b01887fe", + "coins": [ + { + "denom": "BNB", + "amount": "1853000000000000000000000" + } + ] + }, + { + "address": "0xC6D661d5Ee633eA3DfD4D86f368cdd839D682D18", "coins": [ { "denom": "BNB", @@ -962,7 +1032,7 @@ ] }, { - "address": "0xd8EF56759FB89A23a88795841a2857Cf705B33A5", + "address": "0xc748C39C96e708218e54971231F795391FCB690C", "coins": [ { "denom": "BNB", @@ -971,7 +1041,7 @@ ] }, { - "address": "0xe12692932eF227EbCbF73C20e8ec8F9FA5333715", + "address": "0xCd9122341c22A89901c9Fd87F84Bd5B8A32ac90a", "coins": [ { "denom": "BNB", @@ -980,7 +1050,7 @@ ] }, { - "address": "0xE2100FE4575C4bC9A87e4D0f16d4359e2d65a0A3", + "address": "0xCE5FC4786fbbFEf97841B2CB3c3F1C3A03C3ba13", "coins": [ { "denom": "BNB", @@ -989,7 +1059,7 @@ ] }, { - "address": "0xE42B5AD90AfF1e8Ad90F76e02541A71Ca9D41A11", + "address": "0xcf8351B881D578DaCEeb7fc55B0b4fB0971070f6", "coins": [ { "denom": "BNB", @@ -998,7 +1068,7 @@ ] }, { - "address": "0xE44c4e725598CCa7Da3c506869d658a84e599983", + "address": "0xDC6Aa552aae06EE8b5F78bA849D6e29675C38D04", "coins": [ { "denom": "BNB", @@ -1007,7 +1077,16 @@ ] }, { - "address": "0xE4F1Ac4B9312724D2819347c5c91252b650C4AEb", + "address": "0xe5B0A517809D0980582722Ae7505f19A5592cB25", + "coins": [ + { + "denom": "BNB", + "amount": "3000000000000000000000" + } + ] + }, + { + "address": "0xEA0FB8E8341C287805d1204b0b7E88DdbB6F7192", "coins": [ { "denom": "BNB", @@ -1016,7 +1095,25 @@ ] }, { - "address": "0xe630C94958220B8a7BD6c7438BFD273009047306", + "address": "0xeC09d6E7D8B3F4ddE3D4Ec684172e325fA1af852", + "coins": [ + { + "denom": "BNB", + "amount": "3000000000000000000000" + } + ] + }, + { + "address": "0xEeeE317f27dD698C8F0Eb06Cc331f37129eC351B", + "coins": [ + { + "denom": "BNB", + "amount": "3000000000000000000000" + } + ] + }, + { + "address": "0xF5E274F603B79312e575d90B1F09b0d784AB171D", "coins": [ { "denom": "BNB", @@ -1025,7 +1122,7 @@ ] }, { - "address": "0xF543641BCdc9C8C5d993473376eE1B40A2b0780b", + "address": "0xf7ddEE80B3710ad1926d784571feF70B15493D92", "coins": [ { "denom": "BNB", @@ -1034,7 +1131,7 @@ ] }, { - "address": "0xFCE3084e2AC67E1f698926b7FbcbD2204bFa7F92", + "address": "0xfABDd8b607201667fE54054CB4AD9068Afa2993e", "coins": [ { "denom": "BNB", @@ -1043,7 +1140,7 @@ ] }, { - "address": "0xfF755134416a0Ebc4A614f951163a2Ecf48C069b", + "address": "0xfeb17aDA5076B13C68b4CD83aA8918c2931d66f0", "coins": [ { "denom": "BNB", @@ -1058,8 +1155,8 @@ }, "bridge": { "params": { - "transfer_out_relayer_fee": "250000000000000", - "transfer_out_ack_relayer_fee": "0" + "bsc_transfer_out_relayer_fee": "250000000000000", + "bsc_transfer_out_ack_relayer_fee": "0" } }, "challenge": { @@ -1073,15 +1170,17 @@ "reward_validator_ratio": "0.900000000000000000", "reward_submitter_ratio": "0.001000000000000000", "reward_submitter_threshold": "1000000000000000", - "heartbeat_interval": "1000", - "attestation_inturn_interval": "120", - "attestation_kept_count": "300" + "heartbeat_interval": "100", + "attestation_inturn_interval": "600", + "attestation_kept_count": "300", + "sp_slash_max_amount": "5000000000000000000", + "sp_slash_counting_window": "43200" } }, "consensus": null, "crosschain": { "params": { - "init_module_balance": "1867000000000000000000000" + "init_module_balance": "1853000000000000000000000" } }, "distribution": { @@ -1142,6 +1241,12 @@ "fixed_gas": "0" } }, + { + "msg_type_url": "/cosmos.crosschain.v1.MsgUpdateChannelPermissions", + "fixed_type": { + "fixed_gas": "0" + } + }, { "msg_type_url": "/cosmos.distribution.v1beta1.MsgUpdateParams", "fixed_type": { @@ -1397,7 +1502,7 @@ { "msg_type_url": "/greenfield.storage.MsgSealObject", "fixed_type": { - "fixed_gas": "1200" + "fixed_gas": "120" } }, { @@ -1472,6 +1577,12 @@ "fixed_gas": "1200" } }, + { + "msg_type_url": "/greenfield.storage.MsgUpdateGroupExtra", + "fixed_type": { + "fixed_gas": "1200" + } + }, { "msg_type_url": "/greenfield.storage.MsgMirrorGroup", "fixed_type": { @@ -1526,6 +1637,42 @@ "fixed_gas": "100" } }, + { + "msg_type_url": "/greenfield.virtualgroup.MsgCreateGlobalVirtualGroup", + "fixed_type": { + "fixed_gas": "1000000" + } + }, + { + "msg_type_url": "/greenfield.virtualgroup.MsgDeleteGlobalVirtualGroup", + "fixed_type": { + "fixed_gas": "1200" + } + }, + { + "msg_type_url": "/greenfield.virtualgroup.MsgDeposit", + "fixed_type": { + "fixed_gas": "1200" + } + }, + { + "msg_type_url": "/greenfield.virtualgroup.MsgWithdraw", + "fixed_type": { + "fixed_gas": "1200" + } + }, + { + "msg_type_url": "/greenfield.virtualgroup.MsgSettle", + "fixed_type": { + "fixed_gas": "1200" + } + }, + { + "msg_type_url": "/greenfield.virtualgroup.MsgUpdateParams", + "fixed_type": { + "fixed_gas": "1200" + } + }, { "msg_type_url": "/cosmos.authz.v1beta1.MsgGrant", "grant_type": { @@ -1556,27 +1703,29 @@ "messages": [ { "@type": "/greenfield.sp.MsgCreateStorageProvider", - "creator": "0x7715d0680fE84cA6d7eaEF6e8A7CAcE29a4C0064", + "creator": "0xCE5FC4786fbbFEf97841B2CB3c3F1C3A03C3ba13", "description": { - "moniker": "Cogsworth", + "moniker": "bnb-chain-sp-1", "identity": "", - "website": "https://gnfd-testnet-sp-1.bnbchain.org", + "website": "https://gnfd-testnet-sp1.bnbchain.org", "security_contact": "", - "details": "Cogsworth" - }, - "sp_address": "0x7715d0680fE84cA6d7eaEF6e8A7CAcE29a4C0064", - "funding_address": "0x34C78a5BCC1b0fD7F58E4f36393d29A356603698", - "seal_address": "0x735851c190f6999826f2a128dD53b9cA02F32C25", - "approval_address": "0x2489613b7AA789e7e6f5f6713D95154AEdF4A9DC", - "gc_address": "0x35Bb57d2b84E363a293F918f273975B8dfAE8201", - "endpoint": "https://gnfd-testnet-sp-1.bnbchain.org", + "details": "bnb-chain-sp-1" + }, + "sp_address": "0xCE5FC4786fbbFEf97841B2CB3c3F1C3A03C3ba13", + "funding_address": "0x3146305eB4fA7C069c873f8D01e93909703e2389", + "seal_address": "0xEA0FB8E8341C287805d1204b0b7E88DdbB6F7192", + "approval_address": "0xBf94803A169D34f3F8f67F243be4288866C8B08b", + "gc_address": "0xDC6Aa552aae06EE8b5F78bA849D6e29675C38D04", + "endpoint": "https://gnfd-testnet-sp1.bnbchain.org", "deposit": { "denom": "BNB", "amount": "1000000000000000000000" }, - "read_price": "100.000000000000000000", - "free_read_quota": "10000", - "store_price": "10000.000000000000000000" + "read_price": "0.108000000000000000", + "free_read_quota": "1073741824", + "store_price": "0.016000000000000000", + "bls_key": "a32ac8bca191e645646b84c83bc604af20c5f589bfa6cf52f554bb7baa4ba74b4a1822cfad2cf0368561092ab94d4030", + "bls_proof": "8735246220d44f1f51e09a02f27d20df78ac9a5e8d0eafdd3fe54271b0a7ecf42263d2d41705bd847401695205e9d6b8158cec60d57d048b006765a1653c22f02b886711aeb621c63ca86da3ea6fb66491f9da1943de12a18fdc28a812a364aa" } ], "memo": "", @@ -1589,7 +1738,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "AhcaMqS5m/EmwZGl8CGezwZyiNoz0W25wGkEwduSGnuH" + "key": "Am+TLEhVMm35bM6PIXxA6+uskH8z934hpYIRYwqgOfni" }, "mode_info": { "single": { @@ -1608,7 +1757,7 @@ "tip": null }, "signatures": [ - "Gf4lnUS7zgQ/7cmnLm8KsakHdzIoaaalgMG+PyFHyC53b4bFnCaBOfRM/q7MQMWxPOEGKlXd+xpFxpWHDy0jOAA=" + "SPn6NAiRhHKtbGkNd85VkVllnYcewbmHMDKP5sFsAcsuoV1YZ1mXtylrxTgEzwBZW/tvEtgjTA2xtmSRKh6phwA=" ] }, { @@ -1616,27 +1765,29 @@ "messages": [ { "@type": "/greenfield.sp.MsgCreateStorageProvider", - "creator": "0x22804504786F44289D4156E7317142e25B92c00e", + "creator": "0x8A26E3752031A08cBf791f45f09dee66579a8A9d", "description": { - "moniker": "Zenon", + "moniker": "bnb-chain-sp-2", "identity": "", - "website": "https://gnfd-testnet-sp-2.bnbchain.org", + "website": "https://gnfd-testnet-sp2.bnbchain.org", "security_contact": "", - "details": "Zenon" - }, - "sp_address": "0x22804504786F44289D4156E7317142e25B92c00e", - "funding_address": "0xd641C35f947Eb60676f0e0793691bB174256C651", - "seal_address": "0xE4F1Ac4B9312724D2819347c5c91252b650C4AEb", - "approval_address": "0xaF07AdBb21029adf12FB6E4515Ed8dA0A7e252a2", - "gc_address": "0xfF755134416a0Ebc4A614f951163a2Ecf48C069b", - "endpoint": "https://gnfd-testnet-sp-2.bnbchain.org", + "details": "bnb-chain-sp-2" + }, + "sp_address": "0x8A26E3752031A08cBf791f45f09dee66579a8A9d", + "funding_address": "0x1Bba5f483efADc5ECecD372A7326beE90bc3F865", + "seal_address": "0xf7ddEE80B3710ad1926d784571feF70B15493D92", + "approval_address": "0x36a088954a587eEc93b58eBbA552aa20d5d7E698", + "gc_address": "0x3d7aa60c7F8bf5A9bF9CafAf075DE348845C515F", + "endpoint": "https://gnfd-testnet-sp2.bnbchain.org", "deposit": { "denom": "BNB", "amount": "1000000000000000000000" }, - "read_price": "100.000000000000000000", - "free_read_quota": "10000", - "store_price": "10000.000000000000000000" + "read_price": "0.108000000000000000", + "free_read_quota": "1073741824", + "store_price": "0.016000000000000000", + "bls_key": "894902409975b7be0744c93db03c3849723eef89fdd75d40e6f7bf2deb854610a26f59aa1d5b47cf8ea3e2144e3c9ba2", + "bls_proof": "8e446282b53674929fbafbd3862997bd724d16bfe2921241a4bb99354ae7f85741b856dbf60bd3862982a40063119a0a1329a44ecb2d6a8d8ea36fe4b4160ad1142cedea5ae27232abac4577476869d52abc2ba828b0f7115de574fea7836a63" } ], "memo": "", @@ -1649,7 +1800,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "A/m0HQwdK7aGBO5SYSFurtdAJRnefQ8oN68HkSg8x22/" + "key": "AoEb91c8LHJCaaLj6qQBI3ZeDExa7Cq8UumNL+3NG2z3" }, "mode_info": { "single": { @@ -1668,7 +1819,7 @@ "tip": null }, "signatures": [ - "ihRW+L8DGll+3rNlss1+tocZyHctSg2OhS+37AXpR6RpszXVG7IUfLK1mV6njpJ+neQMxDCb3UWYhTMsFHKBHwA=" + "R5KQBySBM+V3/2snNslAGBfzuAHYiMx/mkToENXzPI9cAqlHPPK08fBkFsHVt4LIUQKsRzVaquvR427j0qfLOgE=" ] }, { @@ -1676,27 +1827,29 @@ "messages": [ { "@type": "/greenfield.sp.MsgCreateStorageProvider", - "creator": "0xE42B5AD90AfF1e8Ad90F76e02541A71Ca9D41A11", + "creator": "0x9E49844DB47f07c7059131F9635fa56Cb3CE8c57", "description": { - "moniker": "Neuronet", + "moniker": "bnb-chain-sp-3", "identity": "", - "website": "https://gnfd-testnet-sp-3.bnbchain.org", + "website": "https://gnfd-testnet-sp3.bnbchain.org", "security_contact": "", - "details": "Neuronet" - }, - "sp_address": "0xE42B5AD90AfF1e8Ad90F76e02541A71Ca9D41A11", - "funding_address": "0x05e10816F92aB9aE545733db2f73bB858F9DC1fa", - "seal_address": "0x47B07B9dBA6117F800b4f7D2e31B0C4b32127A90", - "approval_address": "0xAe51dE302F70A7a2ff9d04B3c372e90de1518329", - "gc_address": "0xC0B4285E54981011853197b535DF27Dfb24eEde5", - "endpoint": "https://gnfd-testnet-sp-3.bnbchain.org", + "details": "bnb-chain-sp-3" + }, + "sp_address": "0x9E49844DB47f07c7059131F9635fa56Cb3CE8c57", + "funding_address": "0x9770a28871268f62F0aDc37D14eBED5B7C4dFc95", + "seal_address": "0x26e38923b66dFdf25575377AA8521Db5287421aE", + "approval_address": "0x0e4E6325307c80eaBFE1F9fe8Ca54504d7e26cB4", + "gc_address": "0xC2fCA75950fD6bbE9E67f441E7B2f1B1a197C3c3", + "endpoint": "https://gnfd-testnet-sp3.bnbchain.org", "deposit": { "denom": "BNB", "amount": "1000000000000000000000" }, - "read_price": "100.000000000000000000", - "free_read_quota": "10000", - "store_price": "10000.000000000000000000" + "read_price": "0.108000000000000000", + "free_read_quota": "1073741824", + "store_price": "0.016000000000000000", + "bls_key": "ab95e035d6606fac6e2c0bbc391d7563e27476a9a25ab8d16cf568b4b7440ac6fad78fb7953b36f33a49015976f562f1", + "bls_proof": "8f350a21378e6eb37b2f7fbe369d5a4e74f71d2121126f9dcd38851749851f68abe1afc555c0d114faca9250e773ce9d035d06619b041a3895500feecdf4428e2c335f2d83248f9e0a35629df74075f68f42694fabcdcd0b07a612934635c066" } ], "memo": "", @@ -1709,7 +1862,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "Am5dLJNLPQYJ+1P6553JrOKHvZ0bt/Gvi4h7d27efgUg" + "key": "A0Y2VnqJMlGE1rODktaKE5WNGsBHQ0cIpAHTl3S9Whqm" }, "mode_info": { "single": { @@ -1728,7 +1881,7 @@ "tip": null }, "signatures": [ - "0QUvcSHboDtmCSimZ7BHqlZ38zVSpD0EhxkIi6IG3HcVG3CLDe64Dnhw2Tr6g53eGwjWbHftF4GywSL8EJ9lwQA=" + "daAuUYAyJs06imBg5YaIF22Xfv54Dng1xoHgSETw1eRBUIsOWKWxLX6wAWQBR6LkGkip4WnfKAArHQUEI5en3QE=" ] }, { @@ -1736,27 +1889,29 @@ "messages": [ { "@type": "/greenfield.sp.MsgCreateStorageProvider", - "creator": "0x5E340C0721bD5f49627e7E34eb94bedfA575E993", + "creator": "0xcf8351B881D578DaCEeb7fc55B0b4fB0971070f6", "description": { - "moniker": "Thorax", + "moniker": "bnb-chain-sp-4", "identity": "", - "website": "https://gnfd-testnet-sp-4.bnbchain.org", + "website": "https://gnfd-testnet-sp4.bnbchain.org", "security_contact": "", - "details": "Thorax" - }, - "sp_address": "0x5E340C0721bD5f49627e7E34eb94bedfA575E993", - "funding_address": "0xD3af86C62D53dA3aD7FD3eaF867D91E1Ba9c61AC", - "seal_address": "0xFCE3084e2AC67E1f698926b7FbcbD2204bFa7F92", - "approval_address": "0xbc01dE0Cc6D7F23822De6352c570d7E4798070f7", - "gc_address": "0x61FcD913b09894fa53d926bEFc2ED92EF3F014b2", - "endpoint": "https://gnfd-testnet-sp-4.bnbchain.org", + "details": "bnb-chain-sp-4" + }, + "sp_address": "0xcf8351B881D578DaCEeb7fc55B0b4fB0971070f6", + "funding_address": "0x02EA1f2f26D09fb771D4BDCEcF47eF4Fa0444765", + "seal_address": "0x169F5002cdE1bC58d130edCeE40818DD7e862aF9", + "approval_address": "0x6508D5Ec804Bf96F8367eB09b5C6218D81E64c68", + "gc_address": "0x5C1Af1bC9F751616145BC7f521bE3E5571332152", + "endpoint": "https://gnfd-testnet-sp4.bnbchain.org", "deposit": { "denom": "BNB", "amount": "1000000000000000000000" }, - "read_price": "100.000000000000000000", - "free_read_quota": "10000", - "store_price": "10000.000000000000000000" + "read_price": "0.108000000000000000", + "free_read_quota": "1073741824", + "store_price": "0.016000000000000000", + "bls_key": "85620df6dde08a4215b9346523b4580d691fed6724d72216836a4f2f45f84a18617a48d59ee023a1aef41d08269206f7", + "bls_proof": "b65bc73c977a46448593f7ca3a85a8d7aa69e9a01dff1c003532ee63b01cf5b6f28b5169ae99fad816eba4a1b7c1af3b09bbc37ad67a2901fd30a98f17ec1ef6bc5f6064f4f6b8eef135efad85dc2f9c30717509c8eb8610e1b569f7c55210c2" } ], "memo": "", @@ -1769,7 +1924,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "AxEHywNxzxRh1YkZ1M0w44NZTitRQLgNlQ6GecSKRKeV" + "key": "Aka0EFpR18Beg6kx4RderMFfELz/cpK8ZULMCPFCHhiv" }, "mode_info": { "single": { @@ -1788,7 +1943,7 @@ "tip": null }, "signatures": [ - "58kUVJ7/JHGVXvdnyknOH+BgJVmO/hCOgk4kAA1NPwZabMd8Wwx9UzArtLlYlm0JZ0DwJ4lbKtXKwQ7clY7MjgE=" + "my6B23fMHLFMbdW3Gzv3pnsbO6EGJGyLbtObZoOSqK48brc2wrGpYydw0imd4WlrIqABbMLSselPCJRmiIqXfwE=" ] }, { @@ -1796,27 +1951,29 @@ "messages": [ { "@type": "/greenfield.sp.MsgCreateStorageProvider", - "creator": "0xC6fA3F3640e3b594335efAb349abdD4A82C83736", + "creator": "0xb27457Bb90C902B690c276A470A5fA393FD7BD4F", "description": { - "moniker": "Voltbot", + "moniker": "nodereal-sp1", "identity": "", - "website": "https://gnfd-testnet-sp-5.bnbchain.org", + "website": "https://gnfd-testnet-sp1.nodereal.io", "security_contact": "", - "details": "Voltbot" - }, - "sp_address": "0xC6fA3F3640e3b594335efAb349abdD4A82C83736", - "funding_address": "0x8FeD9Ba853B685c2e482DEba08cE30F6942A9F2f", - "seal_address": "0x3f92219ef03F8aF218F9DA601Eaf254DB022f13D", - "approval_address": "0x4ea8378e4c64a41e417750E8f7fBa0F264AD379A", - "gc_address": "0x431EA58C86Abd737e0606cEa0f332115a4E1F5c1", - "endpoint": "https://gnfd-testnet-sp-5.bnbchain.org", + "details": "nodereal-sp1" + }, + "sp_address": "0xb27457Bb90C902B690c276A470A5fA393FD7BD4F", + "funding_address": "0x4C54914cc75DB4851F461b10a11429C33C817bBb", + "seal_address": "0xc748C39C96e708218e54971231F795391FCB690C", + "approval_address": "0x5944ffdA31A929510fD9842adE32B0cf5aFb402b", + "gc_address": "0x30fD9d9dD53dddda51A90B97D31ad186702aC31F", + "endpoint": "https://gnfd-testnet-sp1.nodereal.io", "deposit": { "denom": "BNB", "amount": "1000000000000000000000" }, - "read_price": "100.000000000000000000", - "free_read_quota": "10000", - "store_price": "10000.000000000000000000" + "read_price": "0.108000000000000000", + "free_read_quota": "1073741824", + "store_price": "0.016000000000000000", + "bls_key": "a764e66cb69c47c02262f9ed529247b46952a51bb82e64ca4f5c9216da208e862ac68574d23f28b509f737e676075885", + "bls_proof": "8ca5c6b9d8a60daed0af8098822c0783737aab2ec80b457e0bf826a6ae732be3e05588320aa0252f716aacde51c3b7840066a8339d157406b08614a49c2251009e4db03f842b64286457f9dc519d37239e8ed5e8519a8e1c93b03283cdccd862" } ], "memo": "", @@ -1829,7 +1986,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "AsAqh8jzG8Jyd74VsibNgz0TfNbzYiMYT1LKNkcmJRuj" + "key": "A75sckNOMSNZm4ZCMCiFfk7EA1CITZ/pLCnlpWe2maLR" }, "mode_info": { "single": { @@ -1848,7 +2005,7 @@ "tip": null }, "signatures": [ - "+l+uzaRoEU4fAefmoMj99Rg3CJGQ+Yy7GV8p07PZZpQyLjYOlgN6hoTiWQAoJO+NktHNPkXMD2bT54zqtiaEywA=" + "0+aKikE2osiCOPfZRu2NLfeHTltdYo9QX1k6DSkSai50QOE47CHVD55WCJC0D5h8Of9b659dLoN28VQO/exhXAE=" ] }, { @@ -1856,27 +2013,29 @@ "messages": [ { "@type": "/greenfield.sp.MsgCreateStorageProvider", - "creator": "0x3CFC8b2095DA8F0722412Dc16f8A067942d2c697", + "creator": "0x7df63379274A445AA4eFa6cc2bFb574B41B7D859", "description": { - "moniker": "Gadgetron", + "moniker": "nodereal-sp2", "identity": "", - "website": "https://gnfd-testnet-sp-6.bnbchain.org", + "website": "https://gnfd-testnet-sp2.nodereal.io", "security_contact": "", - "details": "Gadgetron" - }, - "sp_address": "0x3CFC8b2095DA8F0722412Dc16f8A067942d2c697", - "funding_address": "0xE44c4e725598CCa7Da3c506869d658a84e599983", - "seal_address": "0x43416fd2Dd08Bc6F2004B9a5fA53686B7F541d58", - "approval_address": "0x0DC08D602aaAAAA7e2fD604f9f96DdD2cD67FE51", - "gc_address": "0xD27faC13b0C38f57ce1840Fc55e7B8b66dEBB342", - "endpoint": "https://gnfd-testnet-sp-6.bnbchain.org", + "details": "nodereal-sp2" + }, + "sp_address": "0x7df63379274A445AA4eFa6cc2bFb574B41B7D859", + "funding_address": "0x49F4236Da953c2CEa8904CC0Cc71F562c5AAa1fE", + "seal_address": "0xBce1030CF99c6a5b55cAf461ba4349acebaB89B4", + "approval_address": "0xF5E274F603B79312e575d90B1F09b0d784AB171D", + "gc_address": "0x229ECf480a25469d924cfF7B8eFAbac6ab0baEca", + "endpoint": "https://gnfd-testnet-sp2.nodereal.io", "deposit": { "denom": "BNB", "amount": "1000000000000000000000" }, - "read_price": "100.000000000000000000", - "free_read_quota": "10000", - "store_price": "10000.000000000000000000" + "read_price": "0.108000000000000000", + "free_read_quota": "1073741824", + "store_price": "0.016000000000000000", + "bls_key": "aeeab58260a668aceac0512e806b662494893d518ae0cb011076ef68febe03da36c4ae3618b22bede5d287de6f081bc9", + "bls_proof": "8238992e42338a6c1ab23a8b48b07d576daac2c8562d4fe92b8ab9658de7fa9ae5543b5c24ce4592b205ebd7f9c8a88c18fb9a536aced2ffea129af11cd9f30d0712f543dc4ec38ff9822c5e5273f2e08db8c7da214e1a16c5f3546c401846b4" } ], "memo": "", @@ -1889,7 +2048,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "AnMnl/vEoa/ZGIjl6krrEYPajAmzR3hbM1SbnH21NyE0" + "key": "AwM/Z0lq8eNYrdHjd96LC6cn7oppOFtrrn6TDCU0FDL3" }, "mode_info": { "single": { @@ -1908,7 +2067,7 @@ "tip": null }, "signatures": [ - "pvkSZ8j0fdY4MqG30FhjspB3FwBy3vfotAFs9Mmga1h9uVnn1SUk2POeEf5SfEzqrCON8oRUBY7rCLgVA8v5UAA=" + "sqiJe5ZTD3pt7aqm2NJ0zLDXuJmO9UU6ddq3jlEIGfBqP9AFPd6mmevkt67xOc1/sf58BvYlV11NeF98mp1fFAA=" ] }, { @@ -1916,27 +2075,29 @@ "messages": [ { "@type": "/greenfield.sp.MsgCreateStorageProvider", - "creator": "0xB573F5c174f33aF0CA033c8A287061C1538fb130", + "creator": "0x3ae3A9670D85B7F80aF823Ac2Ca72415d0975D0b", "description": { - "moniker": "Titan", + "moniker": "nodereal-sp3", "identity": "", - "website": "https://gnfd-testnet-sp-7.bnbchain.org", + "website": "https://gnfd-testnet-sp3.nodereal.io", "security_contact": "", - "details": "Titan" - }, - "sp_address": "0xB573F5c174f33aF0CA033c8A287061C1538fb130", - "funding_address": "0x4B956d53E466a53d5FdE86781F1f547B44a19260", - "seal_address": "0x674d969927AbA4eE9Cd05e5079655BB099D83d85", - "approval_address": "0x648848d33938Ab930Da70cC71eda2Bd0175f7150", - "gc_address": "0xc5f1910AF4771720395f33f2FBBe782233215b4B", - "endpoint": "https://gnfd-testnet-sp-7.bnbchain.org", + "details": "nodereal-sp3" + }, + "sp_address": "0x3ae3A9670D85B7F80aF823Ac2Ca72415d0975D0b", + "funding_address": "0x6128C0850864783C668a9c906295Fb7c16a0e9fb", + "seal_address": "0x46c091B03728df63b3D53ADd1f40A87A27Ff5b50", + "approval_address": "0x6ecDEDB0a6D42B268D222e5DaFBF686Ad6f4CD6e", + "gc_address": "0x37E728443fa75b1dF65214033EBa15aD9840b544", + "endpoint": "https://gnfd-testnet-sp3.nodereal.io", "deposit": { "denom": "BNB", "amount": "1000000000000000000000" }, - "read_price": "100.000000000000000000", - "free_read_quota": "10000", - "store_price": "10000.000000000000000000" + "read_price": "0.108000000000000000", + "free_read_quota": "1073741824", + "store_price": "0.016000000000000000", + "bls_key": "a6bac5b7bd32f89a592edeaa785ecd7f0972846b40e2c7bc01e0b263f26d7328029c85e328a8ae04b929dc57a485dc08", + "bls_proof": "90e3ef4175b6d41c4736d50607fb0e3acfc069b9458a0a9343f8290912ff5e031f73f8f5db91efe6c0c48a7d33af9dd4168e7bacff9315f115f40717cfedc19c7254ab660390250fdb12cb10a97e03d29a3a842958f60fd3b833529df3a4432c" } ], "memo": "", @@ -1949,7 +2110,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "A3j3Czu8lvbZpIFJqkHMvZetA4pAEqaIwAbjkgS6FSqk" + "key": "AtnhrKDTT2TLaKlmBhat9xgBPDQx+cL8Mt1A84lUOV/X" }, "mode_info": { "single": { @@ -1968,7 +2129,7 @@ "tip": null }, "signatures": [ - "/XyFUVzylXr2B6NXLZJCl1VAID6EMZT7+F5iP8L8CcsyS9B0Gya3x0fLHmIC+t+0zqwUCVgzIbzWif6+MxbeBgE=" + "gZm/a+BshyBZVZ/rxeN34ItCnjVqG5RL0k6Axv8MKrNpS6GIojBRsHvqcWO+mIYE5Weivt49ig0qbyD4/e64+QE=" ] } ] @@ -1985,7 +2146,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Alpha-5" + "details": "Alpha-5 Validator" }, "commission": { "rate": "0.000000000000000000", @@ -1993,20 +2154,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0xd232339d21D20673CAb8c7EA2b7e96B1Ceb702C5", - "validator_address": "0xd232339d21D20673CAb8c7EA2b7e96B1Ceb702C5", + "delegator_address": "0xe5B0A517809D0980582722Ae7505f19A5592cB25", + "validator_address": "0xe5B0A517809D0980582722Ae7505f19A5592cB25", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "h3HfJh6R8nAMKVw1Lmp19B0qSZhnthqyErmLG0gm1nI=" + "key": "A9aHaQLTcA9ZwWZ8/ojcMrRrlFT3hDOc/KlFESP+Iv0=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0xd232339d21D20673CAb8c7EA2b7e96B1Ceb702C5", - "relayer_address": "0x2283a68aa25e372eAdfE76adF604388C7b8EE10d", - "challenger_address": "0x65460A347cD5244350B46343D3F961f0fC3B3Bfa", - "bls_key": "b7130fb95ceb93c201e504bf5de99f7e2ccec983d6a59d5a2600a62dd87f89baf404ebaf60cdda9f7d28651819dd4c8f" + "from": "0xe5B0A517809D0980582722Ae7505f19A5592cB25", + "relayer_address": "0x878427DDDd2b65985D36A82D527b0273cd86BFAC", + "challenger_address": "0x1f0b30996a0a91091a34Af953876a318cB10dF8e", + "bls_key": "ae7cb2014c8dd8993b0da3b87bb2886b57cc7e24f39874a07abd239d31c166fe8455643d63ca2eb240276eabf4253953", + "bls_proof": "b188cb011b228b665901cdad2845b7f3df93e18c47d95edaa11988e0c2cb87e2bd680b1401d277f541323b382c9cb8e81975f4f3cf0e7b05b75f309b3615e1f1a3e4ce2f661127efc1730b3c0edb1ced7ae58d345884beb3815768f4d9871a1a" } ], "memo": "Alpha-5@127.0.0.1:26656", @@ -2019,7 +2181,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "A5obp2TBEg3VjAJ0E386eR8l5vhhH4LTl6eyDV/yjwUP" + "key": "AnMiNnJNbFLWFy1Zl5R6NZR/VPzNq/bnsRSuvguFCT9O" }, "mode_info": { "single": { @@ -2038,7 +2200,7 @@ "tip": null }, "signatures": [ - "xNERDpPkdQoz2G4aF6KbaATjg6xOjyNJzhLRVEmVvbtsCbC5+zrtCXkeRQQ5JqYK02ZO6izARPSa7LFnvN5ImgA=" + "6EpE04v5EvkyMhtMSe62ISkUWxVQ+fp1fHJQnU0YV+YSh9/xvImmgOVqgRPlXH5S7BKuaxkWg/9wntuU+u8fHAA=" ] }, { @@ -2051,7 +2213,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Cogsworth" + "details": "Cogsworth Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2059,20 +2221,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0x89b7f5dBAde74CB8c2c78Af26B3841cFF8182945", - "validator_address": "0x89b7f5dBAde74CB8c2c78Af26B3841cFF8182945", + "delegator_address": "0x30C9eaD1aafc7ACeD3dF6EE5868f10766485c5B5", + "validator_address": "0x30C9eaD1aafc7ACeD3dF6EE5868f10766485c5B5", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "ICaj8d7fAXwHDcYY16uvR5Tz6CHWU1H1ET8piZ/pEvE=" + "key": "UdGwCqp7V6hKAepbSpdoc9DRiIGPJdCMpvUJ+UeyQI0=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0x89b7f5dBAde74CB8c2c78Af26B3841cFF8182945", - "relayer_address": "0x19FC305a8C2107125e3eC6Ee05C5a47894B70392", - "challenger_address": "0x552680552d2F2B9342AC9cA55eB7a173F7C51bda", - "bls_key": "98b1021a4a60f27965db1390ea4bdc1e2e4f87566f0a8b0f3d35f69ef04dfeb5051e3ac09434127912a9e0989a5b60b8" + "from": "0x30C9eaD1aafc7ACeD3dF6EE5868f10766485c5B5", + "relayer_address": "0x94e5Ca4349df395bFBc1c933b007Cf79Df545A19", + "challenger_address": "0x04610ac4921dA11F230deFc3F5f4d7bF382c843A", + "bls_key": "94c84d0f7a98b09683b8d394ba1f34dd56d60fec8bbe4d7173db74dd981bff466317525fead5201c70dd070f101dfcda", + "bls_proof": "aa958c6a50136e45dd20236d8b143299736e041d91c4b29ac59270ddb96aedc7f13bcccd59478aa5e567a16128fdb07c066b346183ad9921e1672ad5a1fb8e8b4e057b20a3dfc27175358c7e81e67ab0e4f7fa558594c357e8001fd6bde11e8b" } ], "memo": "Cogsworth@127.0.0.1:26656", @@ -2085,7 +2248,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "As1WwVUnO3Hem7KABmowTU825gXEQi17oJwENvfKdkWz" + "key": "A832mGcu1ETa/sOVuBuCxAJI8VP5k3awTNH63iqgeyHh" }, "mode_info": { "single": { @@ -2104,7 +2267,7 @@ "tip": null }, "signatures": [ - "L0LwZRdRk491vq3NKRQwG2db2pzUPKDgdL5V1sYb8eQmHtyB/T7yXhOAJcXRW7l5uG04tTp+stTuLyEYtP3H7gE=" + "evDEcBrZ/BqMoY7p1HN6pFpt8jnDbh6dZ32x95ASYXlmQJb/1UypRG+Ax+mdmaShsYi20gqnnUZDC50xmkRjfgA=" ] }, { @@ -2117,7 +2280,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Gadgetron" + "details": "Gadgetron Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2125,20 +2288,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0x3a1422D7d1466aA95302F20eE45236258b8C2472", - "validator_address": "0x3a1422D7d1466aA95302F20eE45236258b8C2472", + "delegator_address": "0x41F3B0C665D0b1a918B4AA48FB691561BeC05E47", + "validator_address": "0x41F3B0C665D0b1a918B4AA48FB691561BeC05E47", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "oem0oUWZhOc1dFzOnQLvH+EO382NV+hmzX8rORfPazk=" + "key": "y5CPrewa7DtIEtgsDjS6BeloQKUjBxmjNVKXgylYXIo=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0x3a1422D7d1466aA95302F20eE45236258b8C2472", - "relayer_address": "0x149Cb630Bc5BC853Aa72C1B2fEb0f4E1A0CFFe6A", - "challenger_address": "0xC80e147fBF307b97B0553a6359A50b70025eb0C7", - "bls_key": "99288818a4bd0ec582b8ce1e181543fee3750ab7e852c42dc137bb759d5734fe37bcef24162e6f444679fbeaf6f858c0" + "from": "0x41F3B0C665D0b1a918B4AA48FB691561BeC05E47", + "relayer_address": "0x67d3Fe3A13CE1f7AcB683278164CA5abC854efa1", + "challenger_address": "0x2697e8FfFf3B4cBc2927fD69a8b70CEc6eDf33d4", + "bls_key": "aa47897a128a71372eb3abc029aa683ea0f596561330b12f17ff4701d6534ebb64480f7c0b7d625d77a17af551e2cbfa", + "bls_proof": "b0070037e91b95e1635345e2f8162ee40c2a763f2d6830fdd2b05d4584ad0f458e36db2e2d84c111da970c1974b8a5a20e49e8282dda31f2be2098b274c93235ced27e05737de0d21103870459fa37a2944f2a9cb04a6e32ef70d2b48c194bb4" } ], "memo": "Gadgetron@127.0.0.1:26656", @@ -2151,7 +2315,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "Ao7ZTyHrRyLuFHRhriTvyjJBtglMgdah7L5UCYM0oK4V" + "key": "As+DroYrOPBJD/fF/uBxIKkI+OwyIcoH6zOtNMyCwxzL" }, "mode_info": { "single": { @@ -2170,7 +2334,7 @@ "tip": null }, "signatures": [ - "1aVqi6t+XcmTrsi7L3VV5s6AMfugV+c5t0wPZDqGrWxGlRFsX7r44WMUzlzcoRhL/FdjQQMidDjoazAn3W41lwE=" + "gy61Pmv6Vm3GAIhHekW49yhfiFxN09tj7i1Jnp6FgURGMkqXLQolSdK6mUugPMZqIB3T0/f9WJEhnnthCTCrVgE=" ] }, { @@ -2183,7 +2347,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Lumibot" + "details": "Lumibot Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2191,20 +2355,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0x5fd2786474F9785725CfD617B733ecfCB1A09142", - "validator_address": "0x5fd2786474F9785725CfD617B733ecfCB1A09142", + "delegator_address": "0x748d9CAAEE996f793612ad9d21Fe4F06B638C1a4", + "validator_address": "0x748d9CAAEE996f793612ad9d21Fe4F06B638C1a4", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "++Lj2Oae050eQXk2nDsWIEhLfk+XrSGhZFNZmMrEkcM=" + "key": "+obhJREyrATOmz4ePOuVNfDAg77J2YaLAoBORBZZs+Y=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0x5fd2786474F9785725CfD617B733ecfCB1A09142", - "relayer_address": "0x7051943E02fbABdAB53C7b0Ea3890bF375517FaB", - "challenger_address": "0x57647B3324D03A95Bb710b3cb2e8af1FF15653FA", - "bls_key": "94534c71ce22d271236eca856d745f914dfefa83608628c2028b494916042b3bdce802193c87d8f18091ae17ca5f508d" + "from": "0x748d9CAAEE996f793612ad9d21Fe4F06B638C1a4", + "relayer_address": "0x7E64d4676fcEFE17BC2dd01182992987D63B6205", + "challenger_address": "0x307E33532E039440134d29C00b5F73ea85A6430e", + "bls_key": "b8ab7df5cd0fb746b918f19d4fd2723e83298f4fefd5c423d44218834c4c26b791acbbf1046e15e41add79aa370e66be", + "bls_proof": "a15b516166d88f0e5164ad3ab20183c921a14f173890e6d7dfd93a87a90aea61ae35a2556be3f2a9f2e68761fb76fbb30f47495da5ccf97fd7ab190783e94c005d4886fb298fff48d677497670d4da9597c0c3617acfd61aa88f7f2db8c13fb5" } ], "memo": "Lumibot@127.0.0.1:26656", @@ -2217,7 +2382,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "Ap0NqWysFwgMP2gOsZ/NgYuSfMax3V6L5rvwnM7PvEC5" + "key": "A1yoG0NVpnVR/kgNmgibARE8ztORYkFVNOEXLk628w6h" }, "mode_info": { "single": { @@ -2236,7 +2401,74 @@ "tip": null }, "signatures": [ - "sszkT9frikRRBccjgcg4F6z4Kk56h3wB0ZYkTG/tUhIfrNu+r77q6hXxxu1r96fdqOx1jMsjo9xl4aWxutdsIQE=" + "wYb5DfL1Eghqbhvfq/nGXZZD8JT642kp2+LTgl4EEsh9kIT8lrpqpCg/65jzrlAHtbPffU11PXr8aSxDI3/aYgA=" + ] + }, + { + "body": { + "messages": [ + { + "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "Megatron", + "identity": "", + "website": "", + "security_contact": "", + "details": "Megatron Validator" + }, + "commission": { + "rate": "0.000000000000000000", + "max_rate": "1.000000000000000000", + "max_change_rate": "0.010000000000000000" + }, + "min_self_delegation": "1000000000000000000000", + "delegator_address": "0xa661b6eE4970713EA38962a37b9DC6fF24a203c5", + "validator_address": "0xa661b6eE4970713EA38962a37b9DC6fF24a203c5", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "RV9D63ek7byz7JzLTdGa47foKrFov9Bp5t5CMKC5qj8=" + }, + "value": { + "denom": "BNB", + "amount": "1000000000000000000000" + }, + "from": "0xa661b6eE4970713EA38962a37b9DC6fF24a203c5", + "relayer_address": "0x4EFF7B03d1bF18Aa22f197aec96CF37b551B4176", + "challenger_address": "0xaf73d3E602B84309c292f05b27B29c00d76E9134", + "bls_key": "8108938c78b2c5c5e158c7857321e040a6bef0ca038ffe2ac9a2a2df9b48170f62b6e00026cfa5353772d5715d0d79e8", + "bls_proof": "a507244bf14ee10105dc8225aec49b4b68c2b3361dbfba7025b4f2d12bd47f9570b1d6084f8be3c2042185957c6becfb06b3b90d0d9d524cfcf6ab75f14addc184c447c7429ee313d5180f4bcdfd44b84d3c9b8687737a0061fe957b5ec8b36a" + } + ], + "memo": "Megatron@127.0.0.1:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", + "key": "A5krpH8BdyqJgYr5TiZT2H0roFcoFx2OyYRx9xL/5gTm" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_EIP_712" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [], + "gas_limit": "200000000", + "payer": "", + "granter": "" + }, + "tip": null + }, + "signatures": [ + "/F1vMivToLtKAmTpzltn3tLzYVneUGIM2w3QqzKlojVzZ+Z8KOLirylwTPhvAOAep5XukQCJVQT51XKztpU3KAA=" ] }, { @@ -2249,7 +2481,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Neuronet" + "details": "Neuronet Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2257,20 +2489,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0x9D37729D08A346A5548a58Bf69Ec629d5B51A9b5", - "validator_address": "0x9D37729D08A346A5548a58Bf69Ec629d5B51A9b5", + "delegator_address": "0xeC09d6E7D8B3F4ddE3D4Ec684172e325fA1af852", + "validator_address": "0xeC09d6E7D8B3F4ddE3D4Ec684172e325fA1af852", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "rku2fNplE8ujo2Rgo8vrozr8MGzXH0Jh8/5Wr9916LE=" + "key": "xKLKba9RAStfi1NoG+jLXzt1KSx6wjJM7wsuI/DKDLU=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0x9D37729D08A346A5548a58Bf69Ec629d5B51A9b5", - "relayer_address": "0xE2100FE4575C4bC9A87e4D0f16d4359e2d65a0A3", - "challenger_address": "0x53CF9745E01dDd6C4217ddBb9a73b57Af9E977f9", - "bls_key": "a51539542577a9b25881ea06eae7442482fe3eb11efa8bdc4dc50435d8aad9c72974747132a4adb258b18d1f46d41a7d" + "from": "0xeC09d6E7D8B3F4ddE3D4Ec684172e325fA1af852", + "relayer_address": "0xAd0d91320117DDdec10e7Cba66e393B1AaC0D8f6", + "challenger_address": "0x634AafEf507e28a907815Aa8025C7850A2945120", + "bls_key": "ac71f8bdbe4c75b6b840d0c19e7e654c388b108c3f1fb4d5d948215060d3bc667a4e7cb892d4edcfc1087bfe6e4d4f86", + "bls_proof": "b3ddf0a9d6384f4556f41f4e043c8529e519f4cb2d3980f323379c9b2f29199d5799e5647f4f47ebbf5252f42e41df0b10aa2f60612eba5819f3a0d3f22d13a5340b8ec14a15fa72773d1f85ea1591f4d0e921e631b3fec3a6e7606d9b6d1a35" } ], "memo": "Neuronet@127.0.0.1:26656", @@ -2283,7 +2516,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "A0K4mitINwdRArCfzRBCgf+6/LSQN0HVfIKPzR226dWL" + "key": "AlvAk+El/nS06C79QMlQ4LZ4FgWemzGiA6cNihmOGc7p" }, "mode_info": { "single": { @@ -2302,7 +2535,74 @@ "tip": null }, "signatures": [ - "vl/jZIgb8hhYKKM+C/3ENv0dpP0Th15nYlkT5+gDm1BtMM0qd1KTPYhOM1bqwBabXClhU3+ppvcLBRPDTOQqqQE=" + "1oQj76OlbcP2la4Hl2K6RKlGidhctmi6655xLUyyeEJEI/vvD9rktyUcgzQ5fJJn/eXWF2hf5BxtSm7eH370owA=" + ] + }, + { + "body": { + "messages": [ + { + "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "Nodereal", + "identity": "", + "website": "", + "security_contact": "", + "details": "Nodereal Validator" + }, + "commission": { + "rate": "0.000000000000000000", + "max_rate": "1.000000000000000000", + "max_change_rate": "0.010000000000000000" + }, + "min_self_delegation": "1000000000000000000000", + "delegator_address": "0x5dB332dB5e312223c0Ae2bb7305453814D1AF182", + "validator_address": "0x5dB332dB5e312223c0Ae2bb7305453814D1AF182", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "hagdERmOdLJQQcAXjU19CeGm0pnaJYiSlrueYWmTYek=" + }, + "value": { + "denom": "BNB", + "amount": "1000000000000000000000" + }, + "from": "0x5dB332dB5e312223c0Ae2bb7305453814D1AF182", + "relayer_address": "0x48A1aae6aB9FA8FE9d5F0A24f1b075ef48F2a6F5", + "challenger_address": "0xC6D661d5Ee633eA3DfD4D86f368cdd839D682D18", + "bls_key": "95c3995ab3c2247885df63204f05b7d52aaf0e8129a3c591ca0b451262b400efe3ecb9ba5c98456f9e97411cbdc2aaf2", + "bls_proof": "add3eb63e0172ecec4fa2899e2b37fd26202d0ed57aaa8564c786c362d8d155e948fd0462af2ddb7274bc373a1d00b33018af336cc73c2c3e31c703fa5cb6bfc91fc67c04077f22c5854463310190a57bbf302feb72a882a3f110c4e196bc1c4" + } + ], + "memo": "Nodereal@127.0.0.1:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", + "key": "Aoaz7lVmnYFbtN7VpC8/WyvxojMPFKYD96yErPwDdnzA" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_EIP_712" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [], + "gas_limit": "200000000", + "payer": "", + "granter": "" + }, + "tip": null + }, + "signatures": [ + "LDDIOYkQiFHL3kdGuWy+83U8PGUhzwZux/35ahhELd04erpTGQuqopkw18Ata4Ejbbc+uYCzjDmeEXYmUjQxwwE=" ] }, { @@ -2315,7 +2615,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Thorax" + "details": "Thorax Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2323,20 +2623,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0xcA3168c36ceaC3ED7eE7C6097B031f94A2C62094", - "validator_address": "0xcA3168c36ceaC3ED7eE7C6097B031f94A2C62094", + "delegator_address": "0xa258eb261Ccd5Ae0AAbc757bDc4f40634FF7b5eA", + "validator_address": "0xa258eb261Ccd5Ae0AAbc757bDc4f40634FF7b5eA", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "7GUJOWkNEtWNAx7VaaqHixUpggOawDmV9OSpS0dHS/A=" + "key": "fetnkodReraqHK7zKUaRq/3gWFHWjLlUgd3bGjx1RPA=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0xcA3168c36ceaC3ED7eE7C6097B031f94A2C62094", - "relayer_address": "0xe12692932eF227EbCbF73C20e8ec8F9FA5333715", - "challenger_address": "0xe630C94958220B8a7BD6c7438BFD273009047306", - "bls_key": "b7087d420ea863e8f25a2e732f56180da0d1286646939d2887aa1693aa2c0d59a1215f95ceeeea562d5f2843ef4325eb" + "from": "0xa258eb261Ccd5Ae0AAbc757bDc4f40634FF7b5eA", + "relayer_address": "0x08D2F2FE8dc0B9E0aE4DCD1b6D8aA46f9C71dbE0", + "challenger_address": "0x0dFA33E3260986f4Bf3A2C515fCeCD3b4e8D1DAe", + "bls_key": "97733c0937dfe0dc14a658846aa8c95908ae9c82eee6e38c4bc7b11bcfe030ca5239fd76bb59faa1267cf56889aa7b30", + "bls_proof": "89d70abf52e000a6fa5fedac1cb3c1ab1703abcf4d784a829374300a4b0026a77a96554b7144ac0d4a0cbd8631c485a910c7332c422656171acc607da23180358447532a3c2cebaa0b77259d104c5e3184d20ba815f5c37968e2628c1b38df36" } ], "memo": "Thorax@127.0.0.1:26656", @@ -2349,7 +2650,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "AvJteYxLZhaqNYcZJRn2WA01lbuZs1YVFpJjon8BQBXs" + "key": "A6639BXk/LuI4Rv1AGbFtPkzyL/8Gls2D1WfI0p5A//E" }, "mode_info": { "single": { @@ -2368,7 +2669,7 @@ "tip": null }, "signatures": [ - "zNrdrsytssDidILOapzVnBYHB/gvsauVbfxguiJD8+JxvPGgoBCB1Mqf3UJ0Mi4qMVvuifvgnqcinHtQdAiLpQE=" + "NJIk7Ahx7FgugoH5hJiijhazcG754gqYHvRWCIRMyTxF3xbzU4N8TddxK6Fc1mF/WmAYGSfJyQ/G/NoUs+qlGQE=" ] }, { @@ -2381,7 +2682,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Titan" + "details": "Titan Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2389,20 +2690,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0xcB22c3FcdDd5Ee57639b0f053ce50C7516eC1fBF", - "validator_address": "0xcB22c3FcdDd5Ee57639b0f053ce50C7516eC1fBF", + "delegator_address": "0xA7F5CE47701CB1988c92958d5B94583fa3AFCee4", + "validator_address": "0xA7F5CE47701CB1988c92958d5B94583fa3AFCee4", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "FqpzmaybkftYJ4ADUOkgN96rQhSsRAExEF1lw4SwRc0=" + "key": "JvVsaNrwb2+CRR8INotTblFJAlLoft9hbiai1JY5vok=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0xcB22c3FcdDd5Ee57639b0f053ce50C7516eC1fBF", - "relayer_address": "0xF543641BCdc9C8C5d993473376eE1B40A2b0780b", - "challenger_address": "0x7258A423040087004037260Ab2BB7dD0f15F42c9", - "bls_key": "88a6e234bae06f73c29b6f0a6e84cf1b56dfe1d56171413fc7d3d3f58eccd0078538c2610832518081958fffc6589e21" + "from": "0xA7F5CE47701CB1988c92958d5B94583fa3AFCee4", + "relayer_address": "0xCd9122341c22A89901c9Fd87F84Bd5B8A32ac90a", + "challenger_address": "0xfeb17aDA5076B13C68b4CD83aA8918c2931d66f0", + "bls_key": "b3297eb88a33659a5b9cb2769058ae8a6c2572cf749359dc3b8a842facda5746f6e4282e9861fff6e09578d377e181f5", + "bls_proof": "ab3c95c3e8e7902eed5dca96e2d3cd212f9f49ea36fae08caee909fb4b732dffe37d0a52059c90f30818fb80f2d2c77d11b7950ccd5a336b752ca859764aec8df828d87e702fa15d3eddc1e2262cb1d297a2ac8ce12097f5a7077641ef2f6a79" } ], "memo": "Titan@127.0.0.1:26656", @@ -2415,7 +2717,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "Aj9vBtFCo5xXsnX277EAI1Y9oUZCiG3l6IyH3Yq/wo2d" + "key": "ApMfuB8G5eeNV3ETwoyi1NQSOl5NLGzYw+8EBoMQFbut" }, "mode_info": { "single": { @@ -2434,7 +2736,7 @@ "tip": null }, "signatures": [ - "+8WHqrHry1jB5SJ+zeFNjD+iUgZC6DC5XNme8h0ngrBP6BGajwDiwwzNQ6VYaD0IdIXAKTkMhCa2LivZGtTOLgE=" + "2Gk/kaBngD5dTLPVTbMccvRiPWzYXHE+e49VexFjXvheCoWGsDheaCRkE0Zrei2rbjpICATuocqOZ33WlSBtIwA=" ] }, { @@ -2447,7 +2749,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Voltbot" + "details": "Voltbot Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2455,20 +2757,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0x14ed904094a90cE2E8274E64a8D70F59cEDAdBdF", - "validator_address": "0x14ed904094a90cE2E8274E64a8D70F59cEDAdBdF", + "delegator_address": "0xEeeE317f27dD698C8F0Eb06Cc331f37129eC351B", + "validator_address": "0xEeeE317f27dD698C8F0Eb06Cc331f37129eC351B", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "VFwx84EbKTsWYSwotDN3+qTrlMF79pc22BxxNTIo+68=" + "key": "iDBvATnWWhyfyPmTQUXQAo6YAHY6reASf+pQqLDDpMY=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0x14ed904094a90cE2E8274E64a8D70F59cEDAdBdF", - "relayer_address": "0x530750b734A59b7762d28F4440d370CFb2b14C46", - "challenger_address": "0xd8EF56759FB89A23a88795841a2857Cf705B33A5", - "bls_key": "992d7b735f18fca02da4217eb5d4e8bbf67c087a3b9579a334b4dd74c46e6f2ee13cd481fe459bf1b12ab61a461e4046" + "from": "0xEeeE317f27dD698C8F0Eb06Cc331f37129eC351B", + "relayer_address": "0x3364A7ccBBFc623AcAC3d8691450218Ff5e8d5Ea", + "challenger_address": "0x171cDB9420a990c1E0c1711C67d9218686823CF6", + "bls_key": "b78b0a98912c710899bde6265e594d687d6b69d986478ca9462cf460b5989c113531f9a8d5bcc8a42ee649e7b7eeae3e", + "bls_proof": "92c57cd6699db47a229809e28e50da8a904e142366f4619d0d17f1381a5dfb7702e7b1ef0be285926a39158297bed50e0c7f244b82e3241f9bf5e7af5d3e646dc31a576fd443ff71a805504a34fcf4080c1834bd1ae4411d9d1b7d7d8264d14b" } ], "memo": "Voltbot@127.0.0.1:26656", @@ -2481,7 +2784,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "AgcZVskwddteeZbFZtZHjCyRv+/IdSE07FEbsSLOZUyx" + "key": "AhUk+NMddboiUDEA7rizefjOvQ32Kg4f16IT+YluF/UP" }, "mode_info": { "single": { @@ -2500,7 +2803,7 @@ "tip": null }, "signatures": [ - "WUVv9XQPg2MWMFlORPRiZ2WvVEePPLmT4wPDULlx2a05Wnfa0H1tT/FBbS0lnCkA/II4HxieHGlzv8omb59IYQE=" + "B5ayrJxLduFI14fMt1w2xYNZwKBKcagUA/mLK3knYpMWbFEshP72uOU1dz64fhfqFi5uGGQepkxguJiJDfiqBwE=" ] }, { @@ -2513,7 +2816,7 @@ "identity": "", "website": "", "security_contact": "", - "details": "Zenon" + "details": "Zenon Validator" }, "commission": { "rate": "0.000000000000000000", @@ -2521,20 +2824,21 @@ "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1000000000000000000000", - "delegator_address": "0x1CA8e333a58b292d0e12Dd01F3314cAbB52e3975", - "validator_address": "0x1CA8e333a58b292d0e12Dd01F3314cAbB52e3975", + "delegator_address": "0x2c29c11069Ad404D8CE0d04d1EA646310a300306", + "validator_address": "0x2c29c11069Ad404D8CE0d04d1EA646310a300306", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "dtoCUymxEF+aU6cNllCdutNI+wGQ/gY5c8lZqOCSJpE=" + "key": "Def/sWARhbwYoDMvrgaPElxByY5zUfysClrKiR+5seA=" }, "value": { "denom": "BNB", "amount": "1000000000000000000000" }, - "from": "0x1CA8e333a58b292d0e12Dd01F3314cAbB52e3975", - "relayer_address": "0x317AF415a8964509014160C8d255fa1d23B87768", - "challenger_address": "0x045f487b6070E8D6D3a60Cd932e0f9E8BA53B4e7", - "bls_key": "a126305784c7137d73be4fda9c296d733fb772017f005aee63927ae97f0b6cffa84efbfb96900fc7b69c0064d6fb9778" + "from": "0x2c29c11069Ad404D8CE0d04d1EA646310a300306", + "relayer_address": "0x9Ed0F2B0Ca585D7728966421db19A97C83a879D4", + "challenger_address": "0xfABDd8b607201667fE54054CB4AD9068Afa2993e", + "bls_key": "adb0cc64b2877b11803c9fe4858474487bd6c8405781c3b5ed7d09e8e8bb456fdbe3cde2b2938a0530861099db87fc1a", + "bls_proof": "9148975fe3b06b8391224cbf4242540a490afce7fe4633eaf10e0976fe5652fe64d5b4e132676676ea43f6d21907bb59085993a73771dbeeee0e1e3c97102c2eee92fd59c04b469c979b6f2587c2e2c1c18e0767ca5aca2100fcbbe755dd1356" } ], "memo": "Zenon@127.0.0.1:26656", @@ -2547,7 +2851,7 @@ { "public_key": { "@type": "/cosmos.crypto.eth.ethsecp256k1.PubKey", - "key": "A32J87t/4nUlgAIM40AJ2REL0q8Ns158xPUtlPIknn/+" + "key": "AoFFu9IvEPojCl1tPq84gNy/CoVX8pEtyPeC5laKrAka" }, "mode_info": { "single": { @@ -2566,7 +2870,7 @@ "tip": null }, "signatures": [ - "2geg1DC6hM74Av/7XZffTO8BHws+IQHN29CH7ru5nnxoq/iycrPWbE5wPdB99z9XSAtUFMHA71vQKcKWhWxHeAA=" + "I3vzjfFlCrqqgW+8q2dgc5U+0JO6Mv5UgkR6kKM54Q1bAgzwsb5mEQ/PIo4ILMGQ3NsjN1xKo7xFQoSfh4TuVgE=" ] } ] @@ -2583,7 +2887,7 @@ "min_deposit": [ { "denom": "BNB", - "amount": "1000000000000000000" + "amount": "10000000" } ], "max_deposit_period": "86400s", @@ -2607,12 +2911,15 @@ "params": null, "payment": { "params": { - "reserve_time": "15552000", + "versioned_params": { + "reserve_time": "604800", + "validator_tax_rate": "0.010000000000000000" + }, "payment_account_count_limit": "200", - "forced_settle_time": "86400", - "max_auto_force_settle_num": "100", - "fee_denom": "BNB", - "validator_tax_rate": "0.010000000000000000" + "forced_settle_time": "43200", + "max_auto_settle_flow_count": "100", + "max_auto_resume_flow_count": "100", + "fee_denom": "BNB" }, "stream_record_list": [], "payment_account_count_list": [], @@ -2640,7 +2947,7 @@ "params": { "deposit_denom": "BNB", "min_deposit": "1000000000000000000000", - "secondary_sp_store_price_ratio": "0.650000000000000000" + "secondary_sp_store_price_ratio": "0.120000000000000000" }, "storage_providers": [], "sp_storage_price_list": [] @@ -2671,22 +2978,33 @@ "redundant_parity_chunk_num": 2, "min_charge_size": "1048576" }, - "max_payload_size": "2147483648", - "mirror_bucket_relayer_fee": "250000000000000", - "mirror_bucket_ack_relayer_fee": "250000000000000", - "mirror_object_relayer_fee": "250000000000000", - "mirror_object_ack_relayer_fee": "250000000000000", - "mirror_group_relayer_fee": "250000000000000", - "mirror_group_ack_relayer_fee": "250000000000000", + "max_payload_size": "68719476736", + "bsc_mirror_bucket_relayer_fee": "250000000000000", + "bsc_mirror_bucket_ack_relayer_fee": "250000000000000", + "bsc_mirror_object_relayer_fee": "250000000000000", + "bsc_mirror_object_ack_relayer_fee": "250000000000000", + "bsc_mirror_group_relayer_fee": "250000000000000", + "bsc_mirror_group_ack_relayer_fee": "250000000000000", "max_buckets_per_account": 100, "discontinue_counting_window": "10000", "discontinue_object_max": "18446744073709551615", "discontinue_bucket_max": "18446744073709551615", - "discontinue_confirm_period": "604800", + "discontinue_confirm_period": "300", "discontinue_deletion_max": "100", - "stale_policy_cleanup_max": "200" + "stale_policy_cleanup_max": "200", + "min_quota_update_interval": "2592000", + "max_local_virtual_group_num_per_bucket": 10 } }, - "upgrade": {} + "upgrade": {}, + "virtualgroup": { + "params": { + "deposit_denom": "BNB", + "gvg_staking_per_bytes": "16000", + "max_local_virtual_group_num_per_bucket": 0, + "max_global_virtual_group_num_per_family": 10, + "max_store_size_per_family": "70368744177664" + } + } } } \ No newline at end of file From 53125503496fb739c4aaf8f3412e8f64c3e8a615 Mon Sep 17 00:00:00 2001 From: Fynn Date: Thu, 3 Aug 2023 19:26:37 +0800 Subject: [PATCH 18/24] fix: add cancel mb event for discontinue and delete (#391) * add cancel migrate bucket events for delete and discontinue bucket * fix lint * Update msg_server_test.go * Update msg_server_test.go * fix lint --- x/storage/keeper/keeper.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index d06a6e275..20b6e1676 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -230,14 +230,26 @@ func (k Keeper) doDeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketI if err != nil { return err } - err = ctx.EventManager().EmitTypedEvents(&types.EventDeleteBucket{ + if err = ctx.EventManager().EmitTypedEvents(&types.EventDeleteBucket{ Operator: operator.String(), Owner: bucketInfo.Owner, BucketName: bucketInfo.BucketName, BucketId: bucketInfo.Id, GlobalVirtualGroupFamilyId: bucketInfo.GlobalVirtualGroupFamilyId, - }) - return err + }); err != nil { + return err + } + + if bucketInfo.BucketStatus == types.BUCKET_STATUS_MIGRATING { + if err = ctx.EventManager().EmitTypedEvents(&types.EventCancelMigrationBucket{ + Operator: operator.String(), + BucketName: bucketInfo.BucketName, + BucketId: bucketInfo.Id, + }); err != nil { + return err + } + } + return nil } func (k Keeper) GetPrimarySPForBucket(ctx sdk.Context, bucketInfo *types.BucketInfo) (*sptypes.StorageProvider, error) { @@ -463,6 +475,16 @@ func (k Keeper) DiscontinueBucket(ctx sdk.Context, operator sdk.AccAddress, buck k.appendDiscontinueBucketIds(ctx, deleteAt, []sdkmath.Uint{bucketInfo.Id}) k.SetDiscontinueBucketCount(ctx, operator, count+1) + if bucketInfo.BucketStatus == types.BUCKET_STATUS_MIGRATING { + if err := ctx.EventManager().EmitTypedEvents(&types.EventCancelMigrationBucket{ + Operator: operator.String(), + BucketName: bucketInfo.BucketName, + BucketId: bucketInfo.Id, + }); err != nil { + return err + } + } + if err := ctx.EventManager().EmitTypedEvents(&types.EventDiscontinueBucket{ BucketId: bucketInfo.Id, BucketName: bucketInfo.BucketName, From 6e8fb98951feee0379d4a7c37b4fe25d5faf3189 Mon Sep 17 00:00:00 2001 From: dylanhuang Date: Tue, 8 Aug 2023 14:58:58 +0800 Subject: [PATCH 19/24] feat: group member expiration (#374) * feat: group member expiration * fix: missing group members id for query function * fix: post check if the operator has not been expired * fix: allow add group member without expiration from corss-chain package * chore: add export_validator to localup.sh * chore: fix upgrade name * chore: fix proto format * fix: resolve comments * chore: add annotation to maxTimeStampSeconds * chore: refine the maxTimeStamp * chore: fix go.sum * fix: remove NagquUpgrade * refactor: group member's expiration time process flow * chore: fix lint and proto error * chore: gen swagger * chore: fix e2e * chore: fix comments * chore: fix mockgen version * chore: fix swagger * chore: fix e2e test * fix: correct the VerifyPolicy * fixup! fix: correct the VerifyPolicy --- .github/workflows/buf.yml | 4 + Makefile | 1 + deployment/localup/localup.sh | 16 + deployment/readme.md | 11 + e2e/tests/permission_test.go | 45 +- e2e/tests/storage_test.go | 97 +- go.mod | 13 +- go.sum | 29 +- proto/greenfield/permission/types.proto | 5 + proto/greenfield/storage/events.proto | 36 +- proto/greenfield/storage/tx.proto | 36 +- swagger/static/swagger.yaml | 14 + x/permission/keeper/keeper.go | 24 +- x/permission/types/types.pb.go | 119 +- x/storage/client/cli/flags.go | 1 - x/storage/client/cli/tx.go | 130 ++- x/storage/keeper/cross_app_group.go | 52 +- x/storage/keeper/grpc_query.go | 1 + x/storage/keeper/keeper.go | 84 +- x/storage/keeper/msg_server.go | 47 +- x/storage/types/crosschain.go | 47 +- x/storage/types/errors.go | 50 +- x/storage/types/events.pb.go | 978 +++++++++++++---- x/storage/types/expected_keepers.go | 5 +- x/storage/types/expected_keepers_mocks.go | 46 +- x/storage/types/message.go | 100 +- x/storage/types/message_test.go | 53 +- x/storage/types/options.go | 16 +- x/storage/types/tx.pb.go | 1219 ++++++++++++++++----- 29 files changed, 2574 insertions(+), 705 deletions(-) diff --git a/.github/workflows/buf.yml b/.github/workflows/buf.yml index 00e3c809b..67052077c 100644 --- a/.github/workflows/buf.yml +++ b/.github/workflows/buf.yml @@ -14,6 +14,9 @@ on: jobs: protobuf-check: + strategy: + matrix: + go-version: [1.20.x] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -26,6 +29,7 @@ jobs: - name: Test protobuf changes generates new go files run: | export PATH="$PATH:$(go env GOPATH)/bin" + go mod tidy make tools proto-gen-check - name: Test protobuf swagger changes run: | diff --git a/Makefile b/Makefile index f9653fbf1..08d2fb68b 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ format: tools: go install github.com/cosmos/gogoproto/protoc-gen-gocosmos go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway + go install github.com/golang/mock/mockgen@v1.6.0 proto-gen: cd proto && buf generate && cp -r github.com/bnb-chain/greenfield/x/* ../x && cp -r github.com/bnb-chain/greenfield/types/* ../types && rm -rf github.com && go mod tidy diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index f4fe16708..c3627c2c1 100644 --- a/deployment/localup/localup.sh +++ b/deployment/localup/localup.sh @@ -248,6 +248,18 @@ function generate_sp_genesis { ${bin} collect-spgentxs --gentx-dir ${workspace}/.local/validator0/config/gensptx --home ${workspace}/.local/validator0 } +function export_validator { + size=$1 + + for ((i = 0; i < ${size}; i++)); do + bls_priv_key=("$(echo "y" | ${bin} keys export validator_bls${i} --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/validator${i})") + relayer_key=("$(echo "y" | ${bin} keys export relayer${i} --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/relayer${i})") + + echo "validator_bls${i} bls_priv_key: ${bls_priv_key}" + echo "relayer${i} relayer_key: ${relayer_key}" + done +} + function export_sps { size=$1 sp_size=1 @@ -312,6 +324,10 @@ generate) export_sps) export_sps $SIZE $SP_SIZE ;; + +export_validator) + export_validator $SIZE + ;; start) echo "===== start ====" start $SIZE diff --git a/deployment/readme.md b/deployment/readme.md index 546995e53..8fbc86068 100644 --- a/deployment/readme.md +++ b/deployment/readme.md @@ -86,6 +86,17 @@ bash ./deployment/localup/localup.sh stop 3. Send Tx ```bash +VALIDATOR=$(./build/bin/gnfd keys show validator0 -a --home ./deployment/localup/.local/validator0 --keyring-backend test) +GROUP_NAME="admin2" + +./build/bin/gnfd tx storage create-group $GROUP_NAME --from validator0 --home ./deployment/localup/.local/validator0 --keyring-backend test --node http://localhost:26750 -b sync + +./build/bin/gnfd tx storage update-group-member $GROUP_NAME "0xfABDd8b607201667fE54054CB4AD9068Afa2993e,0xba8dde27ddc0f39041a1d9a4efd24b5b5d81fe17" "1691118864,2691118864" "" --from validator0 --home ./deployment/localup/.local/validator0 --keyring-backend test --node http://localhost:26750 -b sync +./build/bin/gnfd tx storage renew-group-member $GROUP_NAME 0xfABDd8b607201667fE54054CB4AD9068Afa2993e 1791118864 --from validator0 --home ./deployment/localup/.local/validator0 --keyring-backend test --node http://localhost:26750 -b sync + +./build/bin/gnfd q storage head-group-member $VALIDATOR $GROUP_NAME 0xfABDd8b607201667fE54054CB4AD9068Afa2993e --node http://localhost:26750 +./build/bin/gnfd q storage head-group-member $VALIDATOR $GROUP_NAME 0xba8dde27ddc0f39041a1d9a4efd24b5b5d81fe17 --node http://localhost:26750 + ./build/bin/gnfd tx bank send validator0 0x32Ff14Fa1547314b95991976DB432F9Aa648A423 500000000000000000000BNB --home ./deployment/localup/.local/validator0 --keyring-backend test --node http://localhost:26750 -b sync ``` diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index aad76dd6e..3829058f3 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -671,9 +671,15 @@ func (s *StorageTestSuite) TestGrantsPermissionToGroup() { // Create Group testGroupName := "testGroup" - msgCreateGroup := storagetypes.NewMsgCreateGroup(user[0].GetAddr(), testGroupName, []sdk.AccAddress{user[1].GetAddr()}, "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(user[0].GetAddr(), testGroupName, "") s.SendTxBlock(user[0], msgCreateGroup) + membersToAdd := []*storagetypes.MsgGroupMember{ + {Member: user[1].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete := []sdk.AccAddress{} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(user[0].GetAddr(), user[0].GetAddr(), testGroupName, membersToAdd, membersToDelete) + s.SendTxBlock(user[0], msgUpdateGroupMember) + // Head Group headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: user[0].GetAddr().String(), GroupName: testGroupName} headGroupResponse, err := s.Client.HeadGroup(ctx, &headGroupRequest) @@ -1168,10 +1174,14 @@ func (s *StorageTestSuite) TestDeleteGroupPolicy() { // Create Group testGroupName := "testGroup" - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, - []sdk.AccAddress{user[1].GetAddr(), user[2].GetAddr(), user[3].GetAddr()}, - "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, "") s.SendTxBlock(owner, msgCreateGroup) + membersToAdd := []*storagetypes.MsgGroupMember{ + {Member: user[1].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}, + {Member: user[2].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete := []sdk.AccAddress{} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), testGroupName, membersToAdd, membersToDelete) + s.SendTxBlock(owner, msgUpdateGroupMember) // Head Group headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} @@ -1219,8 +1229,13 @@ func (s *StorageTestSuite) TestStalePermissionForGroupGC() { // Create Group testGroupName := "testGroup" - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, []sdk.AccAddress{user[0].GetAddr(), user[1].GetAddr(), user[2].GetAddr()}, "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, "") s.SendTxBlock(owner, msgCreateGroup) + membersToAdd := []*storagetypes.MsgGroupMember{ + {Member: user[1].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete := []sdk.AccAddress{} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), testGroupName, membersToAdd, membersToDelete) + s.SendTxBlock(owner, msgUpdateGroupMember) // Head Group headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} @@ -1316,10 +1331,14 @@ func (s *StorageTestSuite) TestGroupMembersAndPolicyGC() { // Create Group testGroupName := "testGroup" - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, - []sdk.AccAddress{user[1].GetAddr(), user[2].GetAddr(), user[3].GetAddr()}, - "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, "") s.SendTxBlock(owner, msgCreateGroup) + membersToAdd := []*storagetypes.MsgGroupMember{ + {Member: user[1].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}, + {Member: user[2].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete := []sdk.AccAddress{} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), testGroupName, membersToAdd, membersToDelete) + s.SendTxBlock(owner, msgUpdateGroupMember) // Head Group headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} @@ -1489,10 +1508,14 @@ func (s *StorageTestSuite) TestUpdateGroupExtraWithPermission() { // Create Group testGroupName := "testGroup" - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, - []sdk.AccAddress{user[1].GetAddr(), user[2].GetAddr(), user[3].GetAddr()}, - "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, "") s.SendTxBlock(owner, msgCreateGroup) + membersToAdd := []*storagetypes.MsgGroupMember{ + {Member: user[1].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}, + {Member: user[2].GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete := []sdk.AccAddress{} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), testGroupName, membersToAdd, membersToDelete) + s.SendTxBlock(owner, msgUpdateGroupMember) // Head Group headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} diff --git a/e2e/tests/storage_test.go b/e2e/tests/storage_test.go index 49bb2ab90..8c491658e 100644 --- a/e2e/tests/storage_test.go +++ b/e2e/tests/storage_test.go @@ -276,7 +276,7 @@ func (s *StorageTestSuite) TestCreateGroup() { groupName := storageutils.GenRandomGroupName() // 1. CreateGroup - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, []sdk.AccAddress{member.GetAddr()}, "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, "") s.SendTxBlock(owner, msgCreateGroup) s.T().Logf("CerateGroup success, owner: %s, group name: %s", owner.GetAddr().String(), groupName) @@ -300,7 +300,14 @@ func (s *StorageTestSuite) TestCreateGroup() { s.Require().NoError(err) s.Require().GreaterOrEqual(len(queryListGroupResp.GroupInfos), 1) - // 3. HeadGroupMember + // 4. UpdateGroupMember(add) + membersToAdd := []*storagetypes.MsgGroupMember{ + {Member: member.GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete := []sdk.AccAddress{} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), groupName, membersToAdd, membersToDelete) + s.SendTxBlock(owner, msgUpdateGroupMember) + + // 4-1. HeadGroupMember(add) queryHeadGroupMemberReq := storagetypes.QueryHeadGroupMemberRequest{ Member: member.GetAddr().String(), GroupName: groupName, @@ -310,14 +317,15 @@ func (s *StorageTestSuite) TestCreateGroup() { s.Require().NoError(err) s.Require().Equal(queryHeadGroupMemberResp.GroupMember.GroupId, queryHeadGroupResp.GroupInfo.Id) - // 4. UpdateGroupMember + // 5. UpdateGroupMember(delete) member2 := s.GenAndChargeAccounts(1, 1000000)[0] - membersToAdd := []sdk.AccAddress{member2.GetAddr()} - membersToDelete := []sdk.AccAddress{member.GetAddr()} - msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), groupName, membersToAdd, membersToDelete) + membersToAdd = []*storagetypes.MsgGroupMember{ + {Member: member2.GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete = []sdk.AccAddress{member.GetAddr()} + msgUpdateGroupMember = storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), groupName, membersToAdd, membersToDelete) s.SendTxBlock(owner, msgUpdateGroupMember) - // 5. HeadGroupMember (delete) + // 5-1. HeadGroupMember (delete) queryHeadGroupMemberReqDelete := storagetypes.QueryHeadGroupMemberRequest{ Member: member.GetAddr().String(), GroupName: groupName, @@ -325,18 +333,9 @@ func (s *StorageTestSuite) TestCreateGroup() { } _, err = s.Client.HeadGroupMember(ctx, &queryHeadGroupMemberReqDelete) s.Require().True(strings.Contains(err.Error(), storagetypes.ErrNoSuchGroupMember.Error())) - // 5. HeadGroupMember (add) - queryHeadGroupMemberReqAdd := storagetypes.QueryHeadGroupMemberRequest{ - Member: member2.GetAddr().String(), - GroupName: groupName, - GroupOwner: owner.GetAddr().String(), - } - queryHeadGroupMemberRespAdd, err := s.Client.HeadGroupMember(ctx, &queryHeadGroupMemberReqAdd) - s.Require().NoError(err) - s.Require().Equal(queryHeadGroupMemberRespAdd.GroupMember.GroupId, queryHeadGroupResp.GroupInfo.Id) // 6. Create a group with the same name - msgCreateGroup = storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, []sdk.AccAddress{member.GetAddr()}, "") + msgCreateGroup = storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, "") s.SendTxBlockWithExpectErrorString(msgCreateGroup, owner, "exists") } @@ -348,9 +347,14 @@ func (s *StorageTestSuite) TestLeaveGroup() { groupName := storageutils.GenRandomGroupName() // 1. CreateGroup - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, []sdk.AccAddress{member.GetAddr()}, "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, "") s.SendTxBlock(owner, msgCreateGroup) s.T().Logf("CerateGroup success, owner: %s, group name: %s", owner.GetAddr().String(), groupName) + membersToAdd := []*storagetypes.MsgGroupMember{ + {Member: member.GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete := []sdk.AccAddress{} + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), groupName, membersToAdd, membersToDelete) + s.SendTxBlock(owner, msgUpdateGroupMember) // 2. HeadGroup queryHeadGroupReq := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: groupName} @@ -384,9 +388,10 @@ func (s *StorageTestSuite) TestLeaveGroup() { // 4. UpdateGroupMember member2 := s.GenAndChargeAccounts(1, 1000000)[0] - membersToAdd := []sdk.AccAddress{member2.GetAddr()} - membersToDelete := []sdk.AccAddress{member.GetAddr()} - msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), groupName, membersToAdd, membersToDelete) + membersToAdd = []*storagetypes.MsgGroupMember{ + {Member: member2.GetAddr().String(), ExpirationTime: storagetypes.MaxTimeStamp}} + membersToDelete = []sdk.AccAddress{member.GetAddr()} + msgUpdateGroupMember = storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), groupName, membersToAdd, membersToDelete) s.SendTxBlock(owner, msgUpdateGroupMember) // 5. leave group @@ -692,11 +697,10 @@ func (s *StorageTestSuite) TestMirrorGroup() { ctx := context.Background() owner := s.GenAndChargeAccounts(1, 1000000)[0] - member := s.GenAndChargeAccounts(1, 1000000)[0] groupName := storageutils.GenRandomGroupName() // 1. CreateGroup - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, []sdk.AccAddress{member.GetAddr()}, "") + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, "") s.SendTxBlock(owner, msgCreateGroup) s.T().Logf("CerateGroup success, owner: %s, group name: %s", owner.GetAddr().String(), groupName) @@ -713,7 +717,7 @@ func (s *StorageTestSuite) TestMirrorGroup() { // CreateGroup groupName = storageutils.GenRandomGroupName() - msgCreateGroup = storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, []sdk.AccAddress{member.GetAddr()}, "") + msgCreateGroup = storagetypes.NewMsgCreateGroup(owner.GetAddr(), groupName, "") s.SendTxBlock(owner, msgCreateGroup) // MirrorGroup using name @@ -1488,10 +1492,10 @@ func (s *StorageTestSuite) TestCreateAndUpdateGroupExtraField() { ctx := context.Background() owner := s.GenAndChargeAccounts(1, 1000000)[0] - // Create a group without members + // Create a group testGroupName := "appName/bucketName" extra := "{\"description\":\"no description\",\"imageUrl\":\"www.images.com/image1\"}" - msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, nil, extra) + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, extra) s.SendTxBlock(owner, msgCreateGroup) // Head Group @@ -1532,6 +1536,47 @@ func (s *StorageTestSuite) TestCreateAndUpdateGroupExtraField() { s.T().Logf("GroupInfo: %s", headGroupResponse.GetGroupInfo().String()) } +func (s *StorageTestSuite) TestCreateAndRenewGroup() { + var err error + ctx := context.Background() + owner := s.GenAndChargeAccounts(1, 1000000)[0] + member := s.GenAndChargeAccounts(1, 1000000)[0] + + // Create a group + testGroupName := "appName/bucketName" + extra := "{\"description\":\"no description\",\"imageUrl\":\"www.images.com/image1\"}" + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, extra) + s.SendTxBlock(owner, msgCreateGroup) + s.T().Logf("CerateGroup success, owner: %s, group name: %s", owner.GetAddr().String(), testGroupName) + + // Head Group + headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} + headGroupResponse, err := s.Client.HeadGroup(ctx, &headGroupRequest) + s.Require().NoError(err) + s.Require().Equal(headGroupResponse.GroupInfo.GroupName, testGroupName) + s.Require().True(owner.GetAddr().Equals(sdk.MustAccAddressFromHex(headGroupResponse.GroupInfo.Owner))) + s.Require().Equal(headGroupResponse.GroupInfo.Extra, extra) + + // Renew GroupMember + expiration, err := time.Parse(time.RFC3339, "2022-12-31T23:59:59Z") + s.Require().NoError(err) + members := []*storagetypes.MsgGroupMember{ + {Member: member.GetAddr().String(), ExpirationTime: expiration}} + msgUpdateGroupMember := storagetypes.NewMsgRenewGroupMember(owner.GetAddr(), owner.GetAddr(), testGroupName, members) + s.SendTxBlock(owner, msgUpdateGroupMember) + + // Head GroupMember + queryHeadGroupMemberReq := storagetypes.QueryHeadGroupMemberRequest{ + Member: member.GetAddr().String(), + GroupName: testGroupName, + GroupOwner: owner.GetAddr().String(), + } + queryHeadGroupMemberResp, err := s.Client.HeadGroupMember(ctx, &queryHeadGroupMemberReq) + s.Require().NoError(err) + s.Require().Equal(queryHeadGroupMemberResp.GroupMember.GroupId, headGroupResponse.GroupInfo.Id) + s.Require().True(queryHeadGroupMemberResp.GroupMember.ExpirationTime.Equal(expiration)) +} + func (s *StorageTestSuite) TestRejectSealObject() { var err error // CreateBucket diff --git a/go.mod b/go.mod index 30740871a..5e9ff92eb 100644 --- a/go.mod +++ b/go.mod @@ -157,12 +157,13 @@ require ( github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect - golang.org/x/crypto v0.9.0 // indirect + golang.org/x/crypto v0.10.0 // indirect golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/net v0.11.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/term v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect + golang.org/x/tools v0.10.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect @@ -176,7 +177,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.3.0.20230803020148-9216a6aea390 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230807083232-9a0d3b09e97f 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 82c607fbf..9d042109b 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.3.0.20230803020148-9216a6aea390 h1:tuXCEm4WHJ/7mhYM9Nqq5z+Qu96xsSZ6pqw0LE0+Fqo= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230803020148-9216a6aea390/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230807083232-9a0d3b09e97f h1:3rBKrvNg2PXJUgkyZMgf2x8l6/7UWD1qGUgOTL7WmAk= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230807083232-9a0d3b09e97f/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas= 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= @@ -1502,8 +1502,8 @@ golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5 golang.org/x/crypto v0.0.0-20210813211128-0a44fdfbc16e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1548,7 +1548,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1613,8 +1613,8 @@ golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1749,13 +1749,13 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1766,8 +1766,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20170424234030-8be79e1e0910/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1842,7 +1842,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= +golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= +golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/proto/greenfield/permission/types.proto b/proto/greenfield/permission/types.proto index 7fc819bfb..143e347e1 100644 --- a/proto/greenfield/permission/types.proto +++ b/proto/greenfield/permission/types.proto @@ -71,4 +71,9 @@ message GroupMember { ]; // member is the account address of the member string member = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // expiration_time defines the expiration time of the group member + google.protobuf.Timestamp expiration_time = 4 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; } diff --git a/proto/greenfield/storage/events.proto b/proto/greenfield/storage/events.proto index 527da5f34..2f91cd047 100644 --- a/proto/greenfield/storage/events.proto +++ b/proto/greenfield/storage/events.proto @@ -3,6 +3,7 @@ package greenfield.storage; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "greenfield/storage/common.proto"; import "greenfield/storage/types.proto"; @@ -284,10 +285,8 @@ message EventCreateGroup { ]; // source_type define the source of the group. CrossChain or Greenfield origin SourceType source_type = 4; - // members define the all the address of the members. - repeated string members = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // extra defines extra info for the group - string extra = 6; + string extra = 5; } // EventDeleteGroup is emitted on MsgDeleteGroup @@ -335,11 +334,40 @@ message EventUpdateGroupMember { (gogoproto.nullable) = false ]; // members_to_add defines all the members to be added to the group - repeated string members_to_add = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated EventGroupMemberDetail members_to_add = 5; // members_to_add defines all the members to be deleted from the group repeated string members_to_delete = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } +message EventRenewGroupMember { + // operator define the account address of operator who update the group member + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // owner define the account address of group owner + string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // group_name define the name of the group + string group_name = 3; + // id define an u256 id for group + string group_id = 4 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "Uint", + (gogoproto.nullable) = false + ]; + // source_type define the source of the group. CrossChain or Greenfield origin + SourceType source_type = 5; + // members define the all the address of the members. + repeated EventGroupMemberDetail members = 6; +} + +message EventGroupMemberDetail { + // member defines the account address of the group member + string member = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // expiration_time defines the expiration time of the group member + google.protobuf.Timestamp expiration_time = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; +} + // EventUpdateGroupExtra is emitted on MsgUpdateGroupExtra message EventUpdateGroupExtra { // operator define the account address of operator who update the group member diff --git a/proto/greenfield/storage/tx.proto b/proto/greenfield/storage/tx.proto index 2537a7b70..ef9de2aaf 100644 --- a/proto/greenfield/storage/tx.proto +++ b/proto/greenfield/storage/tx.proto @@ -42,6 +42,7 @@ service Msg { rpc UpdateGroupExtra(MsgUpdateGroupExtra) returns (MsgUpdateGroupExtraResponse); rpc LeaveGroup(MsgLeaveGroup) returns (MsgLeaveGroupResponse); rpc MirrorGroup(MsgMirrorGroup) returns (MsgMirrorGroupResponse); + rpc RenewGroupMember(MsgRenewGroupMember) returns (MsgRenewGroupMemberResponse); // basic operation of policy rpc PutPolicy(MsgPutPolicy) returns (MsgPutPolicyResponse); @@ -274,11 +275,8 @@ message MsgCreateGroup { // group_name defines the name of the group. it's not globally unique. string group_name = 2; - // member_request defines a list of member which to be add or remove - repeated string members = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // extra defines extra info for the group - string extra = 4; + string extra = 3; } message MsgCreateGroupResponse { @@ -314,7 +312,7 @@ message MsgUpdateGroupMember { string group_name = 3; // members_to_add defines a list of members account address which will be add to the group - repeated string members_to_add = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated MsgGroupMember members_to_add = 4; // members_to_delete defines a list of members account address which will be remove from the group repeated string members_to_delete = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; @@ -322,6 +320,34 @@ message MsgUpdateGroupMember { message MsgUpdateGroupMemberResponse {} +message MsgRenewGroupMember { + option (cosmos.msg.v1.signer) = "operator"; + + // operator defines the account address of the operator who has the UpdateGroupMember permission of the group. + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // group_owner defines the account address of the group owner + string group_owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // group_name defines the name of the group which to be updated + string group_name = 3; + + // members defines a list of members which will be renew to the group + repeated MsgGroupMember members = 4; +} + +message MsgRenewGroupMemberResponse {} + +message MsgGroupMember { + // member defines the account address of the group member + string member = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // expiration_time defines the expiration time of the group member + google.protobuf.Timestamp expiration_time = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; +} + message MsgUpdateGroupExtra { option (cosmos.msg.v1.signer) = "operator"; diff --git a/swagger/static/swagger.yaml b/swagger/static/swagger.yaml index 3cb9f0a63..a612b7c14 100644 --- a/swagger/static/swagger.yaml +++ b/swagger/static/swagger.yaml @@ -2826,6 +2826,12 @@ paths: member: type: string title: member is the account address of the member + expiration_time: + type: string + format: date-time + title: >- + expiration_time defines the expiration time of the group + member default: description: An unexpected error response. schema: @@ -33135,6 +33141,10 @@ definitions: member: type: string title: member is the account address of the member + expiration_time: + type: string + format: date-time + title: expiration_time defines the expiration time of the group member greenfield.permission.Policy: type: object properties: @@ -34083,6 +34093,10 @@ definitions: member: type: string title: member is the account address of the member + expiration_time: + type: string + format: date-time + title: expiration_time defines the expiration time of the group member greenfield.storage.QueryHeadGroupResponse: type: object properties: diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index d94e635ff..2a1055407 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "time" "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" @@ -58,15 +59,16 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) AddGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress) error { +func (k Keeper) AddGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress, expiration time.Time) error { store := ctx.KVStore(k.storeKey) memberKey := types.GetGroupMemberKey(groupID, member) if store.Has(memberKey) { return storagetypes.ErrGroupMemberAlreadyExists } groupMember := types.GroupMember{ - GroupId: groupID, - Member: member.String(), + GroupId: groupID, + Member: member.String(), + ExpirationTime: expiration, } id := k.groupMemberSeq.NextVal(store) store.Set(memberKey, id.Bytes()) @@ -74,6 +76,16 @@ func (k Keeper) AddGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.Ac return nil } +func (k Keeper) UpdateGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress, memberID math.Uint, expiration time.Time) { + store := ctx.KVStore(k.storeKey) + groupMember := types.GroupMember{ + GroupId: groupID, + Member: member.String(), + ExpirationTime: expiration, + } + store.Set(types.GetGroupMemberByIDKey(memberID), k.cdc.MustMarshal(&groupMember)) +} + func (k Keeper) RemoveGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress) error { store := ctx.KVStore(k.storeKey) memberKey := types.GetGroupMemberKey(groupID, member) @@ -105,6 +117,7 @@ func (k Keeper) GetGroupMemberByID(ctx sdk.Context, groupMemberID math.Uint) (*t } var groupMember types.GroupMember k.cdc.MustUnmarshal(bz, &groupMember) + groupMember.Id = groupMemberID return &groupMember, true } @@ -283,8 +296,9 @@ func (k Keeper) VerifyPolicy(ctx sdk.Context, resourceID math.Uint, resourceType effect, newPolicy = p.Eval(action, ctx.BlockTime(), opts) if effect != types.EFFECT_UNSPECIFIED { // check the operator is the member of this group - _, memberFound := k.GetGroupMember(ctx, item.GroupId, operator) - if memberFound { + groupMember, memberFound := k.GetGroupMember(ctx, item.GroupId, operator) + if memberFound && groupMember.ExpirationTime.After(ctx.BlockTime().UTC()) { + // check if the operator has been revoked if effect == types.EFFECT_ALLOW { allowed = true } else if effect == types.EFFECT_DENY { diff --git a/x/permission/types/types.pb.go b/x/permission/types/types.pb.go index 341a415a1..d4cdca199 100644 --- a/x/permission/types/types.pb.go +++ b/x/permission/types/types.pb.go @@ -199,6 +199,8 @@ type GroupMember struct { GroupId Uint `protobuf:"bytes,2,opt,name=group_id,json=groupId,proto3,customtype=Uint" json:"group_id"` // member is the account address of the member Member string `protobuf:"bytes,3,opt,name=member,proto3" json:"member,omitempty"` + // expiration_time defines the expiration time of the group member + ExpirationTime time.Time `protobuf:"bytes,4,opt,name=expiration_time,json=expirationTime,proto3,stdtime" json:"expiration_time"` } func (m *GroupMember) Reset() { *m = GroupMember{} } @@ -241,6 +243,13 @@ func (m *GroupMember) GetMember() string { return "" } +func (m *GroupMember) GetExpirationTime() time.Time { + if m != nil { + return m.ExpirationTime + } + return time.Time{} +} + func init() { proto.RegisterType((*Policy)(nil), "greenfield.permission.Policy") proto.RegisterType((*PolicyGroup)(nil), "greenfield.permission.PolicyGroup") @@ -251,40 +260,41 @@ func init() { func init() { proto.RegisterFile("greenfield/permission/types.proto", fileDescriptor_0d2afeea9f743f03) } var fileDescriptor_0d2afeea9f743f03 = []byte{ - // 521 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x6a, 0x13, 0x41, - 0x1c, 0xc7, 0x33, 0x49, 0x1a, 0x93, 0x89, 0x56, 0x18, 0x2a, 0xac, 0x11, 0x36, 0x69, 0x2e, 0x06, + // 530 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6b, 0x13, 0x41, + 0x18, 0xc6, 0x33, 0x69, 0x1a, 0x93, 0x89, 0x56, 0x18, 0x2a, 0xac, 0x11, 0x36, 0x69, 0x2e, 0x06, 0x24, 0xb3, 0x12, 0x41, 0x3c, 0xa8, 0x68, 0x0e, 0x4a, 0xc0, 0x42, 0xd9, 0xd6, 0x8b, 0x97, 0x90, - 0xdd, 0x9d, 0x6e, 0x07, 0x32, 0x7f, 0x98, 0x99, 0x40, 0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0x36, 0x0d, 0x70, 0x28, + 0x98, 0x17, 0xf0, 0xa0, 0x17, 0x9e, 0x8d, 0x29, 0xf7, 0x36, 0xfe, 0x9d, 0xb3, 0xdf, 0xbe, 0x27, + 0x41, 0xd5, 0xce, 0x7e, 0xf6, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x13, 0x3a, 0x0a, 0xc5, 0x75, 0x04, + 0x00, 0x00, } func (m *Policy) Marshal() (dAtA []byte, err error) { @@ -471,6 +481,14 @@ func (m *GroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintTypes(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x22 if len(m.Member) > 0 { i -= len(m.Member) copy(dAtA[i:], m.Member) @@ -584,6 +602,8 @@ func (m *GroupMember) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationTime) + n += 1 + l + sovTypes(uint64(l)) return n } @@ -1167,6 +1187,39 @@ func (m *GroupMember) Unmarshal(dAtA []byte) error { } m.Member = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpirationTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.ExpirationTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/x/storage/client/cli/flags.go b/x/storage/client/cli/flags.go index 6597fee89..20b510800 100644 --- a/x/storage/client/cli/flags.go +++ b/x/storage/client/cli/flags.go @@ -27,7 +27,6 @@ const ( FlagObjectName = "object-name" FlagGroupId = "group-id" FlagGroupName = "group-name" - FlagMemberList = "members" FlagExtra = "extra" ) diff --git a/x/storage/client/cli/tx.go b/x/storage/client/cli/tx.go index 62c193b2c..38b7013e1 100644 --- a/x/storage/client/cli/tx.go +++ b/x/storage/client/cli/tx.go @@ -2,10 +2,12 @@ package cli import ( "encoding/hex" + "errors" "fmt" "math/big" "strconv" "strings" + "time" cmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" @@ -52,6 +54,7 @@ func GetTxCmd() *cobra.Command { CmdDeleteGroup(), CmdUpdateGroupMember(), CmdUpdateGroupExtra(), + CmdRenewGroupMember(), CmdLeaveGroup(), CmdMirrorGroup(), ) @@ -522,7 +525,6 @@ func CmdCreateGroup() *cobra.Command { Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { argGroupName := args[0] - argMemberList, _ := cmd.Flags().GetString(FlagMemberList) extra, _ := cmd.Flags().GetString(FlagExtra) clientCtx, err := client.GetClientTxContext(cmd) @@ -530,21 +532,9 @@ func CmdCreateGroup() *cobra.Command { return err } - var memberAddrs []sdk.AccAddress - if argMemberList != "" { - members := strings.Split(argMemberList, ",") - for _, member := range members { - memberAddr, err := sdk.AccAddressFromHexUnsafe(member) - if err != nil { - return err - } - memberAddrs = append(memberAddrs, memberAddr) - } - } msg := types.NewMsgCreateGroup( clientCtx.GetFromAddress(), argGroupName, - memberAddrs, extra, ) if err := msg.ValidateBasic(); err != nil { @@ -555,7 +545,6 @@ func CmdCreateGroup() *cobra.Command { } cmd.Flags().String(FlagExtra, "", "extra info for the group") - cmd.Flags().String(FlagMemberList, "", "init members of the group") flags.AddTxFlagsToCmd(cmd) return cmd @@ -628,41 +617,62 @@ func CmdLeaveGroup() *cobra.Command { func CmdUpdateGroupMember() *cobra.Command { cmd := &cobra.Command{ - Use: "update-group-member [group-name] [member-to-add] [member-to-delete]", - Short: "Update the member of the group you own, split member addresses by ,", - Args: cobra.ExactArgs(3), + Use: "update-group-member [group-name] [member-to-add] [member-expiration-to-add] [member-to-delete]", + Short: "Update the member of the group you own, split member addresses and expiration(UNIX timestamp) by ,", + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argGroupName := args[0] argMemberToAdd := args[1] - argMemberToDelete := args[2] - + argMemberExpirationToAdd := args[2] + argMemberToDelete := args[3] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - var memberAddrsToAdd []sdk.AccAddress membersToAdd := strings.Split(argMemberToAdd, ",") - for _, member := range membersToAdd { - memberAddr, err := sdk.AccAddressFromHexUnsafe(member) - if err != nil { - return err + memberExpirationStr := strings.Split(argMemberExpirationToAdd, ",") + if len(memberExpirationStr) != len(membersToAdd) { + return errors.New("[member-to-add] and [member-expiration-to-add] should have the same length") + } + + msgGroupMemberToAdd := make([]*types.MsgGroupMember, 0, len(argMemberToAdd)) + if len(membersToAdd) > 0 { + for i := range membersToAdd { + if len(membersToAdd[i]) > 0 { + _, err := sdk.AccAddressFromHexUnsafe(membersToAdd[i]) + if err != nil { + return err + } + expiration, err := strconv.ParseInt(memberExpirationStr[i], 10, 64) + if err != nil { + return err + } + msgGroupMemberToAdd = append(msgGroupMemberToAdd, &types.MsgGroupMember{ + Member: membersToAdd[i], + ExpirationTime: time.Unix(expiration, 0).UTC(), + }) + } } - memberAddrsToAdd = append(memberAddrsToAdd, memberAddr) } + var memberAddrsToDelete []sdk.AccAddress - membersToDelete := strings.Split(argMemberToDelete, ",") - for _, member := range membersToDelete { - memberAddr, err := sdk.AccAddressFromHexUnsafe(member) - if err != nil { - return err + if len(argMemberToDelete) == 0 { + membersToDelete := strings.Split(argMemberToDelete, ",") + for _, member := range membersToDelete { + if len(member) > 0 { + memberAddr, err := sdk.AccAddressFromHexUnsafe(member) + if err != nil { + return err + } + memberAddrsToDelete = append(memberAddrsToDelete, memberAddr) + } } - memberAddrsToDelete = append(memberAddrsToDelete, memberAddr) } msg := types.NewMsgUpdateGroupMember( clientCtx.GetFromAddress(), clientCtx.GetFromAddress(), argGroupName, - memberAddrsToAdd, + msgGroupMemberToAdd, memberAddrsToDelete, ) if err := msg.ValidateBasic(); err != nil { @@ -677,6 +687,62 @@ func CmdUpdateGroupMember() *cobra.Command { return cmd } +func CmdRenewGroupMember() *cobra.Command { + cmd := &cobra.Command{ + Use: "renew-group-member [group-name] [member] [member-expiration]", + Short: "renew the member of the group you own, split member-addresses and member-expiration(UNIX timestamp) by ,", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argGroupName := args[0] + argMember := args[1] + argMemberExpiration := args[2] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + memberExpirationStr := strings.Split(argMemberExpiration, ",") + members := strings.Split(argMember, ",") + + if len(memberExpirationStr) != len(members) { + return errors.New("member and member-expiration should have the same length") + } + + msgGroupMember := make([]*types.MsgGroupMember, 0, len(argMember)) + for i := range members { + _, err := sdk.AccAddressFromHexUnsafe(members[i]) + if err != nil { + return err + } + expiration, err := strconv.ParseInt(memberExpirationStr[i], 10, 64) + if err != nil { + return err + } + msgGroupMember = append(msgGroupMember, &types.MsgGroupMember{ + Member: members[i], + ExpirationTime: time.Unix(expiration, 0), + }) + } + + msg := types.NewMsgRenewGroupMember( + clientCtx.GetFromAddress(), + clientCtx.GetFromAddress(), + argGroupName, + msgGroupMember, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + func CmdUpdateGroupExtra() *cobra.Command { cmd := &cobra.Command{ Use: "update-group-extra [group-name] [extra]", diff --git a/x/storage/keeper/cross_app_group.go b/x/storage/keeper/cross_app_group.go index 77b8e27a0..0a23a1253 100644 --- a/x/storage/keeper/cross_app_group.go +++ b/x/storage/keeper/cross_app_group.go @@ -336,21 +336,13 @@ func (app *GroupApp) handleUpdateGroupMemberSynPackage(ctx sdk.Context, header * } } - options := types.UpdateGroupMemberOptions{ - SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, - } - if updateGroupPackage.OperationType == types.OperationAddGroupMember { - options.MembersToAdd = updateGroupPackage.GetMembers() - } else { - options.MembersToDelete = updateGroupPackage.GetMembers() + switch updateGroupPackage.OperationType { + case types.OperationAddGroupMember, types.OperationDeleteGroupMember: + err = app.handleAddOrDeleteGroupMemberOperation(ctx, groupInfo, updateGroupPackage) + case types.OperationRenewGroupMember: + err = app.handleRenewGroupOperation(ctx, groupInfo, updateGroupPackage) } - err = app.storageKeeper.UpdateGroupMember( - ctx, - updateGroupPackage.Operator, - groupInfo, - options, - ) if err != nil { return sdk.ExecuteResult{ Payload: types.UpdateGroupMemberAckPackage{ @@ -374,6 +366,40 @@ func (app *GroupApp) handleUpdateGroupMemberSynPackage(ctx sdk.Context, header * } } +func (app *GroupApp) handleAddOrDeleteGroupMemberOperation(ctx sdk.Context, groupInfo *types.GroupInfo, updateGroupPackage *types.UpdateGroupMemberSynPackage) error { + options := types.UpdateGroupMemberOptions{ + SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, + } + if updateGroupPackage.OperationType == types.OperationAddGroupMember { + options.MembersToAdd = updateGroupPackage.GetMembers() + options.MembersExpirationToAdd = updateGroupPackage.GetMemberExpiration() + } else { + options.MembersToDelete = updateGroupPackage.GetMembers() + } + + return app.storageKeeper.UpdateGroupMember( + ctx, + updateGroupPackage.Operator, + groupInfo, + options, + ) +} + +func (app *GroupApp) handleRenewGroupOperation(ctx sdk.Context, groupInfo *types.GroupInfo, updateGroupPackage *types.UpdateGroupMemberSynPackage) error { + options := types.RenewGroupMemberOptions{ + SourceType: types.SOURCE_TYPE_BSC_CROSS_CHAIN, + Members: updateGroupPackage.GetMembers(), + MembersExpiration: updateGroupPackage.GetMemberExpiration(), + } + + return app.storageKeeper.RenewGroupMember( + ctx, + updateGroupPackage.Operator, + groupInfo, + options, + ) +} + func (app *GroupApp) handleUpdateGroupMemberAckPackage(ctx sdk.Context, header *sdk.CrossChainAppContext, createGroupPackage *types.UpdateGroupMemberAckPackage) sdk.ExecuteResult { app.storageKeeper.Logger(ctx).Error("received update group member ack package ") diff --git a/x/storage/keeper/grpc_query.go b/x/storage/keeper/grpc_query.go index ea2aa50a7..e866773f4 100644 --- a/x/storage/keeper/grpc_query.go +++ b/x/storage/keeper/grpc_query.go @@ -558,6 +558,7 @@ func (k Keeper) HeadGroupMember(goCtx context.Context, req *types.QueryHeadGroup if !found { return nil, types.ErrNoSuchGroupMember } + return &types.QueryHeadGroupMemberResponse{GroupMember: groupMember}, nil } diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 20b6e1676..2372197d1 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1254,23 +1254,11 @@ func (k Keeper) CreateGroup( store.Set(groupKey, k.groupSeq.EncodeSequence(groupInfo.Id)) store.Set(types.GetGroupByIDKey(groupInfo.Id), gbz) - // need to limit the size of Msg.Members to avoid taking too long to execute the msg - for _, member := range opts.Members { - memberAddress, err := sdk.AccAddressFromHexUnsafe(member) - if err != nil { - return sdkmath.ZeroUint(), err - } - err = k.permKeeper.AddGroupMember(ctx, groupInfo.Id, memberAddress) - if err != nil { - return sdkmath.Uint{}, err - } - } if err := ctx.EventManager().EmitTypedEvents(&types.EventCreateGroup{ Owner: groupInfo.Owner, GroupName: groupInfo.GroupName, GroupId: groupInfo.Id, SourceType: groupInfo.SourceType, - Members: opts.Members, Extra: opts.Extra, }); err != nil { return sdkmath.ZeroUint(), err @@ -1386,15 +1374,26 @@ func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, grou operator.String(), groupInfo.GroupName, groupInfo.Owner) } - for _, member := range opts.MembersToAdd { - memberAcc, err := sdk.AccAddressFromHexUnsafe(member) + addedMembersDetailEvent := make([]*types.EventGroupMemberDetail, 0, len(opts.MembersToAdd)) + for i := range opts.MembersToAdd { + memberAcc, err := sdk.AccAddressFromHexUnsafe(opts.MembersToAdd[i]) if err != nil { return err } - err = k.permKeeper.AddGroupMember(ctx, groupInfo.Id, memberAcc) + + groupMemberDetailEvent := &types.EventGroupMemberDetail{ + Member: opts.MembersToAdd[i], + ExpirationTime: types.MaxTimeStamp, + } + + memberExpiration := opts.MembersExpirationToAdd[i].UTC() + groupMemberDetailEvent.ExpirationTime = memberExpiration + err = k.permKeeper.AddGroupMember(ctx, groupInfo.Id, memberAcc, memberExpiration) if err != nil { return err } + + addedMembersDetailEvent = append(addedMembersDetailEvent, groupMemberDetailEvent) } for _, member := range opts.MembersToDelete { @@ -1413,7 +1412,7 @@ func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, grou Owner: groupInfo.Owner, GroupName: groupInfo.GroupName, GroupId: groupInfo.Id, - MembersToAdd: opts.MembersToAdd, + MembersToAdd: addedMembersDetailEvent, MembersToDelete: opts.MembersToDelete, }); err != nil { return err @@ -1421,8 +1420,59 @@ func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, grou return nil } -func (k Keeper) UpdateGroupExtra(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, extra string) error { +func (k Keeper) RenewGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, opts types.RenewGroupMemberOptions) error { + if groupInfo.SourceType != opts.SourceType { + return types.ErrSourceTypeMismatch + } + + // check permission + effect := k.VerifyGroupPermission(ctx, groupInfo, operator, permtypes.ACTION_UPDATE_GROUP_MEMBER) + if effect != permtypes.EFFECT_ALLOW { + return types.ErrAccessDenied.Wrapf( + "The operator(%s) has no UpdateGroupMember permission of the group(%s), operator(%s)", + operator.String(), groupInfo.GroupName, groupInfo.Owner) + } + + eventMembersDetail := make([]*types.EventGroupMemberDetail, 0, len(opts.Members)) + for i := range opts.Members { + member := opts.Members[i] + memberExpiration := opts.MembersExpiration[i].UTC() + memberAcc, err := sdk.AccAddressFromHexUnsafe(member) + if err != nil { + return err + } + groupMember, found := k.permKeeper.GetGroupMember(ctx, groupInfo.Id, memberAcc) + if !found { + err = k.permKeeper.AddGroupMember(ctx, groupInfo.Id, memberAcc, memberExpiration) + if err != nil { + return err + } + } else { + k.permKeeper.UpdateGroupMember(ctx, groupInfo.Id, memberAcc, groupMember.Id, memberExpiration) + } + + eventMembersDetail = append(eventMembersDetail, &types.EventGroupMemberDetail{ + Member: member, + ExpirationTime: memberExpiration, + }) + } + + if err := ctx.EventManager().EmitTypedEvents(&types.EventRenewGroupMember{ + Operator: operator.String(), + Owner: groupInfo.Owner, + GroupName: groupInfo.GroupName, + GroupId: groupInfo.Id, + SourceType: groupInfo.SourceType, + Members: eventMembersDetail, + }); err != nil { + return err + } + + return nil +} + +func (k Keeper) UpdateGroupExtra(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, extra string) error { // check permission effect := k.VerifyGroupPermission(ctx, groupInfo, operator, permtypes.ACTION_UPDATE_GROUP_EXTRA) if effect != permtypes.EFFECT_ALLOW { diff --git a/x/storage/keeper/msg_server.go b/x/storage/keeper/msg_server.go index cd7277471..8ea4ef613 100644 --- a/x/storage/keeper/msg_server.go +++ b/x/storage/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "time" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -232,7 +233,7 @@ func (k msgServer) CreateGroup(goCtx context.Context, msg *types.MsgCreateGroup) ownerAcc := sdk.MustAccAddressFromHex(msg.Creator) - id, err := k.Keeper.CreateGroup(ctx, ownerAcc, msg.GroupName, storagetypes.CreateGroupOptions{Members: msg.Members, Extra: msg.Extra}) + id, err := k.Keeper.CreateGroup(ctx, ownerAcc, msg.GroupName, storagetypes.CreateGroupOptions{Extra: msg.Extra}) if err != nil { return nil, err } @@ -280,10 +281,17 @@ func (k msgServer) UpdateGroupMember(goCtx context.Context, msg *types.MsgUpdate if !found { return nil, types.ErrNoSuchGroup } + membersToAdd := make([]string, 0, len(msg.MembersToAdd)) + membersExpirationToAdd := make([]time.Time, 0, len(msg.MembersToAdd)) + for i := range msg.MembersToAdd { + membersToAdd = append(membersToAdd, msg.MembersToAdd[i].GetMember()) + membersExpirationToAdd = append(membersExpirationToAdd, msg.MembersToAdd[i].GetExpirationTime()) + } err := k.Keeper.UpdateGroupMember(ctx, operator, groupInfo, storagetypes.UpdateGroupMemberOptions{ - SourceType: types.SOURCE_TYPE_ORIGIN, - MembersToAdd: msg.MembersToAdd, - MembersToDelete: msg.MembersToDelete, + SourceType: types.SOURCE_TYPE_ORIGIN, + MembersToAdd: membersToAdd, + MembersExpirationToAdd: membersExpirationToAdd, + MembersToDelete: msg.MembersToDelete, }) if err != nil { return nil, err @@ -292,6 +300,37 @@ func (k msgServer) UpdateGroupMember(goCtx context.Context, msg *types.MsgUpdate return &types.MsgUpdateGroupMemberResponse{}, nil } +func (k msgServer) RenewGroupMember(goCtx context.Context, msg *types.MsgRenewGroupMember) (*types.MsgRenewGroupMemberResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + operator := sdk.MustAccAddressFromHex(msg.Operator) + + groupOwner := sdk.MustAccAddressFromHex(msg.GroupOwner) + + groupInfo, found := k.GetGroupInfo(ctx, groupOwner, msg.GroupName) + if !found { + return nil, types.ErrNoSuchGroup + } + + members := make([]string, 0, len(msg.Members)) + membersExpiration := make([]time.Time, 0, len(msg.Members)) + for i := range msg.Members { + members = append(members, msg.Members[i].GetMember()) + membersExpiration = append(membersExpiration, msg.Members[i].GetExpirationTime()) + } + + err := k.Keeper.RenewGroupMember(ctx, operator, groupInfo, storagetypes.RenewGroupMemberOptions{ + SourceType: types.SOURCE_TYPE_ORIGIN, + Members: members, + MembersExpiration: membersExpiration, + }) + if err != nil { + return nil, err + } + + return &types.MsgRenewGroupMemberResponse{}, nil +} + func (k msgServer) UpdateGroupExtra(goCtx context.Context, msg *types.MsgUpdateGroupExtra) (*types.MsgUpdateGroupExtraResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/storage/types/crosschain.go b/x/storage/types/crosschain.go index e43b2650b..f19333182 100644 --- a/x/storage/types/crosschain.go +++ b/x/storage/types/crosschain.go @@ -2,6 +2,7 @@ package types import ( "math/big" + time "time" "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -873,22 +874,25 @@ func (p DeleteGroupAckPackage) MustSerialize() []byte { const ( OperationAddGroupMember uint8 = 0 OperationDeleteGroupMember uint8 = 1 + OperationRenewGroupMember uint8 = 2 ) type UpdateGroupMemberSynPackage struct { - Operator sdk.AccAddress - GroupId *big.Int - OperationType uint8 - Members []sdk.AccAddress - ExtraData []byte + Operator sdk.AccAddress + GroupId *big.Int + OperationType uint8 + Members []sdk.AccAddress + ExtraData []byte + MemberExpiration []uint64 } type UpdateGroupMemberSynPackageStruct struct { - Operator common.Address - GroupId *big.Int - OperationType uint8 - Members []common.Address - ExtraData []byte + Operator common.Address + GroupId *big.Int + OperationType uint8 + Members []common.Address + ExtraData []byte + MemberExpiration []uint64 } var ( @@ -898,6 +902,7 @@ var ( {Name: "OperationType", Type: "uint8"}, {Name: "Members", Type: "address[]"}, {Name: "ExtraData", Type: "bytes"}, + {Name: "MemberExpiration", Type: "uint64[]"}, }) updateGroupMemberSynPackageArgs = abi.Arguments{ @@ -913,6 +918,14 @@ func (p UpdateGroupMemberSynPackage) GetMembers() []string { return members } +func (p UpdateGroupMemberSynPackage) GetMemberExpiration() []time.Time { + memberExpiration := make([]time.Time, 0, len(p.MemberExpiration)) + for _, expiration := range p.MemberExpiration { + memberExpiration = append(memberExpiration, time.Unix(int64(expiration), 0)) + } + return memberExpiration +} + func (p UpdateGroupMemberSynPackage) MustSerialize() []byte { totalMember := len(p.Members) members := make([]common.Address, totalMember) @@ -926,6 +939,7 @@ func (p UpdateGroupMemberSynPackage) MustSerialize() []byte { p.OperationType, members, p.ExtraData, + p.MemberExpiration, }) if err != nil { panic("encode update group member syn package error") @@ -934,7 +948,7 @@ func (p UpdateGroupMemberSynPackage) MustSerialize() []byte { } func (p UpdateGroupMemberSynPackage) ValidateBasic() error { - if p.OperationType != OperationAddGroupMember && p.OperationType != OperationDeleteGroupMember { + if p.OperationType != OperationAddGroupMember && p.OperationType != OperationDeleteGroupMember && p.OperationType != OperationRenewGroupMember { return ErrInvalidOperationType } @@ -950,19 +964,25 @@ func (p UpdateGroupMemberSynPackage) ValidateBasic() error { return sdkerrors.ErrInvalidAddress } } + + if (p.OperationType == OperationRenewGroupMember || p.OperationType == OperationAddGroupMember) && + len(p.Members) != len(p.MemberExpiration) { + return ErrInvalidGroupMemberExpiration + } + return nil } func DeserializeUpdateGroupMemberSynPackage(serializedPackage []byte) (interface{}, error) { unpacked, err := updateGroupMemberSynPackageArgs.Unpack(serializedPackage) if err != nil { - return nil, errors.Wrapf(ErrInvalidCrossChainPackage, "deserialize delete bucket ack package failed") + return nil, errors.Wrapf(ErrInvalidCrossChainPackage, "deserialize update group member sun package failed") } unpackedStruct := abi.ConvertType(unpacked[0], UpdateGroupMemberSynPackageStruct{}) pkgStruct, ok := unpackedStruct.(UpdateGroupMemberSynPackageStruct) if !ok { - return nil, errors.Wrapf(ErrInvalidCrossChainPackage, "reflect delete bucket ack package failed") + return nil, errors.Wrapf(ErrInvalidCrossChainPackage, "reflect update group member sun package failed") } totalMember := len(pkgStruct.Members) @@ -976,6 +996,7 @@ func DeserializeUpdateGroupMemberSynPackage(serializedPackage []byte) (interface pkgStruct.OperationType, members, pkgStruct.ExtraData, + pkgStruct.MemberExpiration, } return &tp, nil } diff --git a/x/storage/types/errors.go b/x/storage/types/errors.go index 9fb387674..282eebbab 100644 --- a/x/storage/types/errors.go +++ b/x/storage/types/errors.go @@ -6,31 +6,31 @@ import ( // x/storage module sentinel errors var ( - ErrNoSuchBucket = errors.Register(ModuleName, 1100, "No such bucket") - ErrNoSuchObject = errors.Register(ModuleName, 1101, "No such object") - ErrNoSuchGroup = errors.Register(ModuleName, 1102, "No such group") - ErrNoSuchGroupMember = errors.Register(ModuleName, 1103, "No such group member") - ErrBucketAlreadyExists = errors.Register(ModuleName, 1104, "Bucket already exists") - ErrObjectAlreadyExists = errors.Register(ModuleName, 1105, "Object already exists") - ErrGroupAlreadyExists = errors.Register(ModuleName, 1106, "Group already exists") - ErrAccessDenied = errors.Register(ModuleName, 1107, "Access denied") - ErrObjectAlreadySealed = errors.Register(ModuleName, 1108, "Object already sealed") - ErrBucketNotEmpty = errors.Register(ModuleName, 1109, "Bucket is not empty") - ErrGroupMemberAlreadyExists = errors.Register(ModuleName, 1110, "Group member already exists") - ErrNoSuchStorageProvider = errors.Register(ModuleName, 1111, "No such storage provider") - ErrObjectNotCreated = errors.Register(ModuleName, 1112, "Object not created") - ErrObjectNotSealed = errors.Register(ModuleName, 1113, "Object not sealed") - ErrSourceTypeMismatch = errors.Register(ModuleName, 1114, "Object source type mismatch") - ErrTooLargeObject = errors.Register(ModuleName, 1115, "Object payload size is too large") - ErrInvalidApproval = errors.Register(ModuleName, 1116, "Invalid approval of sp") - ErrChargeFailed = errors.Register(ModuleName, 1117, "charge failed error") - ErrInvalidVisibility = errors.Register(ModuleName, 1118, "Invalid type of visibility") - ErrUpdateQuotaFailed = errors.Register(ModuleName, 1119, "Update quota failed") - - ErrNoSuchPolicy = errors.Register(ModuleName, 1120, "No such Policy") - - ErrInvalidRedundancyType = errors.Register(ModuleName, 1122, "Invalid redundancy type") - ErrInvalidGlobalVirtualGroup = errors.Register(ModuleName, 1123, "invalid global virtual group") + ErrNoSuchBucket = errors.Register(ModuleName, 1100, "No such bucket") + ErrNoSuchObject = errors.Register(ModuleName, 1101, "No such object") + ErrNoSuchGroup = errors.Register(ModuleName, 1102, "No such group") + ErrNoSuchGroupMember = errors.Register(ModuleName, 1103, "No such group member") + ErrBucketAlreadyExists = errors.Register(ModuleName, 1104, "Bucket already exists") + ErrObjectAlreadyExists = errors.Register(ModuleName, 1105, "Object already exists") + ErrGroupAlreadyExists = errors.Register(ModuleName, 1106, "Group already exists") + ErrAccessDenied = errors.Register(ModuleName, 1107, "Access denied") + ErrObjectAlreadySealed = errors.Register(ModuleName, 1108, "Object already sealed") + ErrBucketNotEmpty = errors.Register(ModuleName, 1109, "Bucket is not empty") + ErrGroupMemberAlreadyExists = errors.Register(ModuleName, 1110, "Group member already exists") + ErrNoSuchStorageProvider = errors.Register(ModuleName, 1111, "No such storage provider") + ErrObjectNotCreated = errors.Register(ModuleName, 1112, "Object not created") + ErrObjectNotSealed = errors.Register(ModuleName, 1113, "Object not sealed") + ErrSourceTypeMismatch = errors.Register(ModuleName, 1114, "Object source type mismatch") + ErrTooLargeObject = errors.Register(ModuleName, 1115, "Object payload size is too large") + ErrInvalidApproval = errors.Register(ModuleName, 1116, "Invalid approval of sp") + ErrChargeFailed = errors.Register(ModuleName, 1117, "charge failed error") + ErrInvalidVisibility = errors.Register(ModuleName, 1118, "Invalid type of visibility") + ErrUpdateQuotaFailed = errors.Register(ModuleName, 1119, "Update quota failed") + ErrNoSuchPolicy = errors.Register(ModuleName, 1120, "No such Policy") + ErrInvalidRedundancyType = errors.Register(ModuleName, 1122, "Invalid redundancy type") + ErrInvalidGlobalVirtualGroup = errors.Register(ModuleName, 1123, "invalid global virtual group") + ErrRenewGroupMemberNotAllow = errors.Register(ModuleName, 1124, "Renew group member not allow") + ErrInvalidGroupMemberExpiration = errors.Register(ModuleName, 1125, "invalid group member with expiration") ErrInvalidCrossChainPackage = errors.Register(ModuleName, 3000, "invalid cross chain package") ErrAlreadyMirrored = errors.Register(ModuleName, 3001, "resource is already mirrored") diff --git a/x/storage/types/events.pb.go b/x/storage/types/events.pb.go index 9a23d9396..65f08ec77 100644 --- a/x/storage/types/events.pb.go +++ b/x/storage/types/events.pb.go @@ -8,15 +8,19 @@ import ( _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -1091,10 +1095,8 @@ type EventCreateGroup struct { GroupId Uint `protobuf:"bytes,3,opt,name=group_id,json=groupId,proto3,customtype=Uint" json:"group_id"` // source_type define the source of the group. CrossChain or Greenfield origin SourceType SourceType `protobuf:"varint,4,opt,name=source_type,json=sourceType,proto3,enum=greenfield.storage.SourceType" json:"source_type,omitempty"` - // members define the all the address of the members. - Members []string `protobuf:"bytes,5,rep,name=members,proto3" json:"members,omitempty"` // extra defines extra info for the group - Extra string `protobuf:"bytes,6,opt,name=extra,proto3" json:"extra,omitempty"` + Extra string `protobuf:"bytes,5,opt,name=extra,proto3" json:"extra,omitempty"` } func (m *EventCreateGroup) Reset() { *m = EventCreateGroup{} } @@ -1151,13 +1153,6 @@ func (m *EventCreateGroup) GetSourceType() SourceType { return SOURCE_TYPE_ORIGIN } -func (m *EventCreateGroup) GetMembers() []string { - if m != nil { - return m.Members - } - return nil -} - func (m *EventCreateGroup) GetExtra() string { if m != nil { return m.Extra @@ -1299,7 +1294,7 @@ type EventUpdateGroupMember struct { // id define an u256 id for group GroupId Uint `protobuf:"bytes,4,opt,name=group_id,json=groupId,proto3,customtype=Uint" json:"group_id"` // members_to_add defines all the members to be added to the group - MembersToAdd []string `protobuf:"bytes,5,rep,name=members_to_add,json=membersToAdd,proto3" json:"members_to_add,omitempty"` + MembersToAdd []*EventGroupMemberDetail `protobuf:"bytes,5,rep,name=members_to_add,json=membersToAdd,proto3" json:"members_to_add,omitempty"` // members_to_add defines all the members to be deleted from the group MembersToDelete []string `protobuf:"bytes,6,rep,name=members_to_delete,json=membersToDelete,proto3" json:"members_to_delete,omitempty"` } @@ -1358,7 +1353,7 @@ func (m *EventUpdateGroupMember) GetGroupName() string { return "" } -func (m *EventUpdateGroupMember) GetMembersToAdd() []string { +func (m *EventUpdateGroupMember) GetMembersToAdd() []*EventGroupMemberDetail { if m != nil { return m.MembersToAdd } @@ -1372,6 +1367,143 @@ func (m *EventUpdateGroupMember) GetMembersToDelete() []string { return nil } +type EventRenewGroupMember struct { + // operator define the account address of operator who update the group member + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // owner define the account address of group owner + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + // group_name define the name of the group + GroupName string `protobuf:"bytes,3,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + // id define an u256 id for group + GroupId Uint `protobuf:"bytes,4,opt,name=group_id,json=groupId,proto3,customtype=Uint" json:"group_id"` + // source_type define the source of the group. CrossChain or Greenfield origin + SourceType SourceType `protobuf:"varint,5,opt,name=source_type,json=sourceType,proto3,enum=greenfield.storage.SourceType" json:"source_type,omitempty"` + // members define the all the address of the members. + Members []*EventGroupMemberDetail `protobuf:"bytes,6,rep,name=members,proto3" json:"members,omitempty"` +} + +func (m *EventRenewGroupMember) Reset() { *m = EventRenewGroupMember{} } +func (m *EventRenewGroupMember) String() string { return proto.CompactTextString(m) } +func (*EventRenewGroupMember) ProtoMessage() {} +func (*EventRenewGroupMember) Descriptor() ([]byte, []int) { + return fileDescriptor_946dcba4f763ddc4, []int{16} +} +func (m *EventRenewGroupMember) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventRenewGroupMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventRenewGroupMember.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 *EventRenewGroupMember) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventRenewGroupMember.Merge(m, src) +} +func (m *EventRenewGroupMember) XXX_Size() int { + return m.Size() +} +func (m *EventRenewGroupMember) XXX_DiscardUnknown() { + xxx_messageInfo_EventRenewGroupMember.DiscardUnknown(m) +} + +var xxx_messageInfo_EventRenewGroupMember proto.InternalMessageInfo + +func (m *EventRenewGroupMember) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *EventRenewGroupMember) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *EventRenewGroupMember) GetGroupName() string { + if m != nil { + return m.GroupName + } + return "" +} + +func (m *EventRenewGroupMember) GetSourceType() SourceType { + if m != nil { + return m.SourceType + } + return SOURCE_TYPE_ORIGIN +} + +func (m *EventRenewGroupMember) GetMembers() []*EventGroupMemberDetail { + if m != nil { + return m.Members + } + return nil +} + +type EventGroupMemberDetail struct { + // member defines the account address of the group member + Member string `protobuf:"bytes,1,opt,name=member,proto3" json:"member,omitempty"` + // expiration_time defines the expiration time of the group member + ExpirationTime time.Time `protobuf:"bytes,2,opt,name=expiration_time,json=expirationTime,proto3,stdtime" json:"expiration_time"` +} + +func (m *EventGroupMemberDetail) Reset() { *m = EventGroupMemberDetail{} } +func (m *EventGroupMemberDetail) String() string { return proto.CompactTextString(m) } +func (*EventGroupMemberDetail) ProtoMessage() {} +func (*EventGroupMemberDetail) Descriptor() ([]byte, []int) { + return fileDescriptor_946dcba4f763ddc4, []int{17} +} +func (m *EventGroupMemberDetail) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventGroupMemberDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventGroupMemberDetail.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 *EventGroupMemberDetail) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventGroupMemberDetail.Merge(m, src) +} +func (m *EventGroupMemberDetail) XXX_Size() int { + return m.Size() +} +func (m *EventGroupMemberDetail) XXX_DiscardUnknown() { + xxx_messageInfo_EventGroupMemberDetail.DiscardUnknown(m) +} + +var xxx_messageInfo_EventGroupMemberDetail proto.InternalMessageInfo + +func (m *EventGroupMemberDetail) GetMember() string { + if m != nil { + return m.Member + } + return "" +} + +func (m *EventGroupMemberDetail) GetExpirationTime() time.Time { + if m != nil { + return m.ExpirationTime + } + return time.Time{} +} + // EventUpdateGroupExtra is emitted on MsgUpdateGroupExtra type EventUpdateGroupExtra struct { // operator define the account address of operator who update the group member @@ -1390,7 +1522,7 @@ func (m *EventUpdateGroupExtra) Reset() { *m = EventUpdateGroupExtra{} } func (m *EventUpdateGroupExtra) String() string { return proto.CompactTextString(m) } func (*EventUpdateGroupExtra) ProtoMessage() {} func (*EventUpdateGroupExtra) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{16} + return fileDescriptor_946dcba4f763ddc4, []int{18} } func (m *EventUpdateGroupExtra) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1463,7 +1595,7 @@ func (m *EventMirrorBucket) Reset() { *m = EventMirrorBucket{} } func (m *EventMirrorBucket) String() string { return proto.CompactTextString(m) } func (*EventMirrorBucket) ProtoMessage() {} func (*EventMirrorBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{17} + return fileDescriptor_946dcba4f763ddc4, []int{19} } func (m *EventMirrorBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1529,7 +1661,7 @@ func (m *EventMirrorBucketResult) Reset() { *m = EventMirrorBucketResult func (m *EventMirrorBucketResult) String() string { return proto.CompactTextString(m) } func (*EventMirrorBucketResult) ProtoMessage() {} func (*EventMirrorBucketResult) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{18} + return fileDescriptor_946dcba4f763ddc4, []int{20} } func (m *EventMirrorBucketResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1597,7 +1729,7 @@ func (m *EventMirrorObject) Reset() { *m = EventMirrorObject{} } func (m *EventMirrorObject) String() string { return proto.CompactTextString(m) } func (*EventMirrorObject) ProtoMessage() {} func (*EventMirrorObject) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{19} + return fileDescriptor_946dcba4f763ddc4, []int{21} } func (m *EventMirrorObject) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1672,7 +1804,7 @@ func (m *EventMirrorObjectResult) Reset() { *m = EventMirrorObjectResult func (m *EventMirrorObjectResult) String() string { return proto.CompactTextString(m) } func (*EventMirrorObjectResult) ProtoMessage() {} func (*EventMirrorObjectResult) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{20} + return fileDescriptor_946dcba4f763ddc4, []int{22} } func (m *EventMirrorObjectResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1745,7 +1877,7 @@ func (m *EventMirrorGroup) Reset() { *m = EventMirrorGroup{} } func (m *EventMirrorGroup) String() string { return proto.CompactTextString(m) } func (*EventMirrorGroup) ProtoMessage() {} func (*EventMirrorGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{21} + return fileDescriptor_946dcba4f763ddc4, []int{23} } func (m *EventMirrorGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1811,7 +1943,7 @@ func (m *EventMirrorGroupResult) Reset() { *m = EventMirrorGroupResult{} func (m *EventMirrorGroupResult) String() string { return proto.CompactTextString(m) } func (*EventMirrorGroupResult) ProtoMessage() {} func (*EventMirrorGroupResult) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{22} + return fileDescriptor_946dcba4f763ddc4, []int{24} } func (m *EventMirrorGroupResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1871,7 +2003,7 @@ func (m *EventStalePolicyCleanup) Reset() { *m = EventStalePolicyCleanup func (m *EventStalePolicyCleanup) String() string { return proto.CompactTextString(m) } func (*EventStalePolicyCleanup) ProtoMessage() {} func (*EventStalePolicyCleanup) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{23} + return fileDescriptor_946dcba4f763ddc4, []int{25} } func (m *EventStalePolicyCleanup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1930,7 +2062,7 @@ func (m *EventMigrationBucket) Reset() { *m = EventMigrationBucket{} } func (m *EventMigrationBucket) String() string { return proto.CompactTextString(m) } func (*EventMigrationBucket) ProtoMessage() {} func (*EventMigrationBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{24} + return fileDescriptor_946dcba4f763ddc4, []int{26} } func (m *EventMigrationBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1994,7 +2126,7 @@ func (m *EventCancelMigrationBucket) Reset() { *m = EventCancelMigration func (m *EventCancelMigrationBucket) String() string { return proto.CompactTextString(m) } func (*EventCancelMigrationBucket) ProtoMessage() {} func (*EventCancelMigrationBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{25} + return fileDescriptor_946dcba4f763ddc4, []int{27} } func (m *EventCancelMigrationBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2055,7 +2187,7 @@ func (m *EventCompleteMigrationBucket) Reset() { *m = EventCompleteMigra func (m *EventCompleteMigrationBucket) String() string { return proto.CompactTextString(m) } func (*EventCompleteMigrationBucket) ProtoMessage() {} func (*EventCompleteMigrationBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_946dcba4f763ddc4, []int{26} + return fileDescriptor_946dcba4f763ddc4, []int{28} } func (m *EventCompleteMigrationBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2129,6 +2261,8 @@ func init() { proto.RegisterType((*EventDeleteGroup)(nil), "greenfield.storage.EventDeleteGroup") proto.RegisterType((*EventLeaveGroup)(nil), "greenfield.storage.EventLeaveGroup") proto.RegisterType((*EventUpdateGroupMember)(nil), "greenfield.storage.EventUpdateGroupMember") + proto.RegisterType((*EventRenewGroupMember)(nil), "greenfield.storage.EventRenewGroupMember") + proto.RegisterType((*EventGroupMemberDetail)(nil), "greenfield.storage.EventGroupMemberDetail") proto.RegisterType((*EventUpdateGroupExtra)(nil), "greenfield.storage.EventUpdateGroupExtra") proto.RegisterType((*EventMirrorBucket)(nil), "greenfield.storage.EventMirrorBucket") proto.RegisterType((*EventMirrorBucketResult)(nil), "greenfield.storage.EventMirrorBucketResult") @@ -2145,103 +2279,109 @@ func init() { func init() { proto.RegisterFile("greenfield/storage/events.proto", fileDescriptor_946dcba4f763ddc4) } var fileDescriptor_946dcba4f763ddc4 = []byte{ - // 1525 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0xbf, 0x6f, 0xdb, 0x46, - 0x1b, 0x36, 0x25, 0x4a, 0xb6, 0x4f, 0x96, 0x14, 0xf3, 0xf3, 0x97, 0xe8, 0x73, 0xf2, 0xc9, 0x0a, - 0x87, 0xd4, 0x01, 0x1a, 0x1b, 0x48, 0xda, 0x22, 0x53, 0x03, 0xdb, 0x49, 0x0b, 0xa1, 0xcd, 0x8f, - 0x52, 0x49, 0x86, 0x2e, 0xc4, 0x89, 0x3c, 0xcb, 0x6c, 0x48, 0x1e, 0x7b, 0x77, 0x72, 0xa3, 0xfc, - 0x03, 0x9d, 0x0a, 0x74, 0x6c, 0x97, 0x4e, 0x1d, 0x0a, 0x14, 0x05, 0x3a, 0x64, 0xed, 0x9e, 0x6e, - 0x69, 0xba, 0xf4, 0x07, 0x10, 0x14, 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 0x72, 0x65, 0x72, 0xc3, 0x24, 0x36, 0x80, 0xb0, 0xef, 0x35, 0x80, 0x1d, 0xfd, 0xd6, - 0x1f, 0x29, 0x60, 0x49, 0xb2, 0xd4, 0x23, 0x90, 0x39, 0xd8, 0x7f, 0x89, 0x65, 0x32, 0xd7, 0x85, - 0xf3, 0x59, 0xb0, 0x18, 0x1e, 0x3e, 0x27, 0xdd, 0xba, 0xd4, 0x6c, 0xca, 0x6e, 0x8c, 0x2e, 0x5e, - 0xf4, 0xef, 0x14, 0xb0, 0x1c, 0xbb, 0x30, 0x3a, 0xea, 0xa1, 0xe9, 0x5f, 0x15, 0xc0, 0x29, 0x79, - 0x05, 0xe1, 0x05, 0xe1, 0xd2, 0x1c, 0xf9, 0xc5, 0xc8, 0xbe, 0x62, 0x57, 0x33, 0xbf, 0x20, 0x9d, - 0x05, 0x8b, 0x94, 0x58, 0x63, 0x0b, 0x2a, 0x0a, 0x51, 0x8d, 0x12, 0x2b, 0xb6, 0xa0, 0x9b, 0xed, - 0x07, 0x4f, 0x9a, 0xca, 0xc3, 0x27, 0x4d, 0xe5, 0x8f, 0x27, 0x4d, 0xe5, 0xf3, 0xa7, 0xcd, 0x99, - 0x87, 0x4f, 0x9b, 0x33, 0xbf, 0x3c, 0x6d, 0xce, 0x7c, 0xb8, 0xde, 0x73, 0xd8, 0x4e, 0xbf, 0xbb, - 0x66, 0x61, 0x6f, 0xbd, 0xeb, 0x77, 0xcf, 0xf1, 0x1c, 0x5b, 0x8f, 0x7d, 0xd7, 0xbc, 0x9b, 0xfc, - 0xb2, 0xd9, 0x2d, 0xf3, 0x4f, 0x9b, 0x17, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x30, 0xf3, 0x5c, - 0x69, 0x83, 0x1d, 0x00, 0x00, + // 1631 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0xcd, 0x73, 0xdb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0x1a, 0x50, 0xcd, 0x6d, 0x48, 0xba, + 0xc8, 0x32, 0x08, 0x82, 0x96, 0xf1, 0x51, 0x0f, 0x33, 0x58, 0x9b, 0x6e, 0x28, 0xcb, 0x39, 0xfd, + 0x98, 0xfc, 0x47, 0x47, 0xd0, 0x7a, 0x3f, 0x68, 0x57, 0x57, 0x41, 0xd5, 0x87, 0x7d, 0x17, 0x79, + 0xcc, 0x80, 0x82, 0xca, 0x5a, 0x71, 0x02, 0xc9, 0x15, 0xd9, 0x41, 0xb6, 0xaa, 0x1a, 0x28, 0xfb, + 0xc4, 0x76, 0x21, 0xe9, 0x1b, 0xd4, 0x0f, 0xf2, 0x9d, 0x69, 0x28, 0xcb, 0x65, 0xbd, 0x24, 0x1b, + 0x37, 0xfd, 0xb6, 0xa5, 0xae, 0x81, 0x7a, 0xd7, 0xc1, 0x1d, 0xe8, 0x18, 0x3b, 0x36, 0x61, 0x3d, + 0xe8, 0x18, 0x5d, 0x82, 0x7b, 0xbe, 0xb1, 0x05, 0x5d, 0xdb, 0xe9, 0x07, 0x9d, 0x00, 0xef, 0xb4, + 0x28, 0x50, 0x37, 0x04, 0xe8, 0x9d, 0x00, 0xf3, 0x36, 0x87, 0xb4, 0x2d, 0xf5, 0x3c, 0x28, 0x50, + 0x06, 0x59, 0x8f, 0xd6, 0x4a, 0x9c, 0x94, 0xc6, 0x38, 0x52, 0x84, 0x62, 0x36, 0x39, 0x4e, 0x97, + 0x78, 0xed, 0xd3, 0x8c, 0x54, 0xd5, 0x06, 0x72, 0x50, 0xa8, 0xaa, 0x37, 0x40, 0x11, 0xfb, 0x88, + 0x40, 0x86, 0x27, 0x0b, 0x2b, 0x44, 0x0e, 0xb5, 0x98, 0xd9, 0x97, 0x16, 0xb3, 0x09, 0x2d, 0xc6, + 0xa4, 0x92, 0x4b, 0x23, 0x95, 0xc9, 0xa4, 0xe6, 0x27, 0x91, 0xaa, 0x7d, 0x9c, 0x05, 0xff, 0xe5, + 0xd4, 0x5c, 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62, 0xeb, 0x0f, 0xce, 0x33, 0x3a, 0xb0, 0xc2, 0xdf, 0xda, 0x43, 0x05, 0xcc, 0x4b, + 0x96, 0xba, 0x62, 0x9f, 0x78, 0x81, 0x36, 0x99, 0xea, 0x43, 0xc2, 0x19, 0x30, 0x67, 0x51, 0x66, + 0x8c, 0xbb, 0x4d, 0xab, 0x58, 0x94, 0x5d, 0x1d, 0x5e, 0xa8, 0x69, 0x5f, 0x29, 0x60, 0x31, 0x72, + 0x11, 0x78, 0xd4, 0x53, 0xd3, 0x3e, 0xcf, 0x80, 0x93, 0xf2, 0x6a, 0xc9, 0xf5, 0x83, 0xa9, 0x39, + 0xf2, 0x93, 0x31, 0xf9, 0xd3, 0x49, 0x6e, 0xe2, 0x97, 0xc1, 0x33, 0x60, 0x8e, 0x12, 0x73, 0x64, + 0x42, 0x85, 0x11, 0x55, 0x28, 0x31, 0x23, 0x13, 0xba, 0xd6, 0xbe, 0xff, 0xb8, 0xae, 0x3c, 0x78, + 0x5c, 0x57, 0x7e, 0x7d, 0x5c, 0x57, 0xee, 0x3e, 0xa9, 0x4f, 0x3d, 0x78, 0x52, 0x9f, 0xfa, 0xe1, + 0x49, 0x7d, 0xea, 0x83, 0x56, 0xd7, 0x66, 0xdb, 0xbd, 0x4e, 0xd3, 0xc4, 0x6e, 0xab, 0xe3, 0x75, + 0xce, 0xf2, 0x35, 0xd6, 0x8a, 0x7c, 0xaf, 0xbe, 0x1d, 0xff, 0x62, 0xdd, 0x29, 0xf0, 0x7a, 0xe9, + 0xdc, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x83, 0xef, 0x07, 0x7c, 0x1f, 0x00, 0x00, } func (m *EventCreateBucket) Marshal() (dAtA []byte, err error) { @@ -3092,16 +3232,7 @@ func (m *EventCreateGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Extra) i = encodeVarintEvents(dAtA, i, uint64(len(m.Extra))) i-- - dAtA[i] = 0x32 - } - if len(m.Members) > 0 { - for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Members[iNdEx]) - copy(dAtA[i:], m.Members[iNdEx]) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Members[iNdEx]))) - i-- - dAtA[i] = 0x2a - } + dAtA[i] = 0x2a } if m.SourceType != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.SourceType)) @@ -3267,9 +3398,14 @@ func (m *EventUpdateGroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) } if len(m.MembersToAdd) > 0 { for iNdEx := len(m.MembersToAdd) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.MembersToAdd[iNdEx]) - copy(dAtA[i:], m.MembersToAdd[iNdEx]) - i = encodeVarintEvents(dAtA, i, uint64(len(m.MembersToAdd[iNdEx]))) + { + size, err := m.MembersToAdd[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x2a } @@ -3308,6 +3444,117 @@ func (m *EventUpdateGroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *EventRenewGroupMember) 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 *EventRenewGroupMember) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventRenewGroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Members[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.SourceType != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.SourceType)) + i-- + dAtA[i] = 0x28 + } + { + size := m.GroupId.Size() + i -= size + if _, err := m.GroupId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintEvents(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x1a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventGroupMemberDetail) 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 *EventGroupMemberDetail) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventGroupMemberDetail) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintEvents(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x12 + if len(m.Member) > 0 { + i -= len(m.Member) + copy(dAtA[i:], m.Member) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Member))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *EventUpdateGroupExtra) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -4287,12 +4534,6 @@ func (m *EventCreateGroup) Size() (n int) { if m.SourceType != 0 { n += 1 + sovEvents(uint64(m.SourceType)) } - if len(m.Members) > 0 { - for _, s := range m.Members { - l = len(s) - n += 1 + l + sovEvents(uint64(l)) - } - } l = len(m.Extra) if l > 0 { n += 1 + l + sovEvents(uint64(l)) @@ -4363,8 +4604,8 @@ func (m *EventUpdateGroupMember) Size() (n int) { l = m.GroupId.Size() n += 1 + l + sovEvents(uint64(l)) if len(m.MembersToAdd) > 0 { - for _, s := range m.MembersToAdd { - l = len(s) + for _, e := range m.MembersToAdd { + l = e.Size() n += 1 + l + sovEvents(uint64(l)) } } @@ -4377,7 +4618,7 @@ func (m *EventUpdateGroupMember) Size() (n int) { return n } -func (m *EventUpdateGroupExtra) Size() (n int) { +func (m *EventRenewGroupMember) Size() (n int) { if m == nil { return 0 } @@ -4397,49 +4638,96 @@ func (m *EventUpdateGroupExtra) Size() (n int) { } l = m.GroupId.Size() n += 1 + l + sovEvents(uint64(l)) - l = len(m.Extra) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + if m.SourceType != 0 { + n += 1 + sovEvents(uint64(m.SourceType)) + } + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovEvents(uint64(l)) + } } return n } -func (m *EventMirrorBucket) Size() (n int) { +func (m *EventGroupMemberDetail) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Operator) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - l = len(m.BucketName) + l = len(m.Member) if l > 0 { n += 1 + l + sovEvents(uint64(l)) } - l = m.BucketId.Size() + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationTime) n += 1 + l + sovEvents(uint64(l)) - if m.DestChainId != 0 { - n += 1 + sovEvents(uint64(m.DestChainId)) - } return n } -func (m *EventMirrorBucketResult) Size() (n int) { +func (m *EventUpdateGroupExtra) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Status != 0 { - n += 1 + sovEvents(uint64(m.Status)) + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) } - l = len(m.BucketName) + l = len(m.Owner) if l > 0 { n += 1 + l + sovEvents(uint64(l)) } - l = m.BucketId.Size() + l = len(m.GroupName) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = m.GroupId.Size() + n += 1 + l + sovEvents(uint64(l)) + l = len(m.Extra) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventMirrorBucket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = m.BucketId.Size() + n += 1 + l + sovEvents(uint64(l)) + if m.DestChainId != 0 { + n += 1 + sovEvents(uint64(m.DestChainId)) + } + return n +} + +func (m *EventMirrorBucketResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovEvents(uint64(m.Status)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = m.BucketId.Size() n += 1 + l + sovEvents(uint64(l)) if m.DestChainId != 0 { n += 1 + sovEvents(uint64(m.DestChainId)) @@ -7595,7 +7883,7 @@ func (m *EventCreateGroup) Unmarshal(dAtA []byte) error { } case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Extra", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7623,11 +7911,61 @@ func (m *EventCreateGroup) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Members = append(m.Members, string(dAtA[iNdEx:postIndex])) + m.Extra = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventDeleteGroup) 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 ErrIntOverflowEvents + } + 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: EventDeleteGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventDeleteGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Extra", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7655,7 +7993,73 @@ func (m *EventCreateGroup) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Extra = string(dAtA[iNdEx:postIndex]) + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GroupId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -7678,7 +8082,7 @@ func (m *EventCreateGroup) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventDeleteGroup) Unmarshal(dAtA []byte) error { +func (m *EventLeaveGroup) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7701,12 +8105,44 @@ func (m *EventDeleteGroup) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventDeleteGroup: wiretype end group for non-group") + return fmt.Errorf("proto: EventLeaveGroup: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventDeleteGroup: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventLeaveGroup: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MemberAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MemberAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) @@ -7826,7 +8262,7 @@ func (m *EventDeleteGroup) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventLeaveGroup) Unmarshal(dAtA []byte) error { +func (m *EventUpdateGroupMember) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7849,15 +8285,15 @@ func (m *EventLeaveGroup) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventLeaveGroup: wiretype end group for non-group") + return fmt.Errorf("proto: EventUpdateGroupMember: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventLeaveGroup: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventUpdateGroupMember: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MemberAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Operator", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7885,7 +8321,7 @@ func (m *EventLeaveGroup) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MemberAddress = string(dAtA[iNdEx:postIndex]) + m.Operator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -7985,6 +8421,72 @@ func (m *EventLeaveGroup) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MembersToAdd", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MembersToAdd = append(m.MembersToAdd, &EventGroupMemberDetail{}) + if err := m.MembersToAdd[len(m.MembersToAdd)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MembersToDelete", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MembersToDelete = append(m.MembersToDelete, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -8006,7 +8508,7 @@ func (m *EventLeaveGroup) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventUpdateGroupMember) Unmarshal(dAtA []byte) error { +func (m *EventRenewGroupMember) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8029,10 +8531,10 @@ func (m *EventUpdateGroupMember) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventUpdateGroupMember: wiretype end group for non-group") + return fmt.Errorf("proto: EventRenewGroupMember: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventUpdateGroupMember: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventRenewGroupMember: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8166,10 +8668,29 @@ func (m *EventUpdateGroupMember) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceType", wireType) + } + m.SourceType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SourceType |= SourceType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MembersToAdd", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -8179,27 +8700,79 @@ func (m *EventUpdateGroupMember) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - m.MembersToAdd = append(m.MembersToAdd, string(dAtA[iNdEx:postIndex])) + m.Members = append(m.Members, &EventGroupMemberDetail{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 6: + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventGroupMemberDetail) 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 ErrIntOverflowEvents + } + 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: EventGroupMemberDetail: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventGroupMemberDetail: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MembersToDelete", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -8227,7 +8800,40 @@ func (m *EventUpdateGroupMember) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MembersToDelete = append(m.MembersToDelete, string(dAtA[iNdEx:postIndex])) + m.Member = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpirationTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.ExpirationTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 1ff74670e..c9248665a 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( "math/big" + time "time" "cosmossdk.io/math" sdkmath "cosmossdk.io/math" @@ -54,7 +55,8 @@ type PermissionKeeper interface { resourceID math.Uint) (math.Uint, error) VerifyPolicy(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType, operator sdk.AccAddress, action permtypes.ActionType, opts *permtypes.VerifyOptions) permtypes.Effect - AddGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress) error + AddGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress, expiration time.Time) error + UpdateGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress, memberID math.Uint, expiration time.Time) RemoveGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress) error GetPolicyByID(ctx sdk.Context, policyID math.Uint) (*permtypes.Policy, bool) GetPolicyForAccount(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType, addr sdk.AccAddress) (policy *permtypes.Policy, isFound bool) @@ -105,6 +107,7 @@ type StorageKeeper interface { groupName string, opts CreateGroupOptions) (sdkmath.Uint, error) SetGroupInfo(ctx sdk.Context, groupInfo *GroupInfo) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *GroupInfo, opts UpdateGroupMemberOptions) error + RenewGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *GroupInfo, opts RenewGroupMemberOptions) error GetObjectInfoById(ctx sdk.Context, objectId sdkmath.Uint) (*ObjectInfo, bool) SetObjectInfo(ctx sdk.Context, objectInfo *ObjectInfo) DeleteObject( diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index e5a20df47..5ea50af65 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: expected_keepers.go +// Source: x/storage/types/expected_keepers.go // Package types is a generated GoMock package. package types @@ -7,18 +7,18 @@ package types import ( big "math/big" reflect "reflect" + time "time" math "cosmossdk.io/math" - log "github.com/cometbft/cometbft/libs/log" - types3 "github.com/cosmos/cosmos-sdk/types" - types4 "github.com/cosmos/cosmos-sdk/x/auth/types" - gomock "github.com/golang/mock/gomock" - resource "github.com/bnb-chain/greenfield/types/resource" types "github.com/bnb-chain/greenfield/x/payment/types" types0 "github.com/bnb-chain/greenfield/x/permission/types" types1 "github.com/bnb-chain/greenfield/x/sp/types" types2 "github.com/bnb-chain/greenfield/x/virtualgroup/types" + log "github.com/cometbft/cometbft/libs/log" + types3 "github.com/cosmos/cosmos-sdk/types" + types4 "github.com/cosmos/cosmos-sdk/x/auth/types" + gomock "github.com/golang/mock/gomock" ) // MockAccountKeeper is a mock of AccountKeeper interface. @@ -368,17 +368,17 @@ func (m *MockPermissionKeeper) EXPECT() *MockPermissionKeeperMockRecorder { } // AddGroupMember mocks base method. -func (m *MockPermissionKeeper) AddGroupMember(ctx types3.Context, groupID math.Uint, member types3.AccAddress) error { +func (m *MockPermissionKeeper) AddGroupMember(ctx types3.Context, groupID math.Uint, member types3.AccAddress, expiration time.Time) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddGroupMember", ctx, groupID, member) + ret := m.ctrl.Call(m, "AddGroupMember", ctx, groupID, member, expiration) ret0, _ := ret[0].(error) return ret0 } // AddGroupMember indicates an expected call of AddGroupMember. -func (mr *MockPermissionKeeperMockRecorder) AddGroupMember(ctx, groupID, member interface{}) *gomock.Call { +func (mr *MockPermissionKeeperMockRecorder) AddGroupMember(ctx, groupID, member, expiration interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).AddGroupMember), ctx, groupID, member) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).AddGroupMember), ctx, groupID, member, expiration) } // DeletePolicy mocks base method. @@ -587,6 +587,18 @@ func (mr *MockPermissionKeeperMockRecorder) RemoveGroupMember(ctx, groupID, memb return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).RemoveGroupMember), ctx, groupID, member) } +// UpdateGroupMember mocks base method. +func (m *MockPermissionKeeper) UpdateGroupMember(ctx types3.Context, groupID math.Uint, member types3.AccAddress, memberID math.Uint, expiration time.Time) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "UpdateGroupMember", ctx, groupID, member, memberID, expiration) +} + +// UpdateGroupMember indicates an expected call of UpdateGroupMember. +func (mr *MockPermissionKeeperMockRecorder) UpdateGroupMember(ctx, groupID, member, memberID, expiration interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).UpdateGroupMember), ctx, groupID, member, memberID, expiration) +} + // VerifyPolicy mocks base method. func (m *MockPermissionKeeper) VerifyPolicy(ctx types3.Context, resourceID math.Uint, resourceType resource.ResourceType, operator types3.AccAddress, action types0.ActionType, opts *types0.VerifyOptions) types0.Effect { m.ctrl.T.Helper() @@ -946,6 +958,20 @@ func (mr *MockStorageKeeperMockRecorder) Logger(ctx interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Logger", reflect.TypeOf((*MockStorageKeeper)(nil).Logger), ctx) } +// RenewGroupMember mocks base method. +func (m *MockStorageKeeper) RenewGroupMember(ctx types3.Context, operator types3.AccAddress, groupInfo *GroupInfo, opts RenewGroupMemberOptions) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RenewGroupMember", ctx, operator, groupInfo, opts) + ret0, _ := ret[0].(error) + return ret0 +} + +// RenewGroupMember indicates an expected call of RenewGroupMember. +func (mr *MockStorageKeeperMockRecorder) RenewGroupMember(ctx, operator, groupInfo, opts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenewGroupMember", reflect.TypeOf((*MockStorageKeeper)(nil).RenewGroupMember), ctx, operator, groupInfo, opts) +} + // SetBucketInfo mocks base method. func (m *MockStorageKeeper) SetBucketInfo(ctx types3.Context, bucketInfo *BucketInfo) { m.ctrl.T.Helper() diff --git a/x/storage/types/message.go b/x/storage/types/message.go index b55a6e44a..ba2675dd4 100644 --- a/x/storage/types/message.go +++ b/x/storage/types/message.go @@ -44,6 +44,7 @@ const ( TypeMsgUpdateGroupMember = "update_group_member" TypeMsgUpdateGroupExtra = "update_group_extra" TypeMsgMirrorGroup = "mirror_group" + TypeMsgRenewGroupMember = "renew_group_member" MaxGroupExtraInfoLimit = 512 @@ -91,6 +92,10 @@ var ( // For params _ sdk.Msg = &MsgUpdateParams{} + + // The max timestamp in underlying package `google.golang.org/protobuf/types/known/timestamppb` is 9999-12-31T23:59:59Z + // https://pkg.go.dev/google.golang.org/protobuf/types/known/timestamppb#Timestamp + MaxTimeStamp, _ = time.Parse(time.RFC3339, "9999-12-31T23:59:59Z") ) // NewMsgCreateBucket creates a new MsgCreateBucket instance. @@ -828,15 +833,10 @@ func (msg *MsgUpdateObjectInfo) ValidateBasic() error { return nil } -func NewMsgCreateGroup(creator sdk.AccAddress, groupName string, membersAcc []sdk.AccAddress, extra string) *MsgCreateGroup { - var members []string - for _, member := range membersAcc { - members = append(members, member.String()) - } +func NewMsgCreateGroup(creator sdk.AccAddress, groupName string, extra string) *MsgCreateGroup { return &MsgCreateGroup{ Creator: creator.String(), GroupName: groupName, - Members: members, Extra: extra, } } @@ -877,9 +877,7 @@ func (msg *MsgCreateGroup) ValidateBasic() error { if err != nil { return gnfderrors.ErrInvalidGroupName.Wrapf("invalid groupName (%s)", err) } - if len(msg.Members) > MaxGroupMemberLimitOnce { - return gnfderrors.ErrInvalidParameter.Wrapf("Once update group member limit exceeded") - } + if len(msg.Extra) > MaxGroupExtraInfoLimit { return errors.Wrapf(gnfderrors.ErrInvalidParameter, "extra is too long with length %d, limit to %d", len(msg.Extra), MaxGroupExtraInfoLimit) } @@ -980,12 +978,9 @@ func (msg *MsgLeaveGroup) ValidateBasic() error { } func NewMsgUpdateGroupMember( - operator sdk.AccAddress, groupOwner sdk.AccAddress, groupName string, membersToAdd []sdk.AccAddress, + operator sdk.AccAddress, groupOwner sdk.AccAddress, groupName string, membersToAdd []*MsgGroupMember, membersToDelete []sdk.AccAddress) *MsgUpdateGroupMember { - var membersAddrToAdd, membersAddrToDelete []string - for _, member := range membersToAdd { - membersAddrToAdd = append(membersAddrToAdd, member.String()) - } + var membersAddrToDelete []string for _, member := range membersToDelete { membersAddrToDelete = append(membersAddrToDelete, member.String()) } @@ -993,7 +988,7 @@ func NewMsgUpdateGroupMember( Operator: operator.String(), GroupOwner: groupOwner.String(), GroupName: groupName, - MembersToAdd: membersAddrToAdd, + MembersToAdd: membersToAdd, MembersToDelete: membersAddrToDelete, } } @@ -1044,10 +1039,14 @@ func (msg *MsgUpdateGroupMember) ValidateBasic() error { return gnfderrors.ErrInvalidParameter.Wrapf("Once update group member limit exceeded") } for _, member := range msg.MembersToAdd { - _, err = sdk.AccAddressFromHexUnsafe(member) + _, err = sdk.AccAddressFromHexUnsafe(member.Member) if err != nil { return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid member address (%s)", err) } + if member.ExpirationTime.UTC().After(MaxTimeStamp) { + return gnfderrors.ErrInvalidParameter.Wrapf("Expiration time is bigger than max timestamp [%s]", MaxTimeStamp) + } + } for _, member := range msg.MembersToDelete { _, err = sdk.AccAddressFromHexUnsafe(member) @@ -1425,3 +1424,72 @@ func (m *MsgUpdateParams) ValidateBasic() error { return nil } + +func NewMsgRenewGroupMember( + operator sdk.AccAddress, groupOwner sdk.AccAddress, groupName string, members []*MsgGroupMember) *MsgRenewGroupMember { + + return &MsgRenewGroupMember{ + Operator: operator.String(), + GroupOwner: groupOwner.String(), + GroupName: groupName, + Members: members, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgRenewGroupMember) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgRenewGroupMember) Type() string { + return TypeMsgRenewGroupMember +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgRenewGroupMember) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgRenewGroupMember) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgRenewGroupMember) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid operator address (%s)", err) + } + + _, err = sdk.AccAddressFromHexUnsafe(msg.GroupOwner) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid group owner address (%s)", err) + } + + err = s3util.CheckValidGroupName(msg.GroupName) + if err != nil { + return err + } + + if len(msg.Members) > MaxGroupMemberLimitOnce { + return gnfderrors.ErrInvalidParameter.Wrapf("Once renew group member limit exceeded") + } + for _, member := range msg.Members { + _, err = sdk.AccAddressFromHexUnsafe(member.Member) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid member address (%s)", err) + } + if member.ExpirationTime.UTC().After(MaxTimeStamp) { + return gnfderrors.ErrInvalidParameter.Wrapf("Expiration time is bigger than max timestamp [%s]", MaxTimeStamp) + } + } + + return nil +} diff --git a/x/storage/types/message_test.go b/x/storage/types/message_test.go index f3343a3bf..89c21de2b 100644 --- a/x/storage/types/message_test.go +++ b/x/storage/types/message_test.go @@ -169,7 +169,6 @@ func TestMsgCreateGroup_ValidateBasic(t *testing.T) { msg: MsgCreateGroup{ Creator: sample.RandAccAddressHex(), GroupName: testGroupName, - Members: []string{sample.RandAccAddressHex(), sample.RandAccAddressHex()}, }, }, } @@ -247,10 +246,18 @@ func TestMsgUpdateGroupMember_ValidateBasic(t *testing.T) { { name: "normal", msg: MsgUpdateGroupMember{ - Operator: sample.RandAccAddressHex(), - GroupOwner: sample.RandAccAddressHex(), - GroupName: testGroupName, - MembersToAdd: []string{sample.RandAccAddressHex(), sample.RandAccAddressHex()}, + Operator: sample.RandAccAddressHex(), + GroupOwner: sample.RandAccAddressHex(), + GroupName: testGroupName, + MembersToAdd: []*MsgGroupMember{{ + Member: sample.RandAccAddressHex(), + ExpirationTime: MaxTimeStamp, + }, + { + Member: sample.RandAccAddressHex(), + ExpirationTime: MaxTimeStamp, + }, + }, MembersToDelete: []string{sample.RandAccAddressHex(), sample.RandAccAddressHex()}, }, }, @@ -428,3 +435,39 @@ func TestMsgMirrorGroup_ValidateBasic(t *testing.T) { }) } } + +func TestMsgRenewGroupMember_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgRenewGroupMember + err error + }{ + { + name: "normal", + msg: MsgRenewGroupMember{ + Operator: sample.RandAccAddressHex(), + GroupOwner: sample.RandAccAddressHex(), + GroupName: testGroupName, + Members: []*MsgGroupMember{{ + Member: sample.RandAccAddressHex(), + ExpirationTime: MaxTimeStamp, + }, + { + Member: sample.RandAccAddressHex(), + ExpirationTime: MaxTimeStamp, + }, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/storage/types/options.go b/x/storage/types/options.go index dc36988e8..8364e282c 100644 --- a/x/storage/types/options.go +++ b/x/storage/types/options.go @@ -1,6 +1,8 @@ package types import ( + time "time" + "github.com/bnb-chain/greenfield/types/common" ) @@ -49,7 +51,6 @@ type CopyObjectOptions struct { ApprovalMsgBytes []byte } type CreateGroupOptions struct { - Members []string SourceType SourceType Extra string } @@ -58,9 +59,16 @@ type LeaveGroupOptions struct { } type UpdateGroupMemberOptions struct { - SourceType SourceType - MembersToAdd []string - MembersToDelete []string + SourceType SourceType + MembersToAdd []string + MembersExpirationToAdd []time.Time + MembersToDelete []string +} + +type RenewGroupMemberOptions struct { + SourceType SourceType + Members []string + MembersExpiration []time.Time } type DeleteGroupOptions struct { diff --git a/x/storage/types/tx.pb.go b/x/storage/types/tx.pb.go index b5a626cbb..d2ba802b0 100644 --- a/x/storage/types/tx.pb.go +++ b/x/storage/types/tx.pb.go @@ -1068,10 +1068,8 @@ type MsgCreateGroup struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` // group_name defines the name of the group. it's not globally unique. GroupName string `protobuf:"bytes,2,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` - // member_request defines a list of member which to be add or remove - Members []string `protobuf:"bytes,3,rep,name=members,proto3" json:"members,omitempty"` // extra defines extra info for the group - Extra string `protobuf:"bytes,4,opt,name=extra,proto3" json:"extra,omitempty"` + Extra string `protobuf:"bytes,3,opt,name=extra,proto3" json:"extra,omitempty"` } func (m *MsgCreateGroup) Reset() { *m = MsgCreateGroup{} } @@ -1121,13 +1119,6 @@ func (m *MsgCreateGroup) GetGroupName() string { return "" } -func (m *MsgCreateGroup) GetMembers() []string { - if m != nil { - return m.Members - } - return nil -} - func (m *MsgCreateGroup) GetExtra() string { if m != nil { return m.Extra @@ -1270,7 +1261,7 @@ type MsgUpdateGroupMember struct { // group_name defines the name of the group which to be updated GroupName string `protobuf:"bytes,3,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` // members_to_add defines a list of members account address which will be add to the group - MembersToAdd []string `protobuf:"bytes,4,rep,name=members_to_add,json=membersToAdd,proto3" json:"members_to_add,omitempty"` + MembersToAdd []*MsgGroupMember `protobuf:"bytes,4,rep,name=members_to_add,json=membersToAdd,proto3" json:"members_to_add,omitempty"` // members_to_delete defines a list of members account address which will be remove from the group MembersToDelete []string `protobuf:"bytes,5,rep,name=members_to_delete,json=membersToDelete,proto3" json:"members_to_delete,omitempty"` } @@ -1329,7 +1320,7 @@ func (m *MsgUpdateGroupMember) GetGroupName() string { return "" } -func (m *MsgUpdateGroupMember) GetMembersToAdd() []string { +func (m *MsgUpdateGroupMember) GetMembersToAdd() []*MsgGroupMember { if m != nil { return m.MembersToAdd } @@ -1379,6 +1370,168 @@ func (m *MsgUpdateGroupMemberResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateGroupMemberResponse proto.InternalMessageInfo +type MsgRenewGroupMember struct { + // operator defines the account address of the operator who has the UpdateGroupMember permission of the group. + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // group_owner defines the account address of the group owner + GroupOwner string `protobuf:"bytes,2,opt,name=group_owner,json=groupOwner,proto3" json:"group_owner,omitempty"` + // group_name defines the name of the group which to be updated + GroupName string `protobuf:"bytes,3,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + // members defines a list of members which will be renew to the group + Members []*MsgGroupMember `protobuf:"bytes,4,rep,name=members,proto3" json:"members,omitempty"` +} + +func (m *MsgRenewGroupMember) Reset() { *m = MsgRenewGroupMember{} } +func (m *MsgRenewGroupMember) String() string { return proto.CompactTextString(m) } +func (*MsgRenewGroupMember) ProtoMessage() {} +func (*MsgRenewGroupMember) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{24} +} +func (m *MsgRenewGroupMember) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRenewGroupMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRenewGroupMember.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 *MsgRenewGroupMember) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRenewGroupMember.Merge(m, src) +} +func (m *MsgRenewGroupMember) XXX_Size() int { + return m.Size() +} +func (m *MsgRenewGroupMember) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRenewGroupMember.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRenewGroupMember proto.InternalMessageInfo + +func (m *MsgRenewGroupMember) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgRenewGroupMember) GetGroupOwner() string { + if m != nil { + return m.GroupOwner + } + return "" +} + +func (m *MsgRenewGroupMember) GetGroupName() string { + if m != nil { + return m.GroupName + } + return "" +} + +func (m *MsgRenewGroupMember) GetMembers() []*MsgGroupMember { + if m != nil { + return m.Members + } + return nil +} + +type MsgRenewGroupMemberResponse struct { +} + +func (m *MsgRenewGroupMemberResponse) Reset() { *m = MsgRenewGroupMemberResponse{} } +func (m *MsgRenewGroupMemberResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRenewGroupMemberResponse) ProtoMessage() {} +func (*MsgRenewGroupMemberResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{25} +} +func (m *MsgRenewGroupMemberResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRenewGroupMemberResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRenewGroupMemberResponse.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 *MsgRenewGroupMemberResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRenewGroupMemberResponse.Merge(m, src) +} +func (m *MsgRenewGroupMemberResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRenewGroupMemberResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRenewGroupMemberResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRenewGroupMemberResponse proto.InternalMessageInfo + +type MsgGroupMember struct { + // member defines the account address of the group member + Member string `protobuf:"bytes,1,opt,name=member,proto3" json:"member,omitempty"` + // expiration_time defines the expiration time of the group member + ExpirationTime time.Time `protobuf:"bytes,2,opt,name=expiration_time,json=expirationTime,proto3,stdtime" json:"expiration_time"` +} + +func (m *MsgGroupMember) Reset() { *m = MsgGroupMember{} } +func (m *MsgGroupMember) String() string { return proto.CompactTextString(m) } +func (*MsgGroupMember) ProtoMessage() {} +func (*MsgGroupMember) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{26} +} +func (m *MsgGroupMember) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGroupMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGroupMember.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 *MsgGroupMember) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGroupMember.Merge(m, src) +} +func (m *MsgGroupMember) XXX_Size() int { + return m.Size() +} +func (m *MsgGroupMember) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGroupMember.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGroupMember proto.InternalMessageInfo + +func (m *MsgGroupMember) GetMember() string { + if m != nil { + return m.Member + } + return "" +} + +func (m *MsgGroupMember) GetExpirationTime() time.Time { + if m != nil { + return m.ExpirationTime + } + return time.Time{} +} + type MsgUpdateGroupExtra struct { // operator defines the account address of the operator who has the UpdateGroupMember permission of the group. Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` @@ -1394,7 +1547,7 @@ func (m *MsgUpdateGroupExtra) Reset() { *m = MsgUpdateGroupExtra{} } func (m *MsgUpdateGroupExtra) String() string { return proto.CompactTextString(m) } func (*MsgUpdateGroupExtra) ProtoMessage() {} func (*MsgUpdateGroupExtra) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{24} + return fileDescriptor_ddb71b028305a3cc, []int{27} } func (m *MsgUpdateGroupExtra) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1458,7 +1611,7 @@ func (m *MsgUpdateGroupExtraResponse) Reset() { *m = MsgUpdateGroupExtra func (m *MsgUpdateGroupExtraResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateGroupExtraResponse) ProtoMessage() {} func (*MsgUpdateGroupExtraResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{25} + return fileDescriptor_ddb71b028305a3cc, []int{28} } func (m *MsgUpdateGroupExtraResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1500,7 +1653,7 @@ func (m *MsgLeaveGroup) Reset() { *m = MsgLeaveGroup{} } func (m *MsgLeaveGroup) String() string { return proto.CompactTextString(m) } func (*MsgLeaveGroup) ProtoMessage() {} func (*MsgLeaveGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{26} + return fileDescriptor_ddb71b028305a3cc, []int{29} } func (m *MsgLeaveGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1557,7 +1710,7 @@ func (m *MsgLeaveGroupResponse) Reset() { *m = MsgLeaveGroupResponse{} } func (m *MsgLeaveGroupResponse) String() string { return proto.CompactTextString(m) } func (*MsgLeaveGroupResponse) ProtoMessage() {} func (*MsgLeaveGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{27} + return fileDescriptor_ddb71b028305a3cc, []int{30} } func (m *MsgLeaveGroupResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1606,7 +1759,7 @@ func (m *MsgUpdateBucketInfo) Reset() { *m = MsgUpdateBucketInfo{} } func (m *MsgUpdateBucketInfo) String() string { return proto.CompactTextString(m) } func (*MsgUpdateBucketInfo) ProtoMessage() {} func (*MsgUpdateBucketInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{28} + return fileDescriptor_ddb71b028305a3cc, []int{31} } func (m *MsgUpdateBucketInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1677,7 +1830,7 @@ func (m *MsgUpdateBucketInfoResponse) Reset() { *m = MsgUpdateBucketInfo func (m *MsgUpdateBucketInfoResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateBucketInfoResponse) ProtoMessage() {} func (*MsgUpdateBucketInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{29} + return fileDescriptor_ddb71b028305a3cc, []int{32} } func (m *MsgUpdateBucketInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1719,7 +1872,7 @@ func (m *MsgCancelCreateObject) Reset() { *m = MsgCancelCreateObject{} } func (m *MsgCancelCreateObject) String() string { return proto.CompactTextString(m) } func (*MsgCancelCreateObject) ProtoMessage() {} func (*MsgCancelCreateObject) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{30} + return fileDescriptor_ddb71b028305a3cc, []int{33} } func (m *MsgCancelCreateObject) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1776,7 +1929,7 @@ func (m *MsgCancelCreateObjectResponse) Reset() { *m = MsgCancelCreateOb func (m *MsgCancelCreateObjectResponse) String() string { return proto.CompactTextString(m) } func (*MsgCancelCreateObjectResponse) ProtoMessage() {} func (*MsgCancelCreateObjectResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{31} + return fileDescriptor_ddb71b028305a3cc, []int{34} } func (m *MsgCancelCreateObjectResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1823,7 +1976,7 @@ func (m *MsgPutPolicy) Reset() { *m = MsgPutPolicy{} } func (m *MsgPutPolicy) String() string { return proto.CompactTextString(m) } func (*MsgPutPolicy) ProtoMessage() {} func (*MsgPutPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{32} + return fileDescriptor_ddb71b028305a3cc, []int{35} } func (m *MsgPutPolicy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1895,7 +2048,7 @@ func (m *MsgPutPolicyResponse) Reset() { *m = MsgPutPolicyResponse{} } func (m *MsgPutPolicyResponse) String() string { return proto.CompactTextString(m) } func (*MsgPutPolicyResponse) ProtoMessage() {} func (*MsgPutPolicyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{33} + return fileDescriptor_ddb71b028305a3cc, []int{36} } func (m *MsgPutPolicyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1937,7 +2090,7 @@ func (m *MsgDeletePolicy) Reset() { *m = MsgDeletePolicy{} } func (m *MsgDeletePolicy) String() string { return proto.CompactTextString(m) } func (*MsgDeletePolicy) ProtoMessage() {} func (*MsgDeletePolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{34} + return fileDescriptor_ddb71b028305a3cc, []int{37} } func (m *MsgDeletePolicy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1995,7 +2148,7 @@ func (m *MsgDeletePolicyResponse) Reset() { *m = MsgDeletePolicyResponse func (m *MsgDeletePolicyResponse) String() string { return proto.CompactTextString(m) } func (*MsgDeletePolicyResponse) ProtoMessage() {} func (*MsgDeletePolicyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{35} + return fileDescriptor_ddb71b028305a3cc, []int{38} } func (m *MsgDeletePolicyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2039,7 +2192,7 @@ func (m *MsgMirrorObject) Reset() { *m = MsgMirrorObject{} } func (m *MsgMirrorObject) String() string { return proto.CompactTextString(m) } func (*MsgMirrorObject) ProtoMessage() {} func (*MsgMirrorObject) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{36} + return fileDescriptor_ddb71b028305a3cc, []int{39} } func (m *MsgMirrorObject) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2096,7 +2249,7 @@ func (m *MsgMirrorObjectResponse) Reset() { *m = MsgMirrorObjectResponse func (m *MsgMirrorObjectResponse) String() string { return proto.CompactTextString(m) } func (*MsgMirrorObjectResponse) ProtoMessage() {} func (*MsgMirrorObjectResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{37} + return fileDescriptor_ddb71b028305a3cc, []int{40} } func (m *MsgMirrorObjectResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2138,7 +2291,7 @@ func (m *MsgMirrorBucket) Reset() { *m = MsgMirrorBucket{} } func (m *MsgMirrorBucket) String() string { return proto.CompactTextString(m) } func (*MsgMirrorBucket) ProtoMessage() {} func (*MsgMirrorBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{38} + return fileDescriptor_ddb71b028305a3cc, []int{41} } func (m *MsgMirrorBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2188,7 +2341,7 @@ func (m *MsgUpdateObjectInfoResponse) Reset() { *m = MsgUpdateObjectInfo func (m *MsgUpdateObjectInfoResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateObjectInfoResponse) ProtoMessage() {} func (*MsgUpdateObjectInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{39} + return fileDescriptor_ddb71b028305a3cc, []int{42} } func (m *MsgUpdateObjectInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2233,7 +2386,7 @@ func (m *MsgUpdateObjectInfo) Reset() { *m = MsgUpdateObjectInfo{} } func (m *MsgUpdateObjectInfo) String() string { return proto.CompactTextString(m) } func (*MsgUpdateObjectInfo) ProtoMessage() {} func (*MsgUpdateObjectInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{40} + return fileDescriptor_ddb71b028305a3cc, []int{43} } func (m *MsgUpdateObjectInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2297,7 +2450,7 @@ func (m *MsgMirrorBucketResponse) Reset() { *m = MsgMirrorBucketResponse func (m *MsgMirrorBucketResponse) String() string { return proto.CompactTextString(m) } func (*MsgMirrorBucketResponse) ProtoMessage() {} func (*MsgMirrorBucketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{41} + return fileDescriptor_ddb71b028305a3cc, []int{44} } func (m *MsgMirrorBucketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2339,7 +2492,7 @@ func (m *MsgMirrorGroup) Reset() { *m = MsgMirrorGroup{} } func (m *MsgMirrorGroup) String() string { return proto.CompactTextString(m) } func (*MsgMirrorGroup) ProtoMessage() {} func (*MsgMirrorGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{42} + return fileDescriptor_ddb71b028305a3cc, []int{45} } func (m *MsgMirrorGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2389,7 +2542,7 @@ func (m *MsgMirrorGroupResponse) Reset() { *m = MsgMirrorGroupResponse{} func (m *MsgMirrorGroupResponse) String() string { return proto.CompactTextString(m) } func (*MsgMirrorGroupResponse) ProtoMessage() {} func (*MsgMirrorGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{43} + return fileDescriptor_ddb71b028305a3cc, []int{46} } func (m *MsgMirrorGroupResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2431,7 +2584,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{44} + return fileDescriptor_ddb71b028305a3cc, []int{47} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2482,7 +2635,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{45} + return fileDescriptor_ddb71b028305a3cc, []int{48} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2527,7 +2680,7 @@ func (m *MsgMigrateBucket) Reset() { *m = MsgMigrateBucket{} } func (m *MsgMigrateBucket) String() string { return proto.CompactTextString(m) } func (*MsgMigrateBucket) ProtoMessage() {} func (*MsgMigrateBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{46} + return fileDescriptor_ddb71b028305a3cc, []int{49} } func (m *MsgMigrateBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2591,7 +2744,7 @@ func (m *MsgMigrateBucketResponse) Reset() { *m = MsgMigrateBucketRespon func (m *MsgMigrateBucketResponse) String() string { return proto.CompactTextString(m) } func (*MsgMigrateBucketResponse) ProtoMessage() {} func (*MsgMigrateBucketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{47} + return fileDescriptor_ddb71b028305a3cc, []int{50} } func (m *MsgMigrateBucketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2636,7 +2789,7 @@ func (m *MsgCompleteMigrateBucket) Reset() { *m = MsgCompleteMigrateBuck func (m *MsgCompleteMigrateBucket) String() string { return proto.CompactTextString(m) } func (*MsgCompleteMigrateBucket) ProtoMessage() {} func (*MsgCompleteMigrateBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{48} + return fileDescriptor_ddb71b028305a3cc, []int{51} } func (m *MsgCompleteMigrateBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2700,7 +2853,7 @@ func (m *MsgCompleteMigrateBucketResponse) Reset() { *m = MsgCompleteMig func (m *MsgCompleteMigrateBucketResponse) String() string { return proto.CompactTextString(m) } func (*MsgCompleteMigrateBucketResponse) ProtoMessage() {} func (*MsgCompleteMigrateBucketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{49} + return fileDescriptor_ddb71b028305a3cc, []int{52} } func (m *MsgCompleteMigrateBucketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2741,7 +2894,7 @@ func (m *MsgCancelMigrateBucket) Reset() { *m = MsgCancelMigrateBucket{} func (m *MsgCancelMigrateBucket) String() string { return proto.CompactTextString(m) } func (*MsgCancelMigrateBucket) ProtoMessage() {} func (*MsgCancelMigrateBucket) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{50} + return fileDescriptor_ddb71b028305a3cc, []int{53} } func (m *MsgCancelMigrateBucket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2791,7 +2944,7 @@ func (m *MsgCancelMigrateBucketResponse) Reset() { *m = MsgCancelMigrate func (m *MsgCancelMigrateBucketResponse) String() string { return proto.CompactTextString(m) } func (*MsgCancelMigrateBucketResponse) ProtoMessage() {} func (*MsgCancelMigrateBucketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ddb71b028305a3cc, []int{51} + return fileDescriptor_ddb71b028305a3cc, []int{54} } func (m *MsgCancelMigrateBucketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2845,6 +2998,9 @@ func init() { proto.RegisterType((*MsgDeleteGroupResponse)(nil), "greenfield.storage.MsgDeleteGroupResponse") proto.RegisterType((*MsgUpdateGroupMember)(nil), "greenfield.storage.MsgUpdateGroupMember") proto.RegisterType((*MsgUpdateGroupMemberResponse)(nil), "greenfield.storage.MsgUpdateGroupMemberResponse") + proto.RegisterType((*MsgRenewGroupMember)(nil), "greenfield.storage.MsgRenewGroupMember") + proto.RegisterType((*MsgRenewGroupMemberResponse)(nil), "greenfield.storage.MsgRenewGroupMemberResponse") + proto.RegisterType((*MsgGroupMember)(nil), "greenfield.storage.MsgGroupMember") proto.RegisterType((*MsgUpdateGroupExtra)(nil), "greenfield.storage.MsgUpdateGroupExtra") proto.RegisterType((*MsgUpdateGroupExtraResponse)(nil), "greenfield.storage.MsgUpdateGroupExtraResponse") proto.RegisterType((*MsgLeaveGroup)(nil), "greenfield.storage.MsgLeaveGroup") @@ -2878,142 +3034,146 @@ func init() { func init() { proto.RegisterFile("greenfield/storage/tx.proto", fileDescriptor_ddb71b028305a3cc) } var fileDescriptor_ddb71b028305a3cc = []byte{ - // 2152 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcd, 0x6f, 0x1b, 0xc7, - 0xd9, 0x37, 0x25, 0xea, 0x83, 0x0f, 0xa9, 0x0f, 0xaf, 0x95, 0x88, 0xa1, 0x5e, 0x53, 0x34, 0xf3, - 0x22, 0x91, 0xbf, 0x44, 0x47, 0x75, 0x8d, 0x54, 0x87, 0xa0, 0x92, 0xd3, 0x18, 0x42, 0xa2, 0x5a, - 0x59, 0xda, 0x2e, 0x10, 0xa0, 0x60, 0x86, 0xbb, 0xe3, 0xd5, 0x36, 0xdc, 0x8f, 0xce, 0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b, 0x5f, 0xaf, - 0xc0, 0xf4, 0x3e, 0x35, 0x94, 0x8f, 0xa1, 0x36, 0xf6, 0xbb, 0xd9, 0xeb, 0x69, 0xcc, 0xc4, 0x7e, - 0x9c, 0x69, 0x5c, 0x9e, 0x00, 0x14, 0xd6, 0xe7, 0x8f, 0xa1, 0x36, 0xf6, 0x23, 0x4c, 0xd6, 0x09, - 0x32, 0x28, 0xf3, 0x84, 0xb4, 0x5f, 0x55, 0x94, 0x01, 0x2c, 0x27, 0x9e, 0x25, 0x6f, 0x66, 0x6c, - 0x10, 0x07, 0x36, 0x3a, 0x13, 0x02, 0x65, 0x7d, 0xc6, 0xca, 0x69, 0x96, 0x3e, 0x32, 0x28, 0x53, - 0x9f, 0xb4, 0x84, 0xaf, 0x38, 0x70, 0x36, 0xf9, 0x0b, 0xd1, 0x46, 0x16, 0x23, 0x71, 0x64, 0xe3, - 0xda, 0xa4, 0x48, 0x59, 0xa5, 0xb1, 0xf7, 0x45, 0xbe, 0x13, 0x70, 0x50, 0x81, 0x13, 0xc4, 0xda, - 0x99, 0x1f, 0x01, 0x48, 0xcd, 0xec, 0x0b, 0x19, 0x4b, 0x23, 0x48, 0xe3, 0x62, 0x21, 0x44, 0x36, - 0x7f, 0xa2, 0x5d, 0x9e, 0x65, 0xfe, 0x38, 0x30, 0xd3, 0xfc, 0x59, 0x2d, 0x6e, 0xa6, 0x89, 0xd4, - 0xde, 0xce, 0xd2, 0x24, 0x82, 0x64, 0x6a, 0x92, 0xd2, 0xf4, 0x0d, 0x43, 0xa5, 0xc0, 0x0e, 0x32, - 0xa8, 0x20, 0x54, 0x62, 0x27, 0x10, 0x50, 0x52, 0xde, 0x93, 0x99, 0x22, 0x26, 0xa0, 0x8d, 0xb7, - 0x26, 0x86, 0x26, 0x03, 0xa6, 0x40, 0x2b, 0x19, 0x54, 0x10, 0x30, 0xb1, 0x13, 0xc6, 0x03, 0x46, - 0x1c, 0x33, 0x41, 0xc0, 0x88, 0xb3, 0xae, 0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x43, - 0xbd, 0x94, 0x9b, 0xe1, 0xc7, 0x0f, 0xde, 0x9a, 0x1c, 0x1b, 0x1c, 0xbb, 0xbb, 0xf7, 0xe8, 0x69, - 0xb3, 0xf4, 0xf8, 0x69, 0xb3, 0xf4, 0xd5, 0xd3, 0x66, 0xe9, 0xb3, 0x67, 0xcd, 0x33, 0x8f, 0x9f, - 0x35, 0xcf, 0xfc, 0xf3, 0x59, 0xf3, 0xcc, 0x47, 0x1d, 0xc3, 0xf4, 0x0e, 0x87, 0x7d, 0xf6, 0x78, - 0xe9, 0xf4, 0xed, 0xfe, 0x55, 0xed, 0x10, 0x99, 0x76, 0x47, 0xfa, 0xeb, 0xaf, 0x87, 0xd1, 0xdf, - 0xc8, 0x8d, 0x5c, 0x4c, 0xfb, 0xb3, 0x7e, 0x67, 0xed, 0x3b, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, - 0x66, 0x33, 0x60, 0x9d, 0x46, 0x27, 0x00, 0x00, + // 2212 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4b, 0x6c, 0x1b, 0xc7, + 0x19, 0x36, 0x45, 0xea, 0xc1, 0x9f, 0xd4, 0xc3, 0x1b, 0x39, 0x62, 0xa8, 0x9a, 0xa2, 0x99, 0x22, + 0x91, 0x5f, 0xa2, 0xa3, 0xba, 0x46, 0x2a, 0x14, 0x45, 0x25, 0xa7, 0x71, 0x85, 0x84, 0xb5, 0xb2, + 0xb2, 0x5d, 0x20, 0x40, 0xc1, 0x0c, 0x77, 0xc7, 0xab, 0x6d, 0xc8, 0xdd, 0xed, 0xcc, 0x52, 0x36, + 0x53, 0xa0, 0x87, 0x5e, 0x7a, 0x4d, 0x91, 0x1e, 0x7a, 0x28, 0x0a, 0x14, 0xe8, 0xa1, 0xa7, 0xa2, + 0x28, 0x72, 0x2e, 0x7a, 0x09, 0x10, 0xf4, 0x64, 0xe4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xb1, 0x6f, + 0x9b, 0xd4, 0x0a, 0xcd, 0xc2, 0x7a, 0x79, 0xa7, 0xf6, 0xd9, 0xc7, 0xd7, 0x97, 0x85, 0x5a, 0xb6, + 0x75, 0x9d, 0x60, 0x4a, 0xf7, 0x5d, 0x62, 0x5a, 0x86, 0xea, 0x03, 0x95, 0x35, 0xa8, 0xf4, 0xbc, + 0xd5, 0x5d, 0x0b, 0x0d, 0x70, 0x6d, 0x8a, 0xad, 0x53, 0x81, 0x0f, 0xfd, 0x00, 0x0d, 0xb0, 0xb2, + 0x03, 0x70, 0x68, 0x52, 0xb3, 0x67, 0xf6, 0x4d, 0x77, 0x54, 0x2b, 0x36, 0x0b, 0xeb, 0x0b, 0x9b, + 0xad, 0x8d, 0xb8, 0x95, 0x36, 0x1e, 0x04, 0xa8, 0x7b, 0x23, 0x07, 0xab, 0xd2, 0x2a, 0x65, 0x1b, + 0x16, 0x1d, 0x34, 0x1a, 0x60, 0xcb, 0xed, 0x22, 0xce, 0x46, 0xad, 0x94, 0xc3, 0xe0, 0x82, 0x58, + 0x20, 0x46, 0x95, 0x37, 0x41, 0x71, 0x88, 0x39, 0x40, 0x64, 0xd4, 0xa5, 0x4e, 0x40, 0x65, 0x3a, + 0x87, 0xca, 0x92, 0x58, 0xb3, 0xef, 0xf8, 0x74, 0xde, 0x82, 0x17, 0x64, 0x3a, 0xc2, 0xb6, 0xb5, + 0x99, 0x66, 0x61, 0xbd, 0xb2, 0xb9, 0x2a, 0xcb, 0x25, 0xec, 0xb1, 0x2d, 0x20, 0xea, 0xf9, 0x90, + 0x96, 0x18, 0x52, 0xae, 0x81, 0xa2, 0x1d, 0x20, 0x62, 0x60, 0xbd, 0x4b, 0x30, 0xd2, 0xbb, 0x3f, + 0x19, 0xda, 0x2e, 0xaa, 0xcd, 0x36, 0x0b, 0xeb, 0x25, 0x75, 0x49, 0xcc, 0xa8, 0x18, 0xe9, 0xef, + 0xb0, 0xf1, 0xad, 0xea, 0xcf, 0xff, 0x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, 0x78, 0x95, + 0xd1, 0x97, 0xa1, 0xaa, 0x28, 0x8f, 0x4d, 0x68, 0x24, 0xef, 0xef, 0x73, 0xb8, 0xf9, 0xef, 0x0b, + 0x50, 0xec, 0x50, 0x43, 0x79, 0x0f, 0xaa, 0x63, 0xaf, 0x96, 0x2f, 0xa7, 0xdc, 0x42, 0x65, 0x50, + 0xfd, 0xea, 0x04, 0xa0, 0xe0, 0x7c, 0x7e, 0x0f, 0xaa, 0x63, 0x4f, 0x60, 0x69, 0x3b, 0xc8, 0xa0, + 0xd4, 0x1d, 0x92, 0xde, 0xb4, 0x94, 0x3e, 0x2c, 0xc5, 0xae, 0x25, 0xaf, 0xa6, 0x10, 0x88, 0x02, + 0xeb, 0xed, 0x09, 0x81, 0xb2, 0x3c, 0x63, 0xc7, 0x69, 0x9a, 0x3c, 0x32, 0x28, 0x55, 0x9e, 0xa4, + 0x84, 0xaf, 0xd8, 0x70, 0x3e, 0xfe, 0x3e, 0xb7, 0x9e, 0xa6, 0x91, 0x28, 0xb2, 0x7e, 0x63, 0x52, + 0xa4, 0x2c, 0xd2, 0xd8, 0xfd, 0x22, 0xdb, 0x09, 0x38, 0x28, 0xc7, 0x09, 0x22, 0xcd, 0xe4, 0x77, + 0x01, 0xa4, 0xa7, 0x84, 0x4b, 0x29, 0x4b, 0x43, 0x48, 0xfd, 0x72, 0x2e, 0x44, 0x36, 0x7f, 0xec, + 0xb1, 0x22, 0xcd, 0xfc, 0x51, 0x60, 0xaa, 0xf9, 0xd3, 0x1e, 0x18, 0x98, 0x24, 0xd2, 0xe3, 0x42, + 0x9a, 0x24, 0x21, 0x24, 0x55, 0x92, 0x84, 0x96, 0x7b, 0x10, 0x2a, 0x39, 0x76, 0x90, 0x41, 0x39, + 0xa1, 0x12, 0xd9, 0x81, 0x80, 0x92, 0x70, 0x9f, 0x4c, 0x65, 0x31, 0x06, 0xad, 0xbf, 0x36, 0x31, + 0x34, 0x1e, 0x30, 0x39, 0x52, 0xc9, 0xa0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 0x42, 0xd5, + 0xaf, 0x4d, 0x82, 0x0a, 0x36, 0xf9, 0x29, 0x5c, 0x48, 0xae, 0xdf, 0xaf, 0xa5, 0x1e, 0x51, 0x09, + 0xe8, 0xfa, 0xcd, 0xa3, 0xa0, 0x83, 0xcd, 0x87, 0xf0, 0x42, 0x52, 0x3d, 0x7c, 0x25, 0xf3, 0x3c, + 0x19, 0xdf, 0x78, 0x73, 0x72, 0xac, 0xbf, 0xed, 0xce, 0xee, 0xa7, 0x4f, 0x1b, 0x85, 0x27, 0x4f, + 0x1b, 0x85, 0x2f, 0x9e, 0x36, 0x0a, 0x1f, 0x3e, 0x6b, 0x9c, 0x7b, 0xf2, 0xac, 0x71, 0xee, 0xef, + 0xcf, 0x1a, 0xe7, 0xde, 0x6d, 0x1b, 0xa6, 0x7b, 0x30, 0xec, 0xb1, 0xab, 0x52, 0xbb, 0x67, 0xf5, + 0xae, 0x6b, 0x07, 0xc8, 0xb4, 0xda, 0xd2, 0x2f, 0xfd, 0x1e, 0x87, 0xbf, 0x87, 0x1c, 0x39, 0x98, + 0xf6, 0x66, 0xbc, 0x3e, 0xde, 0x37, 0xfe, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x52, 0x65, 0xa3, 0x5a, + 0x32, 0x29, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3051,6 +3211,7 @@ type MsgClient interface { UpdateGroupExtra(ctx context.Context, in *MsgUpdateGroupExtra, opts ...grpc.CallOption) (*MsgUpdateGroupExtraResponse, error) LeaveGroup(ctx context.Context, in *MsgLeaveGroup, opts ...grpc.CallOption) (*MsgLeaveGroupResponse, error) MirrorGroup(ctx context.Context, in *MsgMirrorGroup, opts ...grpc.CallOption) (*MsgMirrorGroupResponse, error) + RenewGroupMember(ctx context.Context, in *MsgRenewGroupMember, opts ...grpc.CallOption) (*MsgRenewGroupMemberResponse, error) // basic operation of policy PutPolicy(ctx context.Context, in *MsgPutPolicy, opts ...grpc.CallOption) (*MsgPutPolicyResponse, error) DeletePolicy(ctx context.Context, in *MsgDeletePolicy, opts ...grpc.CallOption) (*MsgDeletePolicyResponse, error) @@ -3250,6 +3411,15 @@ func (c *msgClient) MirrorGroup(ctx context.Context, in *MsgMirrorGroup, opts .. return out, nil } +func (c *msgClient) RenewGroupMember(ctx context.Context, in *MsgRenewGroupMember, opts ...grpc.CallOption) (*MsgRenewGroupMemberResponse, error) { + out := new(MsgRenewGroupMemberResponse) + err := c.cc.Invoke(ctx, "/greenfield.storage.Msg/RenewGroupMember", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) PutPolicy(ctx context.Context, in *MsgPutPolicy, opts ...grpc.CallOption) (*MsgPutPolicyResponse, error) { out := new(MsgPutPolicyResponse) err := c.cc.Invoke(ctx, "/greenfield.storage.Msg/PutPolicy", in, out, opts...) @@ -3329,6 +3499,7 @@ type MsgServer interface { UpdateGroupExtra(context.Context, *MsgUpdateGroupExtra) (*MsgUpdateGroupExtraResponse, error) LeaveGroup(context.Context, *MsgLeaveGroup) (*MsgLeaveGroupResponse, error) MirrorGroup(context.Context, *MsgMirrorGroup) (*MsgMirrorGroupResponse, error) + RenewGroupMember(context.Context, *MsgRenewGroupMember) (*MsgRenewGroupMemberResponse, error) // basic operation of policy PutPolicy(context.Context, *MsgPutPolicy) (*MsgPutPolicyResponse, error) DeletePolicy(context.Context, *MsgDeletePolicy) (*MsgDeletePolicyResponse, error) @@ -3404,6 +3575,9 @@ func (*UnimplementedMsgServer) LeaveGroup(ctx context.Context, req *MsgLeaveGrou func (*UnimplementedMsgServer) MirrorGroup(ctx context.Context, req *MsgMirrorGroup) (*MsgMirrorGroupResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method MirrorGroup not implemented") } +func (*UnimplementedMsgServer) RenewGroupMember(ctx context.Context, req *MsgRenewGroupMember) (*MsgRenewGroupMemberResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RenewGroupMember not implemented") +} func (*UnimplementedMsgServer) PutPolicy(ctx context.Context, req *MsgPutPolicy) (*MsgPutPolicyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PutPolicy not implemented") } @@ -3787,6 +3961,24 @@ func _Msg_MirrorGroup_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Msg_RenewGroupMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRenewGroupMember) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RenewGroupMember(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.storage.Msg/RenewGroupMember", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RenewGroupMember(ctx, req.(*MsgRenewGroupMember)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_PutPolicy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgPutPolicy) if err := dec(in); err != nil { @@ -3979,6 +4171,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "MirrorGroup", Handler: _Msg_MirrorGroup_Handler, }, + { + MethodName: "RenewGroupMember", + Handler: _Msg_RenewGroupMember_Handler, + }, { MethodName: "PutPolicy", Handler: _Msg_PutPolicy_Handler, @@ -4783,16 +4979,7 @@ func (m *MsgCreateGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Extra) i = encodeVarintTx(dAtA, i, uint64(len(m.Extra))) i-- - dAtA[i] = 0x22 - } - if len(m.Members) > 0 { - for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Members[iNdEx]) - copy(dAtA[i:], m.Members[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Members[iNdEx]))) - i-- - dAtA[i] = 0x1a - } + dAtA[i] = 0x1a } if len(m.GroupName) > 0 { i -= len(m.GroupName) @@ -4935,9 +5122,14 @@ func (m *MsgUpdateGroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { } if len(m.MembersToAdd) > 0 { for iNdEx := len(m.MembersToAdd) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.MembersToAdd[iNdEx]) - copy(dAtA[i:], m.MembersToAdd[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.MembersToAdd[iNdEx]))) + { + size, err := m.MembersToAdd[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x22 } @@ -4989,7 +5181,7 @@ func (m *MsgUpdateGroupMemberResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *MsgUpdateGroupExtra) Marshal() (dAtA []byte, err error) { +func (m *MsgRenewGroupMember) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4999,22 +5191,29 @@ func (m *MsgUpdateGroupExtra) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateGroupExtra) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRenewGroupMember) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupExtra) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRenewGroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Extra) > 0 { - i -= len(m.Extra) - copy(dAtA[i:], m.Extra) - i = encodeVarintTx(dAtA, i, uint64(len(m.Extra))) - i-- - dAtA[i] = 0x22 + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Members[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } } if len(m.GroupName) > 0 { i -= len(m.GroupName) @@ -5040,7 +5239,7 @@ func (m *MsgUpdateGroupExtra) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgUpdateGroupExtraResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRenewGroupMemberResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -5050,12 +5249,12 @@ func (m *MsgUpdateGroupExtraResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateGroupExtraResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRenewGroupMemberResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupExtraResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRenewGroupMemberResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -5063,7 +5262,7 @@ func (m *MsgUpdateGroupExtraResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *MsgLeaveGroup) Marshal() (dAtA []byte, err error) { +func (m *MsgGroupMember) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -5073,30 +5272,24 @@ func (m *MsgLeaveGroup) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgLeaveGroup) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgGroupMember) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgLeaveGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgGroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.GroupName) > 0 { - i -= len(m.GroupName) - copy(dAtA[i:], m.GroupName) - i = encodeVarintTx(dAtA, i, uint64(len(m.GroupName))) - i-- - dAtA[i] = 0x1a - } - if len(m.GroupOwner) > 0 { - i -= len(m.GroupOwner) - copy(dAtA[i:], m.GroupOwner) - i = encodeVarintTx(dAtA, i, uint64(len(m.GroupOwner))) - i-- - dAtA[i] = 0x12 + n4, err4 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationTime):]) + if err4 != nil { + return 0, err4 } + i -= n4 + i = encodeVarintTx(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x12 if len(m.Member) > 0 { i -= len(m.Member) copy(dAtA[i:], m.Member) @@ -5107,7 +5300,7 @@ func (m *MsgLeaveGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgLeaveGroupResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupExtra) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -5117,19 +5310,137 @@ func (m *MsgLeaveGroupResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgLeaveGroupResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupExtra) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgLeaveGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupExtra) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - return len(dAtA) - i, nil -} - + if len(m.Extra) > 0 { + i -= len(m.Extra) + copy(dAtA[i:], m.Extra) + i = encodeVarintTx(dAtA, i, uint64(len(m.Extra))) + i-- + dAtA[i] = 0x22 + } + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x1a + } + if len(m.GroupOwner) > 0 { + i -= len(m.GroupOwner) + copy(dAtA[i:], m.GroupOwner) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupOwner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupExtraResponse) 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 *MsgUpdateGroupExtraResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupExtraResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgLeaveGroup) 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 *MsgLeaveGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLeaveGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x1a + } + if len(m.GroupOwner) > 0 { + i -= len(m.GroupOwner) + copy(dAtA[i:], m.GroupOwner) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupOwner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Member) > 0 { + i -= len(m.Member) + copy(dAtA[i:], m.Member) + i = encodeVarintTx(dAtA, i, uint64(len(m.Member))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgLeaveGroupResponse) 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 *MsgLeaveGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLeaveGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgUpdateBucketInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -5302,12 +5613,12 @@ func (m *MsgPutPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.ExpirationTime != nil { - n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.ExpirationTime):]) - if err5 != nil { - return 0, err5 + n6, err6 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.ExpirationTime):]) + if err6 != nil { + return 0, err6 } - i -= n5 - i = encodeVarintTx(dAtA, i, uint64(n5)) + i -= n6 + i = encodeVarintTx(dAtA, i, uint64(n6)) i-- dAtA[i] = 0x3a } @@ -6396,12 +6707,6 @@ func (m *MsgCreateGroup) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Members) > 0 { - for _, s := range m.Members { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } l = len(m.Extra) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -6465,8 +6770,8 @@ func (m *MsgUpdateGroupMember) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } if len(m.MembersToAdd) > 0 { - for _, s := range m.MembersToAdd { - l = len(s) + for _, e := range m.MembersToAdd { + l = e.Size() n += 1 + l + sovTx(uint64(l)) } } @@ -6488,6 +6793,57 @@ func (m *MsgUpdateGroupMemberResponse) Size() (n int) { return n } +func (m *MsgRenewGroupMember) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GroupOwner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GroupName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgRenewGroupMemberResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgGroupMember) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Member) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationTime) + n += 1 + l + sovTx(uint64(l)) + return n +} + func (m *MsgUpdateGroupExtra) Size() (n int) { if m == nil { return 0 @@ -9318,38 +9674,6 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { m.GroupName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Members = append(m.Members, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Extra", wireType) } @@ -9779,7 +10103,7 @@ func (m *MsgUpdateGroupMember) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MembersToAdd", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9789,23 +10113,25 @@ func (m *MsgUpdateGroupMember) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.MembersToAdd = append(m.MembersToAdd, string(dAtA[iNdEx:postIndex])) + m.MembersToAdd = append(m.MembersToAdd, &MsgGroupMember{}) + if err := m.MembersToAdd[len(m.MembersToAdd)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 5: if wireType != 2 { @@ -9910,6 +10236,351 @@ func (m *MsgUpdateGroupMemberResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRenewGroupMember) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRenewGroupMember: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRenewGroupMember: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupOwner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupOwner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Members = append(m.Members, &MsgGroupMember{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRenewGroupMemberResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRenewGroupMemberResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRenewGroupMemberResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgGroupMember) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgGroupMember: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGroupMember: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Member = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpirationTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.ExpirationTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgUpdateGroupExtra) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 4bb35c4d90135b197e7ce2b965e594e4e9a36d4d Mon Sep 17 00:00:00 2001 From: dylanhuang Date: Tue, 8 Aug 2023 15:17:14 +0800 Subject: [PATCH 20/24] docs: update document site links (#404) --- readme.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index b1fbd59b7..246480bb4 100644 --- a/readme.md +++ b/readme.md @@ -53,11 +53,11 @@ through decentralized applications known as BNB Greenfield dApps. These dApps pr interacting with the platform, enabling users to create and manipulate data in a secure and decentralized environment. ## Documentation -Visit our official [documentation site](https://greenfield.bnbchain.org/docs/guide/) for more info. +Visit our official [documentation site](https://docs.bnbchain.org/greenfield-docs/docs/guide/introduction/overview) for more info. ## Quick Started -*Note*: Requires [Go 1.19+](https://go.dev/dl/) +*Note*: Requires [Go 1.20+](https://go.dev/dl/) ``` ## Build from source @@ -83,7 +83,7 @@ $ bash ./deployment/localup/localup.sh stop bash ./deployment/localup/localup.sh start 3 3 ``` -More advanced script and command line usage, please refer to the [Tutorial](docs/cli/cli.md). +More advanced script and command line usage, please refer to the [Tutorial](https://docs.bnbchain.org/greenfield-docs/docs/api/blockchain-cli). ## Key Modules @@ -104,14 +104,14 @@ And the following modules are in cosmos-sdk: - `x/staking`: based on the Proof-of-Stake logic. The elected validators are responsible for the security of the Greenfield blockchain. They get involved in the governance and staking of the blockchain. -Refer to the [docs](https://greenfield.bnbchain.org/docs/guide/greenfield-blockchain/modules/storage-module.html) to dive deep into these modules. +Refer to the [docs](https://docs.bnbchain.org/greenfield-docs/docs/guide/greenfield-blockchain/modules/storage-module) to dive deep into these modules. ## Running node -- [Interacting with the Node](https://greenfield.bnbchain.org/docs/guide/greenfield-blockchain/run-node/interact-node.html) -- [Run Local Network](https://greenfield.bnbchain.org/docs/guide/greenfield-blockchain/run-node/run-local-network.html) -- [Run Testnet Node](https://greenfield.bnbchain.org/docs/guide/greenfield-blockchain/run-node/run-testnet-node.html) -- [Become Testnet Validator](https://greenfield.bnbchain.org/docs/guide/greenfield-blockchain/run-node/become-testnet-validator.html) +- [Interacting with the Node](https://docs.bnbchain.org/greenfield-docs/docs/guide/greenfield-blockchain/run-node/interact-node) +- [Run Local Network](https://docs.bnbchain.org/greenfield-docs/docs/guide/greenfield-blockchain/run-node/run-local-network) +- [Run Testnet Node](https://docs.bnbchain.org/greenfield-docs/docs/guide/greenfield-blockchain/run-node/run-testnet-node) +- [Become Testnet Validator](https://docs.bnbchain.org/greenfield-docs/docs/guide/greenfield-blockchain/run-node/become-testnet-validator) ## Related Projects - [Greenfield-Contract](https://github.com/bnb-chain/greenfield-contracts): the cross chain contract for Greenfield that deployed on BSC network. From 3bec088c264c7c4863d3a9afdb7142763038af07 Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:07:25 +0800 Subject: [PATCH 21/24] feat: sp maintenance mode (#403) * add maintenance mode for sp * update cosmos sdk * fix test * add query api and fix test * change underlying storage model * add cmd * fix comments * fix the renaming * only persist when there is change --- deployment/localup/create_sp.json | 1 + deployment/localup/localup.sh | 9 + e2e/core/basesuite.go | 31 +- e2e/core/config.go | 22 +- e2e/tests/gensp_test.go | 13 +- e2e/tests/sp_test.go | 63 ++- e2e/tests/storage_test.go | 173 ++++++++ go.mod | 2 +- go.sum | 4 +- proto/greenfield/sp/events.proto | 28 +- proto/greenfield/sp/params.proto | 6 + proto/greenfield/sp/query.proto | 13 + proto/greenfield/sp/tx.proto | 37 +- proto/greenfield/sp/types.proto | 30 +- sdk/client/gnfd_tm.go | 1 + swagger/static/swagger.yaml | 216 +++++++++- x/sp/abci.go | 13 + x/sp/client/cli/flags.go | 27 +- x/sp/client/cli/query.go | 37 ++ x/sp/client/cli/tx.go | 92 +++- x/sp/keeper/grpc_query.go | 20 + x/sp/keeper/msg_server.go | 102 ++++- x/sp/keeper/msg_server_test.go | 58 +-- x/sp/keeper/sp_status.go | 109 +++++ x/sp/module.go | 3 +- x/sp/types/codec.go | 5 + x/sp/types/errors.go | 32 +- x/sp/types/events.pb.go | 540 +++++++++++++++++++++--- x/sp/types/keys.go | 7 +- x/sp/types/message.go | 115 +++-- x/sp/types/message_test.go | 43 +- x/sp/types/params.go | 68 ++- x/sp/types/params.pb.go | 170 +++++++- x/sp/types/query.pb.go | 507 +++++++++++++++++++--- x/sp/types/query.pb.gw.go | 83 ++++ x/sp/types/tx.pb.go | 672 ++++++++++++++++++++++++++---- x/sp/types/types.go | 40 +- x/sp/types/types.pb.go | 647 ++++++++++++++++++++++++---- x/storage/keeper/keeper.go | 28 +- 39 files changed, 3558 insertions(+), 509 deletions(-) create mode 100644 x/sp/abci.go create mode 100644 x/sp/keeper/sp_status.go diff --git a/deployment/localup/create_sp.json b/deployment/localup/create_sp.json index 450d88bd6..1afe875d9 100644 --- a/deployment/localup/create_sp.json +++ b/deployment/localup/create_sp.json @@ -14,6 +14,7 @@ "seal_address":"0x942a7C3eA3011b831D94BdcA8b950fE26853e74d", "approval_address":"0x8FEe9d987Ce29Dd7e9A6aF5eb9d8AA5f98a367b1", "gc_address": "0x9c024772c932b3E6748AbE50C4e895086Be18249", + "maintenance_address": "0xbE03316B1D7c3FCB69136e47e02442d6Fb3396dB", "endpoint": "https://www.greenfield.io", "deposit":{ "denom":"BNB", diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index c3627c2c1..bda54bdcf 100644 --- a/deployment/localup/localup.sh +++ b/deployment/localup/localup.sh @@ -40,6 +40,7 @@ function init() { ${bin} keys add sp${i}_bls --keyring-backend test --home ${workspace}/.local/sp${i} --algo eth_bls > ${workspace}/.local/sp${i}/bls_info 2>&1 ${bin} keys add sp${i}_approval --keyring-backend test --home ${workspace}/.local/sp${i} > ${workspace}/.local/sp${i}/approval_info 2>&1 ${bin} keys add sp${i}_gc --keyring-backend test --home ${workspace}/.local/sp${i} > ${workspace}/.local/sp${i}/gc_info 2>&1 + ${bin} keys add sp${i}_maintenance --keyring-backend test --home ${workspace}/.local/sp${i} > ${workspace}/.local/sp${i}/maintenance_info 2>&1 done } @@ -198,11 +199,13 @@ function generate_sp_genesis { spseal_addr=("$(${bin} keys show sp${i}_seal -a --keyring-backend test --home ${workspace}/.local/sp${i})") spapproval_addr=("$(${bin} keys show sp${i}_approval -a --keyring-backend test --home ${workspace}/.local/sp${i})") spgc_addr=("$(${bin} keys show sp${i}_gc -a --keyring-backend test --home ${workspace}/.local/sp${i})") + spmaintenance_addr=("$(${bin} keys show sp${i}_maintenance -a --keyring-backend test --home ${workspace}/.local/sp${i})") ${bin} add-genesis-account $spoperator_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0 ${bin} add-genesis-account $spfund_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0 ${bin} add-genesis-account $spseal_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0 ${bin} add-genesis-account $spapproval_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0 ${bin} add-genesis-account $spgc_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0 + ${bin} add-genesis-account $spmaintenance_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0 done rm -rf ${workspace}/.local/gensptx @@ -216,6 +219,7 @@ function generate_sp_genesis { bls_proof=("$(${bin} keys sign "${bls_pub_key}" --from sp${i}_bls --keyring-backend test --home ${workspace}/.local/sp${i})") spapproval_addr=("$(${bin} keys show sp${i}_approval -a --keyring-backend test --home ${workspace}/.local/sp${i})") spgc_addr=("$(${bin} keys show sp${i}_gc -a --keyring-backend test --home ${workspace}/.local/sp${i})") + spmaintenance_addr=("$(${bin} keys show sp${i}_maintenance -a --keyring-backend test --home ${workspace}/.local/sp${i})") validator0Addr="$(${bin} keys show validator0 -a --keyring-backend test --home ${workspace}/.local/validator0)" # create bond storage provider tx ${bin} spgentx sp${i} ${SP_MIN_DEPOSIT_AMOUNT}${STAKING_BOND_DENOM} \ @@ -228,6 +232,7 @@ function generate_sp_genesis { --bls-proof=${bls_proof} \ --approval-address=${spapproval_addr} \ --gc-address=${spgc_addr} \ + --maintenance-address=${spmaintenance_addr} \ --keyring-backend=test \ --chain-id=${CHAIN_ID} \ --moniker="sp${i}" \ @@ -273,12 +278,14 @@ function export_sps { spseal_addr=("$(${bin} keys show sp${i}_seal -a --keyring-backend test --home ${workspace}/.local/sp${i})") spapproval_addr=("$(${bin} keys show sp${i}_approval -a --keyring-backend test --home ${workspace}/.local/sp${i})") spgc_addr=("$(${bin} keys show sp${i}_gc -a --keyring-backend test --home ${workspace}/.local/sp${i})") + spmaintenance_addr=("$(${bin} keys show sp${i}_maintenance -a --keyring-backend test --home ${workspace}/.local/sp${i})") bls_pub_key=("$(${bin} keys show sp${i}_bls --keyring-backend test --home ${workspace}/.local/sp${i} --output json | jq -r .pubkey_hex)") spoperator_priv_key=("$(echo "y" | ${bin} keys export sp${i} --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/sp${i})") spfund_priv_key=("$(echo "y" | ${bin} keys export sp${i}_fund --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/sp${i})") spseal_priv_key=("$(echo "y" | ${bin} keys export sp${i}_seal --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/sp${i})") spapproval_priv_key=("$(echo "y" | ${bin} keys export sp${i}_approval --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/sp${i})") spgc_priv_key=("$(echo "y" | ${bin} keys export sp${i}_gc --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/sp${i})") + spmaintenance_priv_key=("$(echo "y" | ${bin} keys export sp${i}_maintenance --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/sp${i})") bls_priv_key=("$(echo "y" | ${bin} keys export sp${i}_bls --unarmored-hex --unsafe --keyring-backend test --home ${workspace}/.local/sp${i})") output="${output}\"sp${i}\":{" output="${output}\"OperatorAddress\": \"${spoperator_addr}\"," @@ -286,12 +293,14 @@ function export_sps { output="${output}\"SealAddress\": \"${spseal_addr}\"," output="${output}\"ApprovalAddress\": \"${spapproval_addr}\"," output="${output}\"GcAddress\": \"${spgc_addr}\"," + output="${output}\"MaintenanceAddress\": \"${spmaintenance_addr}\"," output="${output}\"BlsPubKey\": \"${bls_pub_key}\"," output="${output}\"OperatorPrivateKey\": \"${spoperator_priv_key}\"," output="${output}\"FundingPrivateKey\": \"${spfund_priv_key}\"," output="${output}\"SealPrivateKey\": \"${spseal_priv_key}\"," output="${output}\"ApprovalPrivateKey\": \"${spapproval_priv_key}\"," output="${output}\"GcPrivateKey\": \"${spgc_priv_key}\"," + output="${output}\"MaintenancePrivateKey\": \"${spmaintenance_priv_key}\"," output="${output}\"BlsPrivateKey\": \"${bls_priv_key}\"" output="${output}}," done diff --git a/e2e/core/basesuite.go b/e2e/core/basesuite.go index 1bfcfd88e..416c6cce8 100644 --- a/e2e/core/basesuite.go +++ b/e2e/core/basesuite.go @@ -44,6 +44,7 @@ type StorageProvider struct { FundingKey keys.KeyManager ApprovalKey keys.KeyManager GcKey keys.KeyManager + MaintenanceKey keys.KeyManager BlsKey keys.KeyManager Info *sptypes.StorageProvider GlobalVirtualGroupFamilies map[uint32][]*virtualgroupmoduletypes.GlobalVirtualGroup @@ -155,6 +156,8 @@ func (s *BaseSuite) SetupSuite() { s.Require().NoError(err) sp.GcKey, err = keys.NewMnemonicKeyManager(spMnemonics.GcMnemonic) s.Require().NoError(err) + sp.MaintenanceKey, err = keys.NewMnemonicKeyManager(spMnemonics.MaintenanceMnemonic) + s.Require().NoError(err) sp.BlsKey, err = keys.NewBlsMnemonicKeyManager(s.Config.SPBLSMnemonic[i]) s.Require().NoError(err) var resp *sptypes.QueryStorageProviderByOperatorAddressResponse @@ -432,16 +435,17 @@ func (sp *StorageProvider) GetFirstGlobalVirtualGroup() (*virtualgroupmoduletype } func (s *BaseSuite) NewSpAcc() *StorageProvider { - userAccs := s.GenAndChargeAccounts(5, 1000000) + userAccs := s.GenAndChargeAccounts(6, 1000000) operatorAcc := userAccs[0] fundingAcc := userAccs[1] approvalAcc := userAccs[2] sealAcc := userAccs[3] gcAcc := userAccs[4] + maintenanceAcc := userAccs[5] blsKm := s.GenRandomBlsKeyManager() return &StorageProvider{OperatorKey: operatorAcc, SealKey: fundingAcc, - FundingKey: approvalAcc, ApprovalKey: sealAcc, GcKey: gcAcc, BlsKey: blsKm} + FundingKey: approvalAcc, ApprovalKey: sealAcc, GcKey: gcAcc, MaintenanceKey: maintenanceAcc, BlsKey: blsKm} } func (s *BaseSuite) CreateNewStorageProvider() *StorageProvider { @@ -484,7 +488,9 @@ func (s *BaseSuite) CreateNewStorageProvider() *StorageProvider { newSP.OperatorKey.GetAddr(), newSP.FundingKey.GetAddr(), newSP.SealKey.GetAddr(), newSP.ApprovalKey.GetAddr(), - newSP.GcKey.GetAddr(), description, + newSP.GcKey.GetAddr(), + newSP.MaintenanceKey.GetAddr(), + description, endpoint, deposit, newReadPrice, 10000, newStorePrice, hex.EncodeToString(newSP.BlsKey.PubKey().Bytes()), hex.EncodeToString(blsProofBz), @@ -549,7 +555,18 @@ func (s *BaseSuite) CreateNewStorageProvider() *StorageProvider { s.Require().Equal(querySPByOperatorAddrResp.StorageProvider.SealAddress, newSP.SealKey.GetAddr().String()) s.Require().Equal(querySPByOperatorAddrResp.StorageProvider.ApprovalAddress, newSP.ApprovalKey.GetAddr().String()) s.Require().Equal(querySPByOperatorAddrResp.StorageProvider.Endpoint, endpoint) + s.Require().Equal(querySPByOperatorAddrResp.StorageProvider.Status, sptypes.STATUS_IN_MAINTENANCE) newSP.Info = querySPByOperatorAddrResp.StorageProvider + + // SP need to activate itself + msg := sptypes.NewMsgUpdateStorageProviderStatus( + newSP.OperatorKey.GetAddr(), + sptypes.STATUS_IN_SERVICE, + 0, + ) + + txRes = s.SendTxBlock(newSP.OperatorKey, msg) + s.Require().Equal(txRes.Code, uint32(0)) return newSP } @@ -736,3 +753,11 @@ func (s *BaseSuite) PickStorageProviderByBucketName(bucketName string) *StorageP return s.StorageProviders[family.GlobalVirtualGroupFamily.PrimarySpId] } + +func (s *BaseSuite) ExistsSPMaintenanceRecords(addr string) (bool, error) { + resp, err := s.Client.StorageProviderMaintenanceRecordsByOperatorAddress(context.Background(), &sptypes.QueryStorageProviderMaintenanceRecordsRequest{OperatorAddress: addr}) + if err != nil { + return false, err + } + return len(resp.Records) > 0, nil +} diff --git a/e2e/core/config.go b/e2e/core/config.go index 4efae3fbd..7f815a110 100644 --- a/e2e/core/config.go +++ b/e2e/core/config.go @@ -8,11 +8,12 @@ import ( ) type SPMnemonics struct { - OperatorMnemonic string `yaml:"OperatorMnemonic"` // operator account mnemonic with enough balance - SealMnemonic string `yaml:"SealMnemonic"` // seal account mnemonic with enough balance - FundingMnemonic string `yaml:"FundingMnemonic"` // funding account mnemonic with enough balance - ApprovalMnemonic string `yaml:"ApprovalMnemonic"` // approval account mnemonic with enough balance - GcMnemonic string `yaml:"GcMnemonic"` // gc account mnemonic with enough balance + OperatorMnemonic string `yaml:"OperatorMnemonic"` // operator account mnemonic with enough balance + SealMnemonic string `yaml:"SealMnemonic"` // seal account mnemonic with enough balance + FundingMnemonic string `yaml:"FundingMnemonic"` // funding account mnemonic with enough balance + ApprovalMnemonic string `yaml:"ApprovalMnemonic"` // approval account mnemonic with enough balance + GcMnemonic string `yaml:"GcMnemonic"` // gc account mnemonic with enough balance + MaintenanceMnemonic string `yaml:"MaintenanceMnemonic"` // maintenance account mnemonic with enough balance } type Config struct { @@ -78,11 +79,12 @@ func ParseChallengerMnemonic(i int) string { // ParseSPMnemonics read the sp mnemonics from file func ParseSPMnemonics(i int) SPMnemonics { return SPMnemonics{ - OperatorMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/info", i)), - SealMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/seal_info", i)), - FundingMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/fund_info", i)), - ApprovalMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/approval_info", i)), - GcMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/gc_info", i)), + OperatorMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/info", i)), + SealMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/seal_info", i)), + FundingMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/fund_info", i)), + ApprovalMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/approval_info", i)), + GcMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/gc_info", i)), + MaintenanceMnemonic: ParseMnemonicFromFile(fmt.Sprintf("../../deployment/localup/.local/sp%d/maintenance_info", i)), } } diff --git a/e2e/tests/gensp_test.go b/e2e/tests/gensp_test.go index 0f257857e..a89d90f29 100644 --- a/e2e/tests/gensp_test.go +++ b/e2e/tests/gensp_test.go @@ -31,12 +31,13 @@ func (s *GenStorageProviderTestSuite) TestGenStorageProvider() { querySPResp, err := s.Client.StorageProviderByOperatorAddress(ctx, &querySPReq) genSP := &sptypes.StorageProvider{ - OperatorAddress: sp.OperatorKey.GetAddr().String(), - FundingAddress: sp.FundingKey.GetAddr().String(), - SealAddress: sp.SealKey.GetAddr().String(), - ApprovalAddress: sp.ApprovalKey.GetAddr().String(), - GcAddress: sp.GcKey.GetAddr().String(), - BlsKey: sp.BlsKey.PubKey().Bytes(), + OperatorAddress: sp.OperatorKey.GetAddr().String(), + FundingAddress: sp.FundingKey.GetAddr().String(), + SealAddress: sp.SealKey.GetAddr().String(), + ApprovalAddress: sp.ApprovalKey.GetAddr().String(), + GcAddress: sp.GcKey.GetAddr().String(), + MaintenanceAddress: sp.MaintenanceKey.GetAddr().String(), + BlsKey: sp.BlsKey.PubKey().Bytes(), Description: sptypes.Description{ Moniker: sp.Info.Description.Moniker, Identity: sp.Info.Description.Identity, diff --git a/e2e/tests/sp_test.go b/e2e/tests/sp_test.go index 9b447466d..1e365bce7 100644 --- a/e2e/tests/sp_test.go +++ b/e2e/tests/sp_test.go @@ -88,12 +88,13 @@ func (s *StorageProviderTestSuite) TestEditStorageProvider() { newBlsPubKeyBz, newBlsProofBz := sample.RandBlsPubKeyAndBlsProofBz() newSP := &sptypes.StorageProvider{ - OperatorAddress: prevSP.OperatorAddress, - FundingAddress: prevSP.FundingAddress, - SealAddress: prevSP.SealAddress, - ApprovalAddress: prevSP.ApprovalAddress, - GcAddress: prevSP.GcAddress, - BlsKey: newBlsPubKeyBz, + OperatorAddress: prevSP.OperatorAddress, + FundingAddress: prevSP.FundingAddress, + SealAddress: prevSP.SealAddress, + ApprovalAddress: prevSP.ApprovalAddress, + GcAddress: prevSP.GcAddress, + MaintenanceAddress: prevSP.MaintenanceAddress, + BlsKey: newBlsPubKeyBz, Description: sptypes.Description{ Moniker: "sp_test_edit", Identity: "", @@ -103,7 +104,7 @@ func (s *StorageProviderTestSuite) TestEditStorageProvider() { } msgEditSP := sptypes.NewMsgEditStorageProvider( sp.OperatorKey.GetAddr(), newSP.Endpoint, &newSP.Description, - sp.SealKey.GetAddr(), sp.ApprovalKey.GetAddr(), sp.GcKey.GetAddr(), + sp.SealKey.GetAddr(), sp.ApprovalKey.GetAddr(), sp.GcKey.GetAddr(), sp.MaintenanceKey.GetAddr(), hex.EncodeToString(newBlsPubKeyBz), hex.EncodeToString(newBlsProofBz), ) @@ -124,7 +125,7 @@ func (s *StorageProviderTestSuite) TestEditStorageProvider() { // 4. revert storage provider info msgEditSP = sptypes.NewMsgEditStorageProvider( sp.OperatorKey.GetAddr(), prevSP.Endpoint, &prevSP.Description, - sp.SealKey.GetAddr(), sp.ApprovalKey.GetAddr(), sp.GcKey.GetAddr(), + sp.SealKey.GetAddr(), sp.ApprovalKey.GetAddr(), sp.GcKey.GetAddr(), sp.MaintenanceKey.GetAddr(), hex.EncodeToString(prevSP.BlsKey), hex.EncodeToString(blsProof)) txRes = s.SendTxBlock(sp.OperatorKey, msgEditSP) @@ -330,3 +331,49 @@ CheckProposalStatus: s.T().Errorf("update params failed") } } + +func (s *StorageProviderTestSuite) TestUpdateStorageProviderStatus() { + ctx := context.Background() + var sp *core.StorageProvider + for _, tempSP := range s.BaseSuite.StorageProviders { + exists, err := s.BaseSuite.ExistsSPMaintenanceRecords(tempSP.OperatorKey.GetAddr().String()) + s.Require().NoError(err) + if !exists { + sp = tempSP + break + } + } + operatorAddr := sp.OperatorKey.GetAddr() + + // 1. query storage provider + req := sptypes.QueryStorageProviderByOperatorAddressRequest{ + OperatorAddress: operatorAddr.String(), + } + spResp, err := s.Client.StorageProviderByOperatorAddress(ctx, &req) + s.Require().NoError(err) + s.Require().Equal(sptypes.STATUS_IN_SERVICE, spResp.StorageProvider.Status) + + msg := sptypes.NewMsgUpdateStorageProviderStatus( + operatorAddr, + sptypes.STATUS_IN_MAINTENANCE, + 120, // seconds + ) + txRes := s.SendTxBlock(sp.OperatorKey, msg) + s.Require().Equal(txRes.Code, uint32(0)) + + spResp, err = s.Client.StorageProviderByOperatorAddress(ctx, &req) + s.Require().NoError(err) + s.Require().Equal(sptypes.STATUS_IN_MAINTENANCE, spResp.StorageProvider.Status) + + msg = sptypes.NewMsgUpdateStorageProviderStatus( + operatorAddr, + sptypes.STATUS_IN_SERVICE, + 0, + ) + + txRes = s.SendTxBlock(sp.OperatorKey, msg) + s.Require().Equal(txRes.Code, uint32(0)) + spResp, err = s.Client.StorageProviderByOperatorAddress(ctx, &req) + s.Require().NoError(err) + s.Require().Equal(sptypes.STATUS_IN_SERVICE, spResp.StorageProvider.Status) +} diff --git a/e2e/tests/storage_test.go b/e2e/tests/storage_test.go index 8c491658e..ce885ebc1 100644 --- a/e2e/tests/storage_test.go +++ b/e2e/tests/storage_test.go @@ -11,6 +11,8 @@ import ( "testing" "time" + sptypes "github.com/bnb-chain/greenfield/x/sp/types" + sdkmath "cosmossdk.io/math" ctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -1829,3 +1831,174 @@ CheckProposalStatus: s.T().Errorf("update params failed") } } + +// when a sp turn into maintenance mode, it should be able to create bucket and object by its testing account. +func (s *StorageTestSuite) TestMaintenanceSPCreateBucketAndObject() { + var err error + ctx := context.Background() + var sp *core.StorageProvider + for _, tempSP := range s.BaseSuite.StorageProviders { + exists, err := s.BaseSuite.ExistsSPMaintenanceRecords(tempSP.OperatorKey.GetAddr().String()) + s.Require().NoError(err) + if !exists { + sp = tempSP + break + } + } + spAddr := sp.OperatorKey.GetAddr() + spMaintenanceAddr := sp.MaintenanceKey.GetAddr() + + req := sptypes.QueryStorageProviderByOperatorAddressRequest{ + OperatorAddress: spAddr.String(), + } + spResp, err := s.Client.StorageProviderByOperatorAddress(ctx, &req) + s.Require().NoError(err) + s.Require().Equal(sptypes.STATUS_IN_SERVICE, spResp.StorageProvider.Status) + + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + + msg := sptypes.NewMsgUpdateStorageProviderStatus( + spAddr, + sptypes.STATUS_IN_MAINTENANCE, + 1200, + ) + txRes := s.SendTxBlock(sp.OperatorKey, msg) + s.Require().Equal(txRes.Code, uint32(0)) + + spResp, err = s.Client.StorageProviderByOperatorAddress(ctx, &req) + s.Require().NoError(err) + s.Require().Equal(sptypes.STATUS_IN_MAINTENANCE, spResp.StorageProvider.Status) + + // create a bucket + bucketName := storageutils.GenRandomBucketName() + msgCreateBucket := storagetypes.NewMsgCreateBucket( + spMaintenanceAddr, bucketName, storagetypes.VISIBILITY_TYPE_PRIVATE, 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(sp.MaintenanceKey, msgCreateBucket) + + // HeadBucket + 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, spMaintenanceAddr.String()) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.GlobalVirtualGroupFamilyId, gvg.FamilyId) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.Visibility, storagetypes.VISIBILITY_TYPE_PRIVATE) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.SourceType, storagetypes.SOURCE_TYPE_ORIGIN) + + // CreateObject + objectName := storageutils.GenRandomObjectName() + // create test buffer + var buffer bytes.Buffer + // 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(spMaintenanceAddr, bucketName, objectName, uint64(payloadSize), storagetypes.VISIBILITY_TYPE_PRIVATE, expectChecksum, contextType, storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil) + msgCreateObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateObject.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxBlock(sp.MaintenanceKey, msgCreateObject) + + // HeadObject + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectName, objectName) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.BucketName, bucketName) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.PayloadSize, uint64(payloadSize)) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.Visibility, storagetypes.VISIBILITY_TYPE_PRIVATE) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_CREATED) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.Owner, spMaintenanceAddr.String()) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.Checksums, expectChecksum) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.SourceType, storagetypes.SOURCE_TYPE_ORIGIN) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.RedundancyType, storagetypes.REDUNDANCY_EC_TYPE) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ContentType, contextType) + + // SealObject + gvgId := gvg.Id + msgSealObject := storagetypes.NewMsgSealObject(sp.SealKey.GetAddr(), bucketName, objectName, gvg.Id, nil) + secondarySigs := make([][]byte, 0) + secondarySPBlsPubKeys := make([]bls.PublicKey, 0) + blsSignHash := storagetypes.NewSecondarySpSealObjectSignDoc(s.GetChainID(), gvgId, queryHeadObjectResponse.ObjectInfo.Id, storagetypes.GenerateHash(queryHeadObjectResponse.ObjectInfo.Checksums[:])).GetBlsSignHash() + // every secondary sp signs the checksums + for _, spID := range gvg.SecondarySpIds { + sig, err := core.BlsSignAndVerify(s.StorageProviders[spID], blsSignHash) + s.Require().NoError(err) + secondarySigs = append(secondarySigs, sig) + pk, err := bls.PublicKeyFromBytes(s.StorageProviders[spID].BlsKey.PubKey().Bytes()) + s.Require().NoError(err) + secondarySPBlsPubKeys = append(secondarySPBlsPubKeys, pk) + } + aggBlsSig, err := core.BlsAggregateAndVerify(secondarySPBlsPubKeys, blsSignHash, secondarySigs) + s.Require().NoError(err) + msgSealObject.SecondarySpBlsAggSignatures = aggBlsSig + s.T().Logf("msg %s", msgSealObject.String()) + s.SendTxBlock(sp.SealKey, msgSealObject) + + // ListBuckets + queryListBucketsRequest := storagetypes.QueryListBucketsRequest{} + queryListBucketResponse, err := s.Client.ListBuckets(ctx, &queryListBucketsRequest) + s.Require().NoError(err) + s.Require().Greater(len(queryListBucketResponse.BucketInfos), 0) + + // ListObject + queryListObjectsRequest := storagetypes.QueryListObjectsRequest{ + BucketName: bucketName, + } + queryListObjectsResponse, err := s.Client.ListObjects(ctx, &queryListObjectsRequest) + s.Require().NoError(err) + s.Require().Equal(len(queryListObjectsResponse.ObjectInfos), 1) + s.Require().Equal(queryListObjectsResponse.ObjectInfos[0].ObjectName, objectName) + + // UpdateObjectInfo + updateObjectInfo := storagetypes.NewMsgUpdateObjectInfo( + spMaintenanceAddr, bucketName, objectName, storagetypes.VISIBILITY_TYPE_INHERIT) + s.Require().NoError(err) + s.SendTxBlock(sp.MaintenanceKey, updateObjectInfo) + s.Require().NoError(err) + + // verify modified objectinfo + // head object + queryHeadObjectAfterUpdateObjectResponse, err := s.Client.HeadObject(context.Background(), &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.Visibility, storagetypes.VISIBILITY_TYPE_INHERIT) + + // verify HeadObjectById + queryHeadObjectAfterUpdateObjectResponse, err = s.Client.HeadObjectById(context.Background(), &storagetypes.QueryHeadObjectByIdRequest{ObjectId: queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.Id.String()}) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.Visibility, storagetypes.VISIBILITY_TYPE_INHERIT) + s.Require().Equal(queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.ObjectName, objectName) + + // DeleteObject + msgDeleteObject := storagetypes.NewMsgDeleteObject(spMaintenanceAddr, bucketName, objectName) + s.SendTxBlock(sp.MaintenanceKey, msgDeleteObject) + + // DeleteBucket + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(spMaintenanceAddr, bucketName) + s.SendTxBlock(sp.MaintenanceKey, msgDeleteBucket) + + // revert back + msg = sptypes.NewMsgUpdateStorageProviderStatus( + spAddr, + sptypes.STATUS_IN_SERVICE, + 0, + ) + txRes = s.SendTxBlock(sp.OperatorKey, msg) + s.Require().Equal(txRes.Code, uint32(0)) + spResp, err = s.Client.StorageProviderByOperatorAddress(ctx, &req) + s.Require().NoError(err) + s.Require().Equal(sptypes.STATUS_IN_SERVICE, spResp.StorageProvider.Status) +} diff --git a/go.mod b/go.mod index 5e9ff92eb..4962c97e1 100644 --- a/go.mod +++ b/go.mod @@ -177,7 +177,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.3.0.20230807083232-9a0d3b09e97f + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230808064832-8b1e6d51ea69 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 9d042109b..fbeccfba4 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.3.0.20230807083232-9a0d3b09e97f h1:3rBKrvNg2PXJUgkyZMgf2x8l6/7UWD1qGUgOTL7WmAk= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230807083232-9a0d3b09e97f/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230808064832-8b1e6d51ea69 h1:977mfnEuBR7Rnoa2r/qqNccXP4FhgciuC38tnP7Ez0Q= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230808064832-8b1e6d51ea69/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas= 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/sp/events.proto b/proto/greenfield/sp/events.proto index 86b07975a..4a2784f08 100644 --- a/proto/greenfield/sp/events.proto +++ b/proto/greenfield/sp/events.proto @@ -22,16 +22,18 @@ message EventCreateStorageProvider { string approval_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // gc_address defines one of the storage provider's accounts which is used for gc purpose string gc_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + string maintenance_address = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // endpoint is the domain name address used by SP to provide storage services - string endpoint = 7; + string endpoint = 8; // total_deposit is the token coin that the storage provider deposit to the storage module - cosmos.base.v1beta1.Coin total_deposit = 8; + cosmos.base.v1beta1.Coin total_deposit = 9; // status defines the status of the storage provider - Status status = 9; + Status status = 10; // description defines the description terms for the storage provider - Description description = 10 [(gogoproto.nullable) = false]; + Description description = 11 [(gogoproto.nullable) = false]; // bls_key defines the bls pub key owned by storage provider used when sealing object and completing migration - string bls_key = 11; + string bls_key = 12; } // EventEditStorageProvider is emitted when SP's metadata is edited. @@ -50,8 +52,10 @@ message EventEditStorageProvider { string approval_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // gc_address defines one of the storage provider's accounts which is used for gc purpose string gc_address = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + string maintenance_address = 8 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // bls_key defines the bls pub key owned by storage provider used when sealing object - string bls_key = 8; + string bls_key = 9; } // EventDeposit is emitted when sp deposit tokens. @@ -95,3 +99,15 @@ message EventSecondarySpStorePriceUpdate { (gogoproto.nullable) = false ]; } + +// EventUpdateStorageProviderStatus is emitted when the SP update its status successfully +message EventUpdateStorageProviderStatus { + // sp_id defines the identifier of storage provider which generated on-chain + uint32 sp_id = 1; + // sp_address is the operator address of the storage provider + string sp_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // pre status + string pre_status = 3; + // new status + string new_status = 4; +} diff --git a/proto/greenfield/sp/params.proto b/proto/greenfield/sp/params.proto index 1b4504d10..2d62ae111 100644 --- a/proto/greenfield/sp/params.proto +++ b/proto/greenfield/sp/params.proto @@ -25,4 +25,10 @@ message Params { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + // previous blocks that be traced back to for maintenance_records + int64 num_of_historical_blocks_for_maintenance_records = 4 [(gogoproto.moretags) = "yaml:\"num_of_historical_blocks_for_maintenance_records\""]; + // the max duration that a SP can be in_maintenance within num_of_historical_blocks_for_maintenance_records + int64 maintenance_duration_quota = 5 [(gogoproto.moretags) = "yaml:\"maintenance_duration_quota\""]; + // the number of blocks to be wait for sp to be in maintenance mode again if already requested + int64 num_of_lockup_blocks_for_maintenance = 6 [(gogoproto.moretags) = "yaml:\"num_of_lockup_blocks_for_maintenance\""]; } diff --git a/proto/greenfield/sp/query.proto b/proto/greenfield/sp/query.proto index 10f5f2d22..0663c5c75 100644 --- a/proto/greenfield/sp/query.proto +++ b/proto/greenfield/sp/query.proto @@ -45,6 +45,11 @@ service Query { rpc StorageProviderByOperatorAddress(QueryStorageProviderByOperatorAddressRequest) returns (QueryStorageProviderByOperatorAddressResponse) { option (google.api.http).get = "/greenfield/sp/storage_provider_by_operator_address"; } + + // Queries a StorageProvider by specify operator address. + rpc StorageProviderMaintenanceRecordsByOperatorAddress(QueryStorageProviderMaintenanceRecordsRequest) returns (QueryStorageProviderMaintenanceRecordsResponse) { + option (google.api.http).get = "/greenfield/sp/storage_provider_maintenance_records_by_operator_address"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -104,3 +109,11 @@ message QueryStorageProviderByOperatorAddressRequest { message QueryStorageProviderByOperatorAddressResponse { StorageProvider storageProvider = 1; } + +message QueryStorageProviderMaintenanceRecordsRequest { + string operator_address = 1; +} + +message QueryStorageProviderMaintenanceRecordsResponse { + repeated MaintenanceRecord records = 1; +} diff --git a/proto/greenfield/sp/tx.proto b/proto/greenfield/sp/tx.proto index 893548819..eae38b85b 100644 --- a/proto/greenfield/sp/tx.proto +++ b/proto/greenfield/sp/tx.proto @@ -19,6 +19,7 @@ service Msg { rpc Deposit(MsgDeposit) returns (MsgDepositResponse); rpc EditStorageProvider(MsgEditStorageProvider) returns (MsgEditStorageProviderResponse); rpc UpdateSpStoragePrice(MsgUpdateSpStoragePrice) returns (MsgUpdateSpStoragePriceResponse); + rpc UpdateSpStatus(MsgUpdateStorageProviderStatus) returns (MsgUpdateStorageProviderStatusResponse); // UpdateParams defines a governance operation for updating the x/sp module parameters. // The authority is defined in the keeper. @@ -46,27 +47,29 @@ message MsgCreateStorageProvider { string approval_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // gc_address defines one of the storage provider's accounts which is used for gc purpose. string gc_address = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + string maintenance_address = 8 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // endpoint is the service address of the storage provider - string endpoint = 8; + string endpoint = 9; // deposit define the deposit token - cosmos.base.v1beta1.Coin deposit = 9 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin deposit = 10 [(gogoproto.nullable) = false]; // read price, in bnb wei per charge byte - string read_price = 10 [ + string read_price = 11 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // free read quota, in byte - uint64 free_read_quota = 11; + uint64 free_read_quota = 12; // store price, in bnb wei per charge byte - string store_price = 12 [ + string store_price = 13 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // bls_key defines the bls pub key of the Storage provider for sealing object - string bls_key = 13; - string bls_proof = 14; + string bls_key = 14; + string bls_proof = 15; } // MsgCreateStorageProviderResponse defines the Msg/CreateStorageProvider response type. @@ -101,9 +104,11 @@ message MsgEditStorageProvider { string approval_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // gc_address defines one of the storage provider's accounts which is used for gc purpose string gc_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + string maintenance_address = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // bls_key defines the bls pub key of the Storage provider for sealing object - string bls_key = 7; - string bls_proof = 8; + string bls_key = 8; + string bls_proof = 9; } // MsgEditStorageProviderResponse defines the Msg/EditStorageProvider response type. @@ -148,3 +153,17 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. message MsgUpdateParamsResponse {} + +// MsgUpdateStorageProviderStatus is used to update the status of a SP by itself +message MsgUpdateStorageProviderStatus { + option (cosmos.msg.v1.signer) = "sp_address"; + // sp_address defines the operator address + string sp_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // status defines the desired status be update to. + Status status = 2; + // duration defines the time requested in desired status + int64 duration = 3; +} + +// MsgUpdateStorageProviderStatusResponse defines the MsgUpdateStorageProviderStatus response type. +message MsgUpdateStorageProviderStatusResponse {} diff --git a/proto/greenfield/sp/types.proto b/proto/greenfield/sp/types.proto index 7d780d30c..9715e2ca6 100644 --- a/proto/greenfield/sp/types.proto +++ b/proto/greenfield/sp/types.proto @@ -28,7 +28,7 @@ enum Status { STATUS_IN_SERVICE = 0; STATUS_IN_JAILED = 1; STATUS_GRACEFUL_EXITING = 2; - STATUS_OUT_OF_SERVICE = 3; + STATUS_IN_MAINTENANCE = 3; } // StorageProvider defines the meta info of storage provider @@ -45,20 +45,22 @@ message StorageProvider { string approval_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // gc_address defines one of the storage provider's accounts which is used for gc purpose. string gc_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + string maintenance_address = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // total_deposit defines the number of tokens deposited by this storage provider for staking. - string total_deposit = 7 [ + string total_deposit = 8 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // status defines the current service status of this storage provider - Status status = 8; + Status status = 9; // endpoint define the storage provider's network service address - string endpoint = 9; + string endpoint = 10; // description defines the description terms for the storage provider. - Description description = 10 [(gogoproto.nullable) = false]; + Description description = 11 [(gogoproto.nullable) = false]; // bls_key defines the bls pub key of the Storage provider for sealing object and completing migration - bytes bls_key = 11; + bytes bls_key = 12; } message RewardInfo { @@ -99,3 +101,19 @@ message SecondarySpStorePrice { (gogoproto.nullable) = false ]; } + +message SpMaintenanceStats { + repeated MaintenanceRecord records = 1; +} + +// MaintenanceRecord is to keep track of every time a sp request to be in Maintenance mode +message MaintenanceRecord { + // block height that request to be in Maintenance mode + int64 height = 1; + // request duration + int64 request_duration = 2; + // actual duration + int64 actual_duration = 3; + // request timestamp + int64 request_at = 4; +} diff --git a/sdk/client/gnfd_tm.go b/sdk/client/gnfd_tm.go index a3558e039..c8a82bab7 100644 --- a/sdk/client/gnfd_tm.go +++ b/sdk/client/gnfd_tm.go @@ -52,6 +52,7 @@ func (c *GreenfieldClient) GetStatus(ctx context.Context) (*ctypes.ResultStatus, func (c *GreenfieldClient) BroadcastVote(ctx context.Context, vote votepool.Vote) error { _, err := c.tendermintClient.BroadcastVote(ctx, vote) + return err } diff --git a/swagger/static/swagger.yaml b/swagger/static/swagger.yaml index a612b7c14..301da9331 100644 --- a/swagger/static/swagger.yaml +++ b/swagger/static/swagger.yaml @@ -1704,6 +1704,24 @@ paths: title: >- the ratio of the store price of the secondary sp to the primary sp, the default value is 80% + num_of_historical_blocks_for_maintenance_records: + type: string + format: int64 + title: >- + previous blocks that be traced back to for + maintenance_records + maintenance_duration_quota: + type: string + format: int64 + title: >- + the max duration that a SP can be in_maintenance within + num_of_historical_blocks_for_maintenance_records + num_of_lockup_blocks_for_maintenance: + type: string + format: int64 + title: >- + the number of blocks to be wait for sp to be in + maintenance mode again if already requested description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -1777,6 +1795,12 @@ paths: description: >- gc_address defines one of the storage provider's accounts which is used for gc purpose. + maintenance_address: + type: string + title: >- + maintenance_address defines one of the storage provider's + accounts which is used for testing while in maintenance + mode total_deposit: type: string description: >- @@ -1791,7 +1815,7 @@ paths: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. endpoint: @@ -1862,6 +1886,69 @@ paths: type: string tags: - Query + /greenfield/sp/storage_provider_maintenance_records_by_operator_address: + get: + summary: Queries a StorageProvider by specify operator address. + operationId: StorageProviderMaintenanceRecordsByOperatorAddress + responses: + '200': + description: A successful response. + schema: + type: object + properties: + records: + type: array + items: + type: object + properties: + height: + type: string + format: int64 + title: block height that request to be in Maintenance mode + request_duration: + type: string + format: int64 + title: request duration + actual_duration: + type: string + format: int64 + title: actual duration + request_at: + type: string + format: int64 + title: request timestamp + title: >- + MaintenanceRecord is to keep track of every time a sp + request to be in Maintenance mode + 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: operator_address + in: query + required: false + type: string + tags: + - Query /greenfield/storage_provider/{id}: get: summary: Queries a storage provider with specify id @@ -1908,6 +1995,12 @@ paths: description: >- gc_address defines one of the storage provider's accounts which is used for gc purpose. + maintenance_address: + type: string + title: >- + maintenance_address defines one of the storage provider's + accounts which is used for testing while in maintenance + mode total_deposit: type: string description: >- @@ -1922,7 +2015,7 @@ paths: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. endpoint: @@ -2042,6 +2135,12 @@ paths: description: >- gc_address defines one of the storage provider's accounts which is used for gc purpose. + maintenance_address: + type: string + title: >- + maintenance_address defines one of the storage + provider's accounts which is used for testing while in + maintenance mode total_deposit: type: string description: >- @@ -2056,7 +2155,7 @@ paths: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. endpoint: @@ -32604,6 +32703,28 @@ definitions: type: string description: details define other optional details. description: Description defines a storage provider description. + greenfield.sp.MaintenanceRecord: + type: object + properties: + height: + type: string + format: int64 + title: block height that request to be in Maintenance mode + request_duration: + type: string + format: int64 + title: request duration + actual_duration: + type: string + format: int64 + title: actual duration + request_at: + type: string + format: int64 + title: request timestamp + title: >- + MaintenanceRecord is to keep track of every time a sp request to be in + Maintenance mode greenfield.sp.Params: type: object properties: @@ -32618,6 +32739,22 @@ definitions: title: >- the ratio of the store price of the secondary sp to the primary sp, the default value is 80% + num_of_historical_blocks_for_maintenance_records: + type: string + format: int64 + title: previous blocks that be traced back to for maintenance_records + maintenance_duration_quota: + type: string + format: int64 + title: >- + the max duration that a SP can be in_maintenance within + num_of_historical_blocks_for_maintenance_records + num_of_lockup_blocks_for_maintenance: + type: string + format: int64 + title: >- + the number of blocks to be wait for sp to be in maintenance mode again + if already requested description: Params defines the parameters for the module. greenfield.sp.QueryGetSecondarySpStorePriceByTimeResponse: type: object @@ -32678,6 +32815,22 @@ definitions: title: >- the ratio of the store price of the secondary sp to the primary sp, the default value is 80% + num_of_historical_blocks_for_maintenance_records: + type: string + format: int64 + title: previous blocks that be traced back to for maintenance_records + maintenance_duration_quota: + type: string + format: int64 + title: >- + the max duration that a SP can be in_maintenance within + num_of_historical_blocks_for_maintenance_records + num_of_lockup_blocks_for_maintenance: + type: string + format: int64 + title: >- + the number of blocks to be wait for sp to be in maintenance mode + again if already requested description: QueryParamsResponse is response type for the Query/Params RPC method. greenfield.sp.QueryStorageProviderByOperatorAddressResponse: type: object @@ -32716,6 +32869,11 @@ definitions: description: >- gc_address defines one of the storage provider's accounts which is used for gc purpose. + maintenance_address: + type: string + title: >- + maintenance_address defines one of the storage provider's accounts + which is used for testing while in maintenance mode total_deposit: type: string description: >- @@ -32728,7 +32886,7 @@ definitions: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. endpoint: @@ -32766,6 +32924,33 @@ definitions: bls_key defines the bls pub key of the Storage provider for sealing object and completing migration title: StorageProvider defines the meta info of storage provider + greenfield.sp.QueryStorageProviderMaintenanceRecordsResponse: + type: object + properties: + records: + type: array + items: + type: object + properties: + height: + type: string + format: int64 + title: block height that request to be in Maintenance mode + request_duration: + type: string + format: int64 + title: request duration + actual_duration: + type: string + format: int64 + title: actual duration + request_at: + type: string + format: int64 + title: request timestamp + title: >- + MaintenanceRecord is to keep track of every time a sp request to be + in Maintenance mode greenfield.sp.QueryStorageProviderResponse: type: object properties: @@ -32803,6 +32988,11 @@ definitions: description: >- gc_address defines one of the storage provider's accounts which is used for gc purpose. + maintenance_address: + type: string + title: >- + maintenance_address defines one of the storage provider's accounts + which is used for testing while in maintenance mode total_deposit: type: string description: >- @@ -32815,7 +33005,7 @@ definitions: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. endpoint: @@ -32892,6 +33082,11 @@ definitions: description: >- gc_address defines one of the storage provider's accounts which is used for gc purpose. + maintenance_address: + type: string + title: >- + maintenance_address defines one of the storage provider's + accounts which is used for testing while in maintenance mode total_deposit: type: string description: >- @@ -32906,7 +33101,7 @@ definitions: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. endpoint: @@ -33004,7 +33199,7 @@ definitions: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. greenfield.sp.StorageProvider: @@ -33039,6 +33234,11 @@ definitions: description: >- gc_address defines one of the storage provider's accounts which is used for gc purpose. + maintenance_address: + type: string + title: >- + maintenance_address defines one of the storage provider's accounts + which is used for testing while in maintenance mode total_deposit: type: string description: >- @@ -33051,7 +33251,7 @@ definitions: - STATUS_IN_SERVICE - STATUS_IN_JAILED - STATUS_GRACEFUL_EXITING - - STATUS_OUT_OF_SERVICE + - STATUS_IN_MAINTENANCE default: STATUS_IN_SERVICE description: Status is the status of a storage provider. endpoint: diff --git a/x/sp/abci.go b/x/sp/abci.go new file mode 100644 index 000000000..0dbf50802 --- /dev/null +++ b/x/sp/abci.go @@ -0,0 +1,13 @@ +package sp + +import ( + "github.com/bnb-chain/greenfield/x/sp/keeper" + "github.com/bnb-chain/greenfield/x/sp/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func EndBlocker(ctx sdk.Context, k keeper.Keeper) { + if ctx.BlockHeight()%types.MaintenanceRecordsGCFrequencyInBlocks == 0 { + k.ForceUpdateMaintenanceRecords(ctx) + } +} diff --git a/x/sp/client/cli/flags.go b/x/sp/client/cli/flags.go index 011157f83..7ac64d3ce 100644 --- a/x/sp/client/cli/flags.go +++ b/x/sp/client/cli/flags.go @@ -1,18 +1,19 @@ package cli const ( - FlagSpendLimit = "spend-limit" - FlagSpAddress = "SPAddress" - FlagOperatorAddress = "operator-address" - FlagFundingAddress = "funding-address" - FlagSealAddress = "seal-address" - FlagBlsPubKey = "bls-pub-key" - FlagBlsProof = "bls-proof" - FlagApprovalAddress = "approval-address" - FlagGcAddress = "gc-address" - FlagCreator = "creator" - FlagExpiration = "expiration" - FlagEndpoint = "endpoint" + FlagSpendLimit = "spend-limit" + FlagSpAddress = "SPAddress" + FlagOperatorAddress = "operator-address" + FlagFundingAddress = "funding-address" + FlagSealAddress = "seal-address" + FlagBlsPubKey = "bls-pub-key" + FlagBlsProof = "bls-proof" + FlagApprovalAddress = "approval-address" + FlagGcAddress = "gc-address" + FlagMaintenanceAddress = "maintenance-address" + FlagCreator = "creator" + FlagExpiration = "expiration" + FlagEndpoint = "endpoint" FlagMoniker = "moniker" FlagEditMoniker = "new-moniker" @@ -28,4 +29,6 @@ const ( FlagFreeReadQuota = "free-read-quota" FlagSecurityContact = "security-contact" + + FlagDuration = "duration" ) diff --git a/x/sp/client/cli/query.go b/x/sp/client/cli/query.go index 2bc625bf7..0f76696a0 100644 --- a/x/sp/client/cli/query.go +++ b/x/sp/client/cli/query.go @@ -28,6 +28,7 @@ func GetQueryCmd() *cobra.Command { CmdStorageProviders(), CmdStorageProvider(), CmdStorageProviderByOperatorAddress(), + CmdMaintenanceRecordsBySPOperatorAddress(), ) // this line is used by starport scaffolding # 1 @@ -137,3 +138,39 @@ func CmdStorageProviderByOperatorAddress() *cobra.Command { return cmd } + +func CmdMaintenanceRecordsBySPOperatorAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "maintenance-records-by-operator-address [operator address]", + Short: "Query storage provider maintenance records with specify operator address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqSpAddr := args[0] + + operatorAddr, err := sdk.AccAddressFromHexUnsafe(reqSpAddr) + if err != nil { + return err + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + params := &types.QueryStorageProviderMaintenanceRecordsRequest{ + OperatorAddress: operatorAddr.String(), + } + + res, err := queryClient.StorageProviderMaintenanceRecordsByOperatorAddress(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/sp/client/cli/tx.go b/x/sp/client/cli/tx.go index 7f1ebb6c3..70213b7eb 100644 --- a/x/sp/client/cli/tx.go +++ b/x/sp/client/cli/tx.go @@ -36,6 +36,7 @@ func GetTxCmd() *cobra.Command { CmdDeposit(), CmdEditStorageProvider(), CmdGrantDepositAuthorization(), + CmdUpdateStorageProviderStatus(), ) // this line is used by starport scaffolding # 1 @@ -69,6 +70,7 @@ Where create_storagep_provider.json contains: "seal_address": "0xbBD6cD73Cd376c3Dda20de0c4CBD8Fb1Bca2410D", "approval_address": "0xdCE01bfaBc7c9c0865bCCeF872493B4BE3b343E8", "gc_address": "0x0a1C8982C619B93bA7100411Fc58382306ab431b", + "maintenance_address": "0xbE03316B1D7c3FCB69136e47e02442d6Fb3396dB", "endpoint": "https://sp0.greenfield.io", "deposit": { "denom": "BNB", @@ -207,6 +209,19 @@ func CmdEditStorageProvider() *cobra.Command { } } + // maintenance address + maintenanceAddressStr, err := cmd.Flags().GetString(FlagMaintenanceAddress) + if err != nil { + return err + } + maintenanceAddress := sdk.AccAddress{} + if maintenanceAddressStr != "" { + maintenanceAddress, err = sdk.AccAddressFromHexUnsafe(maintenanceAddressStr) + if err != nil { + return err + } + } + // bls key blsPubKey, err := cmd.Flags().GetString(FlagBlsPubKey) if err != nil { @@ -231,6 +246,7 @@ func CmdEditStorageProvider() *cobra.Command { sealAddress, approvalAddress, gcAddress, + maintenanceAddress, blsPubKey, blsProof, ) @@ -254,6 +270,7 @@ func CmdEditStorageProvider() *cobra.Command { cmd.Flags().String(FlagBlsProof, "", "The Bls signature of storage provider signing the bls pub key") cmd.Flags().String(FlagApprovalAddress, "", "The approval address of storage provider") cmd.Flags().String(FlagGcAddress, "", "The gc address of storage provider") + cmd.Flags().String(FlagMaintenanceAddress, "", "The maintenance address of storage provider") return cmd } @@ -418,6 +435,7 @@ func CreateStorageProviderMsgFlagSet(ipDefault string) (fs *flag.FlagSet, defaul fsCreateStorageProvider.String(FlagBlsProof, "", "The Bls signature of storage provider signing the bls pub key") fsCreateStorageProvider.String(FlagApprovalAddress, "", "The approval address of storage provider") fsCreateStorageProvider.String(FlagGcAddress, "", "The gc address of storage provider") + fsCreateStorageProvider.String(FlagMaintenanceAddress, "", "The maintenance address of storage provider") fsCreateStorageProvider.String(FlagEndpoint, "", "The storage provider's endpoint") @@ -441,13 +459,14 @@ type TxCreateStorageProviderConfig struct { SecurityContact string Details string - SpAddress sdk.AccAddress - FundingAddress sdk.AccAddress - SealAddress sdk.AccAddress - BlsPubKey string - BlsProof string - ApprovalAddress sdk.AccAddress - GcAddress sdk.AccAddress + SpAddress sdk.AccAddress + FundingAddress sdk.AccAddress + SealAddress sdk.AccAddress + BlsPubKey string + BlsProof string + ApprovalAddress sdk.AccAddress + GcAddress sdk.AccAddress + MaintenanceAddress sdk.AccAddress Endpoint string Deposit string @@ -576,6 +595,17 @@ func PrepareConfigForTxCreateStorageProvider(flagSet *flag.FlagSet) (TxCreateSto } c.GcAddress = addr + // maintenance address + maintenanceAddress, err := flagSet.GetString(FlagMaintenanceAddress) + if err != nil { + return c, err + } + addr, err = sdk.AccAddressFromHexUnsafe(maintenanceAddress) + if err != nil { + return c, err + } + c.MaintenanceAddress = addr + // Endpoint endpoint, err := flagSet.GetString(FlagEndpoint) if err != nil { @@ -629,7 +659,7 @@ func BuildCreateStorageProviderMsg(config TxCreateStorageProviderConfig, txBldr msg, err := types.NewMsgCreateStorageProvider( config.Creator, config.SpAddress, config.FundingAddress, - config.SealAddress, config.ApprovalAddress, config.GcAddress, description, + config.SealAddress, config.ApprovalAddress, config.GcAddress, config.MaintenanceAddress, description, config.Endpoint, deposit, config.ReadPrice, config.FreeReadQuota, config.StorePrice, config.BlsPubKey, config.BlsProof, ) @@ -639,3 +669,49 @@ func BuildCreateStorageProviderMsg(config TxCreateStorageProviderConfig, txBldr return txBldr, msg, nil } + +func CmdUpdateStorageProviderStatus() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-status [sp-address] [new-status] --duration", + Short: "Update status of a storage provider", + Long: strings.TrimSpace( + fmt.Sprintf(`update the storage provider status between STATUS_IN_SERVICE and STATUS_IN_MAINTENANCE, need to provide the maintenance duration in second if status is to STATUS_IN_MAINTENANCE. + +Examples: + $ %s tx %s update-status 0x.... STATUS_IN_MAINTENANCE --duration 21600 + `, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + spAddress, err := sdk.AccAddressFromHexUnsafe(args[0]) + if err != nil { + return err + } + newStatus := args[1] + duration, err := cmd.Flags().GetInt64(FlagDuration) + if err != nil { + return err + } + var msg sdk.Msg + switch newStatus { + case types.STATUS_IN_SERVICE.String(): + msg = types.NewMsgUpdateStorageProviderStatus(spAddress, types.STATUS_IN_SERVICE, 0) + case types.STATUS_IN_MAINTENANCE.String(): + msg = types.NewMsgUpdateStorageProviderStatus(spAddress, types.STATUS_IN_MAINTENANCE, duration) + default: + return fmt.Errorf("status %s is not expected\n", newStatus) + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().Int64(FlagDuration, 0, "maintenance duration requested by a SP") + return cmd +} diff --git a/x/sp/keeper/grpc_query.go b/x/sp/keeper/grpc_query.go index dba3f20cd..413db357b 100644 --- a/x/sp/keeper/grpc_query.go +++ b/x/sp/keeper/grpc_query.go @@ -119,3 +119,23 @@ func (k Keeper) StorageProviderByOperatorAddress(goCtx context.Context, req *typ } return &types.QueryStorageProviderByOperatorAddressResponse{StorageProvider: sp}, nil } + +func (k Keeper) StorageProviderMaintenanceRecordsByOperatorAddress(goCtx context.Context, req *types.QueryStorageProviderMaintenanceRecordsRequest) (*types.QueryStorageProviderMaintenanceRecordsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + operatorAddr, err := sdk.AccAddressFromHexUnsafe(req.OperatorAddress) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid primary storage provider address") + } + records := make([]*types.MaintenanceRecord, 0) + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetStorageProviderMaintenanceRecordsKey(operatorAddr)) + if bz != nil { + stats := &types.SpMaintenanceStats{} + k.cdc.MustUnmarshal(bz, stats) + records = stats.Records + } + return &types.QueryStorageProviderMaintenanceRecordsResponse{Records: records}, nil +} diff --git a/x/sp/keeper/msg_server.go b/x/sp/keeper/msg_server.go index 74c0c42af..ad2199e54 100644 --- a/x/sp/keeper/msg_server.go +++ b/x/sp/keeper/msg_server.go @@ -46,6 +46,7 @@ func (k msgServer) CreateStorageProvider(goCtx context.Context, msg *types.MsgCr sealAcc := sdk.MustAccAddressFromHex(msg.SealAddress) approvalAcc := sdk.MustAccAddressFromHex(msg.ApprovalAddress) gcAcc := sdk.MustAccAddressFromHex(msg.GcAddress) + maintenanceAcc := sdk.MustAccAddressFromHex(msg.MaintenanceAddress) signers := msg.GetSigners() if ctx.BlockHeight() == 0 { @@ -123,12 +124,17 @@ func (k msgServer) CreateStorageProvider(goCtx context.Context, msg *types.MsgCr return nil, err } - sp, err := types.NewStorageProvider(k.GetNextSpID(ctx), spAcc, fundingAcc, sealAcc, approvalAcc, gcAcc, + sp, err := types.NewStorageProvider(k.GetNextSpID(ctx), spAcc, fundingAcc, sealAcc, approvalAcc, gcAcc, maintenanceAcc, msg.Deposit.Amount, msg.Endpoint, msg.Description, msg.BlsKey) if err != nil { return nil, err } + // external sp default to be in STATUS_IN_MAINTENANCE after the proposal passed + if ctx.BlockHeight() != 0 { + sp.Status = types.STATUS_IN_MAINTENANCE + } + k.SetStorageProvider(ctx, &sp) k.SetStorageProviderByOperatorAddr(ctx, &sp) k.SetStorageProviderByApprovalAddr(ctx, &sp) @@ -152,17 +158,18 @@ func (k msgServer) CreateStorageProvider(goCtx context.Context, msg *types.MsgCr } if err = ctx.EventManager().EmitTypedEvents(&types.EventCreateStorageProvider{ - SpId: sp.Id, - SpAddress: spAcc.String(), - FundingAddress: fundingAcc.String(), - SealAddress: sealAcc.String(), - ApprovalAddress: approvalAcc.String(), - GcAddress: gcAcc.String(), - Endpoint: msg.Endpoint, - TotalDeposit: &msg.Deposit, - Status: sp.Status, - Description: sp.Description, - BlsKey: hex.EncodeToString(sp.BlsKey), + SpId: sp.Id, + SpAddress: spAcc.String(), + FundingAddress: fundingAcc.String(), + SealAddress: sealAcc.String(), + ApprovalAddress: approvalAcc.String(), + GcAddress: gcAcc.String(), + MaintenanceAddress: maintenanceAcc.String(), + Endpoint: msg.Endpoint, + TotalDeposit: &msg.Deposit, + Status: sp.Status, + Description: sp.Description, + BlsKey: hex.EncodeToString(sp.BlsKey), }); err != nil { return nil, err } @@ -214,7 +221,11 @@ func (k msgServer) EditStorageProvider(goCtx context.Context, msg *types.MsgEdit sp.GcAddress = gcAcc.String() changed = true } - + if msg.MaintenanceAddress != "" { + testAcc := sdk.MustAccAddressFromHex(msg.MaintenanceAddress) + sp.MaintenanceAddress = testAcc.String() + changed = true + } if msg.BlsKey != "" && len(msg.BlsProof) != 0 { blsPk, err := hex.DecodeString(msg.BlsKey) if err != nil || len(blsPk) != sdk.BLSPubKeyLength { @@ -239,14 +250,15 @@ func (k msgServer) EditStorageProvider(goCtx context.Context, msg *types.MsgEdit k.SetStorageProviderByBlsKey(ctx, sp) if err := ctx.EventManager().EmitTypedEvents(&types.EventEditStorageProvider{ - SpId: sp.Id, - SpAddress: operatorAcc.String(), - Endpoint: sp.Endpoint, - Description: sp.Description, - ApprovalAddress: sp.ApprovalAddress, - SealAddress: sp.SealAddress, - GcAddress: sp.GcAddress, - BlsKey: hex.EncodeToString(sp.BlsKey), + SpId: sp.Id, + SpAddress: operatorAcc.String(), + Endpoint: sp.Endpoint, + Description: sp.Description, + ApprovalAddress: sp.ApprovalAddress, + SealAddress: sp.SealAddress, + GcAddress: sp.GcAddress, + MaintenanceAddress: sp.MaintenanceAddress, + BlsKey: hex.EncodeToString(sp.BlsKey), }); err != nil { return nil, err } @@ -358,3 +370,51 @@ func (k msgServer) checkBlsProof(blsPk []byte, sig string) error { } return nil } + +// UpdateSpStatus only allow SP to update status between STATUS_MAINTENANCE and STATUS_IN_SERVICE for now. +func (k msgServer) UpdateSpStatus(goCtx context.Context, msg *types.MsgUpdateStorageProviderStatus) (*types.MsgUpdateStorageProviderStatusResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + operatorAcc := sdk.MustAccAddressFromHex(msg.SpAddress) + + sp, found := k.GetStorageProviderByOperatorAddr(ctx, operatorAcc) + if !found { + return nil, types.ErrStorageProviderNotFound + } + + curStatus := sp.Status + newStatus := msg.GetStatus() + + if curStatus == newStatus { + return nil, types.ErrStorageProviderNotChanged + } + + switch curStatus { + case types.STATUS_IN_SERVICE: + if newStatus != types.STATUS_IN_MAINTENANCE { + return nil, types.ErrStorageProviderStatusUpdateNotAllow + } + err := k.UpdateToInMaintenance(ctx, sp, msg.GetDuration()) + if err != nil { + return nil, err + } + case types.STATUS_IN_MAINTENANCE: + if newStatus != types.STATUS_IN_SERVICE { + return nil, types.ErrStorageProviderStatusUpdateNotAllow + } + k.UpdateToInService(ctx, sp) + case types.STATUS_IN_JAILED, types.STATUS_GRACEFUL_EXITING: + return nil, types.ErrStorageProviderStatusUpdateNotAllow + } + k.SetStorageProvider(ctx, sp) + + if err := ctx.EventManager().EmitTypedEvents(&types.EventUpdateStorageProviderStatus{ + SpId: sp.Id, + SpAddress: operatorAcc.String(), + PreStatus: curStatus.String(), + NewStatus: newStatus.String(), + }); err != nil { + return nil, err + } + return &types.MsgUpdateStorageProviderStatusResponse{}, nil +} diff --git a/x/sp/keeper/msg_server_test.go b/x/sp/keeper/msg_server_test.go index a069bd3cc..05b5c07d6 100644 --- a/x/sp/keeper/msg_server_test.go +++ b/x/sp/keeper/msg_server_test.go @@ -30,6 +30,8 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() { s.Require().Nil(err, "error should be nil") gcAddr, _, err := testutil.GenerateCoinKey(hd.Secp256k1, s.cdc) s.Require().Nil(err, "error should be nil") + maintenanceAddr, _, err := testutil.GenerateCoinKey(hd.Secp256k1, s.cdc) + s.Require().Nil(err, "error should be nil") blsPubKeyHex := sample.RandBlsPubKeyHex() @@ -51,12 +53,13 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() { Moniker: "sp_test", Identity: "", }, - SpAddress: operatorAddr.String(), - FundingAddress: sample.RandAccAddressHex(), - SealAddress: sealAddr.String(), - ApprovalAddress: approvalAddr.String(), - GcAddress: gcAddr.String(), - BlsKey: blsPubKeyHex, + SpAddress: operatorAddr.String(), + FundingAddress: sample.RandAccAddressHex(), + SealAddress: sealAddr.String(), + ApprovalAddress: approvalAddr.String(), + GcAddress: gcAddr.String(), + MaintenanceAddress: maintenanceAddr.String(), + BlsKey: blsPubKeyHex, Deposit: sdk.Coin{ Denom: types.Denom, Amount: types.NewIntFromInt64WithDecimal(10000, types.DecimalBNB), @@ -72,13 +75,14 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() { Moniker: "sp_test", Identity: "", }, - SpAddress: operatorAddr.String(), - FundingAddress: fundingAddr.String(), - SealAddress: sealAddr.String(), - ApprovalAddress: approvalAddr.String(), - GcAddress: gcAddr.String(), - BlsKey: blsPubKeyHex, - Endpoint: "sp.io", + SpAddress: operatorAddr.String(), + FundingAddress: fundingAddr.String(), + SealAddress: sealAddr.String(), + ApprovalAddress: approvalAddr.String(), + GcAddress: gcAddr.String(), + MaintenanceAddress: maintenanceAddr.String(), + BlsKey: blsPubKeyHex, + Endpoint: "sp.io", Deposit: sdk.Coin{ Denom: types.Denom, Amount: types.NewIntFromInt64WithDecimal(10000, types.DecimalBNB), @@ -94,13 +98,14 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() { Moniker: "sp_test", Identity: "", }, - SpAddress: operatorAddr.String(), - FundingAddress: fundingAddr.String(), - SealAddress: sealAddr.String(), - ApprovalAddress: approvalAddr.String(), - GcAddress: gcAddr.String(), - BlsKey: "InValidBlsPubkey", - Endpoint: "sp.io", + SpAddress: operatorAddr.String(), + FundingAddress: fundingAddr.String(), + SealAddress: sealAddr.String(), + ApprovalAddress: approvalAddr.String(), + GcAddress: gcAddr.String(), + MaintenanceAddress: maintenanceAddr.String(), + BlsKey: "InValidBlsPubkey", + Endpoint: "sp.io", Deposit: sdk.Coin{ Denom: types.Denom, Amount: types.NewIntFromInt64WithDecimal(10000, types.DecimalBNB), @@ -116,12 +121,13 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() { Moniker: "MsgServer_sp_test", Identity: "", }, - SpAddress: operatorAddr.String(), - FundingAddress: fundingAddr.String(), - SealAddress: sealAddr.String(), - ApprovalAddress: approvalAddr.String(), - GcAddress: gcAddr.String(), - BlsKey: blsPubKeyHex, + SpAddress: operatorAddr.String(), + FundingAddress: fundingAddr.String(), + SealAddress: sealAddr.String(), + ApprovalAddress: approvalAddr.String(), + GcAddress: gcAddr.String(), + MaintenanceAddress: maintenanceAddr.String(), + BlsKey: blsPubKeyHex, Deposit: sdk.Coin{ Denom: types.Denom, Amount: types.NewIntFromInt64WithDecimal(10000, types.DecimalBNB), diff --git a/x/sp/keeper/sp_status.go b/x/sp/keeper/sp_status.go new file mode 100644 index 000000000..acdf83560 --- /dev/null +++ b/x/sp/keeper/sp_status.go @@ -0,0 +1,109 @@ +package keeper + +import ( + "cosmossdk.io/errors" + "github.com/bnb-chain/greenfield/x/sp/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) UpdateToInMaintenance(ctx sdk.Context, sp *types.StorageProvider, requestDuration int64) error { + params := k.GetParams(ctx) + if requestDuration > params.GetMaintenanceDurationQuota() { + return errors.Wrapf(types.ErrStorageProviderStatusUpdateNotAllow, "not enough quota, quota=%d is less than requested=%d", params.GetMaintenanceDurationQuota(), requestDuration) + } + store := ctx.KVStore(k.storeKey) + newRecord := &types.MaintenanceRecord{ + Height: ctx.BlockHeight(), + RequestDuration: requestDuration, + RequestAt: ctx.BlockTime().Unix(), + } + key := types.GetStorageProviderMaintenanceRecordsKey(sdk.MustAccAddressFromHex(sp.OperatorAddress)) + bz := store.Get(key) + sp.Status = types.STATUS_IN_MAINTENANCE + if bz == nil { + newStats := types.SpMaintenanceStats{Records: []*types.MaintenanceRecord{newRecord}} + store.Set(key, k.cdc.MustMarshal(&newStats)) + return nil + } + var stats types.SpMaintenanceStats + k.cdc.MustUnmarshal(bz, &stats) + size := len(stats.Records) + totalUsedTime := int64(0) + for i := size - 1; i >= 0; i-- { + record := stats.Records[i] + if i == size-1 { + threshHold := record.GetHeight() + params.GetNumOfLockupBlocksForMaintenance() + if ctx.BlockHeight() < threshHold { + return errors.Wrapf(types.ErrStorageProviderStatusUpdateNotAllow, "wait after block height %d", threshHold) + } + } + totalUsedTime = totalUsedTime + record.GetActualDuration() + } + if totalUsedTime+requestDuration > params.GetMaintenanceDurationQuota() { + return errors.Wrapf(types.ErrStorageProviderStatusUpdateNotAllow, "not enough quota, quota=%d is less than requested=%d", params.GetMaintenanceDurationQuota()-totalUsedTime, requestDuration) + } + stats.Records = append(stats.Records, newRecord) + store.Set(key, k.cdc.MustMarshal(&stats)) + return nil +} + +func (k Keeper) UpdateToInService(ctx sdk.Context, sp *types.StorageProvider) { + store := ctx.KVStore(k.storeKey) + key := types.GetStorageProviderMaintenanceRecordsKey(sdk.MustAccAddressFromHex(sp.OperatorAddress)) + bz := store.Get(key) + if bz != nil { + var stats types.SpMaintenanceStats + k.cdc.MustUnmarshal(bz, &stats) + size := len(stats.Records) + if size != 0 { + lastRecord := stats.Records[size-1] + lastRecord.ActualDuration = ctx.BlockTime().Unix() - lastRecord.RequestAt + store.Set(key, k.cdc.MustMarshal(&stats)) + } + } + sp.Status = types.STATUS_IN_SERVICE +} + +func (k Keeper) ForceUpdateMaintenanceRecords(ctx sdk.Context) { + params := k.GetParams(ctx) + store := ctx.KVStore(k.storeKey) + curTime := ctx.BlockTime().Unix() + iter := storetypes.KVStorePrefixIterator(store, types.StorageProviderKey) + for ; iter.Valid(); iter.Next() { + sp := types.MustUnmarshalStorageProvider(k.cdc, iter.Value()) + key := types.GetStorageProviderMaintenanceRecordsKey(sdk.MustAccAddressFromHex(sp.OperatorAddress)) + bz := store.Get(key) + if bz != nil { + var stats types.SpMaintenanceStats + k.cdc.MustUnmarshal(bz, &stats) + size := len(stats.Records) + // force update any maintenance record that not been updated back to in_service after requested duration. + changed := false + if sp.Status != types.STATUS_IN_SERVICE { + for i := size - 1; i >= 0; i-- { + if stats.Records[i].GetActualDuration() == 0 && stats.Records[i].RequestAt+stats.Records[i].GetRequestDuration() < curTime { + stats.Records[i].ActualDuration = stats.Records[i].RequestDuration + store.Set(key, k.cdc.MustMarshal(&stats)) + sp.Status = types.STATUS_IN_SERVICE + k.SetStorageProvider(ctx, sp) + changed = true + } + } + } + // purge outdated records + for i := size - 1; i >= 0; i-- { + if stats.Records[i].GetHeight()+params.GetNumOfHistoricalBlocksForMaintenanceRecords() < ctx.BlockHeight() { + stats.Records = stats.Records[i+1:] + changed = true + break + } + } + if len(stats.Records) == 0 { + store.Delete(key) + } else if changed { + store.Set(key, k.cdc.MustMarshal(&stats)) + } + } + } +} diff --git a/x/sp/module.go b/x/sp/module.go index 1cd21a2b7..fb86150e3 100644 --- a/x/sp/module.go +++ b/x/sp/module.go @@ -141,6 +141,7 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} } diff --git a/x/sp/types/codec.go b/x/sp/types/codec.go index f789cbd0a..0bcdd1c44 100644 --- a/x/sp/types/codec.go +++ b/x/sp/types/codec.go @@ -14,6 +14,8 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgEditStorageProvider{}, "sp/EditStorageProvider", nil) cdc.RegisterConcrete(&MsgUpdateSpStoragePrice{}, "sp/UpdateSpStoragePrice", nil) cdc.RegisterConcrete(&DepositAuthorization{}, "sp/DepositAuthorization", nil) + cdc.RegisterConcrete(&MsgUpdateStorageProviderStatus{}, "sp/UpdateSpStatus", nil) + // this line is used by starport scaffolding # 2 } @@ -30,6 +32,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSpStoragePrice{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateStorageProviderStatus{}, + ) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateParams{}, ) diff --git a/x/sp/types/errors.go b/x/sp/types/errors.go index c7d411c21..1824ca068 100644 --- a/x/sp/types/errors.go +++ b/x/sp/types/errors.go @@ -6,21 +6,23 @@ import ( // x/sp module sentinel errors var ( - ErrStorageProviderNotFound = errors.Register(ModuleName, 1, "StorageProvider does not exist") - ErrStorageProviderNotInService = errors.Register(ModuleName, 2, "StorageProvider is not in service") - ErrStorageProviderOwnerExists = errors.Register(ModuleName, 3, "StorageProvider already exist for this operator address; must use new StorageProvider operator address") - ErrInsufficientDepositAmount = errors.Register(ModuleName, 4, "insufficient deposit amount") - ErrDepositAccountNotAllowed = errors.Register(ModuleName, 5, "the deposit address must be the fund address of sp.") - ErrInvalidDenom = errors.Register(ModuleName, 6, "Invalid denom.") - ErrStorageProviderFundingAddrExists = errors.Register(ModuleName, 7, "StorageProvider already exist for this funding address; must use new StorageProvider funding address.") - ErrStorageProviderSealAddrExists = errors.Register(ModuleName, 8, "StorageProvider already exist for this seal address; must use new StorageProvider seal address.") - ErrStorageProviderApprovalAddrExists = errors.Register(ModuleName, 9, "StorageProvider already exist for this approval address; must use new StorageProvider approval address.") - ErrStorageProviderGcAddrExists = errors.Register(ModuleName, 10, "StorageProvider already exist for this gc address; must use new StorageProvider gc address.") - ErrStorageProviderPriceExpired = errors.Register(ModuleName, 11, "StorageProvider price expired") - ErrStorageProviderNotChanged = errors.Register(ModuleName, 12, "StorageProvider not changed") - ErrStorageProviderExitFailed = errors.Register(ModuleName, 13, "StorageProvider exit failed.") - ErrStorageProviderInvalidBlsKey = errors.Register(ModuleName, 14, "StorageProvider bls pubkey is invalid") - ErrStorageProviderBlsKeyExists = errors.Register(ModuleName, 15, "StorageProvider already exist for this bls pubkey; must use new bls pubkey") + ErrStorageProviderNotFound = errors.Register(ModuleName, 1, "StorageProvider does not exist") + ErrStorageProviderNotInService = errors.Register(ModuleName, 2, "StorageProvider is not in service") + ErrStorageProviderOwnerExists = errors.Register(ModuleName, 3, "StorageProvider already exist for this operator address; must use new StorageProvider operator address") + ErrInsufficientDepositAmount = errors.Register(ModuleName, 4, "insufficient deposit amount") + ErrDepositAccountNotAllowed = errors.Register(ModuleName, 5, "the deposit address must be the fund address of sp.") + ErrInvalidDenom = errors.Register(ModuleName, 6, "Invalid denom.") + ErrStorageProviderFundingAddrExists = errors.Register(ModuleName, 7, "StorageProvider already exist for this funding address; must use new StorageProvider funding address.") + ErrStorageProviderSealAddrExists = errors.Register(ModuleName, 8, "StorageProvider already exist for this seal address; must use new StorageProvider seal address.") + ErrStorageProviderApprovalAddrExists = errors.Register(ModuleName, 9, "StorageProvider already exist for this approval address; must use new StorageProvider approval address.") + ErrStorageProviderGcAddrExists = errors.Register(ModuleName, 10, "StorageProvider already exist for this gc address; must use new StorageProvider gc address.") + ErrStorageProviderPriceExpired = errors.Register(ModuleName, 11, "StorageProvider price expired") + ErrStorageProviderNotChanged = errors.Register(ModuleName, 12, "StorageProvider not changed") + ErrStorageProviderExitFailed = errors.Register(ModuleName, 13, "StorageProvider exit failed.") + ErrStorageProviderInvalidBlsKey = errors.Register(ModuleName, 14, "StorageProvider bls pubkey is invalid") + ErrStorageProviderBlsKeyExists = errors.Register(ModuleName, 15, "StorageProvider already exist for this bls pubkey; must use new bls pubkey") + ErrStorageProviderStatusUpdateNotAllow = errors.Register(ModuleName, 16, "StorageProvider status is not allow to change") + ErrStorageProviderMaintenanceAddrExists = errors.Register(ModuleName, 17, "StorageProvider already exist for this maintenance address; must use new StorageProvider maintenance address.") ErrSignerNotGovModule = errors.Register(ModuleName, 40, "signer is not gov module account") ErrSignerEmpty = errors.Register(ModuleName, 41, "signer is empty") diff --git a/x/sp/types/events.pb.go b/x/sp/types/events.pb.go index 402332365..ddded03fd 100644 --- a/x/sp/types/events.pb.go +++ b/x/sp/types/events.pb.go @@ -40,16 +40,18 @@ type EventCreateStorageProvider struct { ApprovalAddress string `protobuf:"bytes,5,opt,name=approval_address,json=approvalAddress,proto3" json:"approval_address,omitempty"` // gc_address defines one of the storage provider's accounts which is used for gc purpose GcAddress string `protobuf:"bytes,6,opt,name=gc_address,json=gcAddress,proto3" json:"gc_address,omitempty"` + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + MaintenanceAddress string `protobuf:"bytes,7,opt,name=maintenance_address,json=maintenanceAddress,proto3" json:"maintenance_address,omitempty"` // endpoint is the domain name address used by SP to provide storage services - Endpoint string `protobuf:"bytes,7,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Endpoint string `protobuf:"bytes,8,opt,name=endpoint,proto3" json:"endpoint,omitempty"` // total_deposit is the token coin that the storage provider deposit to the storage module - TotalDeposit *types.Coin `protobuf:"bytes,8,opt,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit,omitempty"` + TotalDeposit *types.Coin `protobuf:"bytes,9,opt,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit,omitempty"` // status defines the status of the storage provider - Status Status `protobuf:"varint,9,opt,name=status,proto3,enum=greenfield.sp.Status" json:"status,omitempty"` + Status Status `protobuf:"varint,10,opt,name=status,proto3,enum=greenfield.sp.Status" json:"status,omitempty"` // description defines the description terms for the storage provider - Description Description `protobuf:"bytes,10,opt,name=description,proto3" json:"description"` + Description Description `protobuf:"bytes,11,opt,name=description,proto3" json:"description"` // bls_key defines the bls pub key owned by storage provider used when sealing object and completing migration - BlsKey string `protobuf:"bytes,11,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` + BlsKey string `protobuf:"bytes,12,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` } func (m *EventCreateStorageProvider) Reset() { *m = EventCreateStorageProvider{} } @@ -127,6 +129,13 @@ func (m *EventCreateStorageProvider) GetGcAddress() string { return "" } +func (m *EventCreateStorageProvider) GetMaintenanceAddress() string { + if m != nil { + return m.MaintenanceAddress + } + return "" +} + func (m *EventCreateStorageProvider) GetEndpoint() string { if m != nil { return m.Endpoint @@ -178,8 +187,10 @@ type EventEditStorageProvider struct { ApprovalAddress string `protobuf:"bytes,6,opt,name=approval_address,json=approvalAddress,proto3" json:"approval_address,omitempty"` // gc_address defines one of the storage provider's accounts which is used for gc purpose GcAddress string `protobuf:"bytes,7,opt,name=gc_address,json=gcAddress,proto3" json:"gc_address,omitempty"` + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + MaintenanceAddress string `protobuf:"bytes,8,opt,name=maintenance_address,json=maintenanceAddress,proto3" json:"maintenance_address,omitempty"` // bls_key defines the bls pub key owned by storage provider used when sealing object - BlsKey string `protobuf:"bytes,8,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` + BlsKey string `protobuf:"bytes,9,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` } func (m *EventEditStorageProvider) Reset() { *m = EventEditStorageProvider{} } @@ -264,6 +275,13 @@ func (m *EventEditStorageProvider) GetGcAddress() string { return "" } +func (m *EventEditStorageProvider) GetMaintenanceAddress() string { + if m != nil { + return m.MaintenanceAddress + } + return "" +} + func (m *EventEditStorageProvider) GetBlsKey() string { if m != nil { return m.BlsKey @@ -449,63 +467,141 @@ func (m *EventSecondarySpStorePriceUpdate) GetUpdateTimeSec() int64 { return 0 } +// EventUpdateStorageProviderStatus is emitted when the SP update its status successfully +type EventUpdateStorageProviderStatus struct { + // sp_id defines the identifier of storage provider which generated on-chain + SpId uint32 `protobuf:"varint,1,opt,name=sp_id,json=spId,proto3" json:"sp_id,omitempty"` + // sp_address is the operator address of the storage provider + SpAddress string `protobuf:"bytes,2,opt,name=sp_address,json=spAddress,proto3" json:"sp_address,omitempty"` + // pre status + PreStatus string `protobuf:"bytes,3,opt,name=pre_status,json=preStatus,proto3" json:"pre_status,omitempty"` + // new status + NewStatus string `protobuf:"bytes,4,opt,name=new_status,json=newStatus,proto3" json:"new_status,omitempty"` +} + +func (m *EventUpdateStorageProviderStatus) Reset() { *m = EventUpdateStorageProviderStatus{} } +func (m *EventUpdateStorageProviderStatus) String() string { return proto.CompactTextString(m) } +func (*EventUpdateStorageProviderStatus) ProtoMessage() {} +func (*EventUpdateStorageProviderStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_685cbfa50fdf0841, []int{5} +} +func (m *EventUpdateStorageProviderStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUpdateStorageProviderStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUpdateStorageProviderStatus.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 *EventUpdateStorageProviderStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUpdateStorageProviderStatus.Merge(m, src) +} +func (m *EventUpdateStorageProviderStatus) XXX_Size() int { + return m.Size() +} +func (m *EventUpdateStorageProviderStatus) XXX_DiscardUnknown() { + xxx_messageInfo_EventUpdateStorageProviderStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUpdateStorageProviderStatus proto.InternalMessageInfo + +func (m *EventUpdateStorageProviderStatus) GetSpId() uint32 { + if m != nil { + return m.SpId + } + return 0 +} + +func (m *EventUpdateStorageProviderStatus) GetSpAddress() string { + if m != nil { + return m.SpAddress + } + return "" +} + +func (m *EventUpdateStorageProviderStatus) GetPreStatus() string { + if m != nil { + return m.PreStatus + } + return "" +} + +func (m *EventUpdateStorageProviderStatus) GetNewStatus() string { + if m != nil { + return m.NewStatus + } + return "" +} + func init() { proto.RegisterType((*EventCreateStorageProvider)(nil), "greenfield.sp.EventCreateStorageProvider") proto.RegisterType((*EventEditStorageProvider)(nil), "greenfield.sp.EventEditStorageProvider") proto.RegisterType((*EventDeposit)(nil), "greenfield.sp.EventDeposit") proto.RegisterType((*EventSpStoragePriceUpdate)(nil), "greenfield.sp.EventSpStoragePriceUpdate") proto.RegisterType((*EventSecondarySpStorePriceUpdate)(nil), "greenfield.sp.EventSecondarySpStorePriceUpdate") + proto.RegisterType((*EventUpdateStorageProviderStatus)(nil), "greenfield.sp.EventUpdateStorageProviderStatus") } func init() { proto.RegisterFile("greenfield/sp/events.proto", fileDescriptor_685cbfa50fdf0841) } var fileDescriptor_685cbfa50fdf0841 = []byte{ - // 711 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x4e, 0xdb, 0x4a, - 0x14, 0x8e, 0xc9, 0x1f, 0x99, 0x10, 0xb8, 0xf2, 0xe5, 0xea, 0x9a, 0x2c, 0x42, 0x94, 0x4a, 0x28, - 0xaa, 0x14, 0x47, 0xd0, 0x05, 0x8b, 0x56, 0x95, 0x08, 0x61, 0x51, 0x75, 0xd3, 0x3a, 0xed, 0xa6, - 0x55, 0x65, 0x8d, 0x3d, 0x07, 0x33, 0x22, 0xf1, 0x4c, 0x3d, 0x93, 0xa8, 0x79, 0x0b, 0x1e, 0xa0, - 0x2f, 0xd0, 0x3d, 0xcb, 0x3e, 0x00, 0x4b, 0xc4, 0xaa, 0xea, 0x02, 0x55, 0xf0, 0x22, 0x95, 0xc7, - 0xe3, 0x90, 0x44, 0x91, 0xd2, 0x16, 0xba, 0x4a, 0xe6, 0x9c, 0xf3, 0x7d, 0xf3, 0xcd, 0x39, 0x9f, - 0x67, 0x50, 0x35, 0x88, 0x00, 0xc2, 0x63, 0x0a, 0x7d, 0xd2, 0x16, 0xbc, 0x0d, 0x23, 0x08, 0xa5, - 0xb0, 0x79, 0xc4, 0x24, 0x33, 0x2b, 0x77, 0x39, 0x5b, 0xf0, 0x6a, 0xcd, 0x67, 0x62, 0xc0, 0x44, - 0xdb, 0xc3, 0x02, 0xda, 0xa3, 0x5d, 0x0f, 0x24, 0xde, 0x6d, 0xfb, 0x8c, 0x86, 0x49, 0x79, 0x75, - 0x2b, 0xc9, 0xbb, 0x6a, 0xd5, 0x4e, 0x16, 0x3a, 0xb5, 0x19, 0xb0, 0x80, 0x25, 0xf1, 0xf8, 0x5f, - 0x0a, 0x98, 0xdd, 0x5b, 0x8e, 0x39, 0x68, 0x40, 0xe3, 0x32, 0x87, 0xaa, 0x47, 0xb1, 0x96, 0xc3, - 0x08, 0xb0, 0x84, 0x9e, 0x64, 0x11, 0x0e, 0xe0, 0x55, 0xc4, 0x46, 0x94, 0x40, 0x64, 0xfe, 0x8b, - 0xf2, 0x82, 0xbb, 0x94, 0x58, 0x46, 0xdd, 0x68, 0x56, 0x9c, 0x9c, 0xe0, 0x2f, 0x88, 0xb9, 0x8f, - 0x90, 0xe0, 0x2e, 0x26, 0x24, 0x02, 0x21, 0xac, 0x95, 0xba, 0xd1, 0x2c, 0x75, 0xac, 0xab, 0xf3, - 0xd6, 0xa6, 0x96, 0x72, 0x90, 0x64, 0x7a, 0x32, 0xa2, 0x61, 0xe0, 0x94, 0x04, 0xd7, 0x01, 0xf3, - 0x00, 0x6d, 0x1c, 0x0f, 0x43, 0x42, 0xc3, 0x60, 0x82, 0xce, 0x2e, 0x41, 0xaf, 0x6b, 0x40, 0x4a, - 0xf1, 0x14, 0xad, 0x09, 0xc0, 0xfd, 0x09, 0x3e, 0xb7, 0x04, 0x5f, 0x8e, 0xab, 0x53, 0xf0, 0x21, - 0xfa, 0x07, 0x73, 0x1e, 0xb1, 0xd1, 0x14, 0x41, 0x7e, 0x09, 0xc1, 0x46, 0x8a, 0x48, 0x49, 0xf6, - 0x11, 0x0a, 0xfc, 0x09, 0xbc, 0xb0, 0xec, 0xf4, 0x81, 0x9f, 0x02, 0xab, 0x68, 0x15, 0x42, 0xc2, - 0x19, 0x0d, 0xa5, 0x55, 0x8c, 0x61, 0xce, 0x64, 0x6d, 0x3e, 0x47, 0x15, 0xc9, 0x24, 0xee, 0xbb, - 0x04, 0x38, 0x13, 0x54, 0x5a, 0xab, 0x75, 0xa3, 0x59, 0xde, 0xdb, 0xb2, 0x35, 0x69, 0x6c, 0x05, - 0x5b, 0x5b, 0xc1, 0x3e, 0x64, 0x34, 0x74, 0xd6, 0x54, 0x7d, 0x37, 0x29, 0x37, 0x5b, 0xa8, 0x20, - 0x24, 0x96, 0x43, 0x61, 0x95, 0xea, 0x46, 0x73, 0x7d, 0xef, 0x3f, 0x7b, 0xc6, 0x52, 0x76, 0x4f, - 0x25, 0x1d, 0x5d, 0x64, 0x76, 0x50, 0x99, 0x80, 0xf0, 0x23, 0xca, 0x25, 0x65, 0xa1, 0x85, 0xd4, - 0x66, 0xd5, 0x39, 0x4c, 0xf7, 0xae, 0xa2, 0x93, 0xbb, 0xb8, 0xde, 0xce, 0x38, 0xd3, 0x20, 0xf3, - 0x7f, 0x54, 0xf4, 0xfa, 0xc2, 0x3d, 0x85, 0xb1, 0x55, 0x56, 0xa7, 0x29, 0x78, 0x7d, 0xf1, 0x12, - 0xc6, 0x8d, 0xcf, 0x59, 0x64, 0x29, 0x4b, 0x1d, 0x11, 0x2a, 0xff, 0xae, 0xa1, 0xa6, 0x5b, 0x9a, - 0x9d, 0x6b, 0xe9, 0xdc, 0x19, 0x73, 0x7f, 0x72, 0xc6, 0x79, 0xb7, 0xe5, 0xef, 0xeb, 0xb6, 0xc2, - 0xfd, 0xdc, 0x56, 0xfc, 0x75, 0xb7, 0x4d, 0x8d, 0x67, 0x75, 0x66, 0x3c, 0x67, 0x06, 0x5a, 0x53, - 0xe3, 0x49, 0xbd, 0xb3, 0xe0, 0xab, 0x34, 0x7e, 0xf3, 0xab, 0xb4, 0x50, 0x31, 0x35, 0xae, 0x9a, - 0x9e, 0x93, 0x2e, 0xcd, 0x47, 0xf3, 0xc6, 0x4e, 0xc6, 0x34, 0xe3, 0xde, 0xc6, 0x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x14, 0xb7, 0x17, 0x7a, 0x2d, 0xff, 0x04, 0xd3, 0xb0, 0x3d, 0xf5, 0x72, - 0x7d, 0x9a, 0xbc, 0x5d, 0x5e, 0x41, 0x3d, 0x5e, 0x4f, 0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0xa7, - 0xee, 0x58, 0xf0, 0x55, 0x07, 0x00, 0x00, + // 781 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x8f, 0x1b, 0x35, + 0x14, 0xde, 0xd9, 0x4d, 0xb2, 0x9b, 0x97, 0xa4, 0x8b, 0xa6, 0x45, 0xcc, 0x46, 0x6a, 0x1a, 0x05, + 0xa9, 0x8a, 0x90, 0x32, 0x51, 0xcb, 0xa1, 0x07, 0x10, 0x52, 0xb3, 0xe9, 0xa1, 0xe2, 0x02, 0x13, + 0xb8, 0x80, 0xd0, 0xc8, 0x33, 0x7e, 0x3b, 0xb5, 0x9a, 0xd8, 0xc6, 0x76, 0x52, 0xf2, 0x2f, 0x7a, + 0xe7, 0x17, 0x70, 0xe1, 0xd4, 0x23, 0x3f, 0xa0, 0xc7, 0xaa, 0x27, 0xc4, 0xa1, 0x42, 0xbb, 0x07, + 0xfe, 0x06, 0x1a, 0x8f, 0x27, 0x4d, 0xa2, 0x48, 0x11, 0xdd, 0xe5, 0x94, 0xd8, 0xef, 0x7d, 0xdf, + 0xfb, 0xfc, 0xfc, 0xcd, 0x93, 0xa1, 0x9d, 0x29, 0x44, 0x7e, 0xc1, 0x70, 0x4a, 0x87, 0x5a, 0x0e, + 0x71, 0x81, 0xdc, 0xe8, 0x50, 0x2a, 0x61, 0x84, 0xdf, 0x7a, 0x1f, 0x0b, 0xb5, 0x6c, 0x77, 0x52, + 0xa1, 0x67, 0x42, 0x0f, 0x13, 0xa2, 0x71, 0xb8, 0x78, 0x90, 0xa0, 0x21, 0x0f, 0x86, 0xa9, 0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7, 0xcd, 0x5d, 0x00, 0xa9, 0x30, 0x76, 0xa3, 0xb6, 0xf0, 0x5f, 0x5d, 0x2a, 0x74, 0xc5, + 0xee, 0x02, 0x70, 0x7c, 0x51, 0x86, 0x2b, 0x45, 0x98, 0xe3, 0x8b, 0x22, 0x3c, 0x1a, 0xbf, 0xbe, + 0xec, 0x78, 0x6f, 0x2e, 0x3b, 0xde, 0xdf, 0x97, 0x1d, 0xef, 0xe5, 0x55, 0xe7, 0xe0, 0xcd, 0x55, + 0xe7, 0xe0, 0xcf, 0xab, 0xce, 0xc1, 0x0f, 0x9f, 0xad, 0x35, 0x23, 0xe1, 0xc9, 0x20, 0x7d, 0x46, + 0x18, 0x1f, 0xae, 0x3d, 0x00, 0x7e, 0x59, 0x3d, 0x01, 0x92, 0x9a, 0x7d, 0x03, 0x7c, 0xfe, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xfc, 0xe5, 0x66, 0xee, 0x9c, 0x08, 0x00, 0x00, } func (m *EventCreateStorageProvider) Marshal() (dAtA []byte, err error) { @@ -533,7 +629,7 @@ func (m *EventCreateStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, err copy(dAtA[i:], m.BlsKey) i = encodeVarintEvents(dAtA, i, uint64(len(m.BlsKey))) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x62 } { size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) @@ -544,11 +640,11 @@ func (m *EventCreateStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintEvents(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a if m.Status != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x48 + dAtA[i] = 0x50 } if m.TotalDeposit != nil { { @@ -560,13 +656,20 @@ func (m *EventCreateStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintEvents(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } if len(m.Endpoint) > 0 { i -= len(m.Endpoint) copy(dAtA[i:], m.Endpoint) i = encodeVarintEvents(dAtA, i, uint64(len(m.Endpoint))) i-- + dAtA[i] = 0x42 + } + if len(m.MaintenanceAddress) > 0 { + i -= len(m.MaintenanceAddress) + copy(dAtA[i:], m.MaintenanceAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.MaintenanceAddress))) + i-- dAtA[i] = 0x3a } if len(m.GcAddress) > 0 { @@ -637,6 +740,13 @@ func (m *EventEditStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error copy(dAtA[i:], m.BlsKey) i = encodeVarintEvents(dAtA, i, uint64(len(m.BlsKey))) i-- + dAtA[i] = 0x4a + } + if len(m.MaintenanceAddress) > 0 { + i -= len(m.MaintenanceAddress) + copy(dAtA[i:], m.MaintenanceAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.MaintenanceAddress))) + i-- dAtA[i] = 0x42 } if len(m.GcAddress) > 0 { @@ -832,6 +942,55 @@ func (m *EventSecondarySpStorePriceUpdate) MarshalToSizedBuffer(dAtA []byte) (in return len(dAtA) - i, nil } +func (m *EventUpdateStorageProviderStatus) 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 *EventUpdateStorageProviderStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUpdateStorageProviderStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewStatus) > 0 { + i -= len(m.NewStatus) + copy(dAtA[i:], m.NewStatus) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewStatus))) + i-- + dAtA[i] = 0x22 + } + if len(m.PreStatus) > 0 { + i -= len(m.PreStatus) + copy(dAtA[i:], m.PreStatus) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PreStatus))) + i-- + dAtA[i] = 0x1a + } + if len(m.SpAddress) > 0 { + i -= len(m.SpAddress) + copy(dAtA[i:], m.SpAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.SpAddress))) + i-- + dAtA[i] = 0x12 + } + if m.SpId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.SpId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -872,6 +1031,10 @@ func (m *EventCreateStorageProvider) Size() (n int) { if l > 0 { n += 1 + l + sovEvents(uint64(l)) } + l = len(m.MaintenanceAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } l = len(m.Endpoint) if l > 0 { n += 1 + l + sovEvents(uint64(l)) @@ -923,6 +1086,10 @@ func (m *EventEditStorageProvider) Size() (n int) { if l > 0 { n += 1 + l + sovEvents(uint64(l)) } + l = len(m.MaintenanceAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } l = len(m.BlsKey) if l > 0 { n += 1 + l + sovEvents(uint64(l)) @@ -987,6 +1154,30 @@ func (m *EventSecondarySpStorePriceUpdate) Size() (n int) { return n } +func (m *EventUpdateStorageProviderStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SpId != 0 { + n += 1 + sovEvents(uint64(m.SpId)) + } + l = len(m.SpAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.PreStatus) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewStatus) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1202,6 +1393,38 @@ func (m *EventCreateStorageProvider) Unmarshal(dAtA []byte) error { m.GcAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaintenanceAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MaintenanceAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Endpoint", wireType) } @@ -1233,7 +1456,7 @@ func (m *EventCreateStorageProvider) Unmarshal(dAtA []byte) error { } m.Endpoint = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalDeposit", wireType) } @@ -1269,7 +1492,7 @@ func (m *EventCreateStorageProvider) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } @@ -1288,7 +1511,7 @@ func (m *EventCreateStorageProvider) Unmarshal(dAtA []byte) error { break } } - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } @@ -1321,7 +1544,7 @@ func (m *EventCreateStorageProvider) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlsKey", wireType) } @@ -1616,6 +1839,38 @@ func (m *EventEditStorageProvider) Unmarshal(dAtA []byte) error { m.GcAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaintenanceAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MaintenanceAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlsKey", wireType) } @@ -2092,6 +2347,171 @@ func (m *EventSecondarySpStorePriceUpdate) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventUpdateStorageProviderStatus) 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 ErrIntOverflowEvents + } + 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: EventUpdateStorageProviderStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateStorageProviderStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SpId", wireType) + } + m.SpId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SpId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreStatus", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PreStatus = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewStatus", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewStatus = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/sp/types/keys.go b/x/sp/types/keys.go index 858f09052..82d705f66 100644 --- a/x/sp/types/keys.go +++ b/x/sp/types/keys.go @@ -33,8 +33,9 @@ var ( SpStoragePriceKeyPrefix = []byte{0x28} SecondarySpStorePriceKeyPrefix = []byte{0x29} StorageProviderByBlsPubKeyKey = []byte{0x30} // prefix for each key to a storage provider index, by bls pub key + StorageProviderSequenceKey = []byte{0x31} - StorageProviderSequenceKey = []byte{0x31} + StorageProviderMaintenanceRecordPrefix = []byte{0x41} ) // GetStorageProviderKey creates the key for the provider with address @@ -132,3 +133,7 @@ func ParseSecondarySpStorePriceKey(key []byte) (timestamp int64) { timestamp = int64(binary.BigEndian.Uint64(key)) return } + +func GetStorageProviderMaintenanceRecordsKey(spAddr sdk.AccAddress) []byte { + return append(StorageProviderMaintenanceRecordPrefix, spAddr.Bytes()...) +} diff --git a/x/sp/types/message.go b/x/sp/types/message.go index c50881a27..69756a86b 100644 --- a/x/sp/types/message.go +++ b/x/sp/types/message.go @@ -12,11 +12,12 @@ import ( ) const ( - TypeMsgCreateStorageProvider = "create_storage_provider" - TypeMsgEditStorageProvider = "edit_storage_provider" - TypeMsgDeposit = "deposit" - TypeMsgUpdateSpStoragePrice = "update_sp_storage_price" - TypeMsgUpdateParams = "update_params" + TypeMsgCreateStorageProvider = "create_storage_provider" + TypeMsgEditStorageProvider = "edit_storage_provider" + TypeMsgDeposit = "deposit" + TypeMsgUpdateSpStoragePrice = "update_sp_storage_price" + TypeMsgUpdateParams = "update_params" + TypeMsgUpdateStorageProviderStatus = "update_storage_provider_status" ) var ( @@ -26,6 +27,7 @@ var ( _ sdk.Msg = &MsgEditStorageProvider{} _ sdk.Msg = &MsgUpdateSpStoragePrice{} _ sdk.Msg = &MsgUpdateParams{} + _ sdk.Msg = &MsgUpdateStorageProviderStatus{} ) // NewMsgCreateStorageProvider creates a new MsgCreateStorageProvider instance. @@ -36,23 +38,24 @@ var ( // blsProof is the signature signed via bls private key on bls public key bytes func NewMsgCreateStorageProvider( creator sdk.AccAddress, spAddress sdk.AccAddress, fundingAddress sdk.AccAddress, - sealAddress sdk.AccAddress, approvalAddress sdk.AccAddress, gcAddress sdk.AccAddress, + sealAddress sdk.AccAddress, approvalAddress sdk.AccAddress, gcAddress sdk.AccAddress, maintenanceAddress sdk.AccAddress, description Description, endpoint string, deposit sdk.Coin, readPrice sdk.Dec, freeReadQuota uint64, storePrice sdk.Dec, blsKey, blsProof string) (*MsgCreateStorageProvider, error) { return &MsgCreateStorageProvider{ - Creator: creator.String(), - SpAddress: spAddress.String(), - FundingAddress: fundingAddress.String(), - SealAddress: sealAddress.String(), - ApprovalAddress: approvalAddress.String(), - GcAddress: gcAddress.String(), - Description: description, - Endpoint: endpoint, - Deposit: deposit, - ReadPrice: readPrice, - FreeReadQuota: freeReadQuota, - StorePrice: storePrice, - BlsKey: blsKey, - BlsProof: blsProof, + Creator: creator.String(), + SpAddress: spAddress.String(), + FundingAddress: fundingAddress.String(), + SealAddress: sealAddress.String(), + ApprovalAddress: approvalAddress.String(), + GcAddress: gcAddress.String(), + MaintenanceAddress: maintenanceAddress.String(), + Description: description, + Endpoint: endpoint, + Deposit: deposit, + ReadPrice: readPrice, + FreeReadQuota: freeReadQuota, + StorePrice: storePrice, + BlsKey: blsKey, + BlsProof: blsProof, }, nil } @@ -137,16 +140,17 @@ func (msg *MsgCreateStorageProvider) ValidateBasic() error { // NewMsgEditStorageProvider creates a new MsgEditStorageProvider instance func NewMsgEditStorageProvider(spAddress sdk.AccAddress, endpoint string, description *Description, - sealAddress sdk.AccAddress, approvalAddress sdk.AccAddress, gcAddress sdk.AccAddress, blsKey, blsProof string) *MsgEditStorageProvider { + sealAddress sdk.AccAddress, approvalAddress sdk.AccAddress, gcAddress sdk.AccAddress, maintenanceAddress sdk.AccAddress, blsKey, blsProof string) *MsgEditStorageProvider { return &MsgEditStorageProvider{ - SpAddress: spAddress.String(), - Endpoint: endpoint, - Description: description, - SealAddress: sealAddress.String(), - ApprovalAddress: approvalAddress.String(), - GcAddress: gcAddress.String(), - BlsKey: blsKey, - BlsProof: blsProof, + SpAddress: spAddress.String(), + Endpoint: endpoint, + Description: description, + SealAddress: sealAddress.String(), + ApprovalAddress: approvalAddress.String(), + GcAddress: gcAddress.String(), + MaintenanceAddress: maintenanceAddress.String(), + BlsKey: blsKey, + BlsProof: blsProof, } } @@ -210,6 +214,11 @@ func (msg *MsgEditStorageProvider) ValidateBasic() error { return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid gc address (%s)", err) } } + if msg.MaintenanceAddress != "" { + if _, err := sdk.AccAddressFromHexUnsafe(msg.MaintenanceAddress); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid maintenance address (%s)", err) + } + } if msg.BlsKey != "" { if msg.BlsProof == "" { return errors.Wrapf(gnfderrors.ErrInvalidBlsSignature, "bls proof is not provided") @@ -339,3 +348,51 @@ func (m *MsgUpdateParams) ValidateBasic() error { return nil } + +// NewMsgUpdateStorageProviderStatus creates a new MsgUpdateStorageProviderStatus instance +func NewMsgUpdateStorageProviderStatus(spAddress sdk.AccAddress, status Status, duration int64) *MsgUpdateStorageProviderStatus { + return &MsgUpdateStorageProviderStatus{ + SpAddress: spAddress.String(), + Status: status, + Duration: duration, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgUpdateStorageProviderStatus) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgUpdateStorageProviderStatus) Type() string { + return TypeMsgUpdateStorageProviderStatus +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgUpdateStorageProviderStatus) GetSigners() []sdk.AccAddress { + operator, err := sdk.AccAddressFromHexUnsafe(msg.SpAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{operator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgUpdateStorageProviderStatus) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgUpdateStorageProviderStatus) ValidateBasic() error { + if _, err := sdk.AccAddressFromHexUnsafe(msg.SpAddress); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid operator address (%s)", err) + } + if msg.Status != STATUS_IN_SERVICE && msg.Status != STATUS_IN_MAINTENANCE { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "not allowed to update to status %s", msg.Status) + } + if msg.Status == STATUS_IN_MAINTENANCE && msg.Duration <= 0 { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "maintenanceDuration need to be set for %s", msg.Status) + } + return nil +} diff --git a/x/sp/types/message_test.go b/x/sp/types/message_test.go index d2b4e6507..0d71c20d9 100644 --- a/x/sp/types/message_test.go +++ b/x/sp/types/message_test.go @@ -22,32 +22,33 @@ func TestMsgCreateStorageProvider_ValidateBasic(t *testing.T) { blsPubKey, blsProof := sample.RandBlsPubKeyAndBlsProof() tests := []struct { - name, moniker, identity, website, details string - creator, spAddress, fundingAddress, sealAddress, approvalAddress, gcAddress sdk.AccAddress - blsKey, blsProof string - deposit sdk.Coin - err error + name, moniker, identity, website, details string + creator, spAddress, fundingAddress, sealAddress, approvalAddress, gcAddress, maintenanceAddress sdk.AccAddress + blsKey, blsProof string + deposit sdk.Coin + err error }{ - {"basic", "a", "b", "c", "d", spAddr, spAddr, spAddr, spAddr, spAddr, spAddr, blsPubKey, blsProof, coinPos, nil}, - {"basic_empty", "a", "b", "c", "d", sdk.AccAddress{}, spAddr, spAddr, spAddr, spAddr, spAddr, blsPubKey, blsProof, coinPos, sdkerrors.ErrInvalidAddress}, - {"zero deposit", "a", "b", "c", "d", spAddr, spAddr, spAddr, spAddr, spAddr, spAddr, blsPubKey, blsProof, coinZero, nil}, + {"basic", "a", "b", "c", "d", spAddr, spAddr, spAddr, spAddr, spAddr, spAddr, spAddr, blsPubKey, blsProof, coinPos, nil}, + {"basic_empty", "a", "b", "c", "d", sdk.AccAddress{}, spAddr, spAddr, spAddr, spAddr, spAddr, spAddr, blsPubKey, blsProof, coinPos, sdkerrors.ErrInvalidAddress}, + {"zero deposit", "a", "b", "c", "d", spAddr, spAddr, spAddr, spAddr, spAddr, spAddr, spAddr, blsPubKey, blsProof, coinZero, nil}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { msg := MsgCreateStorageProvider{ - Creator: tt.creator.String(), - Description: NewDescription(tt.moniker, tt.identity, tt.website, tt.details), - SpAddress: tt.spAddress.String(), - FundingAddress: tt.fundingAddress.String(), - SealAddress: tt.sealAddress.String(), - ApprovalAddress: tt.approvalAddress.String(), - GcAddress: tt.gcAddress.String(), - BlsKey: tt.blsKey, - BlsProof: tt.blsProof, - Endpoint: "http://127.0.0.1:9033", - StorePrice: sdk.ZeroDec(), - ReadPrice: sdk.ZeroDec(), - Deposit: coinPos, + Creator: tt.creator.String(), + Description: NewDescription(tt.moniker, tt.identity, tt.website, tt.details), + SpAddress: tt.spAddress.String(), + FundingAddress: tt.fundingAddress.String(), + SealAddress: tt.sealAddress.String(), + ApprovalAddress: tt.approvalAddress.String(), + GcAddress: tt.gcAddress.String(), + MaintenanceAddress: tt.maintenanceAddress.String(), + BlsKey: tt.blsKey, + BlsProof: tt.blsProof, + Endpoint: "http://127.0.0.1:9033", + StorePrice: sdk.ZeroDec(), + ReadPrice: sdk.ZeroDec(), + Deposit: coinPos, } err := msg.ValidateBasic() if tt.err != nil { diff --git a/x/sp/types/params.go b/x/sp/types/params.go index fcefd6e85..fd041cad3 100644 --- a/x/sp/types/params.go +++ b/x/sp/types/params.go @@ -16,6 +16,12 @@ import ( const ( // Default deposit denom DefaultDepositDenom = "BNB" + // DefaultNumOfHistoricalBlocksForMaintenanceRecords The oldest block from current will be kept of for SP maintenance records + DefaultNumOfHistoricalBlocksForMaintenanceRecords = 21600 //todo set a reasonable number after test + // DefaultMaintenanceDurationQuota is the total allowed time for a SP to be in Maintenance mode within DefaultNumOfHistoricalBlocksForMaintenanceRecords + DefaultMaintenanceDurationQuota = 21600 // in second + // DefaultNumOfLockUpBlocksForMaintenance defines blocks difference which Sp update itself to Maintenance mode is allowed + DefaultNumOfLockUpBlocksForMaintenance = 10 //todo set a reasonable number after test ) var ( @@ -26,9 +32,12 @@ var ( ) var ( - KeyDepositDenom = []byte("DepositDenom") - KeyMinDeposit = []byte("MinDeposit") - KeySecondarySpStorePriceRatio = []byte("SecondarySpStorePriceRatio") + KeyDepositDenom = []byte("DepositDenom") + KeyMinDeposit = []byte("MinDeposit") + KeySecondarySpStorePriceRatio = []byte("SecondarySpStorePriceRatio") + KeyNumOfHistoricalBlocksForMaintenanceRecords = []byte("NumOfHistoricalBlocksForMaintenanceRecords") + KeyMaintenanceDurationQuota = []byte("MaintenanceDurationQuota") + KeyNumOfLockUpBlocksForMaintenance = []byte("NumOfLockUpBlocksForMaintenance") ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -39,17 +48,22 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new Params instance -func NewParams(depositDenom string, minDeposit math.Int, secondarySpStorePriceRatio sdk.Dec) Params { +func NewParams(depositDenom string, minDeposit math.Int, secondarySpStorePriceRatio sdk.Dec, + historicalBlocksForMaintenanceRecords, maintenanceDurationQuota, lockUpBlocksForMaintenance int64) Params { return Params{ DepositDenom: depositDenom, MinDeposit: minDeposit, SecondarySpStorePriceRatio: secondarySpStorePriceRatio, + NumOfHistoricalBlocksForMaintenanceRecords: historicalBlocksForMaintenanceRecords, + MaintenanceDurationQuota: maintenanceDurationQuota, + NumOfLockupBlocksForMaintenance: lockUpBlocksForMaintenance, } } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams(DefaultDepositDenom, DefaultMinDeposit, DefaultSecondarySpStorePriceRatio) + return NewParams(DefaultDepositDenom, DefaultMinDeposit, DefaultSecondarySpStorePriceRatio, + DefaultNumOfHistoricalBlocksForMaintenanceRecords, DefaultMaintenanceDurationQuota, DefaultNumOfLockUpBlocksForMaintenance) } // ParamSetPairs get the params.ParamSet @@ -58,6 +72,9 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyDepositDenom, &p.DepositDenom, validateDepositDenom), paramtypes.NewParamSetPair(KeyMinDeposit, &p.MinDeposit, validateMinDeposit), paramtypes.NewParamSetPair(KeySecondarySpStorePriceRatio, &p.SecondarySpStorePriceRatio, validateSecondarySpStorePriceRatio), + paramtypes.NewParamSetPair(KeyNumOfHistoricalBlocksForMaintenanceRecords, &p.NumOfHistoricalBlocksForMaintenanceRecords, validateHistoricalBlocksForMaintenanceRecords), + paramtypes.NewParamSetPair(KeyMaintenanceDurationQuota, &p.MaintenanceDurationQuota, validateMaintenanceDurationQuota), + paramtypes.NewParamSetPair(KeyNumOfLockUpBlocksForMaintenance, &p.NumOfLockupBlocksForMaintenance, validateLockUpBlocksForMaintenance), } } @@ -74,6 +91,15 @@ func (p Params) Validate() error { if err := validateSecondarySpStorePriceRatio(p.SecondarySpStorePriceRatio); err != nil { return err } + if err := validateHistoricalBlocksForMaintenanceRecords(p.NumOfHistoricalBlocksForMaintenanceRecords); err != nil { + return err + } + if err := validateMaintenanceDurationQuota(p.MaintenanceDurationQuota); err != nil { + return err + } + if err := validateLockUpBlocksForMaintenance(p.NumOfLockupBlocksForMaintenance); err != nil { + return err + } return nil } @@ -127,3 +153,35 @@ func validateSecondarySpStorePriceRatio(i interface{}) error { } return nil } + +func validateHistoricalBlocksForMaintenanceRecords(i interface{}) error { + v, ok := i.(int64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + if v == 0 { + return errors.New("HistoricalBlocksForMaintenanceRecords cannot be zero") + } + return nil +} + +func validateMaintenanceDurationQuota(i interface{}) error { + v, ok := i.(int64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + if v == 0 { + return errors.New("MaintenanceDurationQuota cannot be zero") + } + return nil +} +func validateLockUpBlocksForMaintenance(i interface{}) error { + v, ok := i.(int64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + if v == 0 { + return errors.New("LockUpBlocksForMaintenance cannot be zero") + } + return nil +} diff --git a/x/sp/types/params.pb.go b/x/sp/types/params.pb.go index 6d10c041b..eb8246bf7 100644 --- a/x/sp/types/params.pb.go +++ b/x/sp/types/params.pb.go @@ -33,6 +33,12 @@ type Params struct { MinDeposit github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=min_deposit,json=minDeposit,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_deposit"` // the ratio of the store price of the secondary sp to the primary sp, the default value is 80% SecondarySpStorePriceRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=secondary_sp_store_price_ratio,json=secondarySpStorePriceRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"secondary_sp_store_price_ratio"` + // previous blocks that be traced back to for maintenance_records + NumOfHistoricalBlocksForMaintenanceRecords int64 `protobuf:"varint,4,opt,name=num_of_historical_blocks_for_maintenance_records,json=numOfHistoricalBlocksForMaintenanceRecords,proto3" json:"num_of_historical_blocks_for_maintenance_records,omitempty" yaml:"num_of_historical_blocks_for_maintenance_records"` + // the max duration that a SP can be in_maintenance within num_of_historical_blocks_for_maintenance_records + MaintenanceDurationQuota int64 `protobuf:"varint,5,opt,name=maintenance_duration_quota,json=maintenanceDurationQuota,proto3" json:"maintenance_duration_quota,omitempty" yaml:"maintenance_duration_quota"` + // the number of blocks to be wait for sp to be in maintenance mode again if already requested + NumOfLockupBlocksForMaintenance int64 `protobuf:"varint,6,opt,name=num_of_lockup_blocks_for_maintenance,json=numOfLockupBlocksForMaintenance,proto3" json:"num_of_lockup_blocks_for_maintenance,omitempty" yaml:"num_of_lockup_blocks_for_maintenance"` } func (m *Params) Reset() { *m = Params{} } @@ -74,6 +80,27 @@ func (m *Params) GetDepositDenom() string { return "" } +func (m *Params) GetNumOfHistoricalBlocksForMaintenanceRecords() int64 { + if m != nil { + return m.NumOfHistoricalBlocksForMaintenanceRecords + } + return 0 +} + +func (m *Params) GetMaintenanceDurationQuota() int64 { + if m != nil { + return m.MaintenanceDurationQuota + } + return 0 +} + +func (m *Params) GetNumOfLockupBlocksForMaintenance() int64 { + if m != nil { + return m.NumOfLockupBlocksForMaintenance + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "greenfield.sp.Params") } @@ -81,28 +108,37 @@ func init() { func init() { proto.RegisterFile("greenfield/sp/params.proto", fileDescriptor_a5353d8e6e407d7e) } var fileDescriptor_a5353d8e6e407d7e = []byte{ - // 321 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x31, 0x4b, 0x33, 0x31, - 0x18, 0xc7, 0x2f, 0x7d, 0xa1, 0xbc, 0x46, 0xbb, 0x1c, 0x0e, 0xf5, 0x86, 0x9c, 0x28, 0x88, 0x08, - 0xbd, 0x1b, 0xdc, 0xc4, 0xa9, 0xdc, 0xd2, 0xad, 0x5c, 0x37, 0x41, 0xc2, 0x5d, 0x2e, 0x5e, 0x83, - 0x5e, 0x9e, 0x90, 0x44, 0xb0, 0x9b, 0x1f, 0xc1, 0x51, 0xb7, 0x7e, 0x08, 0x3f, 0x44, 0xc7, 0xe2, - 0x24, 0x0e, 0x45, 0xda, 0xc5, 0x8f, 0x21, 0xb9, 0x3b, 0xb4, 0xab, 0x53, 0x92, 0xdf, 0xf3, 0xf0, - 0xff, 0x85, 0xe7, 0xc1, 0x41, 0xa9, 0x39, 0x97, 0x37, 0x82, 0xdf, 0x15, 0xb1, 0x51, 0xb1, 0xca, - 0x74, 0x56, 0x99, 0x48, 0x69, 0xb0, 0xe0, 0xf7, 0x7e, 0x6b, 0x91, 0x51, 0xc1, 0x01, 0x03, 0x53, - 0x81, 0xa1, 0x75, 0x31, 0x6e, 0x1e, 0x4d, 0x67, 0xb0, 0x5f, 0x42, 0x09, 0x0d, 0x77, 0xb7, 0x86, - 0x1e, 0xbd, 0x74, 0x70, 0x77, 0x5c, 0x07, 0xfa, 0xc7, 0xb8, 0x57, 0x70, 0x05, 0x46, 0x58, 0x5a, - 0x70, 0x09, 0x55, 0x1f, 0x1d, 0xa2, 0xd3, 0x9d, 0x74, 0xaf, 0x85, 0x89, 0x63, 0xfe, 0x35, 0xde, - 0xad, 0x84, 0xa4, 0x2d, 0xeb, 0x77, 0x5c, 0xcb, 0xf0, 0x72, 0xb1, 0x0a, 0xbd, 0x8f, 0x55, 0x78, - 0x52, 0x0a, 0x3b, 0xbd, 0xcf, 0x23, 0x06, 0x55, 0xeb, 0x6e, 0x8f, 0x81, 0x29, 0x6e, 0x63, 0x3b, - 0x53, 0xdc, 0x44, 0x23, 0x69, 0xdf, 0x5e, 0x07, 0xb8, 0xfd, 0xda, 0x48, 0xda, 0x14, 0x57, 0x42, - 0x26, 0x4d, 0x9e, 0xff, 0x88, 0x30, 0x31, 0x9c, 0x81, 0x2c, 0x32, 0x3d, 0xa3, 0x46, 0x51, 0x63, - 0x41, 0x73, 0xaa, 0xb4, 0x60, 0x9c, 0xea, 0xcc, 0x0a, 0xe8, 0xff, 0xfb, 0xb3, 0x32, 0xe1, 0x6c, - 0x4b, 0x99, 0x70, 0x96, 0x06, 0x3f, 0x8e, 0x89, 0x9a, 0x38, 0xc3, 0xd8, 0x09, 0x52, 0x97, 0x7f, - 0xf1, 0xff, 0x79, 0x1e, 0x7a, 0x5f, 0xf3, 0x10, 0x0d, 0x93, 0xc5, 0x9a, 0xa0, 0xe5, 0x9a, 0xa0, - 0xcf, 0x35, 0x41, 0x4f, 0x1b, 0xe2, 0x2d, 0x37, 0xc4, 0x7b, 0xdf, 0x10, 0xef, 0xea, 0x6c, 0xcb, - 0x9a, 0xcb, 0x7c, 0xc0, 0xa6, 0x99, 0x90, 0xf1, 0xd6, 0x9a, 0x1e, 0xdc, 0xa2, 0x6a, 0x7b, 0xde, - 0xad, 0x07, 0x7d, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xf8, 0xe0, 0x65, 0xb1, 0xc6, 0x01, 0x00, - 0x00, + // 479 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6b, 0xd4, 0x4e, + 0x1c, 0x4e, 0xfe, 0xfd, 0x77, 0xd1, 0xd1, 0x5e, 0x82, 0x87, 0x98, 0x43, 0x52, 0xe3, 0x0b, 0xa5, + 0xb2, 0x1b, 0xc1, 0x83, 0x50, 0x3d, 0x2d, 0x41, 0x2c, 0x28, 0xd6, 0xf4, 0x26, 0xc8, 0x30, 0x99, + 0xcc, 0xee, 0x0e, 0xdd, 0x79, 0x71, 0x66, 0x02, 0xee, 0x45, 0xfc, 0x08, 0x1e, 0x3d, 0x56, 0x3f, + 0x83, 0x1f, 0xa2, 0xc7, 0xe2, 0x49, 0x3c, 0x04, 0xd9, 0xbd, 0x78, 0xde, 0x4f, 0x20, 0x33, 0x09, + 0x6d, 0x04, 0x2b, 0xf4, 0x94, 0xe4, 0xf7, 0x3c, 0xf3, 0xbc, 0x64, 0x66, 0x40, 0x34, 0x55, 0x84, + 0xf0, 0x09, 0x25, 0xf3, 0x2a, 0xd3, 0x32, 0x93, 0x48, 0x21, 0xa6, 0x47, 0x52, 0x09, 0x23, 0x82, + 0xad, 0x73, 0x6c, 0xa4, 0x65, 0x74, 0x13, 0x0b, 0xcd, 0x84, 0x86, 0x0e, 0xcc, 0xda, 0x8f, 0x96, + 0x19, 0xdd, 0x98, 0x8a, 0xa9, 0x68, 0xe7, 0xf6, 0xad, 0x9d, 0xa6, 0x5f, 0x36, 0xc1, 0xe0, 0xc0, + 0x09, 0x06, 0xb7, 0xc1, 0x56, 0x45, 0xa4, 0xd0, 0xd4, 0xc0, 0x8a, 0x70, 0xc1, 0x42, 0x7f, 0xdb, + 0xdf, 0xb9, 0x5a, 0x5c, 0xef, 0x86, 0xb9, 0x9d, 0x05, 0x6f, 0xc0, 0x35, 0x46, 0x39, 0xec, 0x66, + 0xe1, 0x7f, 0x96, 0x32, 0x7e, 0x72, 0xd2, 0x24, 0xde, 0x8f, 0x26, 0xb9, 0x37, 0xa5, 0x66, 0x56, + 0x97, 0x23, 0x2c, 0x58, 0xe7, 0xdd, 0x3d, 0x86, 0xba, 0x3a, 0xca, 0xcc, 0x42, 0x12, 0x3d, 0xda, + 0xe7, 0xe6, 0xdb, 0xd7, 0x21, 0xe8, 0xa2, 0xed, 0x73, 0x53, 0x00, 0x46, 0x79, 0xde, 0xea, 0x05, + 0x1f, 0x7c, 0x10, 0x6b, 0x82, 0x05, 0xaf, 0x90, 0x5a, 0x40, 0x2d, 0xa1, 0x36, 0x42, 0x11, 0x28, + 0x15, 0xc5, 0x04, 0x2a, 0x64, 0xa8, 0x08, 0x37, 0x2e, 0x6d, 0x99, 0x13, 0xdc, 0xb3, 0xcc, 0x09, + 0x2e, 0xa2, 0x33, 0x8f, 0x43, 0x79, 0x68, 0x1d, 0x0e, 0xac, 0x41, 0x61, 0xf5, 0x83, 0xcf, 0x3e, + 0x78, 0xc0, 0x6b, 0x06, 0xc5, 0x04, 0xce, 0xa8, 0xb5, 0xa7, 0x18, 0xcd, 0x61, 0x39, 0x17, 0xf8, + 0x48, 0xc3, 0x89, 0x50, 0x90, 0x21, 0xca, 0x0d, 0xe1, 0x88, 0xdb, 0x48, 0x04, 0x0b, 0x55, 0xe9, + 0xf0, 0xff, 0x6d, 0x7f, 0x67, 0x63, 0xfc, 0x78, 0xdd, 0x24, 0x8f, 0x16, 0x88, 0xcd, 0xf7, 0xd2, + 0xcb, 0x2a, 0xa4, 0xc5, 0x2e, 0xaf, 0xd9, 0xcb, 0xc9, 0xb3, 0xb3, 0x05, 0x63, 0xc7, 0x7f, 0x2a, + 0xd4, 0x8b, 0x73, 0x76, 0xd1, 0x92, 0x03, 0x0c, 0xa2, 0xbe, 0x46, 0x55, 0xbb, 0x5f, 0xc3, 0xe1, + 0xdb, 0x5a, 0x18, 0x14, 0x6e, 0xba, 0x30, 0x77, 0xd7, 0x4d, 0x72, 0xab, 0x0d, 0x73, 0x31, 0x37, + 0x2d, 0xc2, 0x1e, 0x98, 0x77, 0xd8, 0x2b, 0x0b, 0x05, 0xef, 0xc1, 0x9d, 0xae, 0x85, 0x4d, 0x52, + 0xcb, 0x0b, 0x1a, 0x84, 0x03, 0x67, 0x97, 0xad, 0x9b, 0xe4, 0xfe, 0x1f, 0xdd, 0xff, 0xb9, 0x2a, + 0x2d, 0x12, 0xd7, 0xf7, 0xb9, 0x23, 0xfd, 0xad, 0xeb, 0xde, 0x95, 0x4f, 0xc7, 0x89, 0xf7, 0xeb, + 0x38, 0xf1, 0xc7, 0xf9, 0xc9, 0x32, 0xf6, 0x4f, 0x97, 0xb1, 0xff, 0x73, 0x19, 0xfb, 0x1f, 0x57, + 0xb1, 0x77, 0xba, 0x8a, 0xbd, 0xef, 0xab, 0xd8, 0x7b, 0xbd, 0xdb, 0xdb, 0xfe, 0x92, 0x97, 0x43, + 0x3c, 0x43, 0x94, 0x67, 0xbd, 0xfb, 0xf2, 0xce, 0xde, 0x18, 0x77, 0x0c, 0xca, 0x81, 0x3b, 0xf1, + 0x0f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x34, 0x14, 0x4a, 0x4f, 0x03, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -133,6 +169,15 @@ func (this *Params) Equal(that interface{}) bool { if !this.SecondarySpStorePriceRatio.Equal(that1.SecondarySpStorePriceRatio) { return false } + if this.NumOfHistoricalBlocksForMaintenanceRecords != that1.NumOfHistoricalBlocksForMaintenanceRecords { + return false + } + if this.MaintenanceDurationQuota != that1.MaintenanceDurationQuota { + return false + } + if this.NumOfLockupBlocksForMaintenance != that1.NumOfLockupBlocksForMaintenance { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -155,6 +200,21 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NumOfLockupBlocksForMaintenance != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.NumOfLockupBlocksForMaintenance)) + i-- + dAtA[i] = 0x30 + } + if m.MaintenanceDurationQuota != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaintenanceDurationQuota)) + i-- + dAtA[i] = 0x28 + } + if m.NumOfHistoricalBlocksForMaintenanceRecords != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.NumOfHistoricalBlocksForMaintenanceRecords)) + i-- + dAtA[i] = 0x20 + } { size := m.SecondarySpStorePriceRatio.Size() i -= size @@ -210,6 +270,15 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = m.SecondarySpStorePriceRatio.Size() n += 1 + l + sovParams(uint64(l)) + if m.NumOfHistoricalBlocksForMaintenanceRecords != 0 { + n += 1 + sovParams(uint64(m.NumOfHistoricalBlocksForMaintenanceRecords)) + } + if m.MaintenanceDurationQuota != 0 { + n += 1 + sovParams(uint64(m.MaintenanceDurationQuota)) + } + if m.NumOfLockupBlocksForMaintenance != 0 { + n += 1 + sovParams(uint64(m.NumOfLockupBlocksForMaintenance)) + } return n } @@ -348,6 +417,63 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumOfHistoricalBlocksForMaintenanceRecords", wireType) + } + m.NumOfHistoricalBlocksForMaintenanceRecords = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumOfHistoricalBlocksForMaintenanceRecords |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaintenanceDurationQuota", wireType) + } + m.MaintenanceDurationQuota = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaintenanceDurationQuota |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumOfLockupBlocksForMaintenance", wireType) + } + m.NumOfLockupBlocksForMaintenance = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumOfLockupBlocksForMaintenance |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/sp/types/query.pb.go b/x/sp/types/query.pb.go index 63cfe4f2f..5f078b2d7 100644 --- a/x/sp/types/query.pb.go +++ b/x/sp/types/query.pb.go @@ -592,6 +592,102 @@ func (m *QueryStorageProviderByOperatorAddressResponse) GetStorageProvider() *St return nil } +type QueryStorageProviderMaintenanceRecordsRequest struct { + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` +} + +func (m *QueryStorageProviderMaintenanceRecordsRequest) Reset() { + *m = QueryStorageProviderMaintenanceRecordsRequest{} +} +func (m *QueryStorageProviderMaintenanceRecordsRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryStorageProviderMaintenanceRecordsRequest) ProtoMessage() {} +func (*QueryStorageProviderMaintenanceRecordsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_48dd9c8aad3b7a6d, []int{12} +} +func (m *QueryStorageProviderMaintenanceRecordsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStorageProviderMaintenanceRecordsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStorageProviderMaintenanceRecordsRequest.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 *QueryStorageProviderMaintenanceRecordsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStorageProviderMaintenanceRecordsRequest.Merge(m, src) +} +func (m *QueryStorageProviderMaintenanceRecordsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStorageProviderMaintenanceRecordsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStorageProviderMaintenanceRecordsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStorageProviderMaintenanceRecordsRequest proto.InternalMessageInfo + +func (m *QueryStorageProviderMaintenanceRecordsRequest) GetOperatorAddress() string { + if m != nil { + return m.OperatorAddress + } + return "" +} + +type QueryStorageProviderMaintenanceRecordsResponse struct { + Records []*MaintenanceRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` +} + +func (m *QueryStorageProviderMaintenanceRecordsResponse) Reset() { + *m = QueryStorageProviderMaintenanceRecordsResponse{} +} +func (m *QueryStorageProviderMaintenanceRecordsResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryStorageProviderMaintenanceRecordsResponse) ProtoMessage() {} +func (*QueryStorageProviderMaintenanceRecordsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_48dd9c8aad3b7a6d, []int{13} +} +func (m *QueryStorageProviderMaintenanceRecordsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStorageProviderMaintenanceRecordsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStorageProviderMaintenanceRecordsResponse.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 *QueryStorageProviderMaintenanceRecordsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStorageProviderMaintenanceRecordsResponse.Merge(m, src) +} +func (m *QueryStorageProviderMaintenanceRecordsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStorageProviderMaintenanceRecordsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStorageProviderMaintenanceRecordsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStorageProviderMaintenanceRecordsResponse proto.InternalMessageInfo + +func (m *QueryStorageProviderMaintenanceRecordsResponse) GetRecords() []*MaintenanceRecord { + if m != nil { + return m.Records + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "greenfield.sp.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "greenfield.sp.QueryParamsResponse") @@ -605,64 +701,70 @@ func init() { proto.RegisterType((*QueryStorageProviderResponse)(nil), "greenfield.sp.QueryStorageProviderResponse") proto.RegisterType((*QueryStorageProviderByOperatorAddressRequest)(nil), "greenfield.sp.QueryStorageProviderByOperatorAddressRequest") proto.RegisterType((*QueryStorageProviderByOperatorAddressResponse)(nil), "greenfield.sp.QueryStorageProviderByOperatorAddressResponse") + proto.RegisterType((*QueryStorageProviderMaintenanceRecordsRequest)(nil), "greenfield.sp.QueryStorageProviderMaintenanceRecordsRequest") + proto.RegisterType((*QueryStorageProviderMaintenanceRecordsResponse)(nil), "greenfield.sp.QueryStorageProviderMaintenanceRecordsResponse") } func init() { proto.RegisterFile("greenfield/sp/query.proto", fileDescriptor_48dd9c8aad3b7a6d) } var fileDescriptor_48dd9c8aad3b7a6d = []byte{ - // 819 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xd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a5, 0x1f, 0x40, 0x56, 0x13, 0x0e, 0x5d, 0x36, 0xb5, 0xd2, - 0x9d, 0xd3, 0xf3, 0x9c, 0x72, 0x76, 0x9e, 0x53, 0xbe, 0x9e, 0xe7, 0x94, 0x97, 0x17, 0xb9, 0xd4, - 0xd9, 0x45, 0x2e, 0xf5, 0xe9, 0x22, 0x97, 0x7a, 0x9a, 0x77, 0xdc, 0x60, 0xbf, 0x5e, 0xd1, 0xab, - 0xb8, 0x66, 0x54, 0xbc, 0xca, 0x5a, 0x75, 0xdf, 0x72, 0xbd, 0xf6, 0x16, 0xcf, 0x9b, 0x7f, 0x8d, - 0x2a, 0x19, 0xf6, 0xdf, 0xa8, 0xf8, 0x23, 0x00, 0x00, 0xff, 0xff, 0x05, 0x6c, 0xf5, 0xa0, 0xf9, - 0x09, 0x00, 0x00, + // 896 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4d, 0x6f, 0xdc, 0x44, + 0x18, 0xc7, 0xe3, 0x0d, 0xa4, 0xea, 0x53, 0xb5, 0x89, 0x86, 0x46, 0x6d, 0x4d, 0xb2, 0x4d, 0xdd, + 0x02, 0xed, 0xa6, 0xb1, 0xe9, 0xae, 0x38, 0xd0, 0x82, 0x50, 0x16, 0xc4, 0xd2, 0x4a, 0x55, 0x83, + 0xcb, 0x85, 0x0a, 0xc9, 0x9a, 0xb5, 0xa7, 0x8e, 0xa5, 0xac, 0x67, 0xea, 0xf1, 0x56, 0xac, 0xa2, + 0x5c, 0xfa, 0x09, 0x10, 0x2f, 0x17, 0xbe, 0x0f, 0x52, 0x8f, 0x11, 0x5c, 0x10, 0x07, 0x84, 0x12, + 0xf8, 0x1e, 0xc8, 0x33, 0xe3, 0xdd, 0xf5, 0xc4, 0xde, 0x35, 0x2b, 0x6e, 0xbb, 0x33, 0xcf, 0xcb, + 0xff, 0xf7, 0xf8, 0xf1, 0x5f, 0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xd2, 0x96, 0x03, + 0x57, 0x83, 0xb4, 0xf7, 0x70, 0x48, 0x54, 0xae, 0x3b, 0x95, 0x69, 0xfd, 0x6c, 0xc0, 0x66, 0x45, + 0x23, 0x25, 0xff, 0x7d, 0x58, 0xe6, 0x2c, 0xd3, 0xbe, 0x7c, 0xfb, 0x42, 0xbb, 0xa9, 0x69, 0xd7, + 0xb2, 0xdc, 0x2c, 0x14, 0xf5, 0x0a, 0xda, 0x1a, 0x42, 0xdb, 0x7b, 0x73, 0xb5, 0xc9, 0x76, 0x05, + 0x71, 0xdf, 0xc0, 0x4d, 0xa1, 0xad, 0x47, 0xd2, 0xa7, 0x6c, 0xdc, 0x2a, 0xf2, 0x49, 0x77, 0xf4, + 0x55, 0x34, 0xc8, 0x79, 0xd0, 0x15, 0x38, 0xc7, 0x99, 0x87, 0x83, 0x20, 0x11, 0x83, 0x38, 0xef, + 0xae, 0x70, 0xb6, 0x1b, 0x04, 0x09, 0xda, 0x80, 0xf3, 0x69, 0x34, 0x20, 0x3c, 0xc5, 0x03, 0x26, + 0x74, 0x2c, 0xbb, 0x93, 0x03, 0x6b, 0x08, 0xb7, 0x66, 0x57, 0x57, 0x03, 0x78, 0x0c, 0x6b, 0x9c, + 0x79, 0x5c, 0x06, 0x78, 0x2c, 0x8b, 0x50, 0x03, 0xdf, 0xd4, 0xa7, 0x51, 0x2c, 0x23, 0x9f, 0xe8, + 0x25, 0x5e, 0x38, 0xb5, 0x1e, 0x41, 0x6b, 0xdc, 0x96, 0xf8, 0x34, 0x0e, 0x70, 0x32, 0x92, 0x89, + 0x65, 0x6c, 0x05, 0x04, 0x43, 0x47, 0xf8, 0xde, 0x80, 0xed, 0x5a, 0xc5, 0x14, 0x8a, 0x0f, 0x57, + 0x79, 0x1e, 0xe6, 0x29, 0xa8, 0x22, 0xd2, 0x2d, 0x1d, 0xa9, 0xb4, 0xaa, 0x24, 0x5b, 0xe7, 0x65, + 0x97, 0xd6, 0x0e, 0xbc, 0x5d, 0xb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 0x8e, 0x4f, 0x9a, 0xc6, 0x5f, 0x27, 0x4d, 0xe3, 0xbb, 0xd3, 0xe6, 0xd2, 0xf1, 0x69, 0x73, 0xe9, + 0xf7, 0xd3, 0xe6, 0xd2, 0xb3, 0x56, 0x18, 0xa5, 0xfb, 0xc3, 0xbe, 0xed, 0xd3, 0x81, 0xd3, 0x8f, + 0xfb, 0x3b, 0xfe, 0x3e, 0x8e, 0xe2, 0xe9, 0xb6, 0xdf, 0x8e, 0xbf, 0x74, 0xfb, 0x2b, 0xe2, 0x53, + 0xb7, 0xf3, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x58, 0xf5, 0x0f, 0xbb, 0xc8, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -689,6 +791,8 @@ type QueryClient interface { StorageProvider(ctx context.Context, in *QueryStorageProviderRequest, opts ...grpc.CallOption) (*QueryStorageProviderResponse, error) // Queries a StorageProvider by specify operator address. StorageProviderByOperatorAddress(ctx context.Context, in *QueryStorageProviderByOperatorAddressRequest, opts ...grpc.CallOption) (*QueryStorageProviderByOperatorAddressResponse, error) + // Queries a StorageProvider by specify operator address. + StorageProviderMaintenanceRecordsByOperatorAddress(ctx context.Context, in *QueryStorageProviderMaintenanceRecordsRequest, opts ...grpc.CallOption) (*QueryStorageProviderMaintenanceRecordsResponse, error) } type queryClient struct { @@ -753,6 +857,15 @@ func (c *queryClient) StorageProviderByOperatorAddress(ctx context.Context, in * return out, nil } +func (c *queryClient) StorageProviderMaintenanceRecordsByOperatorAddress(ctx context.Context, in *QueryStorageProviderMaintenanceRecordsRequest, opts ...grpc.CallOption) (*QueryStorageProviderMaintenanceRecordsResponse, error) { + out := new(QueryStorageProviderMaintenanceRecordsResponse) + err := c.cc.Invoke(ctx, "/greenfield.sp.Query/StorageProviderMaintenanceRecordsByOperatorAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -767,6 +880,8 @@ type QueryServer interface { StorageProvider(context.Context, *QueryStorageProviderRequest) (*QueryStorageProviderResponse, error) // Queries a StorageProvider by specify operator address. StorageProviderByOperatorAddress(context.Context, *QueryStorageProviderByOperatorAddressRequest) (*QueryStorageProviderByOperatorAddressResponse, error) + // Queries a StorageProvider by specify operator address. + StorageProviderMaintenanceRecordsByOperatorAddress(context.Context, *QueryStorageProviderMaintenanceRecordsRequest) (*QueryStorageProviderMaintenanceRecordsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -791,6 +906,9 @@ func (*UnimplementedQueryServer) StorageProvider(ctx context.Context, req *Query func (*UnimplementedQueryServer) StorageProviderByOperatorAddress(ctx context.Context, req *QueryStorageProviderByOperatorAddressRequest) (*QueryStorageProviderByOperatorAddressResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StorageProviderByOperatorAddress not implemented") } +func (*UnimplementedQueryServer) StorageProviderMaintenanceRecordsByOperatorAddress(ctx context.Context, req *QueryStorageProviderMaintenanceRecordsRequest) (*QueryStorageProviderMaintenanceRecordsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StorageProviderMaintenanceRecordsByOperatorAddress not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -904,6 +1022,24 @@ func _Query_StorageProviderByOperatorAddress_Handler(srv interface{}, ctx contex return interceptor(ctx, in, info, handler) } +func _Query_StorageProviderMaintenanceRecordsByOperatorAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStorageProviderMaintenanceRecordsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StorageProviderMaintenanceRecordsByOperatorAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.sp.Query/StorageProviderMaintenanceRecordsByOperatorAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StorageProviderMaintenanceRecordsByOperatorAddress(ctx, req.(*QueryStorageProviderMaintenanceRecordsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "greenfield.sp.Query", HandlerType: (*QueryServer)(nil), @@ -932,6 +1068,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "StorageProviderByOperatorAddress", Handler: _Query_StorageProviderByOperatorAddress_Handler, }, + { + MethodName: "StorageProviderMaintenanceRecordsByOperatorAddress", + Handler: _Query_StorageProviderMaintenanceRecordsByOperatorAddress_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "greenfield/sp/query.proto", @@ -1334,6 +1474,73 @@ func (m *QueryStorageProviderByOperatorAddressResponse) MarshalToSizedBuffer(dAt return len(dAtA) - i, nil } +func (m *QueryStorageProviderMaintenanceRecordsRequest) 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 *QueryStorageProviderMaintenanceRecordsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStorageProviderMaintenanceRecordsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryStorageProviderMaintenanceRecordsResponse) 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 *QueryStorageProviderMaintenanceRecordsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStorageProviderMaintenanceRecordsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Records) > 0 { + for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Records[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1498,6 +1705,34 @@ func (m *QueryStorageProviderByOperatorAddressResponse) Size() (n int) { return n } +func (m *QueryStorageProviderMaintenanceRecordsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStorageProviderMaintenanceRecordsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Records) > 0 { + for _, e := range m.Records { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2502,6 +2737,172 @@ func (m *QueryStorageProviderByOperatorAddressResponse) Unmarshal(dAtA []byte) e } return nil } +func (m *QueryStorageProviderMaintenanceRecordsRequest) 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: QueryStorageProviderMaintenanceRecordsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStorageProviderMaintenanceRecordsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStorageProviderMaintenanceRecordsResponse) 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: QueryStorageProviderMaintenanceRecordsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStorageProviderMaintenanceRecordsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Records = append(m.Records, &MaintenanceRecord{}) + if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/sp/types/query.pb.gw.go b/x/sp/types/query.pb.gw.go index 727d403ec..c1f381017 100644 --- a/x/sp/types/query.pb.gw.go +++ b/x/sp/types/query.pb.gw.go @@ -307,6 +307,42 @@ func local_request_Query_StorageProviderByOperatorAddress_0(ctx context.Context, } +var ( + filter_Query_StorageProviderMaintenanceRecordsByOperatorAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_StorageProviderMaintenanceRecordsByOperatorAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStorageProviderMaintenanceRecordsRequest + 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_StorageProviderMaintenanceRecordsByOperatorAddress_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.StorageProviderMaintenanceRecordsByOperatorAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StorageProviderMaintenanceRecordsByOperatorAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStorageProviderMaintenanceRecordsRequest + 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_StorageProviderMaintenanceRecordsByOperatorAddress_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.StorageProviderMaintenanceRecordsByOperatorAddress(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -451,6 +487,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_StorageProviderMaintenanceRecordsByOperatorAddress_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_StorageProviderMaintenanceRecordsByOperatorAddress_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_StorageProviderMaintenanceRecordsByOperatorAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -612,6 +671,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_StorageProviderMaintenanceRecordsByOperatorAddress_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_StorageProviderMaintenanceRecordsByOperatorAddress_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_StorageProviderMaintenanceRecordsByOperatorAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -627,6 +706,8 @@ var ( pattern_Query_StorageProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"greenfield", "storage_provider", "id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_StorageProviderByOperatorAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "sp", "storage_provider_by_operator_address"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_StorageProviderMaintenanceRecordsByOperatorAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "sp", "storage_provider_maintenance_records_by_operator_address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -641,4 +722,6 @@ var ( forward_Query_StorageProvider_0 = runtime.ForwardResponseMessage forward_Query_StorageProviderByOperatorAddress_0 = runtime.ForwardResponseMessage + + forward_Query_StorageProviderMaintenanceRecordsByOperatorAddress_0 = runtime.ForwardResponseMessage ) diff --git a/x/sp/types/tx.pb.go b/x/sp/types/tx.pb.go index 493123fde..88102a652 100644 --- a/x/sp/types/tx.pb.go +++ b/x/sp/types/tx.pb.go @@ -48,19 +48,21 @@ type MsgCreateStorageProvider struct { ApprovalAddress string `protobuf:"bytes,6,opt,name=approval_address,json=approvalAddress,proto3" json:"approval_address,omitempty"` // gc_address defines one of the storage provider's accounts which is used for gc purpose. GcAddress string `protobuf:"bytes,7,opt,name=gc_address,json=gcAddress,proto3" json:"gc_address,omitempty"` + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + MaintenanceAddress string `protobuf:"bytes,8,opt,name=maintenance_address,json=maintenanceAddress,proto3" json:"maintenance_address,omitempty"` // endpoint is the service address of the storage provider - Endpoint string `protobuf:"bytes,8,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Endpoint string `protobuf:"bytes,9,opt,name=endpoint,proto3" json:"endpoint,omitempty"` // deposit define the deposit token - Deposit types.Coin `protobuf:"bytes,9,opt,name=deposit,proto3" json:"deposit"` + Deposit types.Coin `protobuf:"bytes,10,opt,name=deposit,proto3" json:"deposit"` // read price, in bnb wei per charge byte - ReadPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=read_price,json=readPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"read_price"` + ReadPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=read_price,json=readPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"read_price"` // free read quota, in byte - FreeReadQuota uint64 `protobuf:"varint,11,opt,name=free_read_quota,json=freeReadQuota,proto3" json:"free_read_quota,omitempty"` + FreeReadQuota uint64 `protobuf:"varint,12,opt,name=free_read_quota,json=freeReadQuota,proto3" json:"free_read_quota,omitempty"` // store price, in bnb wei per charge byte - StorePrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=store_price,json=storePrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"store_price"` + StorePrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=store_price,json=storePrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"store_price"` // bls_key defines the bls pub key of the Storage provider for sealing object - BlsKey string `protobuf:"bytes,13,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` - BlsProof string `protobuf:"bytes,14,opt,name=bls_proof,json=blsProof,proto3" json:"bls_proof,omitempty"` + BlsKey string `protobuf:"bytes,14,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` + BlsProof string `protobuf:"bytes,15,opt,name=bls_proof,json=blsProof,proto3" json:"bls_proof,omitempty"` } func (m *MsgCreateStorageProvider) Reset() { *m = MsgCreateStorageProvider{} } @@ -145,6 +147,13 @@ func (m *MsgCreateStorageProvider) GetGcAddress() string { return "" } +func (m *MsgCreateStorageProvider) GetMaintenanceAddress() string { + if m != nil { + return m.MaintenanceAddress + } + return "" +} + func (m *MsgCreateStorageProvider) GetEndpoint() string { if m != nil { return m.Endpoint @@ -330,9 +339,11 @@ type MsgEditStorageProvider struct { ApprovalAddress string `protobuf:"bytes,5,opt,name=approval_address,json=approvalAddress,proto3" json:"approval_address,omitempty"` // gc_address defines one of the storage provider's accounts which is used for gc purpose GcAddress string `protobuf:"bytes,6,opt,name=gc_address,json=gcAddress,proto3" json:"gc_address,omitempty"` + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + MaintenanceAddress string `protobuf:"bytes,7,opt,name=maintenance_address,json=maintenanceAddress,proto3" json:"maintenance_address,omitempty"` // bls_key defines the bls pub key of the Storage provider for sealing object - BlsKey string `protobuf:"bytes,7,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` - BlsProof string `protobuf:"bytes,8,opt,name=bls_proof,json=blsProof,proto3" json:"bls_proof,omitempty"` + BlsKey string `protobuf:"bytes,8,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` + BlsProof string `protobuf:"bytes,9,opt,name=bls_proof,json=blsProof,proto3" json:"bls_proof,omitempty"` } func (m *MsgEditStorageProvider) Reset() { *m = MsgEditStorageProvider{} } @@ -410,6 +421,13 @@ func (m *MsgEditStorageProvider) GetGcAddress() string { return "" } +func (m *MsgEditStorageProvider) GetMaintenanceAddress() string { + if m != nil { + return m.MaintenanceAddress + } + return "" +} + func (m *MsgEditStorageProvider) GetBlsKey() string { if m != nil { return m.BlsKey @@ -650,6 +668,109 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgUpdateStorageProviderStatus is used to update the status of a SP by itself +type MsgUpdateStorageProviderStatus struct { + // sp_address defines the operator address + SpAddress string `protobuf:"bytes,1,opt,name=sp_address,json=spAddress,proto3" json:"sp_address,omitempty"` + // status defines the desired status be update to. + Status Status `protobuf:"varint,2,opt,name=status,proto3,enum=greenfield.sp.Status" json:"status,omitempty"` + // duration defines the time requested in desired status + Duration int64 `protobuf:"varint,3,opt,name=duration,proto3" json:"duration,omitempty"` +} + +func (m *MsgUpdateStorageProviderStatus) Reset() { *m = MsgUpdateStorageProviderStatus{} } +func (m *MsgUpdateStorageProviderStatus) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateStorageProviderStatus) ProtoMessage() {} +func (*MsgUpdateStorageProviderStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_f630c2933caa1bce, []int{10} +} +func (m *MsgUpdateStorageProviderStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateStorageProviderStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateStorageProviderStatus.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 *MsgUpdateStorageProviderStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateStorageProviderStatus.Merge(m, src) +} +func (m *MsgUpdateStorageProviderStatus) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateStorageProviderStatus) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateStorageProviderStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateStorageProviderStatus proto.InternalMessageInfo + +func (m *MsgUpdateStorageProviderStatus) GetSpAddress() string { + if m != nil { + return m.SpAddress + } + return "" +} + +func (m *MsgUpdateStorageProviderStatus) GetStatus() Status { + if m != nil { + return m.Status + } + return STATUS_IN_SERVICE +} + +func (m *MsgUpdateStorageProviderStatus) GetDuration() int64 { + if m != nil { + return m.Duration + } + return 0 +} + +// MsgUpdateStorageProviderStatusResponse defines the MsgUpdateStorageProviderStatus response type. +type MsgUpdateStorageProviderStatusResponse struct { +} + +func (m *MsgUpdateStorageProviderStatusResponse) Reset() { + *m = MsgUpdateStorageProviderStatusResponse{} +} +func (m *MsgUpdateStorageProviderStatusResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateStorageProviderStatusResponse) ProtoMessage() {} +func (*MsgUpdateStorageProviderStatusResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f630c2933caa1bce, []int{11} +} +func (m *MsgUpdateStorageProviderStatusResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateStorageProviderStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateStorageProviderStatusResponse.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 *MsgUpdateStorageProviderStatusResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateStorageProviderStatusResponse.Merge(m, src) +} +func (m *MsgUpdateStorageProviderStatusResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateStorageProviderStatusResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateStorageProviderStatusResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateStorageProviderStatusResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateStorageProvider)(nil), "greenfield.sp.MsgCreateStorageProvider") proto.RegisterType((*MsgCreateStorageProviderResponse)(nil), "greenfield.sp.MsgCreateStorageProviderResponse") @@ -661,68 +782,76 @@ func init() { proto.RegisterType((*MsgUpdateSpStoragePriceResponse)(nil), "greenfield.sp.MsgUpdateSpStoragePriceResponse") proto.RegisterType((*MsgUpdateParams)(nil), "greenfield.sp.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "greenfield.sp.MsgUpdateParamsResponse") + proto.RegisterType((*MsgUpdateStorageProviderStatus)(nil), "greenfield.sp.MsgUpdateStorageProviderStatus") + proto.RegisterType((*MsgUpdateStorageProviderStatusResponse)(nil), "greenfield.sp.MsgUpdateStorageProviderStatusResponse") } func init() { proto.RegisterFile("greenfield/sp/tx.proto", fileDescriptor_f630c2933caa1bce) } var fileDescriptor_f630c2933caa1bce = []byte{ - // 894 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x36, 0x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73, 0xe5, 0xe7, - 0x70, 0x77, 0xf9, 0xc5, 0xe1, 0x93, 0x5c, 0xc0, 0x55, 0x7b, 0x51, 0x35, 0x36, 0x04, 0xc6, 0xa1, - 0xe5, 0x2f, 0xa1, 0x12, 0x2f, 0xcf, 0xc6, 0x22, 0x57, 0x98, 0xd4, 0xfb, 0x2b, 0x4d, 0x89, 0xa3, - 0x4b, 0xf8, 0x70, 0xd9, 0xaa, 0xfa, 0x78, 0x91, 0xb9, 0x04, 0xa6, 0xb6, 0x37, 0x82, 0x25, 0xc1, - 0x7c, 0xd8, 0x5f, 0x3a, 0x45, 0x47, 0x8b, 0x6e, 0x96, 0xe1, 0x54, 0x7d, 0x33, 0x5c, 0x12, 0xef, - 0x5b, 0xd8, 0xc9, 0x08, 0x49, 0x5b, 0xc5, 0x8f, 0xec, 0xea, 0xd1, 0x7f, 0xdb, 0x63, 0xbf, 0x67, - 0x9d, 0xab, 0x6b, 0x4d, 0x7a, 0x75, 0xad, 0x49, 0x7f, 0x5d, 0x6b, 0xd2, 0xcf, 0x37, 0xda, 0xd6, - 0xab, 0x1b, 0x6d, 0xeb, 0x8f, 0x1b, 0x6d, 0xeb, 0xbb, 0x07, 0xa9, 0xa1, 0xb1, 0x7c, 0xab, 0x6d, - 0x5f, 0x98, 0x9e, 0x6f, 0xa4, 0xee, 0x9d, 0x2f, 0x92, 0x9b, 0xa7, 0x55, 0x0e, 0xaf, 0x9e, 0x0f, - 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x83, 0x53, 0x9f, 0x44, 0x0b, 0x00, 0x00, + // 992 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xc6, 0xae, 0x1d, 0x3f, 0x27, 0x36, 0xda, 0xa6, 0xcd, 0x7a, 0x91, 0x1c, 0xd7, 0x12, + 0x26,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 0xed, 0xe5, 0x55, 0x75, 0xed, 0x8f, 0xab, 0xea, 0xda, 0xb7, 0xf7, 0x13, 0x76, 0x64, 0xf9, 0x56, + 0xd3, 0x3e, 0x43, 0x9e, 0xdf, 0x4e, 0x7c, 0x67, 0x3c, 0x53, 0x5f, 0x1a, 0x56, 0x2e, 0xfc, 0xd4, + 0x78, 0xf0, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0x22, 0xdb, 0xd4, 0x34, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -741,6 +870,7 @@ type MsgClient interface { Deposit(ctx context.Context, in *MsgDeposit, opts ...grpc.CallOption) (*MsgDepositResponse, error) EditStorageProvider(ctx context.Context, in *MsgEditStorageProvider, opts ...grpc.CallOption) (*MsgEditStorageProviderResponse, error) UpdateSpStoragePrice(ctx context.Context, in *MsgUpdateSpStoragePrice, opts ...grpc.CallOption) (*MsgUpdateSpStoragePriceResponse, error) + UpdateSpStatus(ctx context.Context, in *MsgUpdateStorageProviderStatus, opts ...grpc.CallOption) (*MsgUpdateStorageProviderStatusResponse, error) // UpdateParams defines a governance operation for updating the x/sp module parameters. // The authority is defined in the keeper. // @@ -792,6 +922,15 @@ func (c *msgClient) UpdateSpStoragePrice(ctx context.Context, in *MsgUpdateSpSto return out, nil } +func (c *msgClient) UpdateSpStatus(ctx context.Context, in *MsgUpdateStorageProviderStatus, opts ...grpc.CallOption) (*MsgUpdateStorageProviderStatusResponse, error) { + out := new(MsgUpdateStorageProviderStatusResponse) + err := c.cc.Invoke(ctx, "/greenfield.sp.Msg/UpdateSpStatus", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) err := c.cc.Invoke(ctx, "/greenfield.sp.Msg/UpdateParams", in, out, opts...) @@ -807,6 +946,7 @@ type MsgServer interface { Deposit(context.Context, *MsgDeposit) (*MsgDepositResponse, error) EditStorageProvider(context.Context, *MsgEditStorageProvider) (*MsgEditStorageProviderResponse, error) UpdateSpStoragePrice(context.Context, *MsgUpdateSpStoragePrice) (*MsgUpdateSpStoragePriceResponse, error) + UpdateSpStatus(context.Context, *MsgUpdateStorageProviderStatus) (*MsgUpdateStorageProviderStatusResponse, error) // UpdateParams defines a governance operation for updating the x/sp module parameters. // The authority is defined in the keeper. // @@ -830,6 +970,9 @@ func (*UnimplementedMsgServer) EditStorageProvider(ctx context.Context, req *Msg func (*UnimplementedMsgServer) UpdateSpStoragePrice(ctx context.Context, req *MsgUpdateSpStoragePrice) (*MsgUpdateSpStoragePriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateSpStoragePrice not implemented") } +func (*UnimplementedMsgServer) UpdateSpStatus(ctx context.Context, req *MsgUpdateStorageProviderStatus) (*MsgUpdateStorageProviderStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateSpStatus not implemented") +} func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } @@ -910,6 +1053,24 @@ func _Msg_UpdateSpStoragePrice_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_UpdateSpStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateStorageProviderStatus) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateSpStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.sp.Msg/UpdateSpStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateSpStatus(ctx, req.(*MsgUpdateStorageProviderStatus)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgUpdateParams) if err := dec(in); err != nil { @@ -948,6 +1109,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateSpStoragePrice", Handler: _Msg_UpdateSpStoragePrice_Handler, }, + { + MethodName: "UpdateSpStatus", + Handler: _Msg_UpdateSpStatus_Handler, + }, { MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, @@ -982,14 +1147,14 @@ func (m *MsgCreateStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error copy(dAtA[i:], m.BlsProof) i = encodeVarintTx(dAtA, i, uint64(len(m.BlsProof))) i-- - dAtA[i] = 0x72 + dAtA[i] = 0x7a } if len(m.BlsKey) > 0 { i -= len(m.BlsKey) copy(dAtA[i:], m.BlsKey) i = encodeVarintTx(dAtA, i, uint64(len(m.BlsKey))) i-- - dAtA[i] = 0x6a + dAtA[i] = 0x72 } { size := m.StorePrice.Size() @@ -1000,11 +1165,11 @@ func (m *MsgCreateStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x62 + dAtA[i] = 0x6a if m.FreeReadQuota != 0 { i = encodeVarintTx(dAtA, i, uint64(m.FreeReadQuota)) i-- - dAtA[i] = 0x58 + dAtA[i] = 0x60 } { size := m.ReadPrice.Size() @@ -1015,7 +1180,7 @@ func (m *MsgCreateStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a { size, err := m.Deposit.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -1025,12 +1190,19 @@ func (m *MsgCreateStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 if len(m.Endpoint) > 0 { i -= len(m.Endpoint) copy(dAtA[i:], m.Endpoint) i = encodeVarintTx(dAtA, i, uint64(len(m.Endpoint))) i-- + dAtA[i] = 0x4a + } + if len(m.MaintenanceAddress) > 0 { + i -= len(m.MaintenanceAddress) + copy(dAtA[i:], m.MaintenanceAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.MaintenanceAddress))) + i-- dAtA[i] = 0x42 } if len(m.GcAddress) > 0 { @@ -1206,13 +1378,20 @@ func (m *MsgEditStorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.BlsProof) i = encodeVarintTx(dAtA, i, uint64(len(m.BlsProof))) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } if len(m.BlsKey) > 0 { i -= len(m.BlsKey) copy(dAtA[i:], m.BlsKey) i = encodeVarintTx(dAtA, i, uint64(len(m.BlsKey))) i-- + dAtA[i] = 0x42 + } + if len(m.MaintenanceAddress) > 0 { + i -= len(m.MaintenanceAddress) + copy(dAtA[i:], m.MaintenanceAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.MaintenanceAddress))) + i-- dAtA[i] = 0x3a } if len(m.GcAddress) > 0 { @@ -1429,6 +1608,69 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgUpdateStorageProviderStatus) 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 *MsgUpdateStorageProviderStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateStorageProviderStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Duration != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x18 + } + if m.Status != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x10 + } + if len(m.SpAddress) > 0 { + i -= len(m.SpAddress) + copy(dAtA[i:], m.SpAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SpAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateStorageProviderStatusResponse) 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 *MsgUpdateStorageProviderStatusResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateStorageProviderStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1472,6 +1714,10 @@ func (m *MsgCreateStorageProvider) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.MaintenanceAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.Endpoint) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1563,6 +1809,10 @@ func (m *MsgEditStorageProvider) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.MaintenanceAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.BlsKey) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1636,6 +1886,34 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgUpdateStorageProviderStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovTx(uint64(m.Status)) + } + if m.Duration != 0 { + n += 1 + sovTx(uint64(m.Duration)) + } + return n +} + +func (m *MsgUpdateStorageProviderStatusResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1897,6 +2175,38 @@ func (m *MsgCreateStorageProvider) Unmarshal(dAtA []byte) error { m.GcAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaintenanceAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MaintenanceAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Endpoint", wireType) } @@ -1928,7 +2238,7 @@ func (m *MsgCreateStorageProvider) Unmarshal(dAtA []byte) error { } m.Endpoint = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) } @@ -1961,7 +2271,7 @@ func (m *MsgCreateStorageProvider) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ReadPrice", wireType) } @@ -1995,7 +2305,7 @@ func (m *MsgCreateStorageProvider) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field FreeReadQuota", wireType) } @@ -2014,7 +2324,7 @@ func (m *MsgCreateStorageProvider) Unmarshal(dAtA []byte) error { break } } - case 12: + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StorePrice", wireType) } @@ -2048,7 +2358,7 @@ func (m *MsgCreateStorageProvider) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 13: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlsKey", wireType) } @@ -2080,7 +2390,7 @@ func (m *MsgCreateStorageProvider) Unmarshal(dAtA []byte) error { } m.BlsKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 14: + case 15: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlsProof", wireType) } @@ -2606,6 +2916,38 @@ func (m *MsgEditStorageProvider) Unmarshal(dAtA []byte) error { m.GcAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaintenanceAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MaintenanceAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlsKey", wireType) } @@ -2637,7 +2979,7 @@ func (m *MsgEditStorageProvider) Unmarshal(dAtA []byte) error { } m.BlsKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlsProof", wireType) } @@ -3124,6 +3466,176 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateStorageProviderStatus) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateStorageProviderStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateStorageProviderStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= Status(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateStorageProviderStatusResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateStorageProviderStatusResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateStorageProviderStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/sp/types/types.go b/x/sp/types/types.go index 8e1a56829..76bad99f9 100644 --- a/x/sp/types/types.go +++ b/x/sp/types/types.go @@ -10,16 +10,17 @@ import ( ) const ( - MaxMonikerLength = 70 - MaxIdentityLength = 3000 - MaxWebsiteLength = 140 - MaxDetailsLength = 280 + MaxMonikerLength = 70 + MaxIdentityLength = 3000 + MaxWebsiteLength = 140 + MaxDetailsLength = 280 + MaintenanceRecordsGCFrequencyInBlocks = 100 ) // NewStorageProvider constructs a new StorageProvider func NewStorageProvider( spID uint32, operator sdk.AccAddress, fundingAddress sdk.AccAddress, - sealAddress sdk.AccAddress, approvalAddress sdk.AccAddress, gcAddress sdk.AccAddress, + sealAddress sdk.AccAddress, approvalAddress sdk.AccAddress, gcAddress sdk.AccAddress, maintenanceAddress sdk.AccAddress, totalDeposit math.Int, endpoint string, description Description, blsKey string) (StorageProvider, error) { @@ -30,16 +31,17 @@ func NewStorageProvider( } return StorageProvider{ - Id: spID, - OperatorAddress: operator.String(), - FundingAddress: fundingAddress.String(), - SealAddress: sealAddress.String(), - ApprovalAddress: approvalAddress.String(), - GcAddress: gcAddress.String(), - TotalDeposit: totalDeposit, - Endpoint: endpoint, - Description: description, - BlsKey: blsKeyBytes, + Id: spID, + OperatorAddress: operator.String(), + FundingAddress: fundingAddress.String(), + SealAddress: sealAddress.String(), + ApprovalAddress: approvalAddress.String(), + GcAddress: gcAddress.String(), + MaintenanceAddress: maintenanceAddress.String(), + TotalDeposit: totalDeposit, + Endpoint: endpoint, + Description: description, + BlsKey: blsKeyBytes, }, nil } @@ -80,6 +82,14 @@ func (sp *StorageProvider) GetGcAccAddress() sdk.AccAddress { return addr } +func (sp *StorageProvider) GetTestAccAddress() sdk.AccAddress { + if sp.OperatorAddress == "" { + return sdk.AccAddress{} + } + addr := sdk.MustAccAddressFromHex(sp.MaintenanceAddress) + return addr +} + func (sp *StorageProvider) IsInService() bool { return sp.GetStatus() == STATUS_IN_SERVICE } diff --git a/x/sp/types/types.pb.go b/x/sp/types/types.pb.go index b6a7d9fa4..4c40068fd 100644 --- a/x/sp/types/types.pb.go +++ b/x/sp/types/types.pb.go @@ -33,21 +33,21 @@ const ( STATUS_IN_SERVICE Status = 0 STATUS_IN_JAILED Status = 1 STATUS_GRACEFUL_EXITING Status = 2 - STATUS_OUT_OF_SERVICE Status = 3 + STATUS_IN_MAINTENANCE Status = 3 ) var Status_name = map[int32]string{ 0: "STATUS_IN_SERVICE", 1: "STATUS_IN_JAILED", 2: "STATUS_GRACEFUL_EXITING", - 3: "STATUS_OUT_OF_SERVICE", + 3: "STATUS_IN_MAINTENANCE", } var Status_value = map[string]int32{ "STATUS_IN_SERVICE": 0, "STATUS_IN_JAILED": 1, "STATUS_GRACEFUL_EXITING": 2, - "STATUS_OUT_OF_SERVICE": 3, + "STATUS_IN_MAINTENANCE": 3, } func (x Status) String() string { @@ -154,16 +154,18 @@ type StorageProvider struct { ApprovalAddress string `protobuf:"bytes,5,opt,name=approval_address,json=approvalAddress,proto3" json:"approval_address,omitempty"` // gc_address defines one of the storage provider's accounts which is used for gc purpose. GcAddress string `protobuf:"bytes,6,opt,name=gc_address,json=gcAddress,proto3" json:"gc_address,omitempty"` + // maintenance_address defines one of the storage provider's accounts which is used for testing while in maintenance mode + MaintenanceAddress string `protobuf:"bytes,7,opt,name=maintenance_address,json=maintenanceAddress,proto3" json:"maintenance_address,omitempty"` // total_deposit defines the number of tokens deposited by this storage provider for staking. - TotalDeposit github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=total_deposit,json=totalDeposit,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_deposit"` + TotalDeposit github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=total_deposit,json=totalDeposit,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_deposit"` // status defines the current service status of this storage provider - Status Status `protobuf:"varint,8,opt,name=status,proto3,enum=greenfield.sp.Status" json:"status,omitempty"` + Status Status `protobuf:"varint,9,opt,name=status,proto3,enum=greenfield.sp.Status" json:"status,omitempty"` // endpoint define the storage provider's network service address - Endpoint string `protobuf:"bytes,9,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Endpoint string `protobuf:"bytes,10,opt,name=endpoint,proto3" json:"endpoint,omitempty"` // description defines the description terms for the storage provider. - Description Description `protobuf:"bytes,10,opt,name=description,proto3" json:"description"` + Description Description `protobuf:"bytes,11,opt,name=description,proto3" json:"description"` // bls_key defines the bls pub key of the Storage provider for sealing object and completing migration - BlsKey []byte `protobuf:"bytes,11,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` + BlsKey []byte `protobuf:"bytes,12,opt,name=bls_key,json=blsKey,proto3" json:"bls_key,omitempty"` } func (m *StorageProvider) Reset() { *m = StorageProvider{} } @@ -241,6 +243,13 @@ func (m *StorageProvider) GetGcAddress() string { return "" } +func (m *StorageProvider) GetMaintenanceAddress() string { + if m != nil { + return m.MaintenanceAddress + } + return "" +} + func (m *StorageProvider) GetStatus() Status { if m != nil { return m.Status @@ -437,6 +446,123 @@ func (m *SecondarySpStorePrice) GetUpdateTimeSec() int64 { return 0 } +type SpMaintenanceStats struct { + Records []*MaintenanceRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` +} + +func (m *SpMaintenanceStats) Reset() { *m = SpMaintenanceStats{} } +func (m *SpMaintenanceStats) String() string { return proto.CompactTextString(m) } +func (*SpMaintenanceStats) ProtoMessage() {} +func (*SpMaintenanceStats) Descriptor() ([]byte, []int) { + return fileDescriptor_7a9af9b5be8c2eeb, []int{5} +} +func (m *SpMaintenanceStats) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpMaintenanceStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpMaintenanceStats.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 *SpMaintenanceStats) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpMaintenanceStats.Merge(m, src) +} +func (m *SpMaintenanceStats) XXX_Size() int { + return m.Size() +} +func (m *SpMaintenanceStats) XXX_DiscardUnknown() { + xxx_messageInfo_SpMaintenanceStats.DiscardUnknown(m) +} + +var xxx_messageInfo_SpMaintenanceStats proto.InternalMessageInfo + +func (m *SpMaintenanceStats) GetRecords() []*MaintenanceRecord { + if m != nil { + return m.Records + } + return nil +} + +// MaintenanceRecord is to keep track of every time a sp request to be in Maintenance mode +type MaintenanceRecord struct { + // block height that request to be in Maintenance mode + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + // request duration + RequestDuration int64 `protobuf:"varint,2,opt,name=request_duration,json=requestDuration,proto3" json:"request_duration,omitempty"` + // actual duration + ActualDuration int64 `protobuf:"varint,3,opt,name=actual_duration,json=actualDuration,proto3" json:"actual_duration,omitempty"` + // request timestamp + RequestAt int64 `protobuf:"varint,4,opt,name=request_at,json=requestAt,proto3" json:"request_at,omitempty"` +} + +func (m *MaintenanceRecord) Reset() { *m = MaintenanceRecord{} } +func (m *MaintenanceRecord) String() string { return proto.CompactTextString(m) } +func (*MaintenanceRecord) ProtoMessage() {} +func (*MaintenanceRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_7a9af9b5be8c2eeb, []int{6} +} +func (m *MaintenanceRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MaintenanceRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MaintenanceRecord.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 *MaintenanceRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_MaintenanceRecord.Merge(m, src) +} +func (m *MaintenanceRecord) XXX_Size() int { + return m.Size() +} +func (m *MaintenanceRecord) XXX_DiscardUnknown() { + xxx_messageInfo_MaintenanceRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_MaintenanceRecord proto.InternalMessageInfo + +func (m *MaintenanceRecord) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *MaintenanceRecord) GetRequestDuration() int64 { + if m != nil { + return m.RequestDuration + } + return 0 +} + +func (m *MaintenanceRecord) GetActualDuration() int64 { + if m != nil { + return m.ActualDuration + } + return 0 +} + +func (m *MaintenanceRecord) GetRequestAt() int64 { + if m != nil { + return m.RequestAt + } + return 0 +} + func init() { proto.RegisterEnum("greenfield.sp.Status", Status_name, Status_value) proto.RegisterType((*Description)(nil), "greenfield.sp.Description") @@ -444,65 +570,75 @@ func init() { proto.RegisterType((*RewardInfo)(nil), "greenfield.sp.RewardInfo") proto.RegisterType((*SpStoragePrice)(nil), "greenfield.sp.SpStoragePrice") proto.RegisterType((*SecondarySpStorePrice)(nil), "greenfield.sp.SecondarySpStorePrice") + proto.RegisterType((*SpMaintenanceStats)(nil), "greenfield.sp.SpMaintenanceStats") + proto.RegisterType((*MaintenanceRecord)(nil), "greenfield.sp.MaintenanceRecord") } func init() { proto.RegisterFile("greenfield/sp/types.proto", fileDescriptor_7a9af9b5be8c2eeb) } var fileDescriptor_7a9af9b5be8c2eeb = []byte{ - // 835 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xd1, 0x6e, 0x1b, 0x45, - 0x14, 0xf5, 0x3a, 0x8e, 0xd3, 0x5c, 0xc7, 0xb1, 0x19, 0x12, 0x75, 0x63, 0x24, 0x37, 0xf2, 0x43, - 0x14, 0x2a, 0xd9, 0x56, 0xc3, 0x43, 0x1f, 0xe0, 0xc5, 0xb1, 0xdd, 0xca, 0x50, 0xb5, 0xb0, 0x76, - 0x10, 0x02, 0xa1, 0xd5, 0x78, 0xe7, 0x66, 0x3b, 0x8a, 0x3d, 0xb3, 0xcc, 0x8c, 0x53, 0xfc, 0x07, - 0x3c, 0xf2, 0x05, 0x3c, 0xc0, 0x17, 0x20, 0xf5, 0x23, 0xfa, 0x58, 0xf5, 0x09, 0xf1, 0x50, 0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0xa2, 0xbb, 0x72, 0x0b, 0xfd, 0x98, 0xdf, 0x43, 0xd3, - 0x72, 0x72, 0x51, 0x7c, 0xf2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9a, 0xe6, 0xec, 0x1d, 0xa5, - 0x06, 0x00, 0x00, + // 962 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xda, 0x8e, 0xd3, 0x3c, 0x27, 0xb1, 0x3b, 0x4d, 0xe8, 0x26, 0x08, 0x37, 0xca, 0x21, + 0x84, 0x4a, 0xb1, 0xd5, 0x70, 0xa8, 0x04, 0x5c, 0x1c, 0xdb, 0x54, 0x0b, 0x6d, 0x54, 0xd6, 0x29, + 0x42, 0x20, 0xb4, 0x1a, 0xef, 0xbc, 0x38, 0xa3, 0xd8, 0x33, 0xdb, 0x99, 0x71, 0x8a, 0xff, 0x01, + 0x47, 0x7e, 0x01, 0x07, 0xf8, 0x05, 0x48, 0x3d, 0xf1, 0x0b, 0x7a, 0xac, 0x7a, 0x42, 0x1c, 0x2a, + 0x94, 0xfc, 0x11, 0xb4, 0x3b, 0xb3, 0x8e, 0x09, 0x48, 0x16, 0x52, 0x4f, 0xf6, 0xfb, 0xde, 0xfb, + 0xbe, 0x7d, 0x33, 0xf3, 0xbd, 0x19, 0xd8, 0x1a, 0x2a, 0x44, 0x71, 0xca, 0x71, 0xc4, 0x5a, 0x3a, + 0x69, 0x99, 0x69, 0x82, 0xba, 0x99, 0x28, 0x69, 0x24, 0x59, 0xbb, 0x4e, 0x35, 0x75, 0xb2, 0xdd, + 0x88, 0xa5, 0x1e, 0x4b, 0xdd, 0x1a, 0x50, 0x8d, 0xad, 0x8b, 0x07, 0x03, 0x34, 0xf4, 0x41, 0x2b, + 0x96, 0x5c, 0xd8, 0xf2, 0xed, 0x2d, 0x9b, 0x8f, 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7, 0xfe, 0xea, 0x8e, 0xb7, 0xbf, 0x1a, 0x56, 0x06, 0x23, 0xfd, 0x25, 0x4e, 0x77, 0xa7, + 0x00, 0x21, 0xbe, 0xa0, 0x8a, 0x05, 0xe2, 0x54, 0x92, 0x43, 0x58, 0xce, 0xf7, 0xd5, 0x5b, 0xb0, + 0xaf, 0x79, 0x21, 0x79, 0x08, 0x15, 0x3a, 0x96, 0x13, 0x61, 0x32, 0x43, 0x57, 0x0f, 0xb7, 0x9a, + 0xae, 0x3e, 0xbd, 0x05, 0x9a, 0xee, 0x16, 0x68, 0x76, 0x24, 0xcf, 0x1b, 0x73, 0xe5, 0xbb, 0xbf, + 0x15, 0x61, 0xbd, 0x9f, 0xcc, 0x26, 0x87, 0xc7, 0x48, 0xee, 0xc0, 0x92, 0x4e, 0xa2, 0xd9, 0xe4, + 0x94, 0x75, 0x12, 0x30, 0xb2, 0x07, 0xb5, 0x49, 0xc2, 0xa8, 0xc1, 0xc8, 0xf0, 0x31, 0x46, 0x1a, + 0xe3, 0xec, 0x4b, 0xa5, 0x70, 0xcd, 0xc2, 0x27, 0x7c, 0x8c, 0x7d, 0x8c, 0xc9, 0x77, 0x00, 0x0a, + 0x29, 0x8b, 0x92, 0x54, 0xca, 0x4d, 0xc6, 0xff, 0x39, 0xd2, 0x2e, 0xc6, 0x73, 0x47, 0xda, 0xc5, + 0x38, 0x5c, 0x49, 0xf5, 0x6c, 0x67, 0x7b, 0x50, 0x3b, 0x55, 0x88, 0x51, 0xf6, 0x85, 0xe7, 0x13, + 0x69, 0x68, 0x36, 0x3b, 0xe5, 0x70, 0x2d, 0x85, 0x43, 0xa4, 0xec, 0xab, 0x14, 0x24, 0xdf, 0x43, + 0x55, 0x1b, 0xa9, 0xd0, 0x75, 0xb1, 0xf4, 0x0e, 0xba, 0x80, 0x4c, 0x30, 0x6b, 0x63, 0xf7, 0x67, + 0x0f, 0x36, 0xfb, 0x18, 0x4b, 0xc1, 0xa8, 0x9a, 0xda, 0xcd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0e, 0x8e, 0x4f, 0x7a, 0xc7, 0xed, 0xe3, 0x4e, 0xaf, 0x5e, 0xda, 0x2e, 0xff, 0xf8, 0x6b, + 0xa3, 0x70, 0xd4, 0x7d, 0x75, 0xd9, 0xf0, 0x5e, 0x5f, 0x36, 0xbc, 0xbf, 0x2e, 0x1b, 0xde, 0x4f, + 0x57, 0x8d, 0xc2, 0xeb, 0xab, 0x46, 0xe1, 0x8f, 0xab, 0x46, 0xe1, 0xdb, 0xfb, 0x73, 0x67, 0x38, + 0x10, 0x83, 0x83, 0xf8, 0x8c, 0x72, 0xd1, 0x9a, 0x7b, 0xc3, 0x7f, 0x98, 0xbd, 0xe2, 0x83, 0x4a, + 0xf6, 0xcc, 0x7e, 0xfc, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x3d, 0xbe, 0xfd, 0xe3, 0x07, + 0x00, 0x00, } func (m *Description) Marshal() (dAtA []byte, err error) { @@ -588,7 +724,7 @@ func (m *StorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.BlsKey) i = encodeVarintTypes(dAtA, i, uint64(len(m.BlsKey))) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x62 } { size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) @@ -599,18 +735,18 @@ func (m *StorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a if len(m.Endpoint) > 0 { i -= len(m.Endpoint) copy(dAtA[i:], m.Endpoint) i = encodeVarintTypes(dAtA, i, uint64(len(m.Endpoint))) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } if m.Status != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x40 + dAtA[i] = 0x48 } { size := m.TotalDeposit.Size() @@ -621,7 +757,14 @@ func (m *StorageProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 + if len(m.MaintenanceAddress) > 0 { + i -= len(m.MaintenanceAddress) + copy(dAtA[i:], m.MaintenanceAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.MaintenanceAddress))) + i-- + dAtA[i] = 0x3a + } if len(m.GcAddress) > 0 { i -= len(m.GcAddress) copy(dAtA[i:], m.GcAddress) @@ -801,6 +944,86 @@ func (m *SecondarySpStorePrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SpMaintenanceStats) 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 *SpMaintenanceStats) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpMaintenanceStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Records) > 0 { + for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Records[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MaintenanceRecord) 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 *MaintenanceRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MaintenanceRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RequestAt != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.RequestAt)) + i-- + dAtA[i] = 0x20 + } + if m.ActualDuration != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ActualDuration)) + i-- + dAtA[i] = 0x18 + } + if m.RequestDuration != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.RequestDuration)) + i-- + dAtA[i] = 0x10 + } + if m.Height != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -870,6 +1093,10 @@ func (m *StorageProvider) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + l = len(m.MaintenanceAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } l = m.TotalDeposit.Size() n += 1 + l + sovTypes(uint64(l)) if m.Status != 0 { @@ -939,6 +1166,42 @@ func (m *SecondarySpStorePrice) Size() (n int) { return n } +func (m *SpMaintenanceStats) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Records) > 0 { + for _, e := range m.Records { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *MaintenanceRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovTypes(uint64(m.Height)) + } + if m.RequestDuration != 0 { + n += 1 + sovTypes(uint64(m.RequestDuration)) + } + if m.ActualDuration != 0 { + n += 1 + sovTypes(uint64(m.ActualDuration)) + } + if m.RequestAt != 0 { + n += 1 + sovTypes(uint64(m.RequestAt)) + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1364,6 +1627,38 @@ func (m *StorageProvider) Unmarshal(dAtA []byte) error { m.GcAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaintenanceAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MaintenanceAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalDeposit", wireType) } @@ -1397,7 +1692,7 @@ func (m *StorageProvider) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } @@ -1416,7 +1711,7 @@ func (m *StorageProvider) Unmarshal(dAtA []byte) error { break } } - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Endpoint", wireType) } @@ -1448,7 +1743,7 @@ func (m *StorageProvider) Unmarshal(dAtA []byte) error { } m.Endpoint = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } @@ -1481,7 +1776,7 @@ func (m *StorageProvider) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlsKey", wireType) } @@ -1929,6 +2224,216 @@ func (m *SecondarySpStorePrice) Unmarshal(dAtA []byte) error { } return nil } +func (m *SpMaintenanceStats) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpMaintenanceStats: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpMaintenanceStats: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Records = append(m.Records, &MaintenanceRecord{}) + if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MaintenanceRecord) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MaintenanceRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MaintenanceRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestDuration", wireType) + } + m.RequestDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestDuration |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ActualDuration", wireType) + } + m.ActualDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ActualDuration |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestAt", wireType) + } + m.RequestAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 2372197d1..6367b36b2 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -103,15 +103,20 @@ func (k Keeper) CreateBucket( // check sp and its status sp, found := k.spKeeper.GetStorageProviderByOperatorAddr(ctx, primarySpAcc) - if !found || sp.Status != sptypes.STATUS_IN_SERVICE { - return sdkmath.ZeroUint(), errors.Wrap(types.ErrNoSuchStorageProvider, "the storage provider is not exist or not in service") + if !found { + return sdkmath.ZeroUint(), errors.Wrap(types.ErrNoSuchStorageProvider, "the storage provider is not exist") + } + + // a sp is not in service, neither in maintenance + if sp.Status != sptypes.STATUS_IN_SERVICE && !k.fromSpMaintenanceAcct(sp, ownerAcc) { + return sdkmath.ZeroUint(), errors.Wrap(types.ErrNoSuchStorageProvider, "the storage provider is not in service") } // check primary sp approval if opts.PrimarySpApproval.ExpiredHeight < uint64(ctx.BlockHeight()) { return sdkmath.ZeroUint(), errors.Wrapf(types.ErrInvalidApproval, "The approval of sp is expired.") } - err = k.VerifySPAndSignature(ctx, sp, opts.ApprovalMsgBytes, opts.PrimarySpApproval.Sig) + err = k.VerifySPAndSignature(ctx, sp, opts.ApprovalMsgBytes, opts.PrimarySpApproval.Sig, ownerAcc) if err != nil { return sdkmath.ZeroUint(), err } @@ -573,7 +578,7 @@ func (k Keeper) CreateObject( return sdkmath.ZeroUint(), errors.Wrapf(types.ErrInvalidApproval, "The approval of sp is expired.") } - err = k.VerifySPAndSignature(ctx, sp, opts.ApprovalMsgBytes, opts.PrimarySpApproval.Sig) + err = k.VerifySPAndSignature(ctx, sp, opts.ApprovalMsgBytes, opts.PrimarySpApproval.Sig, operator) if err != nil { return sdkmath.ZeroUint(), err } @@ -1014,7 +1019,7 @@ func (k Keeper) CopyObject( return sdkmath.ZeroUint(), errors.Wrapf(types.ErrInvalidApproval, "The approval of sp is expired.") } - err = k.VerifySPAndSignature(ctx, dstPrimarySP, opts.ApprovalMsgBytes, opts.PrimarySpApproval.Sig) + err = k.VerifySPAndSignature(ctx, dstPrimarySP, opts.ApprovalMsgBytes, opts.PrimarySpApproval.Sig, operator) if err != nil { return sdkmath.ZeroUint(), err } @@ -1096,7 +1101,7 @@ func (k Keeper) RejectSealObject(ctx sdk.Context, operator sdk.AccAddress, bucke if !found { return errors.Wrapf(types.ErrNoSuchStorageProvider, "SP seal address: %s", operator.String()) } - if sp.Status != sptypes.STATUS_IN_SERVICE { + if sp.Status != sptypes.STATUS_IN_SERVICE && sp.Status != sptypes.STATUS_IN_MAINTENANCE { return sptypes.ErrStorageProviderNotInService } if sp.Id != spInState.Id { @@ -1499,11 +1504,10 @@ func (k Keeper) UpdateGroupExtra(ctx sdk.Context, operator sdk.AccAddress, group return nil } -func (k Keeper) VerifySPAndSignature(ctx sdk.Context, sp *sptypes.StorageProvider, sigData []byte, signature []byte) error { - if sp.Status != sptypes.STATUS_IN_SERVICE { +func (k Keeper) VerifySPAndSignature(_ sdk.Context, sp *sptypes.StorageProvider, sigData []byte, signature []byte, operator sdk.AccAddress) error { + if sp.Status != sptypes.STATUS_IN_SERVICE && !k.fromSpMaintenanceAcct(sp, operator) { return sptypes.ErrStorageProviderNotInService } - approvalAccAddress := sdk.MustAccAddressFromHex(sp.ApprovalAddress) err := gnfdtypes.VerifySignature(approvalAccAddress, sdk.Keccak256(sigData), signature) @@ -1901,7 +1905,7 @@ func (k Keeper) MigrateBucket(ctx sdk.Context, operator sdk.AccAddress, bucketNa if dstPrimarySPApproval.ExpiredHeight < (uint64)(ctx.BlockHeight()) { return types.ErrInvalidApproval.Wrap("dst primary sp approval timeout") } - err := k.VerifySPAndSignature(ctx, dstSP, approvalBytes, dstPrimarySPApproval.Sig) + err := k.VerifySPAndSignature(ctx, dstSP, approvalBytes, dstPrimarySPApproval.Sig, operator) if err != nil { return err } @@ -2123,3 +2127,7 @@ func (k Keeper) SetInternalBucketInfo(ctx sdk.Context, bucketID sdkmath.Uint, in bz := k.cdc.MustMarshal(internalBucketInfo) store.Set(types.GetInternalBucketInfoKey(bucketID), bz) } + +func (k Keeper) fromSpMaintenanceAcct(sp *sptypes.StorageProvider, operatorAddr sdk.AccAddress) bool { + return sp.Status == sptypes.STATUS_IN_MAINTENANCE && operatorAddr.Equals(sdk.MustAccAddressFromHex(sp.MaintenanceAddress)) +} From 388fddf128784af35b2d8ff0e4463d4632d5e382 Mon Sep 17 00:00:00 2001 From: Fynn Date: Tue, 8 Aug 2023 16:53:50 +0800 Subject: [PATCH 22/24] fix: add group existence check when verify permission (#401) * add group existence check when verify permission * fix get policy group for resource * fix mock gen and lint * fix bug * fix import * fix imports * fix ci --- e2e/tests/permission_test.go | 220 +++++++++++++++++++++- x/permission/keeper/keeper.go | 77 ++------ x/storage/keeper/keeper.go | 6 + x/storage/keeper/permission.go | 66 ++++++- x/storage/types/expected_keepers.go | 4 +- x/storage/types/expected_keepers_mocks.go | 43 +++-- 6 files changed, 332 insertions(+), 84 deletions(-) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index 3829058f3..9f08888f2 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -5,10 +5,14 @@ import ( "context" "fmt" "math" + "strconv" "time" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" sdktype "github.com/bnb-chain/greenfield/sdk/types" storageutil "github.com/bnb-chain/greenfield/testutil/storage" @@ -1560,6 +1564,7 @@ func (s *StorageTestSuite) TestPutPolicy_ObjectWithSlash() { var err error user := s.GenAndChargeAccounts(2, 1000000) + ctx := context.Background() sp := s.BaseSuite.PickStorageProvider() gvg, found := sp.GetFirstGlobalVirtualGroup() s.Require().True(found) @@ -1574,7 +1579,6 @@ func (s *StorageTestSuite) TestPutPolicy_ObjectWithSlash() { s.SendTxBlock(user[0], msgCreateBucket) // HeadBucket - ctx := context.Background() queryHeadBucketRequest := storagetypes.QueryHeadBucketRequest{ BucketName: bucketName, } @@ -1629,3 +1633,217 @@ func (s *StorageTestSuite) TestPutPolicy_ObjectWithSlash() { s.SendTxBlock(user[0], msgPutPolicy) } + +func (s *StorageTestSuite) TestVerifyStaleGroupPermission() { + ctx := context.Background() + + // set the params, not to delete stale policy + queryParamsRequest := storagetypes.QueryParamsRequest{} + queryParamsResponse, err := s.Client.StorageQueryClient.Params(ctx, &queryParamsRequest) + s.Require().NoError(err) + + newParams := queryParamsResponse.GetParams() + newParams.StalePolicyCleanupMax = 0 + s.UpdateParams(&newParams) + + defer func() { + newParams.StalePolicyCleanupMax = 100 + s.UpdateParams(&newParams) + }() + + user := s.GenAndChargeAccounts(3, 10000) + _, owner, bucketName, bucketId, objectName, objectId := s.createObjectWithVisibility(storagetypes.VISIBILITY_TYPE_PUBLIC_READ) + + // Create Group with 3 group member + testGroupName := "testGroup" + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, "") + msgUpdateGroupMember := storagetypes.NewMsgUpdateGroupMember(owner.GetAddr(), owner.GetAddr(), testGroupName, + []*storagetypes.MsgGroupMember{ + { + Member: user[0].GetAddr().String(), + ExpirationTime: storagetypes.MaxTimeStamp, + }, { + Member: user[1].GetAddr().String(), + ExpirationTime: storagetypes.MaxTimeStamp, + }, { + Member: user[2].GetAddr().String(), + ExpirationTime: storagetypes.MaxTimeStamp, + }}, + []sdk.AccAddress{}) + s.SendTxBlock(owner, msgCreateGroup, msgUpdateGroupMember) + + // Head Group + headGroupRequest := storagetypes.QueryHeadGroupRequest{GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} + headGroupResponse, err := s.Client.HeadGroup(ctx, &headGroupRequest) + s.Require().NoError(err) + s.Require().Equal(headGroupResponse.GroupInfo.GroupName, testGroupName) + s.Require().True(owner.GetAddr().Equals(sdk.MustAccAddressFromHex(headGroupResponse.GroupInfo.Owner))) + s.T().Logf("GroupInfo: %s", headGroupResponse.GetGroupInfo().String()) + + principal := types.NewPrincipalWithGroupId(headGroupResponse.GroupInfo.Id) + // Put bucket policy for group + bucketStatement := &types.Statement{ + Actions: []types.ActionType{types.ACTION_DELETE_BUCKET}, + Effect: types.EFFECT_ALLOW, + } + msgPutBucketPolicy := storagetypes.NewMsgPutPolicy(owner.GetAddr(), types2.NewBucketGRN(bucketName).String(), + principal, []*types.Statement{bucketStatement}, nil) + s.SendTxBlock(owner, msgPutBucketPolicy) + + // Put Object policy for group + objectStatement := &types.Statement{ + Actions: []types.ActionType{types.ACTION_DELETE_OBJECT}, + Effect: types.EFFECT_ALLOW, + } + msgPutObjectPolicy := storagetypes.NewMsgPutPolicy(owner.GetAddr(), types2.NewObjectGRN(bucketName, objectName).String(), + principal, []*types.Statement{objectStatement}, nil) + s.SendTxBlock(owner, msgPutObjectPolicy) + + // Query bucket policy for group + grn := types2.NewBucketGRN(bucketName) + queryPolicyForGroupReq := storagetypes.QueryPolicyForGroupRequest{Resource: grn.String(), + PrincipalGroupId: headGroupResponse.GroupInfo.Id.String()} + + queryPolicyForGroupResp, err := s.Client.QueryPolicyForGroup(ctx, &queryPolicyForGroupReq) + s.Require().NoError(err) + s.Require().Equal(bucketId, queryPolicyForGroupResp.Policy.ResourceId) + s.Require().Equal(queryPolicyForGroupResp.Policy.ResourceType, resource.RESOURCE_TYPE_BUCKET) + s.Require().Equal(types.EFFECT_ALLOW, queryPolicyForGroupResp.Policy.Statements[0].Effect) + bucketPolicyID := queryPolicyForGroupResp.Policy.Id + + // Query object policy for group + grn2 := types2.NewObjectGRN(bucketName, objectName) + queryPolicyForGroupResp, err = s.Client.QueryPolicyForGroup(ctx, &storagetypes.QueryPolicyForGroupRequest{Resource: grn2.String(), + PrincipalGroupId: headGroupResponse.GroupInfo.Id.String()}) + s.Require().NoError(err) + s.Require().Equal(objectId, queryPolicyForGroupResp.Policy.ResourceId) + s.Require().Equal(queryPolicyForGroupResp.Policy.ResourceType, resource.RESOURCE_TYPE_OBJECT) + s.Require().Equal(types.EFFECT_ALLOW, queryPolicyForGroupResp.Policy.Statements[0].Effect) + objectPolicyID := queryPolicyForGroupResp.Policy.Id + + // verify group policy + verifyPermResp, err := s.Client.VerifyPermission(ctx, &storagetypes.QueryVerifyPermissionRequest{ + Operator: user[2].GetAddr().String(), + BucketName: bucketName, + ActionType: types.ACTION_DELETE_BUCKET, + }) + s.T().Logf("Verify Bucket Permission, %s", verifyPermResp.String()) + s.Require().NoError(err) + s.Require().Equal(types.EFFECT_ALLOW, verifyPermResp.Effect) + // verify group policy + verifyPermResp, err = s.Client.VerifyPermission(ctx, &storagetypes.QueryVerifyPermissionRequest{ + Operator: user[2].GetAddr().String(), + BucketName: bucketName, + ObjectName: objectName, + ActionType: types.ACTION_DELETE_OBJECT, + }) + s.T().Logf("Verify Object Permission, %s", verifyPermResp.String()) + s.Require().NoError(err) + s.Require().Equal(types.EFFECT_ALLOW, verifyPermResp.Effect) + + // user1 deletes the group + msgDeleteGroup := storagetypes.NewMsgDeleteGroup(owner.GetAddr(), testGroupName) + s.SendTxBlock(owner, msgDeleteGroup) + + // group don't exist after deletion + _, err = s.Client.HeadGroup(ctx, &storagetypes.QueryHeadGroupRequest{ + GroupOwner: owner.GetAddr().String(), + GroupName: testGroupName, + }) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such group") + + // stale permission is still exist + queryPolicyByIDResp, err := s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: bucketPolicyID.String()}) + s.T().Logf("Qyery policy by id resp: %s", queryPolicyByIDResp) + s.Require().NoError(err) + + queryPolicyByIDResp, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: objectPolicyID.String()}) + s.T().Logf("Qyery policy by id resp: %s", queryPolicyByIDResp) + s.Require().NoError(err) + + // verify group policy + verifyPermResp, err = s.Client.VerifyPermission(ctx, &storagetypes.QueryVerifyPermissionRequest{ + Operator: user[2].GetAddr().String(), + BucketName: bucketName, + ActionType: types.ACTION_DELETE_BUCKET, + }) + s.T().Logf("Verify Bucket Permission, %s", verifyPermResp.String()) + s.Require().NoError(err) + s.Require().Equal(types.EFFECT_DENY, verifyPermResp.Effect) + // verify group policy + verifyPermResp, err = s.Client.VerifyPermission(ctx, &storagetypes.QueryVerifyPermissionRequest{ + Operator: user[2].GetAddr().String(), + BucketName: bucketName, + ObjectName: objectName, + ActionType: types.ACTION_DELETE_OBJECT, + }) + s.T().Logf("Verify Object Permission, %s", verifyPermResp.String()) + s.Require().NoError(err) + s.Require().Equal(types.EFFECT_DENY, verifyPermResp.Effect) +} + +func (s *StorageTestSuite) UpdateParams(newParams *storagetypes.Params) { + var err error + validator := s.Validator.GetAddr() + + ctx := context.Background() + + msgUpdateParams := &storagetypes.MsgUpdateParams{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Params: *newParams, + } + + msgProposal, err := govtypesv1.NewMsgSubmitProposal( + []sdk.Msg{msgUpdateParams}, + sdk.Coins{sdk.NewCoin(s.BaseSuite.Config.Denom, sdktype.NewIntFromInt64WithDecimal(100, sdktype.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) + + queryParamsResponse, err := s.Client.StorageQueryClient.Params(ctx, &storagetypes.QueryParamsRequest{}) + s.Require().NoError(err) + s.T().Logf("QueryParmas: %s", queryParamsResponse.Params.String()) + s.Require().Equal(queryParamsResponse.Params, *newParams) +} diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index 2a1055407..7f0412c42 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -237,6 +237,20 @@ func (k Keeper) GetPolicyForAccount(ctx sdk.Context, resourceID math.Uint, return k.GetPolicyByID(ctx, k.policySeq.DecodeSequence(bz)) } +func (k Keeper) GetPolicyGroupForResource(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType) (*types.PolicyGroup, bool) { + store := ctx.KVStore(k.storeKey) + policyGroupKey := types.GetPolicyForGroupKey(resourceID, resourceType) + + bz := store.Get(policyGroupKey) + if bz == nil { + return nil, false + } + + var policyGroup types.PolicyGroup + k.cdc.MustUnmarshal(bz, &policyGroup) + return &policyGroup, true +} + func (k Keeper) GetPolicyForGroup(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType, groupID math.Uint) (policy *types.Policy, isFound bool) { @@ -260,69 +274,6 @@ func (k Keeper) GetPolicyForGroup(ctx sdk.Context, resourceID math.Uint, return nil, false } -func (k Keeper) VerifyPolicy(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType, - operator sdk.AccAddress, action types.ActionType, opts *types.VerifyOptions) types.Effect { - // verify policy which grant permission to account - policy, found := k.GetPolicyForAccount(ctx, resourceID, resourceType, operator) - if found { - effect, newPolicy := policy.Eval(action, ctx.BlockTime(), opts) - k.Logger(ctx).Info(fmt.Sprintf("CreateObject LimitSize update: %s, effect: %s, ctx.TxBytes : %d", - newPolicy.String(), effect, ctx.TxSize())) - if effect != types.EFFECT_UNSPECIFIED { - if effect == types.EFFECT_ALLOW && action == types.ACTION_CREATE_OBJECT && newPolicy != nil && ctx.TxBytes() != nil { - _, err := k.PutPolicy(ctx, newPolicy) - if err != nil { - panic(fmt.Sprintf("Update policy error, %s", err)) - } - } - return effect - } - } - - // verify policy which grant permission to group - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.GetPolicyForGroupKey(resourceID, resourceType)) - if bz != nil { - policyGroup := types.PolicyGroup{} - k.cdc.MustUnmarshal(bz, &policyGroup) - allowed := false - var ( - newPolicy *types.Policy - effect types.Effect - ) - for _, item := range policyGroup.Items { - // check the group has the right permission of this resource - p := k.MustGetPolicyByID(ctx, item.PolicyId) - effect, newPolicy = p.Eval(action, ctx.BlockTime(), opts) - if effect != types.EFFECT_UNSPECIFIED { - // check the operator is the member of this group - groupMember, memberFound := k.GetGroupMember(ctx, item.GroupId, operator) - if memberFound && groupMember.ExpirationTime.After(ctx.BlockTime().UTC()) { - // check if the operator has been revoked - if effect == types.EFFECT_ALLOW { - allowed = true - } else if effect == types.EFFECT_DENY { - return types.EFFECT_DENY - } - } - } - } - if allowed { - if action == types.ACTION_CREATE_OBJECT && newPolicy != nil && ctx.TxBytes() != nil { - if effect == types.EFFECT_ALLOW && action == types.ACTION_CREATE_OBJECT && newPolicy != nil && ctx.TxBytes() != nil { - _, err := k.PutPolicy(ctx, newPolicy) - if err != nil { - panic(fmt.Sprintf("Update policy error, %s", err)) - } - } - } - return types.EFFECT_ALLOW - } - } - - return types.EFFECT_UNSPECIFIED -} - func (k Keeper) DeletePolicy(ctx sdk.Context, principal *types.Principal, resourceType resource.ResourceType, resourceID math.Uint) (math.Uint, error) { store := ctx.KVStore(k.storeKey) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 6367b36b2..24f444961 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -2131,3 +2131,9 @@ func (k Keeper) SetInternalBucketInfo(ctx sdk.Context, bucketID sdkmath.Uint, in func (k Keeper) fromSpMaintenanceAcct(sp *sptypes.StorageProvider, operatorAddr sdk.AccAddress) bool { return sp.Status == sptypes.STATUS_IN_MAINTENANCE && operatorAddr.Equals(sdk.MustAccAddressFromHex(sp.MaintenanceAddress)) } + +func (k Keeper) hasGroup(ctx sdk.Context, groupID sdkmath.Uint) bool { + store := ctx.KVStore(k.storeKey) + + return store.Has(types.GetGroupByIDKey(groupID)) +} diff --git a/x/storage/keeper/permission.go b/x/storage/keeper/permission.go index 2ff0c2271..9b3870b84 100644 --- a/x/storage/keeper/permission.go +++ b/x/storage/keeper/permission.go @@ -1,6 +1,7 @@ package keeper import ( + "fmt" "strings" "cosmossdk.io/math" @@ -49,7 +50,7 @@ func (k Keeper) VerifyBucketPermission(ctx sdk.Context, bucketInfo *types.Bucket return permtypes.EFFECT_ALLOW } // verify policy - effect := k.permKeeper.VerifyPolicy(ctx, bucketInfo.Id, gnfdresource.RESOURCE_TYPE_BUCKET, operator, action, options) + effect := k.VerifyPolicy(ctx, bucketInfo.Id, gnfdresource.RESOURCE_TYPE_BUCKET, operator, action, options) if effect == permtypes.EFFECT_ALLOW { return permtypes.EFFECT_ALLOW } @@ -94,12 +95,12 @@ func (k Keeper) VerifyObjectPermission(ctx sdk.Context, bucketInfo *types.Bucket opts := &permtypes.VerifyOptions{ Resource: types2.NewObjectGRN(objectInfo.BucketName, objectInfo.ObjectName).String(), } - bucketEffect := k.permKeeper.VerifyPolicy(ctx, bucketInfo.Id, gnfdresource.RESOURCE_TYPE_BUCKET, operator, action, opts) + bucketEffect := k.VerifyPolicy(ctx, bucketInfo.Id, gnfdresource.RESOURCE_TYPE_BUCKET, operator, action, opts) if bucketEffect == permtypes.EFFECT_DENY { return permtypes.EFFECT_DENY } - objectEffect := k.permKeeper.VerifyPolicy(ctx, objectInfo.Id, gnfdresource.RESOURCE_TYPE_OBJECT, operator, action, + objectEffect := k.VerifyPolicy(ctx, objectInfo.Id, gnfdresource.RESOURCE_TYPE_OBJECT, operator, action, nil) if objectEffect == permtypes.EFFECT_DENY { return permtypes.EFFECT_DENY @@ -119,7 +120,7 @@ func (k Keeper) VerifyGroupPermission(ctx sdk.Context, groupInfo *types.GroupInf } // verify policy - effect := k.permKeeper.VerifyPolicy(ctx, groupInfo.Id, gnfdresource.RESOURCE_TYPE_GROUP, operator, action, nil) + effect := k.VerifyPolicy(ctx, groupInfo.Id, gnfdresource.RESOURCE_TYPE_GROUP, operator, action, nil) if effect == permtypes.EFFECT_ALLOW { return permtypes.EFFECT_ALLOW } @@ -127,6 +128,63 @@ func (k Keeper) VerifyGroupPermission(ctx sdk.Context, groupInfo *types.GroupInf return permtypes.EFFECT_DENY } +func (k Keeper) VerifyPolicy(ctx sdk.Context, resourceID math.Uint, resourceType gnfdresource.ResourceType, + operator sdk.AccAddress, action permtypes.ActionType, opts *permtypes.VerifyOptions) permtypes.Effect { + // verify policy which grant permission to account + policy, found := k.permKeeper.GetPolicyForAccount(ctx, resourceID, resourceType, operator) + if found { + effect, newPolicy := policy.Eval(action, ctx.BlockTime(), opts) + k.Logger(ctx).Info(fmt.Sprintf("CreateObject LimitSize update: %s, effect: %s, ctx.TxBytes : %d", + newPolicy.String(), effect, ctx.TxSize())) + if effect != permtypes.EFFECT_UNSPECIFIED { + if effect == permtypes.EFFECT_ALLOW && action == permtypes.ACTION_CREATE_OBJECT && newPolicy != nil && ctx.TxBytes() != nil { + _, err := k.permKeeper.PutPolicy(ctx, newPolicy) + if err != nil { + panic(fmt.Sprintf("Update policy error, %s", err)) + } + } + return effect + } + } + + // verify policy which grant permission to group + policyGroup, found := k.permKeeper.GetPolicyGroupForResource(ctx, resourceID, resourceType) + if found { + allowed := false + var allowedPolicy *permtypes.Policy + for _, item := range policyGroup.Items { + if !k.hasGroup(ctx, item.GroupId) { + continue + } + // check the group has the right permission of this resource + p := k.permKeeper.MustGetPolicyByID(ctx, item.PolicyId) + effect, newPolicy := p.Eval(action, ctx.BlockTime(), opts) + if effect != permtypes.EFFECT_UNSPECIFIED { + // check the operator is the member of this group + groupMember, memberFound := k.permKeeper.GetGroupMember(ctx, item.GroupId, operator) + if memberFound && groupMember.ExpirationTime.After(ctx.BlockTime().UTC()) { + if effect == permtypes.EFFECT_ALLOW { + allowed = true + allowedPolicy = newPolicy + } else if effect == permtypes.EFFECT_DENY { + return permtypes.EFFECT_DENY + } + } + } + } + if allowed { + if action == permtypes.ACTION_CREATE_OBJECT && allowedPolicy != nil && ctx.TxBytes() != nil { + _, err := k.permKeeper.PutPolicy(ctx, allowedPolicy) + if err != nil { + panic(fmt.Sprintf("Update policy error, %s", err)) + } + } + return permtypes.EFFECT_ALLOW + } + } + return permtypes.EFFECT_UNSPECIFIED +} + func (k Keeper) GetPolicy(ctx sdk.Context, grn *types2.GRN, principal *permtypes.Principal) (*permtypes.Policy, error) { var resID math.Uint switch grn.ResourceType() { diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index c9248665a..91c35c82a 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -53,10 +53,10 @@ type PermissionKeeper interface { PutPolicy(ctx sdk.Context, policy *permtypes.Policy) (math.Uint, error) DeletePolicy(ctx sdk.Context, principal *permtypes.Principal, resourceType resource.ResourceType, resourceID math.Uint) (math.Uint, error) - VerifyPolicy(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType, operator sdk.AccAddress, - action permtypes.ActionType, opts *permtypes.VerifyOptions) permtypes.Effect AddGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress, expiration time.Time) error UpdateGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress, memberID math.Uint, expiration time.Time) + MustGetPolicyByID(ctx sdk.Context, policyID math.Uint) *permtypes.Policy + GetPolicyGroupForResource(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType) (*permtypes.PolicyGroup, bool) RemoveGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress) error GetPolicyByID(ctx sdk.Context, policyID math.Uint) (*permtypes.Policy, bool) GetPolicyForAccount(ctx sdk.Context, resourceID math.Uint, resourceType resource.ResourceType, addr sdk.AccAddress) (policy *permtypes.Policy, isFound bool) diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 5ea50af65..17ba75331 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -558,6 +558,35 @@ func (mr *MockPermissionKeeperMockRecorder) GetPolicyForGroup(ctx, resourceID, r return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyForGroup", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyForGroup), ctx, resourceID, resourceType, groupID) } +// GetPolicyGroupForResource mocks base method. +func (m *MockPermissionKeeper) GetPolicyGroupForResource(ctx types3.Context, resourceID math.Uint, resourceType resource.ResourceType) (*types0.PolicyGroup, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPolicyGroupForResource", ctx, resourceID, resourceType) + ret0, _ := ret[0].(*types0.PolicyGroup) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetPolicyGroupForResource indicates an expected call of GetPolicyGroupForResource. +func (mr *MockPermissionKeeperMockRecorder) GetPolicyGroupForResource(ctx, resourceID, resourceType interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyGroupForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyGroupForResource), ctx, resourceID, resourceType) +} + +// MustGetPolicyByID mocks base method. +func (m *MockPermissionKeeper) MustGetPolicyByID(ctx types3.Context, policyID math.Uint) *types0.Policy { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MustGetPolicyByID", ctx, policyID) + ret0, _ := ret[0].(*types0.Policy) + return ret0 +} + +// MustGetPolicyByID indicates an expected call of MustGetPolicyByID. +func (mr *MockPermissionKeeperMockRecorder) MustGetPolicyByID(ctx, policyID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MustGetPolicyByID", reflect.TypeOf((*MockPermissionKeeper)(nil).MustGetPolicyByID), ctx, policyID) +} + // PutPolicy mocks base method. func (m *MockPermissionKeeper) PutPolicy(ctx types3.Context, policy *types0.Policy) (math.Uint, error) { m.ctrl.T.Helper() @@ -599,20 +628,6 @@ func (mr *MockPermissionKeeperMockRecorder) UpdateGroupMember(ctx, groupID, memb return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).UpdateGroupMember), ctx, groupID, member, memberID, expiration) } -// VerifyPolicy mocks base method. -func (m *MockPermissionKeeper) VerifyPolicy(ctx types3.Context, resourceID math.Uint, resourceType resource.ResourceType, operator types3.AccAddress, action types0.ActionType, opts *types0.VerifyOptions) types0.Effect { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyPolicy", ctx, resourceID, resourceType, operator, action, opts) - ret0, _ := ret[0].(types0.Effect) - return ret0 -} - -// VerifyPolicy indicates an expected call of VerifyPolicy. -func (mr *MockPermissionKeeperMockRecorder) VerifyPolicy(ctx, resourceID, resourceType, operator, action, opts interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyPolicy", reflect.TypeOf((*MockPermissionKeeper)(nil).VerifyPolicy), ctx, resourceID, resourceType, operator, action, opts) -} - // MockCrossChainKeeper is a mock of CrossChainKeeper interface. type MockCrossChainKeeper struct { ctrl *gomock.Controller From 67831a955b7f031b64b25686a46c4bf8d47f46af Mon Sep 17 00:00:00 2001 From: randyahx <62416962+randyahx@users.noreply.github.com> Date: Tue, 8 Aug 2023 17:35:26 +0800 Subject: [PATCH 23/24] release: draft release for v0.2.4-alpha.1 (#405) * Update CHANGELOG.md * update go.mod * Update CHANGELOG.md --- CHANGELOG.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 6 +++--- go.sum | 12 ++++++------ 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4e0a1eef..457da5b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,54 @@ # Changelog +## v0.2.4-alpha.1 +This release includes 4 features, 9 bugfixes and 2 documentation updates. + +Features: +* [#374](https://github.com/bnb-chain/greenfield/pull/374) feat: group member expiration +* [#390](https://github.com/bnb-chain/greenfield/pull/390) feat: add flag to enable/disable heavy queries and refactor apis +* [#399](https://github.com/bnb-chain/greenfield/pull/399) feat: add new query APIs for group and group member +* [#403](https://github.com/bnb-chain/greenfield/pull/403) feat: sp maintenance mode + +Bugfixes: +* [#377](https://github.com/bnb-chain/greenfield/pull/377) fix: improve e2e tests to include more coverage from server side +* [#379](https://github.com/bnb-chain/greenfield/pull/379) fix: error member name in transferInRefundPackageType +* [#383](https://github.com/bnb-chain/greenfield/pull/383) fix: fix lock balance not updated for frozen payment account +* [#385](https://github.com/bnb-chain/greenfield/pull/385) fix: fix returned operation type in group cross chain app +* [#391](https://github.com/bnb-chain/greenfield/pull/391) fix: add cancel mb event for discontinue and delete +* [#398](https://github.com/bnb-chain/greenfield/pull/398) fix: register gov cross-chain app +* [#400](https://github.com/bnb-chain/greenfield/pull/400) fix: allow edit-sp by cmd without blskey +* [#401](https://github.com/bnb-chain/greenfield/pull/401) fix: add group existence check when verify permission +* [#375](https://github.com/bnb-chain/greenfield/pull/375) fix: fix defining err for ErrInvalidBlsPubKey + +Chores: +* [#376](https://github.com/bnb-chain/greenfield/pull/376) chore: add unit tests for the storage module +* [#378](https://github.com/bnb-chain/greenfield/pull/378) chore: add unit test cases for challenge module +* [#380](https://github.com/bnb-chain/greenfield/pull/380) chore: add unit test cases for payment module +* [#381](https://github.com/bnb-chain/greenfield/pull/381) chore: add tests for bridge module +* [#387](https://github.com/bnb-chain/greenfield/pull/387) chore: add more e2e test cases for payment module +* [#388](https://github.com/bnb-chain/greenfield/pull/388) chore: add cli tests +* [#389](https://github.com/bnb-chain/greenfield/pull/389) chore: add more test cases for cross chain apps + +Documentation: +* [#402](https://github.com/bnb-chain/greenfield/pull/402) docs: update testnet asset to v0.2.3 +* [#404](https://github.com/bnb-chain/greenfield/pull/404) docs: update document site link + +## 0.2.3 +This is a official release for v0.2.3, includes all the changes since v0.2.2. + +Bugfixes: +* [#375](https://github.com/bnb-chain/greenfield/pull/375) fix: defining err +* [#379](https://github.com/bnb-chain/greenfield/pull/379) fix: error member name in transferInRefundPackageType +* [#383](https://github.com/bnb-chain/greenfield/pull/383) fix: lock balance not updated for frozen payment account +* [#385](https://github.com/bnb-chain/greenfield/pull/385) fix: returned operation type in group cross chain app + +Chores: +* [#376](https://github.com/bnb-chain/greenfield/pull/376) chore: add unit tests for the storage module +* [#377](https://github.com/bnb-chain/greenfield/pull/377) chore: improve e2e tests to include more coverage from server side +* [#380](https://github.com/bnb-chain/greenfield/pull/380) chore: add unit test cases for payment module +* [#381](https://github.com/bnb-chain/greenfield/pull/381) chore: add tests for bridge module +* [#383](https://github.com/bnb-chain/greenfield/pull/383) chore: add unit test cases for challenge module + ## 0.2.3-alpha.7 This release includes 2 features and 3 bugfixes. diff --git a/go.mod b/go.mod index 4962c97e1..0442f2f54 100644 --- a/go.mod +++ b/go.mod @@ -174,10 +174,10 @@ replace ( cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0 - github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2 + github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.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.3.0.20230808064832-8b1e6d51ea69 - github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1 + github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) diff --git a/go.sum b/go.sum index fbeccfba4..92ce2a9cd 100644 --- a/go.sum +++ b/go.sum @@ -159,18 +159,18 @@ github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsy github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= -github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2 h1:ys9kmgtRx04wcCextE6CrVmbL1bJDklWr+hWgm1y2k4= -github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2/go.mod h1:EBmwmUdaNbGPyGjf1cMuoN3pAeM2tQu7Lfg95813EAw= +github.com/bnb-chain/greenfield-cometbft v0.0.2 h1:bRamS8Lq1lA3ttRLZBha22uiNG5tqN+diD3hapdUCYI= +github.com/bnb-chain/greenfield-cometbft v0.0.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.3.0.20230808064832-8b1e6d51ea69 h1:977mfnEuBR7Rnoa2r/qqNccXP4FhgciuC38tnP7Ez0Q= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230808064832-8b1e6d51ea69/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1 h1:SpkwHzAjIllIQG8av7MybFjJ8mhW1ZZ+P9JqJIsENxI= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1/go.mod h1:vyZi5fr4gZBVbhV/TLxbm6T8vylHXbfqQmDCUCUPPfo= 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= github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= -github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 h1:ZnIcvkkQVurg0OaAwmUGn2cK5bZbffjVChFyhh86HMk= -github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1/go.mod h1:oLksTs8dfh7DYIKBro7hbRQ+ewls7ghJ27pIXlbEXyI= +github.com/bnb-chain/greenfield-iavl v0.20.1 h1:y3L64GU99otNp27/xLVBTDbv4eroR6CzoYz0rbaVotM= +github.com/bnb-chain/greenfield-iavl v0.20.1/go.mod h1:oLksTs8dfh7DYIKBro7hbRQ+ewls7ghJ27pIXlbEXyI= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= From e207200b5009d77dec449afb06b18685fc240701 Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Tue, 8 Aug 2023 17:44:33 +0800 Subject: [PATCH 24/24] fix: fix params (#407) * add maintenance mode for sp * fix test * add query api and fix test * change underlying storage model * add cmd * fix comments * modify the default params --- x/sp/types/params.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/sp/types/params.go b/x/sp/types/params.go index fd041cad3..d25650a30 100644 --- a/x/sp/types/params.go +++ b/x/sp/types/params.go @@ -17,11 +17,11 @@ const ( // Default deposit denom DefaultDepositDenom = "BNB" // DefaultNumOfHistoricalBlocksForMaintenanceRecords The oldest block from current will be kept of for SP maintenance records - DefaultNumOfHistoricalBlocksForMaintenanceRecords = 21600 //todo set a reasonable number after test + DefaultNumOfHistoricalBlocksForMaintenanceRecords = 864000 // DefaultMaintenanceDurationQuota is the total allowed time for a SP to be in Maintenance mode within DefaultNumOfHistoricalBlocksForMaintenanceRecords - DefaultMaintenanceDurationQuota = 21600 // in second + DefaultMaintenanceDurationQuota = 21600 // 6 hour // DefaultNumOfLockUpBlocksForMaintenance defines blocks difference which Sp update itself to Maintenance mode is allowed - DefaultNumOfLockUpBlocksForMaintenance = 10 //todo set a reasonable number after test + DefaultNumOfLockUpBlocksForMaintenance = 21600 ) var (