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

feat(dAppStaking): Move actions mechanisms for bonus rewards #1402

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ipapandinas
Copy link
Contributor

@ipapandinas ipapandinas commented Jan 3, 2025

⚠️ A fix for the code coverage job is proposed here: #1408

Pull Request Summary

This PR introduces enhancements to the bonus reward eligibility mechanism and implements robust handling for stake movement, particularly during the build&earn subperiod.

Bonus Reward Eligibility

The previously used loyal_staker flag is replaced with and decoded into a bonus_status enum:

enum BonusStatus {
    /// Bonus rewards are forfeited.
    BonusForfeited,
    /// Bonus rewards are preserved with a value which is the number of remaining 'safe moves' allowed in the ongoing B&E subperiod.
    SafeMovesRemaining(u8),
}

This update:

  • Introduces tracking of bonus status to ensure eligibility based on the number of allowed move actions (MaxBonusMovesPerPeriod).
  • Enforces forfeiture of bonus eligibility if move actions exceed the allowable threshold.

Move action

A move action is defined as either:

  • Partial unstaking that reduces the 'voting stake'.
  • Transfers of 'voting stake' between contracts.

If a move action is performed during the build&earn subperiod, the bonus_status attached to the relevant singular staking info is reduced until it is forfeited.

Stake Movement Enhancements

A new move_stake extrinsic is implemented. It is similar to an 'unstake' followed by two 'stakes' for each subperiod. Existing safeguards are extended additional checks to:

  • Ensure the source and destination contracts are different.
  • Validate the amount to be moved.

When moving stake from unregistered contracts, the bonus status is always preserved.

Migration

A multi-block migration is proposed to convert all existing loyal_staker flags to their respective BonusStatus variants:

  • BonusStatus::SafeMovesRemaining(0) for true.
  • BonusStatus::BonusForfeited for false.

Closes #1379

Check list

  • added or updated unit tests
  • updated Astar official documentation
  • added OnRuntimeUpgrade hook for precompile revert code registration
  • added benchmarks & weights for any modified runtime logics.
  • add E2E tests
  • prepare follow-up issue for Astar Portal frontend & forum post

@ipapandinas ipapandinas added enhancement New feature or request dapps-staking Dapps Staking labels Jan 3, 2025
@ipapandinas ipapandinas marked this pull request as ready for review January 13, 2025 18:19
@ipapandinas
Copy link
Contributor Author

/bench shibuya-dev pallet_dapp_staking

Copy link

Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/12753557202.
Please wait for a while.
Branch: feat/move_bonus_dapp_staking
SHA: d94b330

@ipapandinas ipapandinas changed the title WIP - feat(dAppStaking): Move actions mechanisms for bonus rewards feat(dAppStaking): Move actions mechanisms for bonus rewards Jan 13, 2025
Copy link

Benchmarks have been finished.
You can download artifacts if exists https://github.com/AstarNetwork/Astar/actions/runs/12753557202.

@ipapandinas ipapandinas added shibuya related to shibuya runtime This PR/Issue is related to the topic “runtime”. and removed shibuya related to shibuya labels Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dapps-staking Dapps Staking enhancement New feature or request runtime This PR/Issue is related to the topic “runtime”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dAppStaking - Bonus rewards mechanism rework
1 participant