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

make node operator stake weighted #398

Merged
merged 15 commits into from
May 20, 2024
Merged

make node operator stake weighted #398

merged 15 commits into from
May 20, 2024

Conversation

ianhe8x
Copy link
Contributor

@ianhe8x ianhe8x commented Apr 14, 2024

Allow node operators stake to have higher weight than delegators

new storage

  • _runnerStakeWeight: the global node operator's stake weight, it must > 1e6 otherwise will be ignored.
  • _previousRunnerStakeWeights: record the previous node operator's stake weight so even though node operator doesn't change their stake, in collectAndDistributeEraRewards() we will still apply the _runnerStakeWeight for him

Changes

  • when apply stake changes for node operator, use _runnerStakeWeight to calculate weight
  • when collectAndDistributeEraRewards, apply _runnerStakeWeight if it wasn't applied or changed.
  • _updateTotalStakingAmount() will also patch with _runnerStakeWeight, so totalStakingAmount won't be overwritten by delegation changes.

TODO:

  • add more tests

@ianhe8x ianhe8x requested review from mzxyz and nz-neooo April 14, 2024 22:36
@ianhe8x ianhe8x force-pushed the runner-weighted-stake branch from 79806e8 to de97609 Compare April 23, 2024 22:54
@ianhe8x ianhe8x marked this pull request as ready for review May 1, 2024 04:18
@ianhe8x ianhe8x merged commit 2c008e7 into develop May 20, 2024
2 checks passed
@ianhe8x ianhe8x deleted the runner-weighted-stake branch May 20, 2024 08:00
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.

1 participant