Skip to content

Improve fan-out release_stake#133

Open
ismellike wants to merge 3 commits into
mainfrom
release_stake/fan-out
Open

Improve fan-out release_stake#133
ismellike wants to merge 3 commits into
mainfrom
release_stake/fan-out

Conversation

@ismellike
Copy link
Copy Markdown
Collaborator

closes #126

  • Add state cleanup in release_unbonded when locked is zero
  • Call release_unbonded after release_stake for the staker
  • Moves release_unbonded closer to release_stake fn for readability

- Add state cleanup in release_unbonded when locked is zero
- Call release_unbonded after release_stake for the staker
@ismellike ismellike requested review from gangov and ueco-jb January 2, 2025 16:17
State is now cleaned up in release_unbonded
Comment on lines -125 to +126
self.locked - self.max_lien,
self.locked - self.total_slashable,
self.locked.saturating_sub(self.max_lien),
self.locked.saturating_sub(self.total_slashable),
Copy link
Copy Markdown
Member

@ueco-jb ueco-jb Jan 3, 2025

Choose a reason for hiding this comment

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

What would be a valid case where there are less locked tokens then the max lien? The slashing scenario should be covered with total_slashable anyway, shouldn't it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not really any "valid" case. I changed this as an extra layer of security.

Copy link
Copy Markdown
Member

@ueco-jb ueco-jb left a comment

Choose a reason for hiding this comment

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

The code is legit, I'm only worried about that addition of saturating_sub.

@ismellike ismellike self-assigned this Jan 6, 2025
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.

Properly implement release stake on fan out contract

2 participants