Skip to content

Conversation

@CoderZhi
Copy link
Collaborator

@CoderZhi CoderZhi commented Dec 23, 2025

Delegates who want to exit need to submit a request.
At the beginning of each epoch, allowed a delegate to exit if there is no exit in last 24 epoch.
If a candidate is ready to exit, it won't be selected as delegate.

A few TODOs:

  1. Exit endorsement

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

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

@CoderZhi CoderZhi requested a review from a team as a code owner December 23, 2025 14:04
@CoderZhi CoderZhi force-pushed the exit_queue branch 3 times, most recently from ab6f762 to 54ee78d Compare December 26, 2025 05:51
if err != nil {
return false, errors.Wrap(err, "failed to get current height")
}
if cand.ExitBlock != 0 && cand.ExitBlock < curr {
Copy link
Member

Choose a reason for hiding this comment

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

we should not select it as active candidate if it exit during next epoch

Copy link
Member

@envestcc envestcc left a comment

Choose a reason for hiding this comment

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

btw, how about the ExitBlock influence the unstake of selfstake bucket?

@sonarqubecloud
Copy link

err: errors.New("no candidate exit queue"),
failureStatus: iotextypes.ReceiptStatus_ErrUnknown,
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I have double-checked the handling of handleError—it will be settled rather than skipped. Therefore, the "checks allowed after the hardfork" should be moved to Protocol.Validate().

return nil, nil, errCandNotExist
}
if cand.SelfStakeBucketIdx == candidateNoSelfStakeBucketIndex {
return nil, nil, ErrInvalidSelfStkIndex
Copy link
Member

@envestcc envestcc Jan 28, 2026

Choose a reason for hiding this comment

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

should wrap ErrInvalidSelfStkIndex with handleError{}

return nil, nil, errors.New("invalid operation")
}
if err != nil {
return nil, nil, err
Copy link
Member

Choose a reason for hiding this comment

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

could wrap the err with csmErrorToHandleError()

Comment on lines +237 to +241
if err := csm.candCenter.Upsert(cand); err != nil {
return err
}

return csm.putCandidate(cand)
Copy link
Member

Choose a reason for hiding this comment

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

could replace with csm.upsert(cand) instead

epochStartHeight := rp.GetEpochHeight(currentEpochNum)
if epochStartHeight == blkCtx.BlockHeight {
var last lastExitEpoch
if _, err := sr.State(&last, protocol.NamespaceOption(CandsMapNS), protocol.KeyOption(_lastExitEpoch)); err != nil {
Copy link
Member

@envestcc envestcc Jan 28, 2026

Choose a reason for hiding this comment

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

should handle the ErrStateNotExist error for the first time

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