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

[staking] Cannot ChangeCandidate when Bucket is Endorsed #4133

Merged
merged 7 commits into from
Mar 7, 2024

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Feb 6, 2024

Description

After delegate endorsement introduced, there are two changes when handling ChangeCandidate action:

  • cannot if bucket is endorsed
  • clear legacy selfstake bucket of previous candidate

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)

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

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.38%. Comparing base (e1f0636) to head (44cfc54).
Report is 188 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

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

  1. should this be protected by hard-fork flag?
  2. if bucket status = UnEndorsing, it will return nil. This case is considered OK to change candidate?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I think not required, b/c there should be no endorsement before HF, so the validation should pass
  2. It actually returns error if bucket is UnEndorsing

@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

  1. why need this change? change candidate has nothing to do with previous candidate's self-stake bucket

Copy link
Member Author

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

Copy link
Member

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

Copy link

sonarcloud bot commented Mar 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
5.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@envestcc envestcc merged commit 87fda71 into iotexproject:master Mar 7, 2024
3 of 5 checks passed
@envestcc envestcc deleted the pr-changecand branch March 7, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants