-
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 ChangeCandidate when Bucket is Endorsed #4133
Conversation
42ff5e6
to
26c5f6e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4133 +/- ##
==========================================
+ Coverage 75.38% 76.38% +1.00%
==========================================
Files 303 340 +37
Lines 25923 28964 +3041
==========================================
+ Hits 19541 22125 +2584
- Misses 5360 5731 +371
- Partials 1022 1108 +86 ☔ View full report in Codecov by Sentry. |
1964781
to
b69adc8
Compare
action/protocol/staking/handlers.go
Outdated
@@ -314,6 +315,9 @@ func (p *Protocol) handleChangeCandidate(ctx context.Context, act *action.Change | |||
if rErr = validateBucketSelfStake(featureCtx, csm, bucket, false); rErr != nil { | |||
return log, rErr | |||
} | |||
if rErr := validateBucketEndorsement(NewEndorsementStateManager(csm.SM()), bucket, false, blkCtx.BlockHeight); rErr != nil { |
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 this be protected by hard-fork flag?
- if bucket status =
UnEndorsing
, it will returnnil
. This case is considered OK to change candidate?
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.
- I think not required, b/c there should be no endorsement before HF, so the validation should pass
- It actually returns error if bucket is UnEndorsing
action/protocol/staking/handlers.go
Outdated
@@ -357,6 +361,11 @@ func (p *Protocol) handleChangeCandidate(ctx context.Context, act *action.Change | |||
failureStatus: iotextypes.ReceiptStatus_ErrNotEnoughBalance, | |||
} | |||
} | |||
// clear previous candidate's self stake if the bucket is expired |
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 need this change? change candidate has nothing to do with previous candidate's self-stake 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.
we should clear self-stake bucket if the bucket is an expired 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.
then need to check the bucket is an expired endorse bucket? not a regular bucket
Quality Gate failedFailed conditions |
Description
After delegate endorsement introduced, there are two changes when handling ChangeCandidate action:
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: