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

Changing add stake operation #3196

Draft
wants to merge 3 commits into
base: albatross
Choose a base branch
from
Draft

Conversation

ii-cruz
Copy link
Member

@ii-cruz ii-cruz commented Dec 13, 2024

What's in this pull request?

  • Adds the Minimum stake to the add_stake operation. Add stake transactions have an intrinsic check for its value => min_stake and thus are rejected before they can break the invariant.
  • The idea is that this minimum prevents indefinite small value add_stake transactions from hindering the retirement or withdrawal.
  • add_stake assumes that the staker wants to have auto-staking as long as there is active stake. Once no active stake exists, the funds are added to whatever is the biggest balance between inactive and retired.
  • The idea is to prevent residual amounts of funds on the staking contract.
  • Adapts and adds more unit tests

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

@ii-cruz ii-cruz added the bug Something isn't working label Dec 13, 2024
@ii-cruz ii-cruz self-assigned this Dec 13, 2024
@ii-cruz ii-cruz force-pushed the iicruz/fix-staker-dos branch from e62eccb to 94256d9 Compare January 7, 2025 14:06
Copy link
Member

@paberr paberr left a comment

Choose a reason for hiding this comment

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

Looks good to me

// If we are delegating to a validator, we need to update it.
if let Some(validator_address) = &staker.delegation {
// Check that the delegation is still valid, i.e. the validator hasn't been deleted.
store.expect_validator(validator_address)?;
Copy link
Member

Choose a reason for hiding this comment

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

There might be a problem with the ordering. We usually want to do changes only after all potentially failing conditions are checked.
In practice, I don't think it is a problem, as all previous changes are in the staker and that one needs to be put explicitly back.

@sisou
Copy link
Member

sisou commented Mar 30, 2025

When add_stake adds to the inactive balance (when there's no active balance anymore and the inactive one is the biggest), I assume it doesn't reset the inactiveFrom block number?

@paberr
Copy link
Member

paberr commented Mar 30, 2025

It doesn't reset it.

Also, while discussing with @ii-cruz , one thing that is missing is a version gate for the upgrade.
The new behavior should only be active when we have a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants