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

Update stake, staking_contract, delegation_pool to allow for shorter lockup duration on Aptos #16082

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

movekevin
Copy link
Contributor

Description

Here's the implementation for the lockup duration reduction. This change is a lot more complex than expected despite intentions to keep it simple (just lock and vote!). This is due to:

  1. Separation of voter and owner in staking contract. If the voter is separate from the staker, voter cannot extend the lockup. Current implementation simplifies this by having two separate functions - update_lockup to be called by owner to extend the lockup for voter to vote in a separate tx, and extend_lockup_and_vote for when staker and voter are the same account and can extend lockup and vote at the same time
  2. Delegation of voting power from multiple accounts to one account in delegation pools. This makes applying an extra lockup (for when the delegation pool's lockup is less than voting duration) harder as it gets fuzzy which voting power among the one they have (themselves + delegation from others) the lock would apply on. I applied as much simplification as I can think of here and restrict the new lock_and_vote function to only allow delegators who have not delegated their votes to anyone else and who have not received voting from anyone to call.
  3. In delegation pools, voting power uses both active (including pending_active) and pending_inactive (on the way out) stake. This means the extra lockup has to be applied on the withdraw function and not unlock as pending_inactive stake (now inactive) might have been used to vote on some proposals.

How Has This Been Tested?

Unit tests

Key Areas to Review

Everything

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Copy link

trunk-io bot commented Mar 8, 2025

⏱️ 10m total CI duration on this PR
Job Cumulative Duration Recent Runs
check-dynamic-deps 4m 🟩🟩
rust-cargo-deny 3m 🟩🟩
semgrep/ci 1m 🟩🟩
general-lints 54s 🟩🟩
file_change_determinator 26s 🟩🟩
permission-check 6s 🟩🟩
permission-check 6s 🟩🟩

🚨 1 job on the last run was significantly faster/slower than expected

Job Duration vs 7d avg Delta
check-dynamic-deps 1m 2m -47%

settingsfeedbackdocs ⋅ learn more about trunk.io

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