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

Continuous Staking 3 - Restake primary network stakers by default #1494

Open
wants to merge 142 commits into
base: stakerTxs_drop_start_time
Choose a base branch
from

Conversation

abi87
Copy link
Contributor

@abi87 abi87 commented May 11, 2023

Why this should be merged

Simplify staking operations, specifically for primary network validators and delegators which intend to stake for long time

How this works

Post Continuous Staking fork activation:

  1. Modified state.Staker invariants. NextTime is not anymore equal to StartTime or EndTime. Instead it will mark the chain time when a staker should be evaluated for rewards.
  2. Added new txs to for continuous staking. Keep other txs processing unchanged.
  3. Changed reward logic for permissionless validators. Post Continuous Staking Fork validators are not removed from stakers set, nor their stake is returned. Instead reward utxos are generated and made available to staker.
  4. Changed reward logic for permissionless delegators
    5.Added stopStakerTx to explicitly stop staking. Duly handled delegators/subnet validators termination when their validator is requested to stop.

Open Issues

  1. state.rewardUTXOsCache does not seems currently fit to hold multiple rewardUTXOs accrued across different reward cycle. Fix it
  2. We shift stakers when reward time come. Current priority is that delegators are rewarded before validator, which implies that delegator is currently shifted first, so outliving its validator for a few block. This an invariant breach that seems benign but must be solved. Simpler solution seems to be to introduce ad-hoc priorities for shifting vs stopping stakers, to be conveniently ordered.

How this was tested

  • UTs for AddContinuousValidatorTx verification
  • UTs for AddContinuousDelegatorTx verification
  • UTs for Stop continuous validator
  • UTs for Stop continuous delegator
  • UTs for shift continuous validator
  • UTs for shift continuous delegator
  • UTs for reward continuous validator
  • UTs for reward continuous delegator
  • UTs for restake reward fraction
  • UTs for fork activation
  • UTs to verify stakers are correctly rebuilt from db (including shortened period ones)
  • Property tests to check no delegator outlives its validator

TODOs

Add e2e tests with ginkgo

abi87 added 30 commits April 20, 2023 16:44
@abi87 abi87 added the vm This involves virtual machines label Aug 16, 2023

res := int(validatorPeriod) / int(delegatorPeriod)
rem := validatorPeriod % delegatorPeriod
if rem != 0 || (res&(res-1)) != 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

powers of two are such that (res&(res-1)) == 0

@github-actions
Copy link

github-actions bot commented Oct 8, 2023

This PR has become stale because it has been open for 30 days with no activity. Adding the lifecycle/frozen label will cause this PR to ignore lifecycle events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
continuous staking lifecycle/stale vm This involves virtual machines
Projects
Status: Backlog 🗄️
Status: In Progress 🏗
Development

Successfully merging this pull request may close these issues.

Continuous Staking
1 participant