diff --git a/proto/greenfield/storage/tx.proto b/proto/greenfield/storage/tx.proto index 0d5615a89..b0bed7ee0 100644 --- a/proto/greenfield/storage/tx.proto +++ b/proto/greenfield/storage/tx.proto @@ -531,9 +531,7 @@ message MsgUpdateParams { // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // params defines the x/storage parameters to update. - // NOTE: All parameters must be supplied. Params params = 2 [(gogoproto.nullable) = false]; } diff --git a/proto/greenfield/virtualgroup/types.proto b/proto/greenfield/virtualgroup/types.proto index 530828434..a015a8316 100644 --- a/proto/greenfield/virtualgroup/types.proto +++ b/proto/greenfield/virtualgroup/types.proto @@ -31,40 +31,48 @@ message GlobalVirtualGroup { // Each local virtual group is associated with a unique virtual payment account, // where all object fees are streamed to. message LocalVirtualGroup { + // id is the identifier of the local virtual group. uint32 id = 1; - - // id is the unique identification for bucket. + // bucket_id is the unique identification for the bucket. string bucket_id = 2 [ (cosmos_proto.scalar) = "cosmos.Uint", (gogoproto.customtype) = "Uint", (gogoproto.nullable) = false ]; + // global_virtual_group_id is the identifier of the global virtual group. uint32 global_virtual_group_id = 3; + // stored_size is the size of the stored data in the local virtual group. uint64 stored_size = 4; } // Global virtual group family serve as a means of grouping global virtual groups. // Each bucket must be associated with a unique global virtual group family and cannot cross families. message GlobalVirtualGroupFamily { + // id is the identifier of the global virtual group family. uint32 id = 1; - + // global_virtual_group_ids is a list of identifiers of the global virtual groups associated with the family. repeated uint32 global_virtual_group_ids = 2; + // virtual_payment_address is the payment address associated with the global virtual group family. string virtual_payment_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } message GlobalVirtualGroupsBindingOnBucket { - // id is the unique identification for bucket. + // bucket_id is the unique identification for the bucket. string bucket_id = 1 [ (cosmos_proto.scalar) = "cosmos.Uint", (gogoproto.customtype) = "Uint", (gogoproto.nullable) = false ]; + // global_virtual_group_ids is a list of identifiers of the global virtual groups associated with the bucket. repeated uint32 global_virtual_group_ids = 2; + // local_virtual_group_ids is a list of identifiers of the local virtual groups associated with the bucket. repeated uint32 local_virtual_group_ids = 3; } message GVGStatisticsWithinSP { uint32 storage_provider_id = 1; + // secondary_count defines the number of global virtual groups (GVGs) in + // which this storage provider serves as a secondary storage provider. uint32 secondary_count = 3; } diff --git a/x/storage/types/tx.pb.go b/x/storage/types/tx.pb.go index 999216e8d..7f013b80c 100644 --- a/x/storage/types/tx.pb.go +++ b/x/storage/types/tx.pb.go @@ -2422,6 +2422,7 @@ var xxx_messageInfo_MsgMirrorGroupResponse proto.InternalMessageInfo type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/storage parameters to update. // NOTE: All parameters must be supplied. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } diff --git a/x/virtualgroup/keeper/keeper.go b/x/virtualgroup/keeper/keeper.go index 3c220a534..557b24a77 100644 --- a/x/virtualgroup/keeper/keeper.go +++ b/x/virtualgroup/keeper/keeper.go @@ -547,7 +547,6 @@ func (k Keeper) RebindingGVGsToBucket(ctx sdk.Context, bucketID math.Uint, dstSP lvg2gvg[lvgID] = gvgsBindingOnBucket.GlobalVirtualGroupIds[i] } - newGVGBindingOnBucket.BucketId = bucketID // verify secondary signature for _, newLvg2gvg := range newLVGToGVGMappings { dstGVG, found := k.GetGVG(ctx, newLvg2gvg.GlobalVirtualGroupId) @@ -555,6 +554,11 @@ func (k Keeper) RebindingGVGsToBucket(ctx sdk.Context, bucketID math.Uint, dstSP return types.ErrGVGNotExist.Wrapf("dst gvg not found") } + lvg, found := k.GetLVG(ctx, bucketID, newLvg2gvg.LocalVirtualGroupId) + if !found { + return types.ErrGVGNotExist.Wrapf("lvg not found") + } + srcGVGID, exists := lvg2gvg[newLvg2gvg.LocalVirtualGroupId] if exists { return types.ErrMigrationBucketFailed.Wrapf("local virtual group not found, id: %d", newLvg2gvg.LocalVirtualGroupId) @@ -579,17 +583,21 @@ func (k Keeper) RebindingGVGsToBucket(ctx sdk.Context, bucketID math.Uint, dstSP } } - dstGVG.StoredSize += srcGVG.StoredSize + dstGVG.StoredSize += lvg.StoredSize + srcGVG.StoredSize -= lvg.StoredSize // TODO(fynn): add deposit check newGVGBindingOnBucket.LocalVirtualGroupIds = append(newGVGBindingOnBucket.LocalVirtualGroupIds, newLvg2gvg.LocalVirtualGroupId) newGVGBindingOnBucket.GlobalVirtualGroupIds = append(newGVGBindingOnBucket.GlobalVirtualGroupIds, newLvg2gvg.GlobalVirtualGroupId) delete(lvg2gvg, newLvg2gvg.LocalVirtualGroupId) k.SetGVG(ctx, dstGVG) + k.SetGVG(ctx, srcGVG) } if len(lvg2gvg) != 0 || len(gvgsBindingOnBucket.LocalVirtualGroupIds) != len(newGVGBindingOnBucket.LocalVirtualGroupIds) { return types.ErrMigrationBucketFailed.Wrapf("LVG is not fully rebinding.") } + + newGVGBindingOnBucket.BucketId = bucketID k.SetGVGsBindingOnBucket(ctx, &newGVGBindingOnBucket) return nil } diff --git a/x/virtualgroup/types/types.pb.go b/x/virtualgroup/types/types.pb.go index f18ead72c..b3e1eb38e 100644 --- a/x/virtualgroup/types/types.pb.go +++ b/x/virtualgroup/types/types.pb.go @@ -119,11 +119,14 @@ func (m *GlobalVirtualGroup) GetVirtualPaymentAddress() string { // Each local virtual group is associated with a unique virtual payment account, // where all object fees are streamed to. type LocalVirtualGroup struct { + // id is the identifier of the local virtual group. Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // id is the unique identification for bucket. - BucketId Uint `protobuf:"bytes,2,opt,name=bucket_id,json=bucketId,proto3,customtype=Uint" json:"bucket_id"` + // bucket_id is the unique identification for the bucket. + BucketId Uint `protobuf:"bytes,2,opt,name=bucket_id,json=bucketId,proto3,customtype=Uint" json:"bucket_id"` + // global_virtual_group_id is the identifier of the global virtual group. GlobalVirtualGroupId uint32 `protobuf:"varint,3,opt,name=global_virtual_group_id,json=globalVirtualGroupId,proto3" json:"global_virtual_group_id,omitempty"` - StoredSize uint64 `protobuf:"varint,4,opt,name=stored_size,json=storedSize,proto3" json:"stored_size,omitempty"` + // stored_size is the size of the stored data in the local virtual group. + StoredSize uint64 `protobuf:"varint,4,opt,name=stored_size,json=storedSize,proto3" json:"stored_size,omitempty"` } func (m *LocalVirtualGroup) Reset() { *m = LocalVirtualGroup{} } @@ -183,9 +186,12 @@ func (m *LocalVirtualGroup) GetStoredSize() uint64 { // Global virtual group family serve as a means of grouping global virtual groups. // Each bucket must be associated with a unique global virtual group family and cannot cross families. type GlobalVirtualGroupFamily struct { - Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // id is the identifier of the global virtual group family. + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // global_virtual_group_ids is a list of identifiers of the global virtual groups associated with the family. GlobalVirtualGroupIds []uint32 `protobuf:"varint,2,rep,packed,name=global_virtual_group_ids,json=globalVirtualGroupIds,proto3" json:"global_virtual_group_ids,omitempty"` - VirtualPaymentAddress string `protobuf:"bytes,4,opt,name=virtual_payment_address,json=virtualPaymentAddress,proto3" json:"virtual_payment_address,omitempty"` + // virtual_payment_address is the payment address associated with the global virtual group family. + VirtualPaymentAddress string `protobuf:"bytes,4,opt,name=virtual_payment_address,json=virtualPaymentAddress,proto3" json:"virtual_payment_address,omitempty"` } func (m *GlobalVirtualGroupFamily) Reset() { *m = GlobalVirtualGroupFamily{} } @@ -243,10 +249,12 @@ func (m *GlobalVirtualGroupFamily) GetVirtualPaymentAddress() string { } type GlobalVirtualGroupsBindingOnBucket struct { - // id is the unique identification for bucket. - BucketId Uint `protobuf:"bytes,1,opt,name=bucket_id,json=bucketId,proto3,customtype=Uint" json:"bucket_id"` + // bucket_id is the unique identification for the bucket. + BucketId Uint `protobuf:"bytes,1,opt,name=bucket_id,json=bucketId,proto3,customtype=Uint" json:"bucket_id"` + // global_virtual_group_ids is a list of identifiers of the global virtual groups associated with the bucket. GlobalVirtualGroupIds []uint32 `protobuf:"varint,2,rep,packed,name=global_virtual_group_ids,json=globalVirtualGroupIds,proto3" json:"global_virtual_group_ids,omitempty"` - LocalVirtualGroupIds []uint32 `protobuf:"varint,3,rep,packed,name=local_virtual_group_ids,json=localVirtualGroupIds,proto3" json:"local_virtual_group_ids,omitempty"` + // local_virtual_group_ids is a list of identifiers of the local virtual groups associated with the bucket. + LocalVirtualGroupIds []uint32 `protobuf:"varint,3,rep,packed,name=local_virtual_group_ids,json=localVirtualGroupIds,proto3" json:"local_virtual_group_ids,omitempty"` } func (m *GlobalVirtualGroupsBindingOnBucket) Reset() { *m = GlobalVirtualGroupsBindingOnBucket{} } @@ -298,7 +306,9 @@ func (m *GlobalVirtualGroupsBindingOnBucket) GetLocalVirtualGroupIds() []uint32 type GVGStatisticsWithinSP struct { StorageProviderId uint32 `protobuf:"varint,1,opt,name=storage_provider_id,json=storageProviderId,proto3" json:"storage_provider_id,omitempty"` - SecondaryCount uint32 `protobuf:"varint,3,opt,name=secondary_count,json=secondaryCount,proto3" json:"secondary_count,omitempty"` + // secondary_count defines the number of global virtual groups (GVGs) in + // which this storage provider serves as a secondary storage provider. + SecondaryCount uint32 `protobuf:"varint,3,opt,name=secondary_count,json=secondaryCount,proto3" json:"secondary_count,omitempty"` } func (m *GVGStatisticsWithinSP) Reset() { *m = GVGStatisticsWithinSP{} }