-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: remove create object & bucket approval #580
Conversation
7c7277e
to
3815ffd
Compare
0998071
to
ce591d8
Compare
x/storage/keeper/keeper.go
Outdated
@@ -567,6 +559,12 @@ func (k Keeper) CreateObject( | |||
return sdkmath.ZeroUint(), err | |||
} | |||
|
|||
// check object | |||
_, found = k.GetObjectInfo(ctx, bucketName, objectName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is already implemented below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -117,14 +117,6 @@ func (k Keeper) CreateBucket( | |||
return sdkmath.ZeroUint(), errors.Wrap(types.ErrNoSuchStorageProvider, "the storage provider is not in service") | |||
} | |||
|
|||
// check primary sp approval | |||
if opts.PrimarySpApproval.ExpiredHeight < uint64(ctx.BlockHeight()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these code cant be deleted directly. Need to modify after new hardfork is introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't be deleted directly. With the new Go-SDK, verification no longer goes through SP to obtain, thus there is no expiredHeight.
In the old Go-SDK, creating a bucket would go through SP to get approval, but this is no longer necessary for ExpiredHeight verification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed with IsUpgraded(upgradetypes.Pawnee)
the correct hard fork version will be updated before release
}, nil | ||
} | ||
|
||
func (k Keeper) QuerySpOptimalGlobalVirtualGroupFamily(goCtx context.Context, req *types.QuerySpOptimalGlobalVirtualGroupFamilyRequest) (*types.QuerySpOptimalGlobalVirtualGroupFamilyResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this API more flexible? Might define the strategy as enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, an enum was created to select the strategy.
x/virtualgroup/keeper/keeper.go
Outdated
@@ -167,6 +167,7 @@ func (k Keeper) DeleteGVG(ctx sdk.Context, primarySp *sptypes.StorageProvider, g | |||
k.paymentKeeper.IsEmptyNetFlow(ctx, sdk.MustAccAddressFromHex(gvgFamily.VirtualPaymentAddress)) && | |||
!ctx.IsUpgraded(upgradetypes.Manchurian) { | |||
store.Delete(types.GetGVGFamilyKey(gvg.FamilyId)) | |||
k.DeleteGVGFamilyWithinSP(ctx, primarySp.Id, gvg.FamilyId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above GetGVGFamilyKey deletes this VGF. Logically, the list of VGFs under this SP should also have the corresponding VGF removed. Why is this not necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted
x/virtualgroup/keeper/keeper.go
Outdated
break | ||
} | ||
} | ||
if index != -1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be put into the for loop, once meet the desired element, do the manipulation immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
x/virtualgroup/keeper/keeper.go
Outdated
store.Set(types.GetGVGFamilyStatisticsWithinSPKey(vgfStatisticsWithinSP.StorageProviderId), bz) | ||
} | ||
|
||
func (k Keeper) BatchSetGVGFamilyStatisticsWithinSP(ctx sdk.Context, vgfStatisticsWithinSP []*types.GVGFamilyStatisticsWithinSP) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to populate data into store as new key is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BatchSetGVGFamilyStatisticsWithinSP calls SetGVGFamilyStatisticsWithinSP to store it in the store, so there should be no need to add additional logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the logic to set all GVGFamilyStatisticsWithinSP when executing the hardfork
@@ -73,6 +73,13 @@ message GVGStatisticsWithinSP { | |||
uint32 break_redundancy_reqmt_gvg_count = 4; | |||
} | |||
|
|||
message GVGFamilyStatisticsWithinSP { | |||
// storage_provider_id defines the id of the sp which the statistics associated to | |||
uint32 storage_provider_id = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the storage_provider_id
is not needed as the key is the sp_id already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
x/virtualgroup/keeper/keeper.go
Outdated
@@ -289,6 +294,8 @@ func (k Keeper) SwapAsPrimarySP(ctx sdk.Context, primarySP, successorSP *sptypes | |||
|
|||
srcStat := k.MustGetGVGStatisticsWithinSP(ctx, primarySP.Id) | |||
dstStat := k.GetOrCreateGVGStatisticsWithinSP(ctx, successorSP.Id) | |||
srcVGFStat := k.MustGetGVGFamilyStatisticsWithinSP(ctx, primarySP.Id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is executed before the hardfork, there is no stats yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
x/virtualgroup/keeper/keeper.go
Outdated
@@ -358,6 +365,9 @@ func (k Keeper) SwapAsPrimarySP(ctx sdk.Context, primarySP, successorSP *sptypes | |||
} | |||
k.SetGVGStatisticsWithSP(ctx, srcStat) | |||
k.SetGVGStatisticsWithSP(ctx, dstStat) | |||
k.DeleteGVGFamilyWithinSP(ctx, srcVGFStat.SpId, family.Id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is executed before the hardfork, there is no stats yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
x/virtualgroup/keeper/keeper.go
Outdated
var gvgFamily types.GlobalVirtualGroupFamily | ||
k.cdc.MustUnmarshal(iterator.Value(), &gvgFamily) | ||
gvgFamilyStatistics := k.GetOrCreateGVGFamilyStatisticsWithinSP(ctx, gvgFamily.PrimarySpId) | ||
if !slices.Contains(gvgFamilyStatistics.GlobalVirtualGroupFamilyIds, gvgFamily.Id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should't be any family identical to another
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
enum PickVGFStrategy { | ||
option (gogoproto.goproto_enum_prefix) = false; | ||
|
||
StrategyMaximizeFreeStoreSize = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for the style to define enum. It should be like XX_XX_XX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to Strategy_Maximize_Free_Store_Size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be all CAP
x/virtualgroup/keeper/keeper.go
Outdated
@@ -358,6 +369,11 @@ func (k Keeper) SwapAsPrimarySP(ctx sdk.Context, primarySP, successorSP *sptypes | |||
} | |||
k.SetGVGStatisticsWithSP(ctx, srcStat) | |||
k.SetGVGStatisticsWithSP(ctx, dstStat) | |||
if ctx.IsUpgraded(upgradetypes.Serengeti) { | |||
k.DeleteGVGFamilyWithinSP(ctx, srcVGFStat.SpId, family.Id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rename this, a little confused..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to DeleteSpecificGVGFamilyStatisticsFromSP. If it is not appropriate, i will think about another one
x/virtualgroup/keeper/keeper.go
Outdated
store.Set(types.GetGVGFamilyStatisticsWithinSPKey(vgfStatisticsWithinSP.SpId), bz) | ||
} | ||
|
||
func (k Keeper) BatchSetGVGFamilyStatisticsWithinSP(ctx sdk.Context, vgfStatisticsWithinSP []*types.GVGFamilyStatisticsWithinSP) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not being called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted
x/virtualgroup/keeper/keeper.go
Outdated
gvgFamilyStatistics := k.GetOrCreateGVGFamilyStatisticsWithinSP(ctx, gvgFamily.PrimarySpId) | ||
k.Logger(ctx).Info(fmt.Sprintf("gvgFamilyStatistics1 gvgFamily id %v, sp id: %d", gvgFamilyStatistics.GlobalVirtualGroupFamilyIds, gvgFamilyStatistics.SpId)) | ||
gvgFamilyStatistics.GlobalVirtualGroupFamilyIds = append(gvgFamilyStatistics.GlobalVirtualGroupFamilyIds, gvgFamily.Id) | ||
k.Logger(ctx).Info(fmt.Sprintf("gvgFamilyStatistics2 gvgFamily id %v, sp id: %d", gvgFamilyStatistics.GlobalVirtualGroupFamilyIds, gvgFamilyStatistics.SpId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you refine the log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only for debug log,deleted
x/virtualgroup/types/errors.go
Outdated
ErrSwapInFailed = errors.Register(ModuleName, 1127, "swap in failed.") | ||
ErrSwapInInfoNotExist = errors.Register(ModuleName, 1128, "swap in info not exist.") | ||
ErrGVGStatisticsNotExist = errors.Register(ModuleName, 1129, "gvg statistics not exist.") | ||
ErrGVGFamilyStatisticsNotExist = errors.Register(ModuleName, 1130, "vgf statistics not exist.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want the naming consistent like "global virtual group family..." as it is exposed to users..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Description
Remove the create object approval & create bucket approval, and during the process of creating objects & buckets, the calls to the SP side are eliminated through the Go-sdk.
For CreateObject, validation for the object's existence has been added on chain, and the corresponding verify signature has been removed.
For CreateBucket, two gRPC queries have been added and used during the creation process in the Go-sdk to replace the previous logic of Pick VGF on the SP side:
And the limitation on creating buckets under a user has been removed.
Rationale
Before
SP Pick VGF & Create GVG process
Current
Replace the process on the SP side of checking for available VGF & GVG during the create bucket approval. Virtual Group Manager will automatically check the available status of each SP's GVG & VGF and create GVG when the storage is full or the SP does not have any available GVG.Example
N/A
Changes
Notable changes:
Potential Impacts