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

[Go/No-Go] ARC-0037 - Introduce withdrawal address for stakers #2385

Merged
merged 13 commits into from
Mar 15, 2024

Conversation

raychu86
Copy link
Contributor

@raychu86 raychu86 commented Mar 8, 2024

Motivation

This PR implements withdrawal addresses that staker can use claim their unbonded credits in accordance to ARC-0037.

Validators and delegators now need to specify an additional withdrawal_address when they call bond_public. While they are bonded this withdrawal address can not be changed, which is important because a core reason for this separation of addresses is so that the validator funds are secure even if their "hot" keys are compromised. This withdraw address will receive the credits that are unbonded by the staker in claim_unbond_public.

This is done with the following changes:

  • Added a new withdraw mapping

    • Key: staker address
    • Value: withdrawal address
  • Updated bond_public:

    • Add additional withdrawal address as input
    • Check if withdrawal_address exists in the withdraw mapping:
      • true -> Check that the withdrawal address is consistent with the one in the mapping (if it already exists)
      • false -> Update the withdraw mapping.
  • Updated claim_unbond_public:

    • This is still called by the staker.
    • Withdraw the balance to the withdrawal_address
    • Remove the withdraw address if the bonded entry no longer exists for the staker
  • UpdatedBondedBalances:

    • Add a withdrawal address field
    • Update atomic_pre_ratify to process the withdrawal addresses
    • Allows specifying withdrawal addresses in the genesis block

Test Plan

Tests have been added to ensure that:

  • The withdrawal address receives the claimed unbonded credits.
  • The withdrawal address can't be changed unless the staker is completely unbonded.
  • Stakers can't call bond_public with a different withdrawal address that was was set in the withdraw mapping.
  • The processing of Ratify::Genesis is correct with the new withdrawal addresses.

Additional Notes

  • A staker must be completely unbonded before they are able to change their withdrawal address
  • Withdrawal addresses can't be changed once initial stake is bonded

Related PRs

The sister PR can be found here - https://github.com/AleoHQ/snarkOS/pull/3165

@raychu86 raychu86 requested review from ljedrz, d0cd and vicsn March 8, 2024 02:54
@raychu86 raychu86 changed the title [Coinbase Go/No-Go] ARC-037 - Introduce withdrawal address for stakers [Coinbase Go/No-Go] ARC-0037 - Introduce withdrawal address for stakers Mar 8, 2024
Copy link
Collaborator

@ljedrz ljedrz left a comment

Choose a reason for hiding this comment

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

LGTM so far 👍.

Copy link
Contributor

@vicsn vicsn left a comment

Choose a reason for hiding this comment

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

Just some nits

synthesizer/program/src/resources/credits.aleo Outdated Show resolved Hide resolved
Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com>
@raychu86 raychu86 marked this pull request as ready for review March 15, 2024 20:51
@howardwu howardwu merged commit c0441b2 into mainnet-staging Mar 15, 2024
78 checks passed
@howardwu howardwu deleted the feat/withdrawal-address branch March 15, 2024 22:32
@AleoNet AleoNet deleted a comment from jony0406 Mar 20, 2024
@AleoNet AleoNet deleted a comment from Tuneezi Mar 20, 2024
@AleoNet AleoNet deleted a comment from KEJANOW Mar 20, 2024
@AleoNet AleoNet locked as spam and limited conversation to collaborators Mar 20, 2024
@collinc97 collinc97 changed the title [Coinbase Go/No-Go] ARC-0037 - Introduce withdrawal address for stakers [Go/No-Go] ARC-0037 - Introduce withdrawal address for stakers Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants