Skip to content
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

fix: disallow update payment address when there are created/updating objects #584

Merged
merged 7 commits into from
Mar 11, 2024

Conversation

forcodedancing
Copy link
Contributor

@forcodedancing forcodedancing commented Mar 7, 2024

Description

  • When updating the payment address of a bucket, it is required there is no object in created or updating status.
  • Fix GetVersionedParameters is not correct issue.
  • Do not allow delete discontinued objects for DeleteObject message. (no DiscontinueObject message on testnet/mainnet. This does not happen on testnet/qa, just to make the logic easier, especially after the feature of updating object content).

Rationale

Bug fix

Example

NA

Changes

Notable changes:

  • do not allow update payment account when there are objects in created or updating status

Potential Impacts

  • add potential impacts for other components here
  • ...

@forcodedancing forcodedancing force-pushed the disallow_change_payment branch 4 times, most recently from d8bd1c9 to fcf7a66 Compare March 7, 2024 05:46
@keefel
Copy link
Contributor

keefel commented Mar 7, 2024

Please submit to master branch

x/storage/keeper/abci.go Outdated Show resolved Hide resolved
ctx.Logger().Error("should not happen, fail to delete buckets, err " + err.Error())
panic("should not happen")
doDeleteBucket := true
if ctx.BlockHeight() > 5946511 && ctx.ChainID() == "greenfield_5600-1" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add some comments here on why we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

keefel
keefel previously approved these changes Mar 7, 2024
@forcodedancing forcodedancing changed the base branch from develop to master March 8, 2024 02:10
@forcodedancing forcodedancing dismissed keefel’s stale review March 8, 2024 02:10

The base branch was changed.

@@ -123,7 +124,12 @@ func (k Keeper) UpdateFrozenStreamRecord(ctx sdk.Context, streamRecord *types.St
streamRecord.LockBalance = streamRecord.LockBalance.Add(change.LockBalanceChange)
streamRecord.StaticBalance = streamRecord.StaticBalance.Sub(change.LockBalanceChange)
if streamRecord.LockBalance.IsNegative() {
return fmt.Errorf("lock balance can not become negative, current: %s", streamRecord.LockBalance)
if ctx.IsUpgraded(upgradetypes.Pawnee) {
streamRecord.StaticBalance = streamRecord.StaticBalance.Add(streamRecord.LockBalance)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if staticbalance become negative? is it possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the stream record is frozen, it will be negative.
When deposit, the user need to cover the fund.

image

@@ -158,7 +164,12 @@ func (k Keeper) UpdateStreamRecord(ctx sdk.Context, streamRecord *types.StreamRe
streamRecord.LockBalance = streamRecord.LockBalance.Add(change.LockBalanceChange)
streamRecord.StaticBalance = streamRecord.StaticBalance.Sub(change.LockBalanceChange)
if streamRecord.LockBalance.IsNegative() {
return fmt.Errorf("lock balance can not become negative, current: %s", streamRecord.LockBalance)
if ctx.IsUpgraded(upgradetypes.Pawnee) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It could be negative. As when we locking more fund into buffer balance, if the static balance is negative. The new needs to pay for it.

image

@@ -334,6 +335,9 @@ func (k Keeper) ForceDeleteBucket(ctx sdk.Context, bucketId sdkmath.Uint, cap ui
ctx.Logger().Error("unlock store fee error", "err", err)
return false, deleted, err
}
if ctx.IsUpgraded(upgradetypes.Pawnee) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, I think the SP need run a job: scan all the stale created object and reject seal them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can reject seal the stale created object, it will be better. I checked greenfieldscan, cannot find the stale created objects easily.

@@ -1039,6 +1062,9 @@ func (k Keeper) ForceDeleteObject(ctx sdk.Context, objectId sdkmath.Uint) error
ctx.Logger().Error("unlock store fee error", "err", err)
return err
}
if ctx.IsUpgraded(upgradetypes.Pawnee) {
k.DecreaseCreatedObjectCount(ctx, bucketInfo.Id)
}
} else if objectStatus == types.OBJECT_STATUS_SEALED {
internalBucketInfo := k.MustGetInternalBucketInfo(ctx, bucketInfo.Id)
err := k.UnChargeObjectStoreFee(ctx, bucketInfo, internalBucketInfo, objectInfo)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is object being updated, update the payment addr is not allowed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added related codes, please check.

@forcodedancing forcodedancing force-pushed the disallow_change_payment branch from 6dfee73 to b12488c Compare March 8, 2024 07:52
@forcodedancing forcodedancing force-pushed the disallow_change_payment branch from dd74b40 to 6af6cd2 Compare March 8, 2024 08:25
@forcodedancing forcodedancing removed the wip label Mar 8, 2024
@forcodedancing forcodedancing force-pushed the disallow_change_payment branch from d7881ce to 8d672ac Compare March 8, 2024 10:33
@forcodedancing forcodedancing changed the title fix: disallow update payment address when there are created objects fix: disallow update payment address when there are created/updating objects Mar 8, 2024
@keefel keefel added this pull request to the merge queue Mar 11, 2024
@forcodedancing forcodedancing merged commit a74e009 into master Mar 11, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants