-
Notifications
You must be signed in to change notification settings - Fork 324
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
[staking] Cannot Unstake if Bucket is Endorsed #4134
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4134 +/- ##
==========================================
+ Coverage 75.38% 76.38% +1.00%
==========================================
Files 303 340 +37
Lines 25923 28973 +3050
==========================================
+ Hits 19541 22132 +2591
- Misses 5360 5733 +373
- Partials 1022 1108 +86 ☔ View full report in Codecov by Sentry. |
@@ -175,6 +175,10 @@ func (p *Protocol) handleUnstake(ctx context.Context, act *action.Unstake, csm C | |||
failureStatus: iotextypes.ReceiptStatus_ErrUnstakeBeforeMaturity, | |||
} | |||
} | |||
if rErr := validateBucketEndorsement(NewEndorsementStateManager(csm.SM()), bucket, false, blkCtx.BlockHeight); rErr != nil { | |||
return log, rErr |
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.
in func validateBucketEndorsement(
case errors.Is(err, state.ErrStateNotExist):
if isEndorsed {
return &handleError{
err: errors.New("bucket is not endorsed"),
failureStatus: iotextypes.ReceiptStatus_ErrInvalidBucketType,
}
}
should return
err: errors.New("bucket is not an endorse bucket"),
failureStatus: iotextypes.ReceiptStatus_ErrInvalidBucketIndex,
since the bucket is not an endorse bucket
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.
and then if it returns this error, it should be fine to continue?
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.
returning error means validation failed, should not continue
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.
ok, fix the error return
@@ -96,7 +96,7 @@ func validateBucketEndorsement(esm *EndorsementStateManager, bucket *VoteBucket, | |||
case errors.Is(err, state.ErrStateNotExist): | |||
if isEndorsed { | |||
return &handleError{ | |||
err: errors.New("bucket is not endorsed"), | |||
err: errors.New("bucket is not an endorse bucket"), |
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 error here is the same as the error on line 86 above, and it is best to distinguish it
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.
okay
Quality Gate failedFailed conditions |
Description
After delegate endorsement introduced, we cannot unstake bucket if it's a endorse bucket.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: