From d0f35d9b0a074c571a4f3b31ac46411a1ede6ca6 Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Tue, 25 Apr 2023 18:06:13 +0800 Subject: [PATCH 01/13] feat: enable stale permission GC --- app/app.go | 3 +- e2e/tests/permission_test.go | 240 +++++++++ e2e/tests/storage_test.go | 13 +- proto/greenfield/storage/params.proto | 2 + proto/greenfield/storage/query.proto | 13 + proto/greenfield/storage/types.proto | 8 + testutil/keeper/storage.go | 2 + x/permission/keeper/keeper.go | 64 +++ x/permission/types/keys.go | 12 +- x/storage/abci.go | 5 + x/storage/genesis_test.go | 3 + x/storage/keeper/grpc_query_test.go | 3 + x/storage/keeper/keeper.go | 149 ++++++ x/storage/keeper/params.go | 5 + x/storage/keeper/permission.go | 1 - x/storage/keeper/query.go | 14 + x/storage/types/errors.go | 3 + x/storage/types/expected_keepers.go | 3 + x/storage/types/expected_keepers_mocks.go | 36 ++ x/storage/types/keys.go | 17 + x/storage/types/params.go | 7 +- x/storage/types/params.pb.go | 114 +++-- x/storage/types/query.pb.go | 596 ++++++++++++++++++---- x/storage/types/query.pb.gw.go | 101 ++++ x/storage/types/types.go | 22 + x/storage/types/types.pb.go | 429 +++++++++++++--- 26 files changed, 1653 insertions(+), 212 deletions(-) diff --git a/app/app.go b/app/app.go index 3275561d7..744f18639 100644 --- a/app/app.go +++ b/app/app.go @@ -288,7 +288,7 @@ func New( storagemoduletypes.StoreKey, challengemoduletypes.StoreKey, ) - tKeys := storetypes.NewTransientStoreKeys(challengemoduletypes.TStoreKey) + tKeys := storetypes.NewTransientStoreKeys(challengemoduletypes.TStoreKey, storagemoduletypes.TStoreKey) memKeys := storetypes.NewMemoryStoreKeys(challengemoduletypes.MemStoreKey) app := &App{ @@ -467,6 +467,7 @@ func New( app.StorageKeeper = *storagemodulekeeper.NewKeeper( appCodec, keys[storagemoduletypes.StoreKey], + tKeys[storagemoduletypes.TStoreKey], app.AccountKeeper, app.SpKeeper, app.PaymentKeeper, diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index 1ce2b9bb1..8b57ae556 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1002,3 +1002,243 @@ func (s *StorageTestSuite) TestEmptyPermission() { s.Require().Equal(verifyPermResp.Effect, object.Effect) } } + +// When resources are deleted, policies which associated with personal account(address) and resources(Bucket and Object) +// will also be garbage collected. +func (s *StorageTestSuite) TestStalePermissionForAccountGC() { + var err error + ctx := context.Background() + user1 := s.GenAndChargeAccounts(1, 1000000)[0] + + _, owner, bucketName, bucketId, 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(msgPutBucketPolicy, owner) + + // 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(msgPutObjectPolicy, owner) + + // Query the policy which is enforced on bucket and object + grn := types2.NewBucketGRN(bucketName) + queryPolicyForAccountResp, err := s.Client.QueryPolicyForAccount(ctx, &storagetypes.QueryPolicyForAccountRequest{Resource: grn.String(), + PrincipalAddress: user1.GetAddr().String()}) + s.Require().NoError(err) + s.Require().Equal(bucketId, queryPolicyForAccountResp.Policy.ResourceId) + bucketPolicyId := queryPolicyForAccountResp.Policy.Id + + grn2 := types2.NewObjectGRN(bucketName, objectName) + queryPolicyForAccountResp, err = s.Client.QueryPolicyForAccount(ctx, &storagetypes.QueryPolicyForAccountRequest{Resource: grn2.String(), + PrincipalAddress: user1.GetAddr().String()}) + s.Require().NoError(err) + s.Require().Equal(objectId, queryPolicyForAccountResp.Policy.ResourceId) + objectPolicyId := queryPolicyForAccountResp.Policy.Id + s.T().Log(queryPolicyForAccountResp.Policy.String()) + + // user1 deletes the object + msgDeleteObject := storagetypes.NewMsgDeleteObject(user1.GetAddr(), bucketName, objectName) + s.SendTxBlock(msgDeleteObject, user1) + + // user1 deletes the bucket + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user1.GetAddr(), bucketName) + s.SendTxBlock(msgDeleteBucket, user1) + + // bucket and object dont exist after deletion + headObjectReq := storagetypes.QueryHeadObjectRequest{ + BucketName: objectName, + } + _, err = s.Client.HeadObject(ctx, &headObjectReq) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such object") + + headBucketReq := storagetypes.QueryHeadBucketRequest{ + BucketName: bucketName, + } + _, err = s.Client.HeadBucket(ctx, &headBucketReq) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such bucket") + + // policy is GC + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: bucketPolicyId.String()}) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such Policy") + + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: objectPolicyId.String()}) + 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() { + ctx := context.Background() + user := s.GenAndChargeAccounts(3, 10000) + _, owner, bucketName, bucketId, objectName, objectId := s.createObjectWithVisibility(storagetypes.VISIBILITY_TYPE_PUBLIC_READ) + + // Create Group + testGroupName := "testGroup" + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, []sdk.AccAddress{user[0].GetAddr(), user[1].GetAddr(), user[2].GetAddr()}) + s.SendTxBlock(msgCreateGroup, owner) + + // 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.NewPrincipalWithGroup(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(msgPutBucketPolicy, owner) + + // 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(msgPutObjectPolicy, owner) + + // 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 + + // user1 deletes the object + msgDeleteObject := storagetypes.NewMsgDeleteObject(user[1].GetAddr(), bucketName, objectName) + s.SendTxBlock(msgDeleteObject, user[1]) + + // user1 deletes the bucket + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user[1].GetAddr(), bucketName) + s.SendTxBlock(msgDeleteBucket, user[1]) + + // bucket and object dont exist after deletion + headObjectReq := storagetypes.QueryHeadObjectRequest{ + BucketName: objectName, + } + _, err = s.Client.HeadObject(ctx, &headObjectReq) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such object") + + headBucketReq := storagetypes.QueryHeadBucketRequest{ + BucketName: bucketName, + } + _, err = s.Client.HeadBucket(ctx, &headBucketReq) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such bucket") + + time.Sleep(3 * time.Second) + // policy is GC + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: objectPolicyId.String()}) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such Policy") + + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: bucketPolicyId.String()}) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such Policy") +} + +// When a group is deleted, a. Policies associated with group members and group, b. group members +// will be garbage collected. +func (s *StorageTestSuite) TestGroupMembersAndPolicyGC() { + var err error + ctx := context.Background() + + user := s.GenAndChargeAccounts(4, 1000000) + owner := user[0] + _ = s.StorageProviders[0] + + // Create Group + testGroupName := "testGroup" + msgCreateGroup := storagetypes.NewMsgCreateGroup(owner.GetAddr(), testGroupName, + []sdk.AccAddress{user[1].GetAddr(), user[2].GetAddr(), user[3].GetAddr()}) + s.SendTxBlock(msgCreateGroup, owner) + + // 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(msgPutGroupPolicy, owner) + + // 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()) + policyID := queryPolicyForAccountResp.Policy.Id + + // Head Group member + headGroupMemberRequest := storagetypes.QueryHeadGroupMemberRequest{Member: user[2].GetAddr().String(), GroupOwner: owner.GetAddr().String(), GroupName: testGroupName} + headGroupMemberResponse, err := s.Client.HeadGroupMember(ctx, &headGroupMemberRequest) + s.Require().NoError(err) + 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) + s.Require().NoError(err) + s.T().Log(queryListGroupResp.String()) + + // the owner deletes the group + msgDeleteGroup := storagetypes.NewMsgDeleteGroup(owner.GetAddr(), testGroupName) + s.SendTxBlock(msgDeleteGroup, owner) + + // policy is GC + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: policyID.String()}) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such Policy") + +} diff --git a/e2e/tests/storage_test.go b/e2e/tests/storage_test.go index 9f5800009..c81ac641b 100644 --- a/e2e/tests/storage_test.go +++ b/e2e/tests/storage_test.go @@ -1197,14 +1197,19 @@ func (s *StorageTestSuite) TestDiscontinueBucket_UserDeleted() { s.Require().True(statusRes.SyncInfo.LatestBlockHeight > heightAfter) } +// createObject with default VISIBILITY_TYPE_PRIVATE func (s *StorageTestSuite) createObject() (core.SPKeyManagers, keys.KeyManager, string, storagetypes.Uint, string, storagetypes.Uint) { + return s.createObjectWithVisibility(storagetypes.VISIBILITY_TYPE_PRIVATE) +} + +func (s *StorageTestSuite) createObjectWithVisibility(v storagetypes.VisibilityType) (core.SPKeyManagers, keys.KeyManager, string, storagetypes.Uint, string, storagetypes.Uint) { var err error // CreateBucket sp := s.StorageProviders[0] user := s.GenAndChargeAccounts(1, 1000000)[0] bucketName := storageutils.GenRandomBucketName() msgCreateBucket := storagetypes.NewMsgCreateBucket( - user.GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PRIVATE, sp.OperatorKey.GetAddr(), + user.GetAddr(), bucketName, v, sp.OperatorKey.GetAddr(), nil, math.MaxUint, nil, 0) msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) s.Require().NoError(err) @@ -1221,7 +1226,7 @@ func (s *StorageTestSuite) createObject() (core.SPKeyManagers, keys.KeyManager, s.Require().Equal(queryHeadBucketResponse.BucketInfo.Owner, user.GetAddr().String()) s.Require().Equal(queryHeadBucketResponse.BucketInfo.PrimarySpAddress, sp.OperatorKey.GetAddr().String()) s.Require().Equal(queryHeadBucketResponse.BucketInfo.PaymentAddress, user.GetAddr().String()) - s.Require().Equal(queryHeadBucketResponse.BucketInfo.Visibility, storagetypes.VISIBILITY_TYPE_PRIVATE) + s.Require().Equal(queryHeadBucketResponse.BucketInfo.Visibility, v) s.Require().Equal(queryHeadBucketResponse.BucketInfo.SourceType, storagetypes.SOURCE_TYPE_ORIGIN) // CreateObject @@ -1246,7 +1251,7 @@ func (s *StorageTestSuite) createObject() (core.SPKeyManagers, keys.KeyManager, 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, nil) + msgCreateObject := storagetypes.NewMsgCreateObject(user.GetAddr(), bucketName, objectName, uint64(payloadSize), v, expectChecksum, contextType, storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil, nil) msgCreateObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateObject.GetApprovalBytes()) s.Require().NoError(err) s.SendTxBlock(msgCreateObject, user) @@ -1261,7 +1266,7 @@ func (s *StorageTestSuite) createObject() (core.SPKeyManagers, keys.KeyManager, 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.Visibility, v) s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_CREATED) s.Require().Equal(queryHeadObjectResponse.ObjectInfo.Owner, user.GetAddr().String()) s.Require().Equal(queryHeadObjectResponse.ObjectInfo.Checksums, expectChecksum) diff --git a/proto/greenfield/storage/params.proto b/proto/greenfield/storage/params.proto index bd03afd0f..50b3604f4 100644 --- a/proto/greenfield/storage/params.proto +++ b/proto/greenfield/storage/params.proto @@ -44,4 +44,6 @@ message Params { int64 discontinue_confirm_period = 16; // The max delete objects in each end block uint64 discontinue_deletion_max = 17; + // The max delete polies in each end block + uint64 stale_polies_cleanup_max = 18; } diff --git a/proto/greenfield/storage/query.proto b/proto/greenfield/storage/query.proto index 45ee3f466..22c593dcd 100644 --- a/proto/greenfield/storage/query.proto +++ b/proto/greenfield/storage/query.proto @@ -102,6 +102,11 @@ service Query { option (google.api.http).get = "/greenfield/storage/policy_for_group/{resource}/{principal_group_id}"; } + // Queries a policy by policy id + rpc QueryPolicyById(QueryPolicyByIdRequest) returns (QueryPolicyByIdResponse) { + option (google.api.http).get = "/greenfield/storage/policy_by_id/{policy_id}"; + } + // this line is used by starport scaffolding # 2 } @@ -237,4 +242,12 @@ message QueryPolicyForGroupResponse { permission.Policy policy = 1; } +message QueryPolicyByIdRequest { + string policy_id = 1; +} + +message QueryPolicyByIdResponse { + permission.Policy policy = 1; +} + // this line is used by starport scaffolding # 3 diff --git a/proto/greenfield/storage/types.proto b/proto/greenfield/storage/types.proto index ddca4cc9f..60f39292f 100644 --- a/proto/greenfield/storage/types.proto +++ b/proto/greenfield/storage/types.proto @@ -158,3 +158,11 @@ message Ids { (gogoproto.nullable) = false ]; } + + +message DeleteInfo { + Ids bucket_ids = 1; + Ids object_ids = 2; + Ids group_ids = 3; +} + diff --git a/testutil/keeper/storage.go b/testutil/keeper/storage.go index 4dea9b07c..97d370107 100644 --- a/testutil/keeper/storage.go +++ b/testutil/keeper/storage.go @@ -79,6 +79,7 @@ func StorageKeeper(t testing.TB) (*keeper.Keeper, StorageDepKeepers, sdk.Context memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) storeKey := storetypes.NewKVStoreKey(types.StoreKey) + tStorekey := storetypes.NewTransientStoreKey(types.TStoreKey) db := tmdb.NewMemDB() stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NoOpMetrics{}) @@ -153,6 +154,7 @@ func StorageKeeper(t testing.TB) (*keeper.Keeper, StorageDepKeepers, sdk.Context k := keeper.NewKeeper( cdc, storeKey, + tStorekey, accountKeeper, spKeeper, paymentKeeper, diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index 0f28b13a6..23fed6cf5 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -5,6 +5,7 @@ import ( "cosmossdk.io/log" "cosmossdk.io/math" + "cosmossdk.io/store/prefix" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -331,13 +332,21 @@ func (k Keeper) DeletePolicy(ctx sdk.Context, principal *types.Principal, resour if bz != nil { policyGroup := types.PolicyGroup{} k.cdc.MustUnmarshal(bz, &policyGroup) + for i := 0; i < len(policyGroup.Items); i++ { if policyGroup.Items[i].GroupId.Equal(groupID) { // delete this item policyID = policyGroup.Items[i].PolicyId policyGroup.Items = append(policyGroup.Items[:i], policyGroup.Items[i+1:]...) + + // delete the concrete policy + store.Delete(types.GetPolicyByIDKey(policyID)) } } + // delete the key if value is empty + if len(policyGroup.Items) == 0 { + store.Delete(types.GetPolicyForGroupKey(resourceID, resourceType)) + } } } else { return math.ZeroUint(), types.ErrInvalidPrincipal.Wrap("Unknown principal type.") @@ -350,3 +359,58 @@ func (k Keeper) DeletePolicy(ctx sdk.Context, principal *types.Principal, resour } return policyID, nil } + +// ForceDeleteAccountPolicyForResource deletes all individual accounts policy enforced on resources +func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) { + if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { + return + } + resourcePolicyKey := types.PolicyForAccountPrefix(resourceID, resourceType) + store := ctx.KVStore(k.storeKey) + resourcePolicyStore := prefix.NewStore(store, resourcePolicyKey) + iterator := resourcePolicyStore.Iterator(nil, nil) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + // delete mapping policyId -> policy + policyID := sequence.DecodeSequence(iterator.Value()) + store.Delete(types.GetPolicyByIDKey(policyID)) + // delete mapping policyKey -> policyId + store.Delete(iterator.Key()) + } +} + +// ForceDeleteGroupPolicyForResource deletes group policy enforced on resource +func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) { + if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { + return + } + policyGroupKey := types.GetPolicyForGroupKey(resourceID, resourceType) + store := ctx.KVStore(k.storeKey) + bz := store.Get(policyGroupKey) + if bz != nil { + policyGroup := types.PolicyGroup{} + k.cdc.MustUnmarshal(bz, &policyGroup) + for i := 0; i < len(policyGroup.Items); i++ { + // delete concrete policy by policyId + store.Delete(types.GetPolicyByIDKey(policyGroup.Items[i].PolicyId)) + } + store.Delete(policyGroupKey) + } +} + +// ForceDeleteGroupMembers deletes group members when user deletes group +func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) { + + store := ctx.KVStore(k.storeKey) + groupMembersPrefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetGroupMembersKey(groupId)) + iter := groupMembersPrefixStore.Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + memberID := sequence.DecodeSequence(iter.Value()) + // delete GroupMemberByIDPrefix_id -> groupMember + store.Delete(types.GetGroupMemberByIDKey(memberID)) + // delete GroupMemberPrefix_groupId_memberAddr -> memberSequence(id) + store.Delete(iter.Key()) + } +} diff --git a/x/permission/types/keys.go b/x/permission/types/keys.go index 9d18b2124..2fb140328 100644 --- a/x/permission/types/keys.go +++ b/x/permission/types/keys.go @@ -41,7 +41,7 @@ var ( GroupMemberSequencePrefix = []byte{0x42} ) -func GetPolicyForAccountKey(resourceID math.Uint, resourceType resource.ResourceType, addr sdk.AccAddress) []byte { +func PolicyForAccountPrefix(resourceID math.Uint, resourceType resource.ResourceType) []byte { var key []byte switch resourceType { case resource.RESOURCE_TYPE_BUCKET: @@ -54,6 +54,11 @@ func GetPolicyForAccountKey(resourceID math.Uint, resourceType resource.Resource panic(fmt.Sprintf("GetPolicyForAccountKey Invalid Resource Type, %s", resourceType.String())) } key = append(key, resourceID.Bytes()...) + return key +} + +func GetPolicyForAccountKey(resourceID math.Uint, resourceType resource.ResourceType, addr sdk.AccAddress) []byte { + key := PolicyForAccountPrefix(resourceID, resourceType) key = append(key, addr.Bytes()...) return key } @@ -76,9 +81,14 @@ func GetPolicyByIDKey(policyID math.Uint) []byte { return append(PolicyByIDPrefix, policyID.Bytes()...) } +func GetGroupMembersKey(groupID math.Uint) []byte { + return append(GroupMemberPrefix, groupID.Bytes()...) +} + func GetGroupMemberKey(groupID math.Uint, member sdk.AccAddress) []byte { return append(GroupMemberPrefix, append(groupID.Bytes(), member.Bytes()...)...) } + func GetGroupMemberByIDKey(memberID math.Uint) []byte { return append(GroupMemberByIDPrefix, memberID.Bytes()...) } diff --git a/x/storage/abci.go b/x/storage/abci.go index 677a57c32..b0e0eb147 100644 --- a/x/storage/abci.go +++ b/x/storage/abci.go @@ -13,6 +13,7 @@ func BeginBlocker(ctx sdk.Context, keeper k.Keeper) { keeper.ClearDiscontinueObjectCount(ctx) keeper.ClearDiscontinueBucketCount(ctx) } + keeper.InitDeleteInfo(ctx) } func EndBlocker(ctx sdk.Context, keeper k.Keeper) { @@ -37,4 +38,8 @@ func EndBlocker(ctx sdk.Context, keeper k.Keeper) { if err != nil { panic("fail to delete buckets, err " + err.Error()) } + keeper.PersistDeleteInfo(ctx) + + // Permission GC + keeper.GarbageCollectResourcesStalePolicy(ctx) } diff --git a/x/storage/genesis_test.go b/x/storage/genesis_test.go index 0398a791c..bdb38f141 100644 --- a/x/storage/genesis_test.go +++ b/x/storage/genesis_test.go @@ -21,11 +21,14 @@ import ( func makeKeeper(t *testing.T) (*keeper.Keeper, sdk.Context) { encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{}) key := storetypes.NewKVStoreKey(types.StoreKey) + tStoreKey := storetypes.NewTransientStoreKey(types.TStoreKey) + testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) k := keeper.NewKeeper( encCfg.Codec, key, + tStoreKey, &types.MockAccountKeeper{}, &types.MockSpKeeper{}, &types.MockPaymentKeeper{}, diff --git a/x/storage/keeper/grpc_query_test.go b/x/storage/keeper/grpc_query_test.go index 7cc61febc..056269b1d 100644 --- a/x/storage/keeper/grpc_query_test.go +++ b/x/storage/keeper/grpc_query_test.go @@ -19,11 +19,14 @@ import ( func makeKeeper(t *testing.T) (*keeper.Keeper, sdk.Context) { encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{}) key := storetypes.NewKVStoreKey(types.StoreKey) + tStorekey := storetypes.NewTransientStoreKey(types.TStoreKey) + testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) k := keeper.NewKeeper( encCfg.Codec, key, + tStorekey, &types.MockAccountKeeper{}, &types.MockSpKeeper{}, &types.MockPaymentKeeper{}, diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 9419a0fdf..ee817a36e 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/bnb-chain/greenfield/internal/sequence" + "github.com/bnb-chain/greenfield/types/resource" 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" @@ -23,6 +24,7 @@ type ( Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey + tStoreKey storetypes.StoreKey spKeeper types.SpKeeper paymentKeeper types.PaymentKeeper accountKeeper types.AccountKeeper @@ -41,6 +43,7 @@ type ( func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, + tStoreKey storetypes.StoreKey, accountKeeper types.AccountKeeper, spKeeper types.SpKeeper, paymentKeeper types.PaymentKeeper, @@ -52,6 +55,7 @@ func NewKeeper( k := Keeper{ cdc: cdc, storeKey: storeKey, + tStoreKey: tStoreKey, accountKeeper: accountKeeper, spKeeper: spKeeper, paymentKeeper: paymentKeeper, @@ -182,6 +186,9 @@ func (k Keeper) doDeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketI store.Delete(bucketKey) store.Delete(types.GetBucketByIDKey(bucketInfo.Id)) + if err := k.appendResourceIdForDeletion(ctx, bucketInfo); err != nil { + return err + } err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteBucket{ Operator: operator.String(), Owner: bucketInfo.Owner, @@ -743,6 +750,10 @@ func (k Keeper) doDeleteObject(ctx sdk.Context, operator sdk.AccAddress, bucketI store.Delete(types.GetObjectKey(bucketInfo.BucketName, objectInfo.ObjectName)) store.Delete(types.GetObjectByIDKey(objectInfo.Id)) + if err := k.appendResourceIdForDeletion(ctx, objectInfo); err != nil { + return err + } + err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteObject{ Operator: operator.String(), BucketName: bucketInfo.BucketName, @@ -1147,6 +1158,10 @@ func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName store.Delete(types.GetGroupKey(operator, groupName)) store.Delete(types.GetGroupByIDKey(groupInfo.Id)) + if err := k.appendResourceIdForDeletion(ctx, groupInfo); err != nil { + return err + } + if err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteGroup{ Owner: groupInfo.Owner, GroupName: groupInfo.GroupName, @@ -1464,3 +1479,137 @@ func (k Keeper) getDiscontinueObjectStatus(ctx sdk.Context, objectId types.Uint) store.Delete(types.GetDiscontinueObjectStatusKey(objectId)) //remove it at the same time return types.ObjectStatus(status), nil } + +func (k Keeper) appendResourceIdForDeletion(ctx sdk.Context, resource interface{}) error { + if ctx.IsCheckTx() { + return nil + } + + tStore := ctx.TransientStore(k.tStoreKey) + bz := tStore.Get(types.CurrentBlockDeleteStalePoliciesKey) + if bz == nil { + return types.ErrKeyNotExist + } + deleteInfo := &types.DeleteInfo{} + k.cdc.MustUnmarshal(bz, deleteInfo) + switch r := resource.(type) { + case *types.BucketInfo: + bucketIds := deleteInfo.BucketIds.Id + bucketIds = append(bucketIds, r.Id) + deleteInfo.BucketIds = &types.Ids{Id: bucketIds} + case *types.ObjectInfo: + objectIds := deleteInfo.ObjectIds.Id + objectIds = append(objectIds, r.Id) + deleteInfo.ObjectIds = &types.Ids{Id: objectIds} + case *types.GroupInfo: + groupIds := deleteInfo.ObjectIds.Id + groupIds = append(groupIds, r.Id) + deleteInfo.GroupIds = &types.Ids{Id: groupIds} + default: + return types.ErrInvalidResource + } + tStore.Set(types.CurrentBlockDeleteStalePoliciesKey, k.cdc.MustMarshal(deleteInfo)) + return nil +} + +func (k Keeper) PersistDeleteInfo(ctx sdk.Context) { + tStore := ctx.TransientStore(k.tStoreKey) + bz := tStore.Get(types.CurrentBlockDeleteStalePoliciesKey) + if bz == nil { + panic(types.ErrKeyNotExist) + } + deleteInfo := &types.DeleteInfo{} + k.cdc.MustUnmarshal(bz, deleteInfo) + + // persist current block stale permission info to store if exists + if !deleteInfo.IsEmpty() { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetDeleteStalePoliesKey(ctx.BlockHeight()), bz) + } +} + +func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + deleteStalePoliciesPrefixStore := prefix.NewStore(store, types.DeleteStalePoliciesPrefix) + + // todo use store to keep track of processed GC height + iterator := deleteStalePoliciesPrefixStore.Iterator(nil, nil) + defer iterator.Close() + + maxCleanup := k.StalePoliesCleanupMax(ctx) + deletedCount := uint64(0) + + for ; iterator.Valid(); iterator.Next() { + deleteInfo := &types.DeleteInfo{} + k.cdc.MustUnmarshal(iterator.Value(), deleteInfo) + + if deleteInfo.ObjectIds != nil && len(deleteInfo.ObjectIds.Id) > 0 { + ids := deleteInfo.ObjectIds.Id + for idx, id := range ids { + k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, resource.RESOURCE_TYPE_OBJECT, id) + k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, resource.RESOURCE_TYPE_OBJECT, id) + deletedCount++ + // reaches the deletion limit during current endblocker + if deletedCount > maxCleanup { + ids = append(ids, ids[idx+1:]...) + deleteInfo.ObjectIds.Id = ids + return + } + } + // clean deleted objects id from deleteInfo + deleteInfo.ObjectIds = nil + } + + if deleteInfo.BucketIds != nil && len(deleteInfo.BucketIds.Id) > 0 { + ids := deleteInfo.BucketIds.Id + for idx, id := range ids { + k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, resource.RESOURCE_TYPE_BUCKET, id) + k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, resource.RESOURCE_TYPE_BUCKET, id) + deletedCount++ + if deletedCount > maxCleanup { + ids = append(ids, ids[idx+1:]...) + deleteInfo.BucketIds.Id = ids + return + } + } + // clean deleted buckets id from deleteInfo + deleteInfo.BucketIds = nil + } + + if deleteInfo.GroupIds != nil && len(deleteInfo.GroupIds.Id) > 0 { + ids := deleteInfo.GroupIds.Id + // for a group which is deleted by user, there are 2 parts need to clean: + // 1. group members within the group. + // 2. group policy + for idx, id := range ids { + k.permKeeper.ForceDeleteGroupMembers(ctx, id) + k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, resource.RESOURCE_TYPE_GROUP, id) + deletedCount++ + if deletedCount > maxCleanup { + ids = append(ids, ids[idx+1:]...) + deleteInfo.GroupIds.Id = ids + return + } + } + // clean deleted buckets id from deleteInfo + deleteInfo.GroupIds = nil + } + + // the specified block height(iterator-key)'s stale resource permission metadata is purged + if deleteInfo.IsEmpty() { + deleteStalePoliciesPrefixStore.Delete(iterator.Key()) + } + } +} + +// InitDeleteInfo init using transient store in BeginBlocker, and gets discarded in EndBlocker +// the deleteInfo holds resources' Ids, stale policies related to these Ids will be deleted in EndBlocker +func (k Keeper) InitDeleteInfo(ctx sdk.Context) { + deleteInfo := &types.DeleteInfo{ + BucketIds: &types.Ids{}, + ObjectIds: &types.Ids{}, + GroupIds: &types.Ids{}, + } + tStore := ctx.TransientStore(k.tStoreKey) + tStore.Set(types.CurrentBlockDeleteStalePoliciesKey, k.cdc.MustMarshal(deleteInfo)) +} diff --git a/x/storage/keeper/params.go b/x/storage/keeper/params.go index 10916b77a..6157025a2 100644 --- a/x/storage/keeper/params.go +++ b/x/storage/keeper/params.go @@ -139,6 +139,11 @@ func (k Keeper) DiscontinueDeletionMax(ctx sdk.Context) (res uint64) { return params.DiscontinueDeletionMax } +func (k Keeper) StalePoliesCleanupMax(ctx sdk.Context) (res uint64) { + params := k.GetParams(ctx) + return params.StalePoliesCleanupMax +} + // GetParams returns the current storage module parameters. func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { store := ctx.KVStore(k.storeKey) diff --git a/x/storage/keeper/permission.go b/x/storage/keeper/permission.go index 3eecb83a5..a5fb02f4e 100644 --- a/x/storage/keeper/permission.go +++ b/x/storage/keeper/permission.go @@ -295,7 +295,6 @@ func (k Keeper) DeletePolicy(ctx sdk.Context, operator sdk.AccAddress, principal operator.String(), resOwner.String()) } return k.permKeeper.DeletePolicy(ctx, principal, grn.ResourceType(), resID) - } func (k Keeper) validatePrincipal(ctx sdk.Context, resOwner sdk.AccAddress, principal *permtypes.Principal) error { diff --git a/x/storage/keeper/query.go b/x/storage/keeper/query.go index 1727a5b3e..61d671919 100644 --- a/x/storage/keeper/query.go +++ b/x/storage/keeper/query.go @@ -408,3 +408,17 @@ func (k Keeper) HeadGroupMember(goCtx context.Context, req *types.QueryHeadGroup } return &types.QueryHeadGroupMemberResponse{GroupMember: groupMember}, nil } + +func (k Keeper) QueryPolicyById(goCtx context.Context, req *types.QueryPolicyByIdRequest) (*types. + QueryPolicyByIdResponse, error) { + 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/errors.go b/x/storage/types/errors.go index 6231c4599..bf4f38caf 100644 --- a/x/storage/types/errors.go +++ b/x/storage/types/errors.go @@ -41,4 +41,7 @@ var ( ErrBucketDiscontinued = errors.Register(ModuleName, 3104, "the bucket is discontinued") ErrInvalidObjectStatus = errors.Register(ModuleName, 3105, "invalid object status") ErrInvalidBucketStatus = errors.Register(ModuleName, 3106, "invalid bucket status") + + ErrKeyNotExist = errors.Register(ModuleName, 3201, "DeletePermissionKey not exist") + ErrInvalidResource = errors.Register(ModuleName, 3202, "invalid resource type") ) diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index d8e98bcb9..11b0f037e 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -64,6 +64,9 @@ type PermissionKeeper interface { groupID math.Uint) (policy *permtypes.Policy, isFound bool) GetGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress) (*permtypes.GroupMember, bool) GetGroupMemberByID(ctx sdk.Context, groupMemberID math.Uint) (*permtypes.GroupMember, bool) + ForceDeleteAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) + ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) + ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) } type CrossChainKeeper interface { diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 38c2f7a67..23906c94d 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -600,3 +600,39 @@ func (mr *MockCrossChainKeeperMockRecorder) RegisterChannel(name, id, app interf mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterChannel", reflect.TypeOf((*MockCrossChainKeeper)(nil).RegisterChannel), name, id, app) } + +// ForceDeleteAccountPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ForceDeleteAccountPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) { + m.ctrl.T.Helper() + _ = m.ctrl.Call(m, "ForceDeleteAccountPolicyForResource", ctx, resourceType, resourceID) +} + +// ForceDeleteAccountPolicyForResource indicates an expected call of ForceDeleteAccountPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ForceDeletePolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), ctx, resourceType, resourceID) +} + +// ForceDeleteGroupPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ForceDeleteGroupPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) { + m.ctrl.T.Helper() + _ = m.ctrl.Call(m, "ForceDeleteGroupPolicyForResource", ctx, resourceType, resourceID) +} + +// ForceDeleteGroupPolicyForResource indicates an expected call of ForceDeleteGroupPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), ctx, resourceType, resourceID) +} + +// ForceDeleteGroupMembers mocks base method. +func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, groupId math.Uint) { + m.ctrl.T.Helper() + _ = m.ctrl.Call(m, "ForceDeleteGroupMembers", ctx, groupId) +} + +// ForceDeleteGroupMembers indicates an expected call of ForceDeleteGroupMembers. +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, groupId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), ctx, groupId) +} diff --git a/x/storage/types/keys.go b/x/storage/types/keys.go index 61d9a4f55..4d23054ad 100644 --- a/x/storage/types/keys.go +++ b/x/storage/types/keys.go @@ -21,6 +21,9 @@ const ( // MemStoreKey defines the in-memory store key MemStoreKey = "mem_storage" + + // TStoreKey defines the transient store key + TStoreKey = "transient_storage" ) type RawID math.Uint @@ -45,6 +48,13 @@ var ( DiscontinueObjectIdsPrefix = []byte{0x43} DiscontinueBucketIdsPrefix = []byte{0x44} DiscontinueObjectStatusPrefix = []byte{0x45} + + // CurrentBlockDeleteStalePoliciesKey is the key for DeleteInfo which keep track of deleted resources in the current block, + //stale permission of these resources needs to be deleted. + // it is stored in transient store + CurrentBlockDeleteStalePoliciesKey = []byte{0x51} + + DeleteStalePoliciesPrefix = []byte{0x52} ) // GetBucketKey return the bucket name store key @@ -108,3 +118,10 @@ func GetDiscontinueBucketIdsKey(timestamp int64) []byte { func GetDiscontinueObjectStatusKey(objectId math.Uint) []byte { return append(DiscontinueObjectStatusPrefix, sequence.EncodeSequence(objectId)...) } + +// GetDeleteStalePoliesKey return DeletePermission store key +func GetDeleteStalePoliesKey(height int64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, uint64(height)) + return append(DeleteStalePoliciesPrefix, bz...) +} diff --git a/x/storage/types/params.go b/x/storage/types/params.go index ed2119968..ee3745941 100644 --- a/x/storage/types/params.go +++ b/x/storage/types/params.go @@ -22,6 +22,7 @@ const ( DefaultDiscontinueBucketMax uint64 = math.MaxUint64 DefaultDiscontinueConfirmPeriod int64 = 604800 // 7 days (in second) DefaultDiscontinueDeletionMax uint64 = 10000 + DefaultStalePoliesCleanupMax uint64 = 200 DefaultMirrorBucketRelayerFee = "250000000000000" // 0.00025 DefaultMirrorBucketAckRelayerFee = "250000000000000" // 0.00025 @@ -43,7 +44,7 @@ var ( KeyDiscontinueBucketMax = []byte("DiscontinueBucketMax") KeyDiscontinueConfirmPeriod = []byte("DiscontinueConfirmPeriod") KeyDiscontinueDeletionMax = []byte("DiscontinueDeletionMax") - + KeyStalePoliesCleanupMax = []byte("StalePoliesCleanupMax") KeyMirrorBucketRelayerFee = []byte("MirrorBucketRelayerFee") KeyMirrorBucketAckRelayerFee = []byte("MirrorBucketAckRelayerFee") KeyMirrorObjectRelayerFee = []byte("MirrorObjectRelayerFee") @@ -69,6 +70,7 @@ func NewParams( discontinueCountingWindow, discontinueObjectMax, discontinueBucketMax uint64, discontinueConfirmPeriod int64, discontinueDeletionMax uint64, + stalePoliesCleanupMax uint64, ) Params { return Params{ MaxSegmentSize: maxSegmentSize, @@ -88,6 +90,7 @@ func NewParams( DiscontinueBucketMax: discontinueBucketMax, DiscontinueConfirmPeriod: discontinueConfirmPeriod, DiscontinueDeletionMax: discontinueDeletionMax, + StalePoliesCleanupMax: stalePoliesCleanupMax, } } @@ -100,7 +103,7 @@ func DefaultParams() Params { DefaultMirrorObjectRelayerFee, DefaultMirrorObjectAckRelayerFee, DefaultMirrorGroupRelayerFee, DefaultMirrorGroupAckRelayerFee, DefaultDiscontinueCountingWindow, DefaultDiscontinueObjectMax, DefaultDiscontinueBucketMax, - DefaultDiscontinueConfirmPeriod, DefaultDiscontinueDeletionMax, + DefaultDiscontinueConfirmPeriod, DefaultDiscontinueDeletionMax, DefaultStalePoliesCleanupMax, ) } diff --git a/x/storage/types/params.pb.go b/x/storage/types/params.pb.go index 0a96669cb..366296b49 100644 --- a/x/storage/types/params.pb.go +++ b/x/storage/types/params.pb.go @@ -59,6 +59,8 @@ type Params struct { DiscontinueConfirmPeriod int64 `protobuf:"varint,16,opt,name=discontinue_confirm_period,json=discontinueConfirmPeriod,proto3" json:"discontinue_confirm_period,omitempty"` // The max delete objects in each end block DiscontinueDeletionMax uint64 `protobuf:"varint,17,opt,name=discontinue_deletion_max,json=discontinueDeletionMax,proto3" json:"discontinue_deletion_max,omitempty"` + // The max delete polies in each end block + StalePoliesCleanupMax uint64 `protobuf:"varint,18,opt,name=stale_polies_cleanup_max,json=stalePoliesCleanupMax,proto3" json:"stale_polies_cleanup_max,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -212,6 +214,13 @@ func (m *Params) GetDiscontinueDeletionMax() uint64 { return 0 } +func (m *Params) GetStalePoliesCleanupMax() uint64 { + if m != nil { + return m.StalePoliesCleanupMax + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "greenfield.storage.Params") } @@ -219,43 +228,45 @@ func init() { func init() { proto.RegisterFile("greenfield/storage/params.proto", fileDescriptor_127b8b1511d84eca) } var fileDescriptor_127b8b1511d84eca = []byte{ - // 575 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0xcd, 0x6e, 0xd3, 0x4e, - 0x14, 0xc5, 0xe3, 0x7f, 0xfb, 0x6f, 0xe9, 0x40, 0x3f, 0xb0, 0xfa, 0xe1, 0x06, 0x70, 0x23, 0x16, - 0x28, 0x1b, 0xe2, 0x05, 0xa0, 0xf2, 0xa5, 0x8a, 0x36, 0x15, 0x88, 0x45, 0x21, 0x4a, 0x17, 0x48, - 0x6c, 0x46, 0x63, 0xfb, 0xc6, 0x19, 0x92, 0x99, 0xb1, 0xc6, 0x63, 0xd5, 0xe9, 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d, 0x9b, 0xaf, 0xd6, 0xc6, 0x48, - 0xe1, 0x6d, 0x69, 0x74, 0xd7, 0x52, 0xcd, 0xbe, 0x2e, 0x48, 0xb1, 0x4c, 0x55, 0x97, 0x2e, 0xa9, - 0xed, 0xbf, 0x28, 0xd3, 0xb9, 0xa4, 0x5e, 0xa3, 0x66, 0xbd, 0x2b, 0x1f, 0x50, 0xc9, 0xca, 0xbf, - 0x4a, 0x45, 0xec, 0xed, 0xb4, 0x9c, 0xf6, 0x4a, 0xdf, 0xab, 0x55, 0xd5, 0x86, 0x9e, 0xd6, 0xdd, - 0xe7, 0xc8, 0xd6, 0x70, 0x0c, 0x63, 0x50, 0x54, 0x70, 0x9d, 0x7a, 0x57, 0xa7, 0xda, 0x9d, 0xce, - 0x2b, 0xf9, 0x82, 0x14, 0x2f, 0x57, 0xbf, 0x7d, 0x3f, 0x6a, 0x9c, 0xbd, 0xff, 0x31, 0xf5, 0x9d, - 0x9b, 0xa9, 0xef, 0xfc, 0x9e, 0xfa, 0xce, 0xd7, 0x99, 0xdf, 0xb8, 0x99, 0xf9, 0x8d, 0x5f, 0x33, - 0xbf, 0xf1, 0x39, 0x48, 0xa8, 0x1a, 0xe6, 0x61, 0x27, 0x12, 0x2c, 0x08, 0x79, 0xf8, 0x38, 0x1a, - 0x12, 0xca, 0x03, 0xeb, 0x29, 0x29, 0xe6, 0x8f, 0x89, 0x9a, 0xa4, 0x90, 0x85, 0x6b, 0xfa, 0x89, - 0x78, 0xf2, 0x27, 0x00, 0x00, 0xff, 0xff, 0x5d, 0x8e, 0xac, 0x51, 0x6f, 0x04, 0x00, 0x00, + // 603 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x86, 0xe3, 0xaf, 0xfd, 0x4a, 0x3b, 0xd0, 0x1f, 0xac, 0xfe, 0xb8, 0x05, 0xd2, 0x88, 0x05, + 0xca, 0x86, 0x66, 0x01, 0xa8, 0xfc, 0xa9, 0xa2, 0x4d, 0x05, 0x62, 0x51, 0x88, 0xd2, 0x05, 0x12, + 0x9b, 0xd1, 0xd8, 0x3e, 0x75, 0x86, 0x78, 0x66, 0xac, 0xf1, 0x58, 0x75, 0x7a, 0x03, 0x6c, 0x59, + 0xb2, 0xe4, 0x72, 0x58, 0x76, 0xc9, 0x12, 0xb5, 0x37, 0x82, 0x7c, 0xc6, 0x4a, 0xc7, 0x81, 0x5d, + 0x34, 0xcf, 0xfb, 0xf8, 0x3d, 0x99, 0x23, 0x0d, 0xd9, 0x4d, 0x34, 0x80, 0x3c, 0xe3, 0x90, 0xc6, + 0xbd, 0xdc, 0x28, 0xcd, 0x12, 0xe8, 0x65, 0x4c, 0x33, 0x91, 0xef, 0x65, 0x5a, 0x19, 0xe5, 0xfb, + 0x37, 0x81, 0xbd, 0x3a, 0xb0, 0xb3, 0x9e, 0xa8, 0x44, 0x21, 0xee, 0x55, 0xbf, 0x6c, 0xf2, 0xe1, + 0xd7, 0x45, 0xb2, 0x30, 0x40, 0xd5, 0xef, 0x92, 0x35, 0xc1, 0x4a, 0x9a, 0x43, 0x22, 0x40, 0x1a, + 0x9a, 0xf3, 0x0b, 0x08, 0xbc, 0x8e, 0xd7, 0x9d, 0x1f, 0xae, 0x08, 0x56, 0x9e, 0xda, 0xe3, 0x53, + 0x7e, 0x01, 0xfe, 0x3e, 0x09, 0x34, 0xc4, 0x85, 0x8c, 0x99, 0x34, 0x34, 0x66, 0x86, 0xd1, 0x68, + 0x54, 0xc8, 0x31, 0x95, 0x85, 0x08, 0xfe, 0xeb, 0x78, 0xdd, 0xe5, 0xe1, 0xc6, 0x94, 0x1f, 0x33, + 0xc3, 0xfa, 0x15, 0xfd, 0x50, 0x08, 0xff, 0x15, 0xd9, 0xb9, 0x11, 0x33, 0xa6, 0xb9, 0x99, 0x38, + 0xea, 0x1c, 0xaa, 0x5b, 0xd3, 0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b, 0x54, 0x4e, 0x5f, 0x21, 0x33, 0xc9, 0x20, 0x0f, 0x17, 0xf0, 0x6d, 0x79, 0xf2, 0x27, 0x00, + 0x00, 0xff, 0xff, 0xd9, 0x19, 0xcf, 0xa2, 0xa8, 0x04, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -278,6 +289,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.StalePoliesCleanupMax != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.StalePoliesCleanupMax)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } if m.DiscontinueDeletionMax != 0 { i = encodeVarintParams(dAtA, i, uint64(m.DiscontinueDeletionMax)) i-- @@ -456,6 +474,9 @@ func (m *Params) Size() (n int) { if m.DiscontinueDeletionMax != 0 { n += 2 + sovParams(uint64(m.DiscontinueDeletionMax)) } + if m.StalePoliesCleanupMax != 0 { + n += 2 + sovParams(uint64(m.StalePoliesCleanupMax)) + } return n } @@ -895,6 +916,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StalePoliesCleanupMax", wireType) + } + m.StalePoliesCleanupMax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StalePoliesCleanupMax |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/storage/types/query.pb.go b/x/storage/types/query.pb.go index 6699e8423..2c8435919 100644 --- a/x/storage/types/query.pb.go +++ b/x/storage/types/query.pb.go @@ -1423,6 +1423,94 @@ func (m *QueryPolicyForGroupResponse) GetPolicy() *types.Policy { return nil } +type QueryPolicyByIdRequest struct { + PolicyId string `protobuf:"bytes,1,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` +} + +func (m *QueryPolicyByIdRequest) Reset() { *m = QueryPolicyByIdRequest{} } +func (m *QueryPolicyByIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPolicyByIdRequest) ProtoMessage() {} +func (*QueryPolicyByIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{29} +} +func (m *QueryPolicyByIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPolicyByIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPolicyByIdRequest.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 *QueryPolicyByIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPolicyByIdRequest.Merge(m, src) +} +func (m *QueryPolicyByIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPolicyByIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPolicyByIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPolicyByIdRequest proto.InternalMessageInfo + +func (m *QueryPolicyByIdRequest) GetPolicyId() string { + if m != nil { + return m.PolicyId + } + return "" +} + +type QueryPolicyByIdResponse struct { + Policy *types.Policy `protobuf:"bytes,1,opt,name=policy,proto3" json:"policy,omitempty"` +} + +func (m *QueryPolicyByIdResponse) Reset() { *m = QueryPolicyByIdResponse{} } +func (m *QueryPolicyByIdResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPolicyByIdResponse) ProtoMessage() {} +func (*QueryPolicyByIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{30} +} +func (m *QueryPolicyByIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPolicyByIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPolicyByIdResponse.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 *QueryPolicyByIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPolicyByIdResponse.Merge(m, src) +} +func (m *QueryPolicyByIdResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPolicyByIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPolicyByIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPolicyByIdResponse proto.InternalMessageInfo + +func (m *QueryPolicyByIdResponse) GetPolicy() *types.Policy { + if m != nil { + return m.Policy + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "greenfield.storage.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "greenfield.storage.QueryParamsResponse") @@ -1453,114 +1541,119 @@ func init() { proto.RegisterType((*QueryHeadGroupMemberResponse)(nil), "greenfield.storage.QueryHeadGroupMemberResponse") proto.RegisterType((*QueryPolicyForGroupRequest)(nil), "greenfield.storage.QueryPolicyForGroupRequest") proto.RegisterType((*QueryPolicyForGroupResponse)(nil), "greenfield.storage.QueryPolicyForGroupResponse") + proto.RegisterType((*QueryPolicyByIdRequest)(nil), "greenfield.storage.QueryPolicyByIdRequest") + proto.RegisterType((*QueryPolicyByIdResponse)(nil), "greenfield.storage.QueryPolicyByIdResponse") } func init() { proto.RegisterFile("greenfield/storage/query.proto", fileDescriptor_b1b80b580af04cb0) } var fileDescriptor_b1b80b580af04cb0 = []byte{ - // 1623 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xcd, 0x6f, 0xdc, 0x44, - 0x14, 0x8f, 0xd3, 0x12, 0x92, 0xd9, 0xd2, 0x96, 0xa1, 0x2d, 0xa9, 0xdb, 0x6c, 0x5b,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0x33, 0x99, 0x82, 0x13, - 0x7f, 0xa3, 0xa0, 0x3d, 0xb1, 0x16, 0x18, 0xeb, 0xf9, 0xde, 0x89, 0xf4, 0xf5, 0xea, 0x7c, 0x71, - 0x05, 0x00, 0x3b, 0xc7, 0xc1, 0x9e, 0xc0, 0x2f, 0xe6, 0x1c, 0x4e, 0x18, 0x03, 0x7e, 0x51, 0xfc, - 0xdf, 0xd1, 0x91, 0xf6, 0x76, 0xc4, 0x8d, 0x9b, 0xda, 0x6f, 0xab, 0x7a, 0x61, 0x79, 0xc0, 0x79, - 0x99, 0xe3, 0x5c, 0xc1, 0x97, 0x72, 0x8e, 0x23, 0xb8, 0x36, 0xf5, 0x30, 0xfa, 0xbd, 0xfb, 0xb0, - 0xba, 0x76, 0xff, 0x61, 0x59, 0x79, 0xf0, 0xb0, 0xac, 0xfc, 0xfb, 0xb0, 0xac, 0x7c, 0xf2, 0xa8, - 0x3c, 0xf6, 0xe0, 0x51, 0x79, 0xec, 0xcf, 0x47, 0xe5, 0xb1, 0x0d, 0xbd, 0x6d, 0xba, 0x37, 0x7b, - 0x8d, 0x4a, 0x93, 0x75, 0xf4, 0x86, 0xd5, 0x98, 0x6b, 0xde, 0x24, 0xa6, 0x25, 0xef, 0xf9, 0x61, - 0xf4, 0xdf, 0x7d, 0x63, 0x82, 0xff, 0xbc, 0x3f, 0xfb, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe9, - 0xf7, 0x1c, 0x93, 0xf5, 0x18, 0x00, 0x00, + // 1673 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x59, 0xcb, 0x6f, 0xdc, 0x54, + 0x17, 0x8f, 0xd3, 0x7e, 0xf9, 0x92, 0x9b, 0x7e, 0x6d, 0xbf, 0x4b, 0x4b, 0x53, 0xb7, 0x99, 0xb6, + 0x46, 0xf4, 0x45, 0x32, 0x4e, 0xda, 0x06, 0x11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 0x3a, 0xa2, 0x5d, 0xe2, 0x38, + 0xab, 0x78, 0x2a, 0x33, 0x27, 0x53, 0x70, 0xe2, 0xaf, 0x14, 0x74, 0x20, 0x36, 0x8b, 0x63, 0xbd, + 0xd8, 0x3a, 0x91, 0x05, 0x43, 0x9d, 0x29, 0xcf, 0x00, 0x60, 0xa7, 0x39, 0xd8, 0x33, 0xf8, 0xf9, + 0x82, 0xe4, 0x84, 0x7d, 0xe4, 0x27, 0xc5, 0xff, 0x5d, 0x3c, 0x32, 0x67, 0xe7, 0x74, 0xdc, 0xd4, + 0xc1, 0x5f, 0xd5, 0x4b, 0xd3, 0x03, 0xce, 0x6b, 0x1c, 0xe7, 0x32, 0xbe, 0x5a, 0x90, 0x8e, 0x60, + 0xda, 0xd4, 0x64, 0xf4, 0x97, 0x88, 0x81, 0xd7, 0x58, 0x0e, 0xc4, 0x26, 0xf4, 0x9c, 0x29, 0x27, + 0x31, 0xfd, 0xe7, 0x0c, 0x0c, 0xc9, 0x91, 0x3f, 0x3f, 0x1e, 0x00, 0x3a, 0xcc, 0x0a, 0xc1, 0x4a, + 0x31, 0x58, 0x5c, 0x7d, 0xf8, 0xb8, 0xa2, 0x3c, 0x7a, 0x5c, 0x51, 0xfe, 0x7a, 0x5c, 0x51, 0x3e, + 0x7a, 0x52, 0x19, 0x7a, 0xf4, 0xa4, 0x32, 0xf4, 0xdb, 0x93, 0xca, 0xd0, 0x86, 0xde, 0x36, 0xdd, + 0xdb, 0x5b, 0x8d, 0x6a, 0x93, 0x75, 0xf4, 0x86, 0xd5, 0x98, 0x6e, 0xde, 0x26, 0xa6, 0x25, 0xcb, + 0x7e, 0x3f, 0xfa, 0x3f, 0x47, 0x63, 0x84, 0xff, 0xd1, 0x71, 0xf1, 0xdf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xf2, 0x0e, 0x02, 0x5c, 0x21, 0x1a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1609,6 +1702,8 @@ type QueryClient interface { HeadGroupMember(ctx context.Context, in *QueryHeadGroupMemberRequest, opts ...grpc.CallOption) (*QueryHeadGroupMemberResponse, error) // Queries a policy that grants permission to a group QueryPolicyForGroup(ctx context.Context, in *QueryPolicyForGroupRequest, opts ...grpc.CallOption) (*QueryPolicyForGroupResponse, error) + // Queries a policy by policy id + QueryPolicyById(ctx context.Context, in *QueryPolicyByIdRequest, opts ...grpc.CallOption) (*QueryPolicyByIdResponse, error) } type queryClient struct { @@ -1772,6 +1867,15 @@ func (c *queryClient) QueryPolicyForGroup(ctx context.Context, in *QueryPolicyFo return out, nil } +func (c *queryClient) QueryPolicyById(ctx context.Context, in *QueryPolicyByIdRequest, opts ...grpc.CallOption) (*QueryPolicyByIdResponse, error) { + out := new(QueryPolicyByIdResponse) + err := c.cc.Invoke(ctx, "/greenfield.storage.Query/QueryPolicyById", 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. @@ -1808,6 +1912,8 @@ type QueryServer interface { HeadGroupMember(context.Context, *QueryHeadGroupMemberRequest) (*QueryHeadGroupMemberResponse, error) // Queries a policy that grants permission to a group QueryPolicyForGroup(context.Context, *QueryPolicyForGroupRequest) (*QueryPolicyForGroupResponse, error) + // Queries a policy by policy id + QueryPolicyById(context.Context, *QueryPolicyByIdRequest) (*QueryPolicyByIdResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1865,6 +1971,9 @@ func (*UnimplementedQueryServer) HeadGroupMember(ctx context.Context, req *Query func (*UnimplementedQueryServer) QueryPolicyForGroup(ctx context.Context, req *QueryPolicyForGroupRequest) (*QueryPolicyForGroupResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryPolicyForGroup not implemented") } +func (*UnimplementedQueryServer) QueryPolicyById(ctx context.Context, req *QueryPolicyByIdRequest) (*QueryPolicyByIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryPolicyById not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2176,6 +2285,24 @@ func _Query_QueryPolicyForGroup_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _Query_QueryPolicyById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPolicyByIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryPolicyById(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.storage.Query/QueryPolicyById", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryPolicyById(ctx, req.(*QueryPolicyByIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "greenfield.storage.Query", HandlerType: (*QueryServer)(nil), @@ -2248,6 +2375,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryPolicyForGroup", Handler: _Query_QueryPolicyForGroup_Handler, }, + { + MethodName: "QueryPolicyById", + Handler: _Query_QueryPolicyById_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "greenfield/storage/query.proto", @@ -3321,6 +3452,71 @@ func (m *QueryPolicyForGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } +func (m *QueryPolicyByIdRequest) 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 *QueryPolicyByIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPolicyByIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PolicyId) > 0 { + i -= len(m.PolicyId) + copy(dAtA[i:], m.PolicyId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PolicyId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPolicyByIdResponse) 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 *QueryPolicyByIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPolicyByIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Policy != nil { + { + size, err := m.Policy.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 @@ -3767,6 +3963,32 @@ func (m *QueryPolicyForGroupResponse) Size() (n int) { return n } +func (m *QueryPolicyByIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PolicyId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPolicyByIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Policy != nil { + l = m.Policy.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -6644,6 +6866,174 @@ func (m *QueryPolicyForGroupResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPolicyByIdRequest) 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: QueryPolicyByIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPolicyByIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PolicyId", 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.PolicyId = 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 *QueryPolicyByIdResponse) 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: QueryPolicyByIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPolicyByIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Policy", 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.Policy == nil { + m.Policy = &types.Policy{} + } + if err := m.Policy.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/storage/types/query.pb.gw.go b/x/storage/types/query.pb.gw.go index 6e6e586dd..411a68c1e 100644 --- a/x/storage/types/query.pb.gw.go +++ b/x/storage/types/query.pb.gw.go @@ -1094,6 +1094,60 @@ func local_request_Query_QueryPolicyForGroup_0(ctx context.Context, marshaler ru } +func request_Query_QueryPolicyById_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPolicyByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["policy_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "policy_id") + } + + protoReq.PolicyId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "policy_id", err) + } + + msg, err := client.QueryPolicyById(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryPolicyById_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPolicyByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["policy_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "policy_id") + } + + protoReq.PolicyId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "policy_id", err) + } + + msg, err := server.QueryPolicyById(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. @@ -1491,6 +1545,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryPolicyById_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_QueryPolicyById_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_QueryPolicyById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1872,6 +1949,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryPolicyById_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_QueryPolicyById_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_QueryPolicyById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1909,6 +2006,8 @@ var ( 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))) pattern_Query_QueryPolicyForGroup_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", "policy_for_group", "resource", "principal_group_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryPolicyById_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "storage", "policy_by_id", "policy_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1945,4 +2044,6 @@ var ( forward_Query_HeadGroupMember_0 = runtime.ForwardResponseMessage forward_Query_QueryPolicyForGroup_0 = runtime.ForwardResponseMessage + + forward_Query_QueryPolicyById_0 = runtime.ForwardResponseMessage ) diff --git a/x/storage/types/types.go b/x/storage/types/types.go index c7cb7f412..8186b7d25 100644 --- a/x/storage/types/types.go +++ b/x/storage/types/types.go @@ -70,3 +70,25 @@ func getNFTAttributes(m interface{}) []Trait { } return attributes } + +func (di *DeleteInfo) IsEmpty() bool { + isBucketIdsEmpty := false + isObjectIdsEmpty := false + isGroupIdsEmpty := false + if di == nil { + return true + } + if di.BucketIds == nil || (di.BucketIds != nil && len(di.BucketIds.Id) == 0) { + isBucketIdsEmpty = true + } + if di.ObjectIds == nil || (di.ObjectIds != nil && len(di.ObjectIds.Id) == 0) { + isObjectIdsEmpty = true + } + if di.GroupIds == nil || (di.GroupIds != nil && len(di.GroupIds.Id) == 0) { + isGroupIdsEmpty = true + } + if isBucketIdsEmpty && isObjectIdsEmpty && isGroupIdsEmpty { + return true + } + return false +} diff --git a/x/storage/types/types.pb.go b/x/storage/types/types.pb.go index c9b879a6b..4b4a32b19 100644 --- a/x/storage/types/types.pb.go +++ b/x/storage/types/types.pb.go @@ -819,6 +819,66 @@ func (m *Ids) XXX_DiscardUnknown() { var xxx_messageInfo_Ids proto.InternalMessageInfo +type DeleteInfo struct { + BucketIds *Ids `protobuf:"bytes,1,opt,name=bucket_ids,json=bucketIds,proto3" json:"bucket_ids,omitempty"` + ObjectIds *Ids `protobuf:"bytes,2,opt,name=object_ids,json=objectIds,proto3" json:"object_ids,omitempty"` + GroupIds *Ids `protobuf:"bytes,3,opt,name=group_ids,json=groupIds,proto3" json:"group_ids,omitempty"` +} + +func (m *DeleteInfo) Reset() { *m = DeleteInfo{} } +func (m *DeleteInfo) String() string { return proto.CompactTextString(m) } +func (*DeleteInfo) ProtoMessage() {} +func (*DeleteInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{10} +} +func (m *DeleteInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteInfo.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 *DeleteInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteInfo.Merge(m, src) +} +func (m *DeleteInfo) XXX_Size() int { + return m.Size() +} +func (m *DeleteInfo) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteInfo proto.InternalMessageInfo + +func (m *DeleteInfo) GetBucketIds() *Ids { + if m != nil { + return m.BucketIds + } + return nil +} + +func (m *DeleteInfo) GetObjectIds() *Ids { + if m != nil { + return m.ObjectIds + } + return nil +} + +func (m *DeleteInfo) GetGroupIds() *Ids { + if m != nil { + return m.GroupIds + } + return nil +} + func init() { proto.RegisterType((*BucketInfo)(nil), "greenfield.storage.BucketInfo") proto.RegisterType((*BillingInfo)(nil), "greenfield.storage.BillingInfo") @@ -830,74 +890,79 @@ func init() { proto.RegisterType((*ObjectMetaData)(nil), "greenfield.storage.ObjectMetaData") proto.RegisterType((*GroupMetaData)(nil), "greenfield.storage.GroupMetaData") proto.RegisterType((*Ids)(nil), "greenfield.storage.Ids") + proto.RegisterType((*DeleteInfo)(nil), "greenfield.storage.DeleteInfo") } func init() { proto.RegisterFile("greenfield/storage/types.proto", fileDescriptor_bf95fa2efdc74d97) } var fileDescriptor_bf95fa2efdc74d97 = []byte{ - // 990 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xd1, 0x6a, 0xdc, 0x46, - 0x17, 0xb6, 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xfe, 0x3e, 0xed, 0x58, 0xbf, 0x9c, 0x75, 0x16, 0x5e, 0x9d, 0x75, 0x16, 0xfe, 0x3c, 0xeb, - 0x2c, 0x7c, 0x3f, 0x4c, 0xa8, 0x3c, 0x2c, 0xc3, 0x41, 0xc4, 0xb2, 0x61, 0x98, 0x87, 0xdb, 0xd1, - 0x21, 0xa6, 0xf9, 0xb0, 0xf6, 0x93, 0xf9, 0xfc, 0xf2, 0xaf, 0x6e, 0xb8, 0xa4, 0x7e, 0x33, 0x3f, - 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x67, 0x47, 0x78, 0x9a, 0x0d, 0x0b, 0x00, 0x00, + // 1048 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xd1, 0x6a, 0x1b, 0x47, + 0x17, 0xf6, 0x7a, 0x25, 0xff, 0xd6, 0x59, 0xd9, 0x4e, 0x06, 0xe3, 0x7f, 0x9d, 0x60, 0x49, 0xd1, + 0x95, 0x48, 0x6b, 0x09, 0xdc, 0x92, 0x42, 0x29, 0x04, 0xab, 0x49, 0x5b, 0x53, 0x9a, 0xd2, 0x95, + 0xd3, 0x8b, 0xde, 0x2c, 0xb3, 0xbb, 0xe3, 0xf5, 0xd4, 0xbb, 0x3b, 0xdb, 0x99, 0xd9, 0x34, 0x0a, + 0xf4, 0x1d, 0xfa, 0x18, 0xbd, 0x2e, 0x79, 0x85, 0x82, 0x29, 0x14, 0x42, 0xae, 0x4a, 0x2f, 0x4c, + 0xb1, 0xdf, 0xa0, 0x17, 0xbd, 0x2e, 0x3b, 0x33, 0xb2, 0xd7, 0xb6, 0x62, 0xa3, 0x10, 0xdf, 0x69, + 0xce, 0x7c, 0xdf, 0xcc, 0x39, 0xdf, 0x7c, 0xe7, 0x68, 0xa1, 0x15, 0x73, 0x42, 0xb2, 0x3d, 0x4a, + 0x92, 0x68, 0x20, 0x24, 0xe3, 0x38, 0x26, 0x03, 0x39, 0xce, 0x89, 0xe8, 0xe7, 0x9c, 0x49, 0x86, + 0xd0, 0xd9, 0x7e, 0xdf, 0xec, 0xdf, 0x59, 0x0f, 0x99, 0x48, 0x99, 0xf0, 0x15, 0x62, 0xa0, 0x17, + 0x1a, 0x7e, 0x67, 0x35, 0x66, 0x31, 0xd3, 0xf1, 0xf2, 0x97, 0x89, 0x6e, 0x54, 0x2e, 0xc9, 0xf1, + 0x38, 0x25, 0x99, 0x1c, 0x04, 0x58, 0x10, 0xb3, 0xdd, 0x9e, 0x92, 0x43, 0xc8, 0xd2, 0x94, 0x65, + 0x1a, 0xd0, 0xfd, 0xb7, 0x06, 0x30, 0x2c, 0xc2, 0x03, 0x22, 0x77, 0xb2, 0x3d, 0x86, 0xfa, 0x50, + 0x67, 0x3f, 0x66, 0x84, 0xbb, 0x56, 0xc7, 0xea, 0x35, 0x86, 0xee, 0xeb, 0x97, 0x9b, 0xab, 0x26, + 0x8b, 0xed, 0x28, 0xe2, 0x44, 0x88, 0x91, 0xe4, 0x34, 0x8b, 0x3d, 0x0d, 0x43, 0x6d, 0x70, 0x02, + 0xc5, 0xf6, 0x33, 0x9c, 0x12, 0x77, 0xbe, 0x64, 0x79, 0xa0, 0x43, 0x4f, 0x70, 0x4a, 0xd0, 0x10, + 0xe0, 0x19, 0x15, 0x34, 0xa0, 0x09, 0x95, 0x63, 0xd7, 0xee, 0x58, 0xbd, 0xe5, 0xad, 0x6e, 0xff, + 0x72, 0xe5, 0xfd, 0x6f, 0x4f, 0x51, 0xbb, 0xe3, 0x9c, 0x78, 0x15, 0x16, 0x7a, 0x0f, 0xe6, 0x69, + 0xe4, 0xd6, 0x54, 0x46, 0x77, 0x0f, 0x8f, 0xda, 0x73, 0x7f, 0x1d, 0xb5, 0x6b, 0x4f, 0x69, 0x26, + 0x5f, 0xbf, 0xdc, 0x74, 0x4c, 0x76, 0xe5, 0xd2, 0x9b, 0xa7, 0x11, 0x7a, 0x08, 0x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b, 0xf8, 0x83, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x65, 0x75, 0xfd, 0x02, 0xc2, 0x0b, 0x00, 0x00, } func (m *BucketInfo) Marshal() (dAtA []byte, err error) { @@ -1508,6 +1573,65 @@ func (m *Ids) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DeleteInfo) 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 *DeleteInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GroupIds != nil { + { + size, err := m.GroupIds.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.ObjectIds != nil { + { + size, err := m.ObjectIds.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BucketIds != nil { + { + size, err := m.BucketIds.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 encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -1804,6 +1928,27 @@ func (m *Ids) Size() (n int) { return n } +func (m *DeleteInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BucketIds != nil { + l = m.BucketIds.Size() + n += 1 + l + sovTypes(uint64(l)) + } + if m.ObjectIds != nil { + l = m.ObjectIds.Size() + n += 1 + l + sovTypes(uint64(l)) + } + if m.GroupIds != nil { + l = m.GroupIds.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3766,6 +3911,164 @@ func (m *Ids) Unmarshal(dAtA []byte) error { } return nil } +func (m *DeleteInfo) 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: DeleteInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketIds", 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 m.BucketIds == nil { + m.BucketIds = &Ids{} + } + if err := m.BucketIds.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectIds", 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 m.ObjectIds == nil { + m.ObjectIds = &Ids{} + } + if err := m.ObjectIds.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupIds", 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 m.GroupIds == nil { + m.GroupIds = &Ids{} + } + if err := m.GroupIds.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 skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 14fd59379ef067d08e99b70d2740c9996a65773e Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Thu, 27 Apr 2023 15:05:08 +0800 Subject: [PATCH 02/13] refine code --- e2e/tests/permission_test.go | 1 - proto/greenfield/storage/params.proto | 4 +- proto/greenfield/storage/types.proto | 1 - x/permission/keeper/keeper.go | 15 ++-- x/permission/types/keys.go | 2 +- x/storage/keeper/keeper.go | 12 ++-- x/storage/keeper/params.go | 4 +- x/storage/types/keys.go | 4 +- x/storage/types/params.go | 21 ++++-- x/storage/types/params.pb.go | 100 +++++++++++++------------- x/storage/types/types.go | 5 +- 11 files changed, 87 insertions(+), 82 deletions(-) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index 8b57ae556..fa11aab04 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1165,7 +1165,6 @@ func (s *StorageTestSuite) TestStalePermissionForGroupGC() { s.Require().Error(err) s.Require().ErrorContains(err, "No such bucket") - time.Sleep(3 * time.Second) // policy is GC _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: objectPolicyId.String()}) s.Require().Error(err) diff --git a/proto/greenfield/storage/params.proto b/proto/greenfield/storage/params.proto index 50b3604f4..93c2aa2e5 100644 --- a/proto/greenfield/storage/params.proto +++ b/proto/greenfield/storage/params.proto @@ -44,6 +44,6 @@ message Params { int64 discontinue_confirm_period = 16; // The max delete objects in each end block uint64 discontinue_deletion_max = 17; - // The max delete polies in each end block - uint64 stale_polies_cleanup_max = 18; + // The max number for deleting policy in each end block + uint64 stale_policy_cleanup_max = 18; } diff --git a/proto/greenfield/storage/types.proto b/proto/greenfield/storage/types.proto index 60f39292f..2aa7be740 100644 --- a/proto/greenfield/storage/types.proto +++ b/proto/greenfield/storage/types.proto @@ -159,7 +159,6 @@ message Ids { ]; } - message DeleteInfo { Ids bucket_ids = 1; Ids object_ids = 2; diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index 23fed6cf5..5b49f5c82 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -365,10 +365,9 @@ func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, resourceTyp if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { return } - resourcePolicyKey := types.PolicyForAccountPrefix(resourceID, resourceType) store := ctx.KVStore(k.storeKey) - resourcePolicyStore := prefix.NewStore(store, resourcePolicyKey) - iterator := resourcePolicyStore.Iterator(nil, nil) + resourceAccountsPolicyStore := prefix.NewStore(store, types.PolicyForAccountPrefix(resourceID, resourceType)) + iterator := resourceAccountsPolicyStore.Iterator(nil, nil) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { // delete mapping policyId -> policy @@ -384,9 +383,9 @@ func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { return } - policyGroupKey := types.GetPolicyForGroupKey(resourceID, resourceType) + policyForGroupKey := types.GetPolicyForGroupKey(resourceID, resourceType) store := ctx.KVStore(k.storeKey) - bz := store.Get(policyGroupKey) + bz := store.Get(policyForGroupKey) if bz != nil { policyGroup := types.PolicyGroup{} k.cdc.MustUnmarshal(bz, &policyGroup) @@ -394,18 +393,16 @@ func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType // delete concrete policy by policyId store.Delete(types.GetPolicyByIDKey(policyGroup.Items[i].PolicyId)) } - store.Delete(policyGroupKey) + store.Delete(policyForGroupKey) } } // ForceDeleteGroupMembers deletes group members when user deletes group func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) { - store := ctx.KVStore(k.storeKey) - groupMembersPrefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetGroupMembersKey(groupId)) + groupMembersPrefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GroupMembersPrefix(groupId)) iter := groupMembersPrefixStore.Iterator(nil, nil) defer iter.Close() - for ; iter.Valid(); iter.Next() { memberID := sequence.DecodeSequence(iter.Value()) // delete GroupMemberByIDPrefix_id -> groupMember diff --git a/x/permission/types/keys.go b/x/permission/types/keys.go index 2fb140328..caf8df6fe 100644 --- a/x/permission/types/keys.go +++ b/x/permission/types/keys.go @@ -81,7 +81,7 @@ func GetPolicyByIDKey(policyID math.Uint) []byte { return append(PolicyByIDPrefix, policyID.Bytes()...) } -func GetGroupMembersKey(groupID math.Uint) []byte { +func GroupMembersPrefix(groupID math.Uint) []byte { return append(GroupMemberPrefix, groupID.Bytes()...) } diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index ee817a36e..57a4f860d 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -186,7 +186,7 @@ func (k Keeper) doDeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketI store.Delete(bucketKey) store.Delete(types.GetBucketByIDKey(bucketInfo.Id)) - if err := k.appendResourceIdForDeletion(ctx, bucketInfo); err != nil { + if err := k.appendResourceIdForGarbageCollection(ctx, bucketInfo); err != nil { return err } err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteBucket{ @@ -750,7 +750,7 @@ func (k Keeper) doDeleteObject(ctx sdk.Context, operator sdk.AccAddress, bucketI store.Delete(types.GetObjectKey(bucketInfo.BucketName, objectInfo.ObjectName)) store.Delete(types.GetObjectByIDKey(objectInfo.Id)) - if err := k.appendResourceIdForDeletion(ctx, objectInfo); err != nil { + if err := k.appendResourceIdForGarbageCollection(ctx, objectInfo); err != nil { return err } @@ -1158,7 +1158,7 @@ func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName store.Delete(types.GetGroupKey(operator, groupName)) store.Delete(types.GetGroupByIDKey(groupInfo.Id)) - if err := k.appendResourceIdForDeletion(ctx, groupInfo); err != nil { + if err := k.appendResourceIdForGarbageCollection(ctx, groupInfo); err != nil { return err } @@ -1480,7 +1480,7 @@ func (k Keeper) getDiscontinueObjectStatus(ctx sdk.Context, objectId types.Uint) return types.ObjectStatus(status), nil } -func (k Keeper) appendResourceIdForDeletion(ctx sdk.Context, resource interface{}) error { +func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resource interface{}) error { if ctx.IsCheckTx() { return nil } @@ -1524,7 +1524,7 @@ func (k Keeper) PersistDeleteInfo(ctx sdk.Context) { // persist current block stale permission info to store if exists if !deleteInfo.IsEmpty() { store := ctx.KVStore(k.storeKey) - store.Set(types.GetDeleteStalePoliesKey(ctx.BlockHeight()), bz) + store.Set(types.GetDeleteStalePoliciesKey(ctx.BlockHeight()), bz) } } @@ -1536,7 +1536,7 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { iterator := deleteStalePoliciesPrefixStore.Iterator(nil, nil) defer iterator.Close() - maxCleanup := k.StalePoliesCleanupMax(ctx) + maxCleanup := k.StalePolicyCleanupMax(ctx) deletedCount := uint64(0) for ; iterator.Valid(); iterator.Next() { diff --git a/x/storage/keeper/params.go b/x/storage/keeper/params.go index 6157025a2..a9d7dcbe5 100644 --- a/x/storage/keeper/params.go +++ b/x/storage/keeper/params.go @@ -139,9 +139,9 @@ func (k Keeper) DiscontinueDeletionMax(ctx sdk.Context) (res uint64) { return params.DiscontinueDeletionMax } -func (k Keeper) StalePoliesCleanupMax(ctx sdk.Context) (res uint64) { +func (k Keeper) StalePolicyCleanupMax(ctx sdk.Context) (res uint64) { params := k.GetParams(ctx) - return params.StalePoliesCleanupMax + return params.StalePolicyCleanupMax } // GetParams returns the current storage module parameters. diff --git a/x/storage/types/keys.go b/x/storage/types/keys.go index 4d23054ad..912cdf2bd 100644 --- a/x/storage/types/keys.go +++ b/x/storage/types/keys.go @@ -119,8 +119,8 @@ func GetDiscontinueObjectStatusKey(objectId math.Uint) []byte { return append(DiscontinueObjectStatusPrefix, sequence.EncodeSequence(objectId)...) } -// GetDeleteStalePoliesKey return DeletePermission store key -func GetDeleteStalePoliesKey(height int64) []byte { +// GetDeleteStalePoliciesKey return delete stale policies store Key +func GetDeleteStalePoliciesKey(height int64) []byte { bz := make([]byte, 8) binary.BigEndian.PutUint64(bz, uint64(height)) return append(DeleteStalePoliciesPrefix, bz...) diff --git a/x/storage/types/params.go b/x/storage/types/params.go index ee3745941..7f22f9b0c 100644 --- a/x/storage/types/params.go +++ b/x/storage/types/params.go @@ -22,7 +22,7 @@ const ( DefaultDiscontinueBucketMax uint64 = math.MaxUint64 DefaultDiscontinueConfirmPeriod int64 = 604800 // 7 days (in second) DefaultDiscontinueDeletionMax uint64 = 10000 - DefaultStalePoliesCleanupMax uint64 = 200 + DefaultStalePolicyCleanupMax uint64 = 200 DefaultMirrorBucketRelayerFee = "250000000000000" // 0.00025 DefaultMirrorBucketAckRelayerFee = "250000000000000" // 0.00025 @@ -44,7 +44,7 @@ var ( KeyDiscontinueBucketMax = []byte("DiscontinueBucketMax") KeyDiscontinueConfirmPeriod = []byte("DiscontinueConfirmPeriod") KeyDiscontinueDeletionMax = []byte("DiscontinueDeletionMax") - KeyStalePoliesCleanupMax = []byte("StalePoliesCleanupMax") + KeyStalePolicyCleanupMax = []byte("StalePolicyCleanupMax") KeyMirrorBucketRelayerFee = []byte("MirrorBucketRelayerFee") KeyMirrorBucketAckRelayerFee = []byte("MirrorBucketAckRelayerFee") KeyMirrorObjectRelayerFee = []byte("MirrorObjectRelayerFee") @@ -90,7 +90,7 @@ func NewParams( DiscontinueBucketMax: discontinueBucketMax, DiscontinueConfirmPeriod: discontinueConfirmPeriod, DiscontinueDeletionMax: discontinueDeletionMax, - StalePoliesCleanupMax: stalePoliesCleanupMax, + StalePolicyCleanupMax: stalePoliesCleanupMax, } } @@ -103,7 +103,7 @@ func DefaultParams() Params { DefaultMirrorObjectRelayerFee, DefaultMirrorObjectAckRelayerFee, DefaultMirrorGroupRelayerFee, DefaultMirrorGroupAckRelayerFee, DefaultDiscontinueCountingWindow, DefaultDiscontinueObjectMax, DefaultDiscontinueBucketMax, - DefaultDiscontinueConfirmPeriod, DefaultDiscontinueDeletionMax, DefaultStalePoliesCleanupMax, + DefaultDiscontinueConfirmPeriod, DefaultDiscontinueDeletionMax, DefaultStalePolicyCleanupMax, ) } @@ -127,6 +127,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyDiscontinueBucketMax, &p.DiscontinueBucketMax, validateDiscontinueBucketMax), paramtypes.NewParamSetPair(KeyDiscontinueConfirmPeriod, &p.DiscontinueConfirmPeriod, validateDiscontinueConfirmPeriod), paramtypes.NewParamSetPair(KeyDiscontinueDeletionMax, &p.DiscontinueDeletionMax, validateDiscontinueDeletionMax), + paramtypes.NewParamSetPair(KeyStalePolicyCleanupMax, &p.StalePolicyCleanupMax, validateStalePolicyCleanupMax), } } @@ -340,3 +341,15 @@ func validateDiscontinueDeletionMax(i interface{}) error { } return nil } + +func validateStalePolicyCleanupMax(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("StalePolicyCleanupMax must be positive: %d", v) + } + return nil +} diff --git a/x/storage/types/params.pb.go b/x/storage/types/params.pb.go index 366296b49..bdb605ad0 100644 --- a/x/storage/types/params.pb.go +++ b/x/storage/types/params.pb.go @@ -59,8 +59,8 @@ type Params struct { DiscontinueConfirmPeriod int64 `protobuf:"varint,16,opt,name=discontinue_confirm_period,json=discontinueConfirmPeriod,proto3" json:"discontinue_confirm_period,omitempty"` // The max delete objects in each end block DiscontinueDeletionMax uint64 `protobuf:"varint,17,opt,name=discontinue_deletion_max,json=discontinueDeletionMax,proto3" json:"discontinue_deletion_max,omitempty"` - // The max delete polies in each end block - StalePoliesCleanupMax uint64 `protobuf:"varint,18,opt,name=stale_polies_cleanup_max,json=stalePoliesCleanupMax,proto3" json:"stale_polies_cleanup_max,omitempty"` + // The max number for deleting policy in each end block + StalePolicyCleanupMax uint64 `protobuf:"varint,18,opt,name=stale_policy_cleanup_max,json=stalePolicyCleanupMax,proto3" json:"stale_policy_cleanup_max,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -214,9 +214,9 @@ func (m *Params) GetDiscontinueDeletionMax() uint64 { return 0 } -func (m *Params) GetStalePoliesCleanupMax() uint64 { +func (m *Params) GetStalePolicyCleanupMax() uint64 { if m != nil { - return m.StalePoliesCleanupMax + return m.StalePolicyCleanupMax } return 0 } @@ -228,45 +228,45 @@ func init() { func init() { proto.RegisterFile("greenfield/storage/params.proto", fileDescriptor_127b8b1511d84eca) } var fileDescriptor_127b8b1511d84eca = []byte{ - // 603 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x86, 0xe3, 0xaf, 0xfd, 0x4a, 0x3b, 0xd0, 0x1f, 0xac, 0xfe, 0xb8, 0x05, 0xd2, 0x88, 0x05, - 0xca, 0x86, 0x66, 0x01, 0xa8, 0xfc, 0xa9, 0xa2, 0x4d, 0x05, 0x62, 0x51, 0x88, 0xd2, 0x05, 0x12, - 0x9b, 0xd1, 0xd8, 0x3e, 0x75, 0x86, 0x78, 0x66, 0xac, 0xf1, 0x58, 0x75, 0x7a, 0x03, 0x6c, 0x59, - 0xb2, 0xe4, 0x72, 0x58, 0x76, 0xc9, 0x12, 0xb5, 0x37, 0x82, 0x7c, 0xc6, 0x4a, 0xc7, 0x81, 0x5d, - 0x34, 0xcf, 0xfb, 0xf8, 0x3d, 0x99, 0x23, 0x0d, 0xd9, 0x4d, 0x34, 0x80, 0x3c, 0xe3, 0x90, 0xc6, - 0xbd, 0xdc, 0x28, 0xcd, 0x12, 0xe8, 0x65, 0x4c, 0x33, 0x91, 0xef, 0x65, 0x5a, 0x19, 0xe5, 0xfb, - 0x37, 0x81, 0xbd, 0x3a, 0xb0, 0xb3, 0x9e, 0xa8, 0x44, 0x21, 0xee, 0x55, 0xbf, 0x6c, 0xf2, 0xe1, - 0xd7, 0x45, 0xb2, 0x30, 0x40, 0xd5, 0xef, 0x92, 0x35, 0xc1, 0x4a, 0x9a, 0x43, 0x22, 0x40, 0x1a, - 0x9a, 0xf3, 0x0b, 0x08, 0xbc, 0x8e, 0xd7, 0x9d, 0x1f, 0xae, 0x08, 0x56, 0x9e, 0xda, 0xe3, 0x53, - 0x7e, 0x01, 0xfe, 0x3e, 0x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xff, 0xb1, 0xdb, 0x3a, 0x7a, 0xff, 0xf3, 0xaa, 0xed, 0x5d, 0x5e, 0xb5, 0xbd, 0xdf, 0x57, - 0x6d, 0xef, 0xdb, 0x75, 0xbb, 0x75, 0x79, 0xdd, 0x6e, 0xfd, 0xba, 0x6e, 0xb7, 0x3e, 0xf7, 0x12, - 0x6e, 0x46, 0x45, 0xb8, 0x17, 0x29, 0xd1, 0x0b, 0x65, 0xf8, 0x38, 0x1a, 0x31, 0x2e, 0x7b, 0xce, - 0x1b, 0x54, 0x4e, 0x5f, 0x21, 0x33, 0xc9, 0x20, 0x0f, 0x17, 0xf0, 0x6d, 0x79, 0xf2, 0x27, 0x00, - 0x00, 0xff, 0xff, 0xd9, 0x19, 0xcf, 0xa2, 0xa8, 0x04, 0x00, 0x00, + // 605 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0x4d, 0x6f, 0x13, 0x3b, + 0x14, 0x86, 0x33, 0xb7, 0xbd, 0xbd, 0xad, 0xef, 0xed, 0xc7, 0x1d, 0xf5, 0x63, 0x5a, 0x20, 0x8d, + 0x58, 0xa0, 0x6c, 0x68, 0x16, 0x80, 0xca, 0x97, 0x2a, 0xda, 0x54, 0x20, 0x16, 0x85, 0x28, 0x5d, + 0x20, 0xb1, 0xb1, 0x1c, 0xcf, 0xe9, 0xc4, 0x64, 0x6c, 0x8f, 0x3c, 0x1e, 0x75, 0xd2, 0x3f, 0xc0, + 0x96, 0x25, 0x4b, 0x7e, 0x0e, 0xcb, 0x2e, 0x59, 0xa2, 0xf6, 0x8f, 0xa0, 0x39, 0x1e, 0xa5, 0x9e, + 0xc2, 0x2e, 0xf2, 0xf3, 0x3e, 0xf3, 0x9e, 0xf8, 0x48, 0x26, 0xbb, 0x89, 0x01, 0x50, 0x67, 0x02, + 0xd2, 0xb8, 0x97, 0x5b, 0x6d, 0x58, 0x02, 0xbd, 0x8c, 0x19, 0x26, 0xf3, 0xbd, 0xcc, 0x68, 0xab, + 0xc3, 0xf0, 0x26, 0xb0, 0x57, 0x07, 0x76, 0xd6, 0x13, 0x9d, 0x68, 0xc4, 0xbd, 0xea, 0x97, 0x4b, + 0xde, 0xff, 0xbc, 0x48, 0x16, 0x06, 0xa8, 0x86, 0x5d, 0xb2, 0x26, 0x59, 0x49, 0x73, 0x48, 0x24, + 0x28, 0x4b, 0x73, 0x71, 0x01, 0x51, 0xd0, 0x09, 0xba, 0xf3, 0xc3, 0x15, 0xc9, 0xca, 0x53, 0x77, + 0x7c, 0x2a, 0x2e, 0x20, 0xdc, 0x27, 0x91, 0x81, 0xb8, 0x50, 0x31, 0x53, 0x96, 0xc6, 0xcc, 0x32, + 0xca, 0xc7, 0x85, 0x9a, 0x50, 0x55, 0xc8, 0xe8, 0xaf, 0x4e, 0xd0, 0x5d, 0x1e, 0x6e, 0xcc, 0xf8, + 0x31, 0xb3, 0xac, 0x5f, 0xd1, 0x77, 0x85, 0x0c, 0x5f, 0x90, 0x9d, 0x1b, 0x31, 0x63, 0x46, 0xd8, + 0xa9, 0xa7, 0xce, 0xa1, 0xba, 0x35, 0x4b, 0x0c, 0x30, 0x30, 0x93, 0xeb, 0xf9, 0x32, 0x36, 0x4d, + 0x35, 0x8b, 0xdd, 0x7c, 0xf3, 0xb3, 0xf9, 0x06, 0xee, 0x18, 0xe7, 0x7b, 0x40, 0x56, 0xa5, 0x50, + 0x94, 0x8f, 0x99, 0x49, 0xc0, 0x05, 0xff, 0xc6, 0xe0, 0xb2, 0x14, 0xaa, 0x8f, 0xa7, 0x98, 0x7b, + 0x46, 0xb6, 0xa5, 0x30, 0x46, 0x1b, 0x3a, 0x2a, 0xf8, 0x04, 0x2c, 0x35, 0x90, 0xb2, 0x29, 0x18, + 0x7a, 0x06, 0x10, 0x2d, 0x74, 0x82, 0xee, 0xd2, 0x70, 0xd3, 0x05, 0x8e, 0x90, 0x0f, 0x1d, 0x7e, + 0x0d,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, 0xe8, 0xce, 0x0d, 0xa3, 0xc6, 0xa8, 0x18, 0x18, 0x20, + 0x0f, 0x9f, 0x12, 0x9f, 0xd1, 0x18, 0x52, 0xb0, 0x42, 0x2b, 0x6c, 0xfd, 0x1f, 0x5b, 0xfd, 0x99, + 0x8e, 0x6b, 0x5c, 0xf5, 0xee, 0x93, 0x28, 0xb7, 0x2c, 0x05, 0x9a, 0xe9, 0x54, 0xf0, 0x29, 0xe5, + 0x29, 0x30, 0x55, 0x64, 0x68, 0x86, 0x68, 0x6e, 0x20, 0x1f, 0x20, 0xee, 0x3b, 0x7a, 0xc2, 0xca, + 0xe7, 0xf3, 0x5f, 0xbf, 0xed, 0xb6, 0x8e, 0xde, 0x7e, 0xbf, 0x6a, 0x07, 0x97, 0x57, 0xed, 0xe0, + 0xe7, 0x55, 0x3b, 0xf8, 0x72, 0xdd, 0x6e, 0x5d, 0x5e, 0xb7, 0x5b, 0x3f, 0xae, 0xdb, 0xad, 0x8f, + 0xbd, 0x44, 0xd8, 0x71, 0x31, 0xda, 0xe3, 0x5a, 0xf6, 0x46, 0x6a, 0xf4, 0x90, 0x8f, 0x99, 0x50, + 0x3d, 0xef, 0x0d, 0x2a, 0x67, 0xaf, 0x90, 0x9d, 0x66, 0x90, 0x8f, 0x16, 0xf0, 0x6d, 0x79, 0xf4, + 0x2b, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xd9, 0x95, 0x73, 0xa8, 0x04, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -289,8 +289,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.StalePoliesCleanupMax != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.StalePoliesCleanupMax)) + if m.StalePolicyCleanupMax != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.StalePolicyCleanupMax)) i-- dAtA[i] = 0x1 i-- @@ -474,8 +474,8 @@ func (m *Params) Size() (n int) { if m.DiscontinueDeletionMax != 0 { n += 2 + sovParams(uint64(m.DiscontinueDeletionMax)) } - if m.StalePoliesCleanupMax != 0 { - n += 2 + sovParams(uint64(m.StalePoliesCleanupMax)) + if m.StalePolicyCleanupMax != 0 { + n += 2 + sovParams(uint64(m.StalePolicyCleanupMax)) } return n } @@ -918,9 +918,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 18: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StalePoliesCleanupMax", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StalePolicyCleanupMax", wireType) } - m.StalePoliesCleanupMax = 0 + m.StalePolicyCleanupMax = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -930,7 +930,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StalePoliesCleanupMax |= uint64(b&0x7F) << shift + m.StalePolicyCleanupMax |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/storage/types/types.go b/x/storage/types/types.go index 8186b7d25..765a12bf4 100644 --- a/x/storage/types/types.go +++ b/x/storage/types/types.go @@ -87,8 +87,5 @@ func (di *DeleteInfo) IsEmpty() bool { if di.GroupIds == nil || (di.GroupIds != nil && len(di.GroupIds.Id) == 0) { isGroupIdsEmpty = true } - if isBucketIdsEmpty && isObjectIdsEmpty && isGroupIdsEmpty { - return true - } - return false + return isBucketIdsEmpty && isObjectIdsEmpty && isGroupIdsEmpty } From d68b4bb0b9a4779883447caafffcb01440422c5c Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Thu, 27 Apr 2023 19:38:24 +0800 Subject: [PATCH 03/13] fix batch delete and add e2e test for that --- e2e/core/basesuite.go | 7 +++ e2e/tests/permission_test.go | 109 ++++++++++++++++++++++++++++++++++ x/permission/keeper/keeper.go | 4 +- x/storage/keeper/keeper.go | 9 ++- 4 files changed, 124 insertions(+), 5 deletions(-) diff --git a/e2e/core/basesuite.go b/e2e/core/basesuite.go index e09a35783..b263a7aaf 100644 --- a/e2e/core/basesuite.go +++ b/e2e/core/basesuite.go @@ -87,6 +87,13 @@ func (s *BaseSuite) SendTxBlock(msg sdk.Msg, from keys.KeyManager) *sdk.TxRespon return getTxRes.TxResponse } +func (s *BaseSuite) SendTxWithTxOpt(msg sdk.Msg, from keys.KeyManager, txOpt types.TxOption) { + s.Client.SetKeyManager(from) + response, err := s.Client.BroadcastTx(context.Background(), []sdk.Msg{msg}, &txOpt) + s.Require().NoError(err) + s.T().Logf("tx status is %d, txHash = %s", response.TxResponse.Code, response.TxResponse.TxHash) +} + func (s *BaseSuite) SimulateTx(msg sdk.Msg, from keys.KeyManager) (txRes *tx.SimulateResponse) { mode := tx.BroadcastMode_BROADCAST_MODE_SYNC txOpt := &types.TxOption{ diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index fa11aab04..1659c2763 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -7,8 +7,11 @@ import ( "math" "time" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdktype "github.com/bnb-chain/greenfield/sdk/types" storageutil "github.com/bnb-chain/greenfield/testutil/storage" types2 "github.com/bnb-chain/greenfield/types" "github.com/bnb-chain/greenfield/types/common" @@ -1241,3 +1244,109 @@ func (s *StorageTestSuite) TestGroupMembersAndPolicyGC() { s.Require().ErrorContains(err, "No such Policy") } + +func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { + var err error + ctx := context.Background() + owner := s.GenAndChargeAccounts(1, 10000)[0] + user := s.GenAndChargeAccounts(1, 10000)[0] + sp := s.StorageProviders[0] + + s.Client.SetKeyManager(owner) + + nonce, _ := s.Client.GetNonce() + bucketNames := make([]string, 0) + + // Create 1000 Buckets + bucketNumber := 1000 + + feeAmt := sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(int64(15000000000000)))) + txOpt := sdktype.TxOption{ + NoSimulate: true, + GasLimit: 3000, + FeeAmount: feeAmt, + } + + for i := 0; i < bucketNumber; i++ { + txOpt.Nonce = nonce + bucketName := storageutil.GenRandomBucketName() + bucketNames = append(bucketNames, bucketName) + msgCreateBucket := storagetypes.NewMsgCreateBucket( + owner.GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PUBLIC_READ, sp.OperatorKey.GetAddr(), + nil, math.MaxUint, nil, 0) + msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxWithTxOpt(msgCreateBucket, owner, txOpt) + nonce++ + } + err = s.WaitForNextBlock() + s.Require().NoError(err) + + // ListBuckets + queryListBucketsRequest := storagetypes.QueryListBucketsRequest{} + queryListBucketResponse, err := s.Client.ListBuckets(ctx, &queryListBucketsRequest) + s.Require().NoError(err) + s.T().Logf("number of buckes is %d", queryListBucketResponse.Pagination.Total) + + principal := types.NewPrincipalWithAccount(user.GetAddr()) + + for i := 0; i < bucketNumber; i++ { + txOpt.Nonce = nonce + // Put bucket policy + bucketStatement := &types.Statement{ + Actions: []types.ActionType{types.ACTION_DELETE_BUCKET}, + Effect: types.EFFECT_ALLOW, + } + msgPutBucketPolicy := storagetypes.NewMsgPutPolicy(owner.GetAddr(), types2.NewBucketGRN(bucketNames[i]).String(), + principal, []*types.Statement{bucketStatement}, nil) + s.SendTxWithTxOpt(msgPutBucketPolicy, owner, txOpt) + nonce++ + } + err = s.WaitForNextBlock() + s.Require().NoError(err) + + policyIds := make([]sdkmath.Uint, 0) + // policies are present for buckets + for i := 0; i < bucketNumber; i++ { + queryPolicyForAccountResp, err := s.Client.QueryPolicyForAccount(ctx, &storagetypes.QueryPolicyForAccountRequest{Resource: types2.NewBucketGRN(bucketNames[i]).String(), + PrincipalAddress: user.GetAddr().String()}) + policyIds = append(policyIds, queryPolicyForAccountResp.Policy.Id) + s.Require().NoError(err) + } + + // delete batch of buckets + for i := 0; i < bucketNumber; i++ { + txOpt.Nonce = nonce + // the owner deletes the bucket + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(owner.GetAddr(), bucketNames[i]) + s.SendTxWithTxOpt(msgDeleteBucket, owner, txOpt) + nonce++ + } + + // Garbage collection wont be done within next 3 blocks since the total number of policies(1000) to be deleted exceed the + // handling ability of each block(200) + for i := 0; i < 2; i++ { + notAllPoliciesGC := false + for i := 0; i < bucketNumber; i++ { + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: policyIds[i].String()}) + if err == nil { + // if there is at least 1 policy still exist, that means GC is not fully done yet. + notAllPoliciesGC = true + } + } + s.Require().True(notAllPoliciesGC) + _ = s.WaitForNextBlock() + } + + // wait for another 2 block, all policies should be GC + for i := 0; i < 2; i++ { + _ = s.WaitForNextBlock() + } + + for i := 0; i < bucketNumber; i++ { + // policy is GC + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: policyIds[i].String()}) + s.Require().Error(err) + s.Require().ErrorContains(err, "No such Policy") + } +} diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index 5b49f5c82..0af22f1c6 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -374,7 +374,7 @@ func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, resourceTyp policyID := sequence.DecodeSequence(iterator.Value()) store.Delete(types.GetPolicyByIDKey(policyID)) // delete mapping policyKey -> policyId - store.Delete(iterator.Key()) + resourceAccountsPolicyStore.Delete(iterator.Key()) } } @@ -408,6 +408,6 @@ func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) { // delete GroupMemberByIDPrefix_id -> groupMember store.Delete(types.GetGroupMemberByIDKey(memberID)) // delete GroupMemberPrefix_groupId_memberAddr -> memberSequence(id) - store.Delete(iter.Key()) + groupMembersPrefixStore.Delete(iter.Key()) } } diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 57a4f860d..de4bf90b2 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1551,8 +1551,9 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { deletedCount++ // reaches the deletion limit during current endblocker if deletedCount > maxCleanup { - ids = append(ids, ids[idx+1:]...) + ids = ids[idx+1:] deleteInfo.ObjectIds.Id = ids + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } } @@ -1567,8 +1568,9 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, resource.RESOURCE_TYPE_BUCKET, id) deletedCount++ if deletedCount > maxCleanup { - ids = append(ids, ids[idx+1:]...) + ids = ids[idx+1:] deleteInfo.BucketIds.Id = ids + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } } @@ -1586,8 +1588,9 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, resource.RESOURCE_TYPE_GROUP, id) deletedCount++ if deletedCount > maxCleanup { - ids = append(ids, ids[idx+1:]...) + ids = ids[idx+1:] deleteInfo.GroupIds.Id = ids + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } } From ff61c8ee96ac48c72e973d8a12fcb10824a4331e Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Thu, 27 Apr 2023 19:57:36 +0800 Subject: [PATCH 04/13] fix test param --- e2e/tests/permission_test.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index 1659c2763..ca1291369 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1257,8 +1257,8 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { nonce, _ := s.Client.GetNonce() bucketNames := make([]string, 0) - // Create 1000 Buckets - bucketNumber := 1000 + // Create 250 Buckets + bucketNumber := 250 feeAmt := sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(int64(15000000000000)))) txOpt := sdktype.TxOption{ @@ -1323,20 +1323,17 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { nonce++ } - // Garbage collection wont be done within next 3 blocks since the total number of policies(1000) to be deleted exceed the - // handling ability of each block(200) - for i := 0; i < 2; i++ { - notAllPoliciesGC := false - for i := 0; i < bucketNumber; i++ { - _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: policyIds[i].String()}) - if err == nil { - // if there is at least 1 policy still exist, that means GC is not fully done yet. - notAllPoliciesGC = true - } + // Garbage collection wont be done within the block since the total number of policies to be deleted exceed the + // handling ability of each block + notAllPoliciesGC := false + for i := 0; i < bucketNumber; i++ { + _, err = s.Client.QueryPolicyById(ctx, &storagetypes.QueryPolicyByIdRequest{PolicyId: policyIds[i].String()}) + if err == nil { + // if there is at least 1 policy still exist, that means GC is not fully done yet. + notAllPoliciesGC = true } - s.Require().True(notAllPoliciesGC) - _ = s.WaitForNextBlock() } + s.Require().True(notAllPoliciesGC) // wait for another 2 block, all policies should be GC for i := 0; i < 2; i++ { From 7a67174506160769b37be8302f775b3f920d9bb4 Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Fri, 28 Apr 2023 17:42:53 +0800 Subject: [PATCH 05/13] fix comments --- e2e/tests/permission_test.go | 9 ++++++-- x/permission/keeper/keeper.go | 2 +- x/storage/abci.go | 1 - x/storage/keeper/keeper.go | 42 ++++++++++++++--------------------- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index ca1291369..b92ad58fc 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1302,14 +1302,17 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { s.SendTxWithTxOpt(msgPutBucketPolicy, owner, txOpt) nonce++ } - err = s.WaitForNextBlock() - s.Require().NoError(err) + // wait for 2 blocks + for i := 0; i < 2; i++ { + _ = s.WaitForNextBlock() + } policyIds := make([]sdkmath.Uint, 0) // policies are present for buckets for i := 0; i < bucketNumber; i++ { queryPolicyForAccountResp, err := s.Client.QueryPolicyForAccount(ctx, &storagetypes.QueryPolicyForAccountRequest{Resource: types2.NewBucketGRN(bucketNames[i]).String(), PrincipalAddress: user.GetAddr().String()}) + s.Require().NoError(err) policyIds = append(policyIds, queryPolicyForAccountResp.Policy.Id) s.Require().NoError(err) } @@ -1323,6 +1326,8 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { nonce++ } + _ = s.WaitForNextBlock() + // Garbage collection wont be done within the block since the total number of policies to be deleted exceed the // handling ability of each block notAllPoliciesGC := false diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index 0af22f1c6..9c53fe598 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -380,7 +380,7 @@ func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, resourceTyp // ForceDeleteGroupPolicyForResource deletes group policy enforced on resource func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) { - if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { + if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED || resourceType == resource.RESOURCE_TYPE_GROUP { return } policyForGroupKey := types.GetPolicyForGroupKey(resourceID, resourceType) diff --git a/x/storage/abci.go b/x/storage/abci.go index b0e0eb147..3bd22830e 100644 --- a/x/storage/abci.go +++ b/x/storage/abci.go @@ -13,7 +13,6 @@ func BeginBlocker(ctx sdk.Context, keeper k.Keeper) { keeper.ClearDiscontinueObjectCount(ctx) keeper.ClearDiscontinueBucketCount(ctx) } - keeper.InitDeleteInfo(ctx) } func EndBlocker(ctx sdk.Context, keeper k.Keeper) { diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index de4bf90b2..2a67adaeb 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1481,17 +1481,21 @@ func (k Keeper) getDiscontinueObjectStatus(ctx sdk.Context, objectId types.Uint) } func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resource interface{}) error { - if ctx.IsCheckTx() { - return nil - } - tStore := ctx.TransientStore(k.tStoreKey) - bz := tStore.Get(types.CurrentBlockDeleteStalePoliciesKey) - if bz == nil { - return types.ErrKeyNotExist + var deleteInfo types.DeleteInfo + if !tStore.Has(types.CurrentBlockDeleteStalePoliciesKey) { + deleteInfo = types.DeleteInfo{ + BucketIds: &types.Ids{}, + ObjectIds: &types.Ids{}, + GroupIds: &types.Ids{}, + } + } else { + bz := tStore.Get(types.CurrentBlockDeleteStalePoliciesKey) + k.cdc.MustUnmarshal(bz, &deleteInfo) + if bz == nil { + return types.ErrKeyNotExist + } } - deleteInfo := &types.DeleteInfo{} - k.cdc.MustUnmarshal(bz, deleteInfo) switch r := resource.(type) { case *types.BucketInfo: bucketIds := deleteInfo.BucketIds.Id @@ -1508,16 +1512,16 @@ func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resource i default: return types.ErrInvalidResource } - tStore.Set(types.CurrentBlockDeleteStalePoliciesKey, k.cdc.MustMarshal(deleteInfo)) + tStore.Set(types.CurrentBlockDeleteStalePoliciesKey, k.cdc.MustMarshal(&deleteInfo)) return nil } func (k Keeper) PersistDeleteInfo(ctx sdk.Context) { tStore := ctx.TransientStore(k.tStoreKey) - bz := tStore.Get(types.CurrentBlockDeleteStalePoliciesKey) - if bz == nil { - panic(types.ErrKeyNotExist) + if !tStore.Has(types.CurrentBlockDeleteStalePoliciesKey) { + return } + bz := tStore.Get(types.CurrentBlockDeleteStalePoliciesKey) deleteInfo := &types.DeleteInfo{} k.cdc.MustUnmarshal(bz, deleteInfo) @@ -1604,15 +1608,3 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { } } } - -// InitDeleteInfo init using transient store in BeginBlocker, and gets discarded in EndBlocker -// the deleteInfo holds resources' Ids, stale policies related to these Ids will be deleted in EndBlocker -func (k Keeper) InitDeleteInfo(ctx sdk.Context) { - deleteInfo := &types.DeleteInfo{ - BucketIds: &types.Ids{}, - ObjectIds: &types.Ids{}, - GroupIds: &types.Ids{}, - } - tStore := ctx.TransientStore(k.tStoreKey) - tStore.Set(types.CurrentBlockDeleteStalePoliciesKey, k.cdc.MustMarshal(deleteInfo)) -} From 48f3a40bcd4c8638de48f5044e72e627875f83c6 Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Thu, 4 May 2023 17:14:11 +0800 Subject: [PATCH 06/13] fix comments --- e2e/tests/permission_test.go | 4 +- proto/greenfield/storage/events.proto | 8 + x/permission/keeper/keeper.go | 61 +++- x/storage/keeper/keeper.go | 84 +++-- x/storage/types/events.pb.go | 388 +++++++++++++++++----- x/storage/types/expected_keepers.go | 7 +- x/storage/types/expected_keepers_mocks.go | 24 +- x/storage/types/query.pb.gw.go | 10 +- 8 files changed, 445 insertions(+), 141 deletions(-) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index b92ad58fc..2fa4cc764 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1257,8 +1257,8 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { nonce, _ := s.Client.GetNonce() bucketNames := make([]string, 0) - // Create 250 Buckets - bucketNumber := 250 + // Create 420 Buckets + bucketNumber := 420 feeAmt := sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(int64(15000000000000)))) txOpt := sdktype.TxOption{ diff --git a/proto/greenfield/storage/events.proto b/proto/greenfield/storage/events.proto index 51ad94d8e..c16ba1599 100644 --- a/proto/greenfield/storage/events.proto +++ b/proto/greenfield/storage/events.proto @@ -4,6 +4,8 @@ package greenfield.storage; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "greenfield/storage/common.proto"; +import "greenfield/storage/types.proto"; + option go_package = "github.com/bnb-chain/greenfield/x/storage/types"; @@ -424,3 +426,9 @@ message EventMirrorGroupResult { (gogoproto.nullable) = false ]; } + +// EventStalePolicyCleanup is emitted when specified block height's stale policies is garbage collected +message EventStalePolicyCleanup { + int64 blockNum = 1; + DeleteInfo delete_info =2; +} diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index 9c53fe598..7df2ebb5d 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -360,28 +360,39 @@ func (k Keeper) DeletePolicy(ctx sdk.Context, principal *types.Principal, resour return policyID, nil } -// ForceDeleteAccountPolicyForResource deletes all individual accounts policy enforced on resources -func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) { +// ForceDeleteAccountPolicyForResource deletes all individual accounts policy enforced on resources, if +func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { - return + return deletedCount, true } store := ctx.KVStore(k.storeKey) resourceAccountsPolicyStore := prefix.NewStore(store, types.PolicyForAccountPrefix(resourceID, resourceType)) iterator := resourceAccountsPolicyStore.Iterator(nil, nil) defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + // if exceeding the limit, pause the GC and mark the current resource's deletion is not complete yet + if deletedCount > maxDelete { + return deletedCount, false + } // delete mapping policyId -> policy policyID := sequence.DecodeSequence(iterator.Value()) store.Delete(types.GetPolicyByIDKey(policyID)) // delete mapping policyKey -> policyId resourceAccountsPolicyStore.Delete(iterator.Key()) + deletedCount++ + // emit DeletePolicy Event + _ = ctx.EventManager().EmitTypedEvents(&types.EventDeletePolicy{ + PolicyId: policyID, + }) } + return deletedCount, true } // ForceDeleteGroupPolicyForResource deletes group policy enforced on resource -func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) { +func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, maxDelete, deletedTotal uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED || resourceType == resource.RESOURCE_TYPE_GROUP { - return + return deletedTotal, true } policyForGroupKey := types.GetPolicyForGroupKey(resourceID, resourceType) store := ctx.KVStore(k.storeKey) @@ -390,14 +401,23 @@ func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType policyGroup := types.PolicyGroup{} k.cdc.MustUnmarshal(bz, &policyGroup) for i := 0; i < len(policyGroup.Items); i++ { + if deletedTotal > maxDelete { + return deletedTotal, false + } // delete concrete policy by policyId - store.Delete(types.GetPolicyByIDKey(policyGroup.Items[i].PolicyId)) + policyId := policyGroup.Items[i].PolicyId + store.Delete(types.GetPolicyByIDKey(policyId)) + deletedTotal++ + _ = ctx.EventManager().EmitTypedEvents(&types.EventDeletePolicy{ + PolicyId: policyId, + }) } store.Delete(policyForGroupKey) } + return deletedTotal, true } -// ForceDeleteGroupMembers deletes group members when user deletes group +// ForceDeleteGroupMembers deletes group members when user deletes a group func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) { store := ctx.KVStore(k.storeKey) groupMembersPrefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GroupMembersPrefix(groupId)) @@ -411,3 +431,30 @@ func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) { groupMembersPrefixStore.Delete(iter.Key()) } } + +func (k Keeper) ExistAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { + if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { + return false + } + store := ctx.KVStore(k.storeKey) + resourceAccountsPolicyStore := prefix.NewStore(store, types.PolicyForAccountPrefix(resourceID, resourceType)) + iterator := resourceAccountsPolicyStore.Iterator(nil, nil) + defer iterator.Close() + return iterator.Valid() +} + +func (k Keeper) ExistGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { + if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED || resourceType == resource.RESOURCE_TYPE_GROUP { + return false + } + policyForGroupKey := types.GetPolicyForGroupKey(resourceID, resourceType) + store := ctx.KVStore(k.storeKey) + return store.Has(policyForGroupKey) && store.Get(policyForGroupKey) != nil +} + +func (k Keeper) ExistGroupMemberForGroup(ctx sdk.Context, groupId math.Uint) bool { + groupMembersPrefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GroupMembersPrefix(groupId)) + iter := groupMembersPrefixStore.Iterator(nil, nil) + defer iter.Close() + return iter.Valid() +} diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 2a67adaeb..eef5e31cd 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -186,7 +186,7 @@ func (k Keeper) doDeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketI store.Delete(bucketKey) store.Delete(types.GetBucketByIDKey(bucketInfo.Id)) - if err := k.appendResourceIdForGarbageCollection(ctx, bucketInfo); err != nil { + if err := k.appendResourceIdForGarbageCollection(ctx, resource.RESOURCE_TYPE_BUCKET, bucketInfo.Id); err != nil { return err } err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteBucket{ @@ -750,7 +750,7 @@ func (k Keeper) doDeleteObject(ctx sdk.Context, operator sdk.AccAddress, bucketI store.Delete(types.GetObjectKey(bucketInfo.BucketName, objectInfo.ObjectName)) store.Delete(types.GetObjectByIDKey(objectInfo.Id)) - if err := k.appendResourceIdForGarbageCollection(ctx, objectInfo); err != nil { + if err := k.appendResourceIdForGarbageCollection(ctx, resource.RESOURCE_TYPE_OBJECT, objectInfo.Id); err != nil { return err } @@ -1158,7 +1158,7 @@ func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName store.Delete(types.GetGroupKey(operator, groupName)) store.Delete(types.GetGroupByIDKey(groupInfo.Id)) - if err := k.appendResourceIdForGarbageCollection(ctx, groupInfo); err != nil { + if err := k.appendResourceIdForGarbageCollection(ctx, resource.RESOURCE_TYPE_GROUP, groupInfo.Id); err != nil { return err } @@ -1480,7 +1480,11 @@ func (k Keeper) getDiscontinueObjectStatus(ctx sdk.Context, objectId types.Uint) return types.ObjectStatus(status), nil } -func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resource interface{}) error { +func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resourceType resource.ResourceType, resourceID sdkmath.Uint) error { + if !k.permKeeper.ExistAccountPolicyForResource(ctx, resourceType, resourceID) && + !k.permKeeper.ExistGroupPolicyForResource(ctx, resourceType, resourceID) { + return nil + } tStore := ctx.TransientStore(k.tStoreKey) var deleteInfo types.DeleteInfo if !tStore.Has(types.CurrentBlockDeleteStalePoliciesKey) { @@ -1496,18 +1500,18 @@ func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resource i return types.ErrKeyNotExist } } - switch r := resource.(type) { - case *types.BucketInfo: + switch resourceType { + case resource.RESOURCE_TYPE_BUCKET: bucketIds := deleteInfo.BucketIds.Id - bucketIds = append(bucketIds, r.Id) + bucketIds = append(bucketIds, resourceID) deleteInfo.BucketIds = &types.Ids{Id: bucketIds} - case *types.ObjectInfo: + case resource.RESOURCE_TYPE_OBJECT: objectIds := deleteInfo.ObjectIds.Id - objectIds = append(objectIds, r.Id) + objectIds = append(objectIds, resourceID) deleteInfo.ObjectIds = &types.Ids{Id: objectIds} - case *types.GroupInfo: - groupIds := deleteInfo.ObjectIds.Id - groupIds = append(groupIds, r.Id) + case resource.RESOURCE_TYPE_GROUP: + groupIds := deleteInfo.GroupIds.Id + groupIds = append(groupIds, resourceID) deleteInfo.GroupIds = &types.Ids{Id: groupIds} default: return types.ErrInvalidResource @@ -1529,6 +1533,10 @@ func (k Keeper) PersistDeleteInfo(ctx sdk.Context) { if !deleteInfo.IsEmpty() { store := ctx.KVStore(k.storeKey) store.Set(types.GetDeleteStalePoliciesKey(ctx.BlockHeight()), bz) + _ = ctx.EventManager().EmitTypedEvents(&types.EventStalePolicyCleanup{ + BlockNum: ctx.BlockHeight(), + DeleteInfo: deleteInfo, + }) } } @@ -1541,25 +1549,34 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { defer iterator.Close() maxCleanup := k.StalePolicyCleanupMax(ctx) - deletedCount := uint64(0) + + var deletedCount uint64 + var done bool for ; iterator.Valid(); iterator.Next() { deleteInfo := &types.DeleteInfo{} k.cdc.MustUnmarshal(iterator.Value(), deleteInfo) + fmt.Printf("deleteinfo is %s\n", deleteInfo) + if deleteInfo.ObjectIds != nil && len(deleteInfo.ObjectIds.Id) > 0 { ids := deleteInfo.ObjectIds.Id + temp := ids for idx, id := range ids { - k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, resource.RESOURCE_TYPE_OBJECT, id) - k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, resource.RESOURCE_TYPE_OBJECT, id) - deletedCount++ - // reaches the deletion limit during current endblocker - if deletedCount > maxCleanup { - ids = ids[idx+1:] - deleteInfo.ObjectIds.Id = ids + deletedCount, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_OBJECT, id) + if !done { + deleteInfo.ObjectIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } + deletedCount, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_OBJECT, id) + if !done { + deleteInfo.ObjectIds.Id = temp + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) + return + } + // remove current resource id from list of ids to be deleted + temp = ids[idx+1:] } // clean deleted objects id from deleteInfo deleteInfo.ObjectIds = nil @@ -1567,16 +1584,21 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { if deleteInfo.BucketIds != nil && len(deleteInfo.BucketIds.Id) > 0 { ids := deleteInfo.BucketIds.Id + temp := ids for idx, id := range ids { - k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, resource.RESOURCE_TYPE_BUCKET, id) - k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, resource.RESOURCE_TYPE_BUCKET, id) - deletedCount++ - if deletedCount > maxCleanup { - ids = ids[idx+1:] - deleteInfo.BucketIds.Id = ids + deletedCount, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_BUCKET, id) + if !done { + deleteInfo.BucketIds.Id = temp + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) + return + } + deletedCount, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_BUCKET, id) + if !done { + deleteInfo.BucketIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } + temp = ids[idx+1:] } // clean deleted buckets id from deleteInfo deleteInfo.BucketIds = nil @@ -1587,16 +1609,16 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { // for a group which is deleted by user, there are 2 parts need to clean: // 1. group members within the group. // 2. group policy + temp := ids for idx, id := range ids { k.permKeeper.ForceDeleteGroupMembers(ctx, id) - k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, resource.RESOURCE_TYPE_GROUP, id) - deletedCount++ - if deletedCount > maxCleanup { - ids = ids[idx+1:] - deleteInfo.GroupIds.Id = ids + deletedCount, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_GROUP, id) + if !done { + deleteInfo.GroupIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } + temp = ids[idx+1:] } // clean deleted buckets id from deleteInfo deleteInfo.GroupIds = nil diff --git a/x/storage/types/events.pb.go b/x/storage/types/events.pb.go index 04cd38d00..2a4429e79 100644 --- a/x/storage/types/events.pb.go +++ b/x/storage/types/events.pb.go @@ -1723,6 +1723,59 @@ func (m *EventMirrorGroupResult) GetGroupName() string { return "" } +// EventStalePolicyCleanup is emitted when specified block height's stale policies is garbage collected +type EventStalePolicyCleanup struct { + BlockNum int64 `protobuf:"varint,1,opt,name=blockNum,proto3" json:"blockNum,omitempty"` + DeleteInfo *DeleteInfo `protobuf:"bytes,2,opt,name=delete_info,json=deleteInfo,proto3" json:"delete_info,omitempty"` +} + +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{22} +} +func (m *EventStalePolicyCleanup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventStalePolicyCleanup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventStalePolicyCleanup.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 *EventStalePolicyCleanup) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventStalePolicyCleanup.Merge(m, src) +} +func (m *EventStalePolicyCleanup) XXX_Size() int { + return m.Size() +} +func (m *EventStalePolicyCleanup) XXX_DiscardUnknown() { + xxx_messageInfo_EventStalePolicyCleanup.DiscardUnknown(m) +} + +var xxx_messageInfo_EventStalePolicyCleanup proto.InternalMessageInfo + +func (m *EventStalePolicyCleanup) GetBlockNum() int64 { + if m != nil { + return m.BlockNum + } + return 0 +} + +func (m *EventStalePolicyCleanup) GetDeleteInfo() *DeleteInfo { + if m != nil { + return m.DeleteInfo + } + return nil +} + func init() { proto.RegisterType((*EventCreateBucket)(nil), "greenfield.storage.EventCreateBucket") proto.RegisterType((*EventDeleteBucket)(nil), "greenfield.storage.EventDeleteBucket") @@ -1746,96 +1799,100 @@ func init() { proto.RegisterType((*EventMirrorObjectResult)(nil), "greenfield.storage.EventMirrorObjectResult") proto.RegisterType((*EventMirrorGroup)(nil), "greenfield.storage.EventMirrorGroup") proto.RegisterType((*EventMirrorGroupResult)(nil), "greenfield.storage.EventMirrorGroupResult") + proto.RegisterType((*EventStalePolicyCleanup)(nil), "greenfield.storage.EventStalePolicyCleanup") } func init() { proto.RegisterFile("greenfield/storage/events.proto", fileDescriptor_946dcba4f763ddc4) } var fileDescriptor_946dcba4f763ddc4 = []byte{ - // 1334 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0xcd, 0x6f, 0x1b, 0xc5, - 0x1b, 0xce, 0xda, 0xeb, 0xaf, 0x71, 0x1c, 0xa7, 0xfb, 0x4b, 0xf3, 0xdb, 0xb6, 0xe0, 0xb8, 0x7b, - 0xa8, 0x72, 0xa0, 0xb6, 0x14, 0x2a, 0x08, 0x17, 0x22, 0xbb, 0x05, 0x14, 0x41, 0x5b, 0xb1, 0x6e, - 0x39, 0x70, 0x59, 0x8d, 0x77, 0x27, 0xce, 0x52, 0x7b, 0x67, 0x99, 0x19, 0x07, 0xdc, 0x23, 0x17, - 0x2e, 0x80, 0x90, 0x38, 0x21, 0x71, 0xe4, 0xc0, 0x85, 0x13, 0xfd, 0x17, 0x90, 0x0a, 0x12, 0x52, - 0xd5, 0x13, 0x1f, 0xa2, 0x42, 0xc9, 0x89, 0xff, 0x02, 0xed, 0xcc, 0x78, 0xbd, 0x6b, 0x3b, 0x71, - 0xd6, 0xc1, 0x10, 0x6e, 0xde, 0xd9, 0xe7, 0x9d, 0x79, 0xdf, 0x67, 0x9f, 0xf7, 0x63, 0xd7, 0x60, - 0xa3, 0x43, 0x10, 0xf2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e5, 0x5e, 0x8e, 0xa1, 0x81, 0xab, - 0xa5, 0x70, 0xc8, 0x5c, 0xa0, 0x3b, 0xdf, 0xc7, 0x59, 0xfb, 0xcf, 0xf6, 0xe7, 0x6f, 0xe3, 0xb4, - 0x8a, 0x38, 0xce, 0x4a, 0xeb, 0x02, 0xfd, 0x0d, 0x6b, 0xb0, 0xf0, 0xf7, 0x3c, 0x35, 0x25, 0xe3, - 0xe3, 0xe1, 0xac, 0x13, 0xf1, 0x6d, 0x06, 0x95, 0x8b, 0xf1, 0xa4, 0xb9, 0xfb, 0xf8, 0xb0, 0xa2, - 0x3c, 0x39, 0xac, 0x28, 0x7f, 0x1c, 0x56, 0x94, 0xcf, 0x8f, 0x2a, 0x4b, 0x4f, 0x8e, 0x2a, 0x4b, - 0x3f, 0x1f, 0x55, 0x96, 0xde, 0xad, 0x77, 0x5c, 0xb6, 0xdf, 0x6f, 0xd7, 0x6c, 0xdc, 0xab, 0xb7, - 0xbd, 0xf6, 0x75, 0x7b, 0x1f, 0xba, 0x5e, 0x3d, 0xf2, 0xaf, 0xc4, 0x87, 0xe1, 0xff, 0x12, 0x41, - 0x67, 0xa5, 0xed, 0x2c, 0xff, 0x5f, 0xe2, 0xc5, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x4b, - 0xb3, 0x85, 0x20, 0x19, 0x00, 0x00, + // 1392 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0xcf, 0x8f, 0xdb, 0x44, + 0x14, 0x5e, 0x27, 0xde, 0x6c, 0x32, 0xd9, 0x6c, 0xb6, 0x66, 0xbb, 0xb8, 0x2d, 0x64, 0x53, 0x1f, + 0xaa, 0x3d, 0xd0, 0x44, 0x5a, 0x2a, 0x28, 0x17, 0xaa, 0xa4, 0x05, 0xb4, 0x82, 0xb6, 0xe0, 0xb4, + 0x1c, 0xb8, 0x58, 0x13, 0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xe1, 0x50, 0xf0, 0x29, 0xda, 0x95, 0x2c, 0xb4, 0xcf, + 0xbc, 0xd1, 0x4d, 0x50, 0x20, 0x08, 0x52, 0xec, 0x4b, 0x81, 0xcb, 0xa7, 0xa8, 0x08, 0x3a, 0x3c, + 0xe7, 0x12, 0x45, 0x50, 0x2c, 0xb4, 0x98, 0xf1, 0x71, 0x21, 0x55, 0xcc, 0x6f, 0x76, 0xdf, 0x47, + 0x36, 0xd3, 0x76, 0xc0, 0x0a, 0x2f, 0x93, 0x47, 0x90, 0xdc, 0x10, 0xf8, 0xcf, 0x27, 0xe5, 0x16, + 0x28, 0x63, 0xee, 0x8e, 0x00, 0xa8, 0x02, 0x20, 0x96, 0x26, 0x25, 0x5c, 0xc8, 0xc2, 0xe5, 0x65, + 0x50, 0x92, 0x5b, 0xbb, 0x8e, 0x10, 0xc3, 0x0c, 0x4b, 0x81, 0x7e, 0x6a, 0xbe, 0x17, 0x33, 0x17, + 0xd2, 0xf3, 0x60, 0x35, 0x80, 0x83, 0x3e, 0x86, 0x8e, 0x45, 0xdd, 0xbb, 0x88, 0x97, 0x62, 0xd5, + 0x2c, 0xcb, 0xb5, 0x8e, 0x7b, 0x77, 0xbc, 0x01, 0x82, 0xb9, 0x1a, 0xe0, 0x79, 0xb0, 0x1a, 0x09, + 0x30, 0xca, 0x00, 0xde, 0xaa, 0xca, 0x9c, 0xc4, 0xb2, 0x5c, 0xe3, 0xbd, 0x28, 0xd5, 0x23, 0x57, + 0x27, 0x7a, 0xe4, 0xb0, 0xde, 0x57, 0x9e, 0x5e, 0xef, 0x85, 0x68, 0xd2, 0xf5, 0x5e, 0x7b, 0x13, + 0x54, 0x09, 0x72, 0x42, 0xdf, 0x81, 0xbe, 0x3d, 0x10, 0x87, 0xaf, 0x3d, 0x3d, 0x04, 0x33, 0x86, + 0xf2, 0x10, 0xd6, 0x48, 0xea, 0x79, 0xbc, 0xe1, 0x56, 0x33, 0x37, 0xdc, 0xe7, 0x40, 0xc9, 0x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b, 0xcc, 0xe3, 0xe5, 0x21, 0x5a, 0x2e, 0xcc, 0xa5, 0xe5, + 0x1f, 0x15, 0x39, 0xae, 0x9a, 0x88, 0x67, 0xce, 0x09, 0xab, 0x10, 0x59, 0x38, 0x9e, 0x3a, 0xad, + 0xc9, 0x60, 0xc6, 0xdc, 0x52, 0xa6, 0x4d, 0xd1, 0xa3, 0x53, 0x73, 0x59, 0x6e, 0x76, 0xae, 0x69, + 0xed, 0xb3, 0x5c, 0xea, 0x57, 0x82, 0x94, 0xfb, 0x02, 0x7f, 0x25, 0x2c, 0x50, 0xda, 0xe9, 0xf1, + 0x66, 0x79, 0xae, 0x41, 0xfb, 0xf3, 0x1c, 0x58, 0x4f, 0x4c, 0xaf, 0x6f, 0x10, 0x1c, 0x06, 0x99, + 0xdf, 0x44, 0x3c, 0x0f, 0x40, 0x2f, 0x32, 0x4c, 0x72, 0x50, 0xe2, 0x2b, 0x3c, 0xc2, 0x97, 0x40, + 0x51, 0x7c, 0x7d, 0xb4, 0xdf, 0x49, 0x2b, 0x1c, 0x3c, 0xf9, 0x92, 0x40, 0xcd, 0x3c, 0xb3, 0xec, + 0x80, 0x15, 0x0f, 0x79, 0x5d, 0x44, 0xa2, 0x84, 0x3f, 0x3c, 0x49, 0x87, 0x40, 0xe3, 0x2b, 0x45, + 0x12, 0x22, 0xea, 0xde, 0x18, 0x21, 0xb9, 0x79, 0x08, 0xc9, 0x1f, 0x46, 0x88, 0x7a, 0x74, 0x42, + 0x8c, 0x5f, 0x15, 0xd9, 0xff, 0xde, 0x42, 0xf0, 0x40, 0xba, 0x76, 0x05, 0xac, 0x09, 0xd7, 0xe3, + 0xda, 0x36, 0xeb, 0xd2, 0x2a, 0x02, 0x3f, 0x2c, 0x6c, 0x27, 0x24, 0xb6, 0xdf, 0x73, 0xb2, 0x86, + 0x88, 0xc4, 0xe4, 0xc1, 0x5d, 0xe7, 0x8e, 0xfe, 0x4b, 0xaf, 0x38, 0x16, 0x13, 0x97, 0xf6,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, 0xca, 0x17, 0x4f, 0x6a, 0x4b, 0x0f, 0x9e, 0xd4, 0x96, 0x7e, 0x79, 0x52, + 0x5b, 0x7a, 0xaf, 0xd9, 0x73, 0xd9, 0x7e, 0xd8, 0x6d, 0xd8, 0xd8, 0x6b, 0x76, 0xfd, 0xee, 0x45, + 0x7b, 0x1f, 0xba, 0x7e, 0x33, 0xf1, 0x67, 0xc8, 0x47, 0xe9, 0xbf, 0x43, 0xba, 0x05, 0xfe, 0x7f, + 0xc8, 0x8b, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x56, 0x17, 0xe7, 0xb8, 0x19, 0x00, 0x00, } func (m *EventCreateBucket) Marshal() (dAtA []byte, err error) { @@ -3205,6 +3262,46 @@ func (m *EventMirrorGroupResult) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *EventStalePolicyCleanup) 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 *EventStalePolicyCleanup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventStalePolicyCleanup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DeleteInfo != nil { + { + size, err := m.DeleteInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BlockNum != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.BlockNum)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -3824,6 +3921,22 @@ func (m *EventMirrorGroupResult) Size() (n int) { return n } +func (m *EventStalePolicyCleanup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockNum != 0 { + n += 1 + sovEvents(uint64(m.BlockNum)) + } + if m.DeleteInfo != nil { + l = m.DeleteInfo.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -8436,6 +8549,111 @@ func (m *EventMirrorGroupResult) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventStalePolicyCleanup) 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: EventStalePolicyCleanup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventStalePolicyCleanup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockNum", wireType) + } + m.BlockNum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockNum |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeleteInfo", 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 m.DeleteInfo == nil { + m.DeleteInfo = &DeleteInfo{} + } + if err := m.DeleteInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 11b0f037e..9fa2f6f1e 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -64,9 +64,12 @@ type PermissionKeeper interface { groupID math.Uint) (policy *permtypes.Policy, isFound bool) GetGroupMember(ctx sdk.Context, groupID math.Uint, member sdk.AccAddress) (*permtypes.GroupMember, bool) GetGroupMemberByID(ctx sdk.Context, groupMemberID math.Uint) (*permtypes.GroupMember, bool) - ForceDeleteAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) - ForceDeleteGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) + ForceDeleteAccountPolicyForResource(ctx sdk.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) + ForceDeleteGroupPolicyForResource(ctx sdk.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) + ExistAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) bool + ExistGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) bool + ExistGroupMemberForGroup(ctx sdk.Context, groupId math.Uint) bool } type CrossChainKeeper interface { diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 23906c94d..91c48951b 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -602,27 +602,33 @@ func (mr *MockCrossChainKeeperMockRecorder) RegisterChannel(name, id, app interf } // ForceDeleteAccountPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ForceDeleteAccountPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) { +func (m *MockPermissionKeeper) ForceDeleteAccountPolicyForResource(ctx types2.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { m.ctrl.T.Helper() - _ = m.ctrl.Call(m, "ForceDeleteAccountPolicyForResource", ctx, resourceType, resourceID) + ret := m.ctrl.Call(m, "ForceDeleteAccountPolicyForResource", ctx, resourceType, resourceID) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(bool) + return ret0, ret1 } // ForceDeleteAccountPolicyForResource indicates an expected call of ForceDeleteAccountPolicyForResource. -func (mr *MockPermissionKeeperMockRecorder) ForceDeletePolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteAccountPolicyForResource(ctx, maxDelete, deletedCount, resourceType, resourceID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), ctx, resourceType, resourceID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteAccountPolicyForResource), ctx, maxDelete, deletedCount, resourceType, resourceID) } // ForceDeleteGroupPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ForceDeleteGroupPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) { +func (m *MockPermissionKeeper) ForceDeleteGroupPolicyForResource(ctx types2.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { m.ctrl.T.Helper() - _ = m.ctrl.Call(m, "ForceDeleteGroupPolicyForResource", ctx, resourceType, resourceID) + ret := m.ctrl.Call(m, "ForceDeleteGroupPolicyForResource", ctx, resourceType, resourceID) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(bool) + return ret0, ret1 } // ForceDeleteGroupPolicyForResource indicates an expected call of ForceDeleteGroupPolicyForResource. -func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ctx, maxDelete, deletedCount, resourceType, resourceID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), ctx, resourceType, resourceID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupPolicyForResource), ctx, maxDelete, deletedCount, resourceType, resourceID) } // ForceDeleteGroupMembers mocks base method. @@ -634,5 +640,5 @@ func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, group // ForceDeleteGroupMembers indicates an expected call of ForceDeleteGroupMembers. func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, groupId interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), ctx, groupId) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupMembers), ctx, groupId) } diff --git a/x/storage/types/query.pb.gw.go b/x/storage/types/query.pb.gw.go index 411a68c1e..0fc0c4cbf 100644 --- a/x/storage/types/query.pb.gw.go +++ b/x/storage/types/query.pb.gw.go @@ -13,7 +13,7 @@ import ( "io" "net/http" - types_0 "github.com/bnb-chain/greenfield/x/permission/types" + types_1 "github.com/bnb-chain/greenfield/x/permission/types" "github.com/golang/protobuf/descriptor" "github.com/golang/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -758,13 +758,13 @@ func request_Query_VerifyPermission_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "action_type") } - e, err = runtime.Enum(val, types_0.ActionType_value) + e, err = runtime.Enum(val, types_1.ActionType_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "action_type", err) } - protoReq.ActionType = types_0.ActionType(e) + protoReq.ActionType = types_1.ActionType(e) msg, err := client.VerifyPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -821,13 +821,13 @@ func local_request_Query_VerifyPermission_0(ctx context.Context, marshaler runti return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "action_type") } - e, err = runtime.Enum(val, types_0.ActionType_value) + e, err = runtime.Enum(val, types_1.ActionType_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "action_type", err) } - protoReq.ActionType = types_0.ActionType(e) + protoReq.ActionType = types_1.ActionType(e) msg, err := server.VerifyPermission(ctx, &protoReq) return msg, metadata, err From 2b6af1b6981ce4917ba1c1b4994f23106c993b43 Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Thu, 4 May 2023 19:46:29 +0800 Subject: [PATCH 07/13] fix tests --- e2e/tests/permission_test.go | 2 -- x/storage/keeper/keeper.go | 6 +++- x/storage/types/expected_keepers_mocks.go | 42 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index 2fa4cc764..19434b314 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1326,8 +1326,6 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { nonce++ } - _ = s.WaitForNextBlock() - // Garbage collection wont be done within the block since the total number of policies to be deleted exceed the // handling ability of each block notAllPoliciesGC := false diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index eef5e31cd..e873b6f90 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1483,7 +1483,11 @@ func (k Keeper) getDiscontinueObjectStatus(ctx sdk.Context, objectId types.Uint) func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resourceType resource.ResourceType, resourceID sdkmath.Uint) error { if !k.permKeeper.ExistAccountPolicyForResource(ctx, resourceType, resourceID) && !k.permKeeper.ExistGroupPolicyForResource(ctx, resourceType, resourceID) { - return nil + + if resourceType != resource.RESOURCE_TYPE_GROUP || + (resourceType == resource.RESOURCE_TYPE_GROUP && !k.permKeeper.ExistGroupMemberForGroup(ctx, resourceID)) { + return nil + } } tStore := ctx.TransientStore(k.tStoreKey) var deleteInfo types.DeleteInfo diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 91c48951b..f3b070322 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -642,3 +642,45 @@ func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, groupId mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupMembers), ctx, groupId) } + +// ExistAccountPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ExistAccountPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExistAccountPolicyForResource", ctx, resourceType, resourceID) + ret0, _ := ret[0].(bool) + return ret0 +} + +// ExistAccountPolicyForResource indicates an expected call of ExistAccountPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ExistAccountPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistAccountPolicyForResource), ctx, resourceType, resourceID) +} + +// ExistGroupPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ExistGroupPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExistGroupPolicyForResource", ctx, resourceType, resourceID) + ret0, _ := ret[0].(bool) + return ret0 +} + +// ExistGroupPolicyForResource indicates an expected call of ExistGroupPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ExistGroupPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistGroupPolicyForResource), ctx, resourceType, resourceID) +} + +// ExistGroupMemberForGroup mocks base method. +func (m *MockPermissionKeeper) ExistGroupMemberForGroup(ctx types2.Context, groupID math.Uint) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExistGroupMemberForGroup", ctx, groupID) + ret0, _ := ret[0].(bool) + return ret0 +} + +// ExistGroupMemberForGroup indicates an expected call of ExistGroupMemberForGroup. +func (mr *MockPermissionKeeperMockRecorder) ExistGroupMemberForGroup(ctx, groupID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistGroupMemberForGroup", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistGroupMemberForGroup), ctx, groupID) +} From dff7d5550af68a55d988745d6c1ce0573937dfb9 Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Fri, 5 May 2023 10:47:28 +0800 Subject: [PATCH 08/13] delete members after group is deleted --- e2e/core/basesuite.go | 3 +-- e2e/tests/permission_test.go | 1 - x/storage/keeper/keeper.go | 7 +------ 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/e2e/core/basesuite.go b/e2e/core/basesuite.go index b263a7aaf..4f9fc9dbc 100644 --- a/e2e/core/basesuite.go +++ b/e2e/core/basesuite.go @@ -89,9 +89,8 @@ func (s *BaseSuite) SendTxBlock(msg sdk.Msg, from keys.KeyManager) *sdk.TxRespon func (s *BaseSuite) SendTxWithTxOpt(msg sdk.Msg, from keys.KeyManager, txOpt types.TxOption) { s.Client.SetKeyManager(from) - response, err := s.Client.BroadcastTx(context.Background(), []sdk.Msg{msg}, &txOpt) + _, err := s.Client.BroadcastTx(context.Background(), []sdk.Msg{msg}, &txOpt) s.Require().NoError(err) - s.T().Logf("tx status is %d, txHash = %s", response.TxResponse.Code, response.TxResponse.TxHash) } func (s *BaseSuite) SimulateTx(msg sdk.Msg, from keys.KeyManager) (txRes *tx.SimulateResponse) { diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index 19434b314..b895d6f27 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1314,7 +1314,6 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { PrincipalAddress: user.GetAddr().String()}) s.Require().NoError(err) policyIds = append(policyIds, queryPolicyForAccountResp.Policy.Id) - s.Require().NoError(err) } // delete batch of buckets diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index e873b6f90..7dc8522f7 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1500,9 +1500,6 @@ func (k Keeper) appendResourceIdForGarbageCollection(ctx sdk.Context, resourceTy } else { bz := tStore.Get(types.CurrentBlockDeleteStalePoliciesKey) k.cdc.MustUnmarshal(bz, &deleteInfo) - if bz == nil { - return types.ErrKeyNotExist - } } switch resourceType { case resource.RESOURCE_TYPE_BUCKET: @@ -1561,8 +1558,6 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { deleteInfo := &types.DeleteInfo{} k.cdc.MustUnmarshal(iterator.Value(), deleteInfo) - fmt.Printf("deleteinfo is %s\n", deleteInfo) - if deleteInfo.ObjectIds != nil && len(deleteInfo.ObjectIds.Id) > 0 { ids := deleteInfo.ObjectIds.Id temp := ids @@ -1615,13 +1610,13 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { // 2. group policy temp := ids for idx, id := range ids { - k.permKeeper.ForceDeleteGroupMembers(ctx, id) deletedCount, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_GROUP, id) if !done { deleteInfo.GroupIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } + k.permKeeper.ForceDeleteGroupMembers(ctx, id) temp = ids[idx+1:] } // clean deleted buckets id from deleteInfo From 3a903e1ecea4e1fb6c3367d847ff99653fcbae3c Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Fri, 5 May 2023 12:04:00 +0800 Subject: [PATCH 09/13] modify test parameter --- e2e/tests/permission_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/tests/permission_test.go b/e2e/tests/permission_test.go index b895d6f27..2faffa28d 100644 --- a/e2e/tests/permission_test.go +++ b/e2e/tests/permission_test.go @@ -1257,8 +1257,8 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { nonce, _ := s.Client.GetNonce() bucketNames := make([]string, 0) - // Create 420 Buckets - bucketNumber := 420 + // Create 250 Buckets + bucketNumber := 250 feeAmt := sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(int64(15000000000000)))) txOpt := sdktype.TxOption{ @@ -1319,7 +1319,7 @@ func (s *StorageTestSuite) TestExceedEachBlockLimitGC() { // delete batch of buckets for i := 0; i < bucketNumber; i++ { txOpt.Nonce = nonce - // the owner deletes the bucket + // the owner deletes buckets msgDeleteBucket := storagetypes.NewMsgDeleteBucket(owner.GetAddr(), bucketNames[i]) s.SendTxWithTxOpt(msgDeleteBucket, owner, txOpt) nonce++ From fcdcf115e3b8eefd086706baabe4c21a754b023a Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Sat, 6 May 2023 10:41:54 +0800 Subject: [PATCH 10/13] limiting delete group member when GC --- proto/greenfield/storage/events.proto | 2 +- sdk/client/tx_test.go | 4 +-- x/permission/keeper/keeper.go | 34 ++++++++++++++--------- x/storage/keeper/keeper.go | 20 +++++++------ x/storage/types/events.pb.go | 2 +- x/storage/types/expected_keepers.go | 2 +- x/storage/types/expected_keepers_mocks.go | 6 ++-- 7 files changed, 41 insertions(+), 29 deletions(-) diff --git a/proto/greenfield/storage/events.proto b/proto/greenfield/storage/events.proto index c16ba1599..63f56d9d0 100644 --- a/proto/greenfield/storage/events.proto +++ b/proto/greenfield/storage/events.proto @@ -427,7 +427,7 @@ message EventMirrorGroupResult { ]; } -// EventStalePolicyCleanup is emitted when specified block height's stale policies is garbage collected +// EventStalePolicyCleanup is emitted when specified block height's stale policies need to be Garbage collected message EventStalePolicyCleanup { int64 blockNum = 1; DeleteInfo delete_info =2; diff --git a/sdk/client/tx_test.go b/sdk/client/tx_test.go index 63f38b7ee..c1cf49d53 100644 --- a/sdk/client/tx_test.go +++ b/sdk/client/tx_test.go @@ -40,7 +40,7 @@ func TestSendTokenWithTxOptionSucceed(t *testing.T) { transfer := banktypes.NewMsgSend(km.GetAddr(), to, sdk.NewCoins(sdk.NewInt64Coin(test.TEST_TOKEN_NAME, 100))) payerAddr, err := sdk.AccAddressFromHexUnsafe(km.GetAddr().String()) assert.NoError(t, err) - mode := tx.BroadcastMode_BROADCAST_MODE_BLOCK + mode := tx.BroadcastMode_BROADCAST_MODE_SYNC feeAmt := sdk.NewCoins(sdk.NewCoin("BNB", sdk.NewInt(int64(10000000000000)))) // gasPrice * gasLimit txOpt := &types.TxOption{ @@ -67,7 +67,7 @@ func TestErrorOutWhenGasInfoNotFullProvided(t *testing.T) { transfer := banktypes.NewMsgSend(km.GetAddr(), to, sdk.NewCoins(sdk.NewInt64Coin(test.TEST_TOKEN_NAME, 100))) payerAddr, err := sdk.AccAddressFromHexUnsafe(km.GetAddr().String()) assert.NoError(t, err) - mode := tx.BroadcastMode_BROADCAST_MODE_BLOCK + mode := tx.BroadcastMode_BROADCAST_MODE_SYNC txOpt := &types.TxOption{ Mode: &mode, NoSimulate: true, diff --git a/x/permission/keeper/keeper.go b/x/permission/keeper/keeper.go index 133cc67a4..e0872c395 100644 --- a/x/permission/keeper/keeper.go +++ b/x/permission/keeper/keeper.go @@ -361,9 +361,9 @@ func (k Keeper) DeletePolicy(ctx sdk.Context, principal *types.Principal, resour } // ForceDeleteAccountPolicyForResource deletes all individual accounts policy enforced on resources, if -func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { +func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, maxDelete, deletedTotal uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { if resourceType == resource.RESOURCE_TYPE_UNSPECIFIED { - return deletedCount, true + return deletedTotal, true } store := ctx.KVStore(k.storeKey) resourceAccountsPolicyStore := prefix.NewStore(store, types.PolicyForAccountPrefix(resourceID, resourceType)) @@ -371,22 +371,24 @@ func (k Keeper) ForceDeleteAccountPolicyForResource(ctx sdk.Context, maxDelete, defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - // if exceeding the limit, pause the GC and mark the current resource's deletion is not complete yet - if deletedCount > maxDelete { - return deletedCount, false - } // delete mapping policyId -> policy policyID := sequence.DecodeSequence(iterator.Value()) store.Delete(types.GetPolicyByIDKey(policyID)) // delete mapping policyKey -> policyId resourceAccountsPolicyStore.Delete(iterator.Key()) - deletedCount++ + // emit DeletePolicy Event _ = ctx.EventManager().EmitTypedEvents(&types.EventDeletePolicy{ PolicyId: policyID, }) + deletedTotal++ + // if exceeding the limit, pause the GC and mark the current resource's deletion is not complete yet + if deletedTotal > maxDelete { + return deletedTotal, false + } + } - return deletedCount, true + return deletedTotal, true } // ForceDeleteGroupPolicyForResource deletes group policy enforced on resource @@ -401,16 +403,17 @@ func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, maxDelete, de policyGroup := types.PolicyGroup{} k.cdc.MustUnmarshal(bz, &policyGroup) for i := 0; i < len(policyGroup.Items); i++ { - if deletedTotal > maxDelete { - return deletedTotal, false - } // delete concrete policy by policyId policyId := policyGroup.Items[i].PolicyId store.Delete(types.GetPolicyByIDKey(policyId)) - deletedTotal++ + _ = ctx.EventManager().EmitTypedEvents(&types.EventDeletePolicy{ PolicyId: policyId, }) + deletedTotal++ + if deletedTotal > maxDelete { + return deletedTotal, false + } } store.Delete(policyForGroupKey) } @@ -418,7 +421,7 @@ func (k Keeper) ForceDeleteGroupPolicyForResource(ctx sdk.Context, maxDelete, de } // ForceDeleteGroupMembers deletes group members when user deletes a group -func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) { +func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, maxDelete, deletedTotal uint64, groupId math.Uint) (uint64, bool) { store := ctx.KVStore(k.storeKey) groupMembersPrefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GroupMembersPrefix(groupId)) iter := groupMembersPrefixStore.Iterator(nil, nil) @@ -429,7 +432,12 @@ func (k Keeper) ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) { store.Delete(types.GetGroupMemberByIDKey(memberID)) // delete GroupMemberPrefix_groupId_memberAddr -> memberSequence(id) groupMembersPrefixStore.Delete(iter.Key()) + deletedTotal++ + if deletedTotal > maxDelete { + return deletedTotal, false + } } + return deletedTotal, true } func (k Keeper) ExistAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 218e5ed02..2c057576d 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1545,13 +1545,12 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) deleteStalePoliciesPrefixStore := prefix.NewStore(store, types.DeleteStalePoliciesPrefix) - // todo use store to keep track of processed GC height iterator := deleteStalePoliciesPrefixStore.Iterator(nil, nil) defer iterator.Close() maxCleanup := k.StalePolicyCleanupMax(ctx) - var deletedCount uint64 + var deletedTotal uint64 var done bool for ; iterator.Valid(); iterator.Next() { @@ -1562,13 +1561,13 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { ids := deleteInfo.ObjectIds.Id temp := ids for idx, id := range ids { - deletedCount, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_OBJECT, id) + deletedTotal, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_OBJECT, id) if !done { deleteInfo.ObjectIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } - deletedCount, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_OBJECT, id) + deletedTotal, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_OBJECT, id) if !done { deleteInfo.ObjectIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) @@ -1585,13 +1584,13 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { ids := deleteInfo.BucketIds.Id temp := ids for idx, id := range ids { - deletedCount, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_BUCKET, id) + deletedTotal, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_BUCKET, id) if !done { deleteInfo.BucketIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } - deletedCount, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_BUCKET, id) + deletedTotal, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_BUCKET, id) if !done { deleteInfo.BucketIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) @@ -1610,13 +1609,18 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { // 2. group policy temp := ids for idx, id := range ids { - deletedCount, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedCount, resource.RESOURCE_TYPE_GROUP, id) + deletedTotal, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_GROUP, id) + if !done { + deleteInfo.GroupIds.Id = temp + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) + return + } + deletedTotal, done = k.permKeeper.ForceDeleteGroupMembers(ctx, maxCleanup, deletedTotal, id) if !done { deleteInfo.GroupIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) return } - k.permKeeper.ForceDeleteGroupMembers(ctx, id) temp = ids[idx+1:] } // clean deleted buckets id from deleteInfo diff --git a/x/storage/types/events.pb.go b/x/storage/types/events.pb.go index 2a4429e79..21c94deaa 100644 --- a/x/storage/types/events.pb.go +++ b/x/storage/types/events.pb.go @@ -1723,7 +1723,7 @@ func (m *EventMirrorGroupResult) GetGroupName() string { return "" } -// EventStalePolicyCleanup is emitted when specified block height's stale policies is garbage collected +// EventStalePolicyCleanup is emitted when specified block height's stale policies need to be Garbage collected type EventStalePolicyCleanup struct { BlockNum int64 `protobuf:"varint,1,opt,name=blockNum,proto3" json:"blockNum,omitempty"` DeleteInfo *DeleteInfo `protobuf:"bytes,2,opt,name=delete_info,json=deleteInfo,proto3" json:"delete_info,omitempty"` diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 491cac37a..4896e7532 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -66,7 +66,7 @@ type PermissionKeeper interface { GetGroupMemberByID(ctx sdk.Context, groupMemberID math.Uint) (*permtypes.GroupMember, bool) ForceDeleteAccountPolicyForResource(ctx sdk.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) ForceDeleteGroupPolicyForResource(ctx sdk.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) - ForceDeleteGroupMembers(ctx sdk.Context, groupId math.Uint) + ForceDeleteGroupMembers(ctx sdk.Context, maxDelete, deletedTotal uint64, groupId math.Uint) (uint64, bool) ExistAccountPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) bool ExistGroupPolicyForResource(ctx sdk.Context, resourceType resource.ResourceType, resourceID math.Uint) bool ExistGroupMemberForGroup(ctx sdk.Context, groupId math.Uint) bool diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index a3e43e26c..c831cdebe 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -633,15 +633,15 @@ func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ct } // ForceDeleteGroupMembers mocks base method. -func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, groupId math.Uint) { +func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, maxDelete, deletedCount uint64, groupId math.Uint) { m.ctrl.T.Helper() _ = m.ctrl.Call(m, "ForceDeleteGroupMembers", ctx, groupId) } // ForceDeleteGroupMembers indicates an expected call of ForceDeleteGroupMembers. -func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, groupId interface{}) *gomock.Call { +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, maxDelete, deletedCount, groupId interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupMembers), ctx, groupId) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupMembers), ctx, maxDelete, deletedCount, groupId) } // ExistAccountPolicyForResource mocks base method. From 89174d2ec7df01913d85a1f9c9cd4ea9f871187d Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Sat, 6 May 2023 10:49:06 +0800 Subject: [PATCH 11/13] fix test mocking --- x/storage/types/expected_keepers_mocks.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index c831cdebe..90407d30f 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -633,9 +633,12 @@ func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ct } // ForceDeleteGroupMembers mocks base method. -func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, maxDelete, deletedCount uint64, groupId math.Uint) { +func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, maxDelete, deletedCount uint64, groupId math.Uint) (uint64, bool) { m.ctrl.T.Helper() - _ = m.ctrl.Call(m, "ForceDeleteGroupMembers", ctx, groupId) + ret := m.ctrl.Call(m, "ForceDeleteGroupMembers", ctx, groupId) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(bool) + return ret0, ret1 } // ForceDeleteGroupMembers indicates an expected call of ForceDeleteGroupMembers. From cc08737ed0fc7b51d99fe050cb97b8d0f5d06e5c Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Sat, 6 May 2023 17:52:47 +0800 Subject: [PATCH 12/13] reduce duplicate code --- x/storage/keeper/keeper.go | 111 +++++++++++++++---------------------- 1 file changed, 46 insertions(+), 65 deletions(-) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 2c057576d..1f8e88254 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1556,80 +1556,61 @@ func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { for ; iterator.Valid(); iterator.Next() { deleteInfo := &types.DeleteInfo{} k.cdc.MustUnmarshal(iterator.Value(), deleteInfo) - - if deleteInfo.ObjectIds != nil && len(deleteInfo.ObjectIds.Id) > 0 { - ids := deleteInfo.ObjectIds.Id - temp := ids - for idx, id := range ids { - deletedTotal, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_OBJECT, id) - if !done { - deleteInfo.ObjectIds.Id = temp - deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) - return - } - deletedTotal, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_OBJECT, id) - if !done { - deleteInfo.ObjectIds.Id = temp - deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) - return - } - // remove current resource id from list of ids to be deleted - temp = ids[idx+1:] - } - // clean deleted objects id from deleteInfo - deleteInfo.ObjectIds = nil + deletedTotal, done = k.garbageCollectionForResource(ctx, deleteStalePoliciesPrefixStore, iterator, deleteInfo, resource.RESOURCE_TYPE_OBJECT, deleteInfo.ObjectIds, maxCleanup, deletedTotal) + if !done { + return } - - if deleteInfo.BucketIds != nil && len(deleteInfo.BucketIds.Id) > 0 { - ids := deleteInfo.BucketIds.Id - temp := ids - for idx, id := range ids { - deletedTotal, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_BUCKET, id) - if !done { - deleteInfo.BucketIds.Id = temp - deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) - return - } - deletedTotal, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_BUCKET, id) - if !done { - deleteInfo.BucketIds.Id = temp - deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) - return - } - temp = ids[idx+1:] - } - // clean deleted buckets id from deleteInfo - deleteInfo.BucketIds = nil + deleteInfo.ObjectIds = nil + deletedTotal, done = k.garbageCollectionForResource(ctx, deleteStalePoliciesPrefixStore, iterator, deleteInfo, resource.RESOURCE_TYPE_BUCKET, deleteInfo.BucketIds, maxCleanup, deletedTotal) + if !done { + return + } + deleteInfo.BucketIds = nil + deletedTotal, done = k.garbageCollectionForResource(ctx, deleteStalePoliciesPrefixStore, iterator, deleteInfo, resource.RESOURCE_TYPE_GROUP, deleteInfo.GroupIds, maxCleanup, deletedTotal) + if !done { + return + } + deleteInfo.GroupIds = nil + // the specified block height(iterator-key)'s stale resource permission metadata is purged + if deleteInfo.IsEmpty() { + deleteStalePoliciesPrefixStore.Delete(iterator.Key()) } + } +} - if deleteInfo.GroupIds != nil && len(deleteInfo.GroupIds.Id) > 0 { - ids := deleteInfo.GroupIds.Id - // for a group which is deleted by user, there are 2 parts need to clean: - // 1. group members within the group. - // 2. group policy - temp := ids - for idx, id := range ids { - deletedTotal, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedTotal, resource.RESOURCE_TYPE_GROUP, id) - if !done { - deleteInfo.GroupIds.Id = temp - deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) - return - } +func (k Keeper) garbageCollectionForResource(ctx sdk.Context, deleteStalePoliciesPrefixStore prefix.Store, iterator storetypes.Iterator, + deleteInfo *types.DeleteInfo, resourceType resource.ResourceType, resourceIds *types.Ids, maxCleanup, deletedTotal uint64) (uint64, bool) { + var done bool + if resourceIds != nil && len(resourceIds.Id) > 0 { + ids := resourceIds.Id + temp := ids + for idx, id := range ids { + deletedTotal, done = k.permKeeper.ForceDeleteAccountPolicyForResource(ctx, maxCleanup, deletedTotal, resourceType, id) + if !done { + resourceIds.Id = temp + + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) + return deletedTotal, false + } + if resourceType == resource.RESOURCE_TYPE_GROUP { deletedTotal, done = k.permKeeper.ForceDeleteGroupMembers(ctx, maxCleanup, deletedTotal, id) if !done { deleteInfo.GroupIds.Id = temp deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) - return + return deletedTotal, false } - temp = ids[idx+1:] + // no need to deal with group policy when resource type is group + continue } - // clean deleted buckets id from deleteInfo - deleteInfo.GroupIds = nil - } - - // the specified block height(iterator-key)'s stale resource permission metadata is purged - if deleteInfo.IsEmpty() { - deleteStalePoliciesPrefixStore.Delete(iterator.Key()) + deletedTotal, done = k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, maxCleanup, deletedTotal, resourceType, id) + if !done { + resourceIds.Id = temp + deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) + return deletedTotal, false + } + // remove current resource id from list of ids to be deleted + temp = ids[idx+1:] } } + return deletedTotal, true } From 0f4b7e9413fb736670bab0a8defd7366172e698c Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Sat, 6 May 2023 18:16:29 +0800 Subject: [PATCH 13/13] fix comments --- x/storage/types/types.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/storage/types/types.go b/x/storage/types/types.go index 765a12bf4..c5b0f7469 100644 --- a/x/storage/types/types.go +++ b/x/storage/types/types.go @@ -78,13 +78,13 @@ func (di *DeleteInfo) IsEmpty() bool { if di == nil { return true } - if di.BucketIds == nil || (di.BucketIds != nil && len(di.BucketIds.Id) == 0) { + if di.BucketIds == nil || len(di.BucketIds.Id) == 0 { isBucketIdsEmpty = true } - if di.ObjectIds == nil || (di.ObjectIds != nil && len(di.ObjectIds.Id) == 0) { + if di.ObjectIds == nil || len(di.ObjectIds.Id) == 0 { isObjectIdsEmpty = true } - if di.GroupIds == nil || (di.GroupIds != nil && len(di.GroupIds.Id) == 0) { + if di.GroupIds == nil || len(di.GroupIds.Id) == 0 { isGroupIdsEmpty = true } return isBucketIdsEmpty && isObjectIdsEmpty && isGroupIdsEmpty