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: allow withdrawing without cleaning #502

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

guibescos
Copy link
Contributor

@guibescos guibescos commented Aug 27, 2024

We can withdraw without cleaning.
For that I just need to update validate to ignore Unlocked positions.
We also need to update slashing since governance exposure no longer counts unlocked positions, so we ignore unlocked positions when we adjust positions in slash_account

Copy link

vercel bot commented Aug 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 4:49pm
staking-devnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 4:49pm

@guibescos guibescos changed the title Feat/allow withdrawing without cleaning feat: allow withdrawing without cleaning Aug 27, 2024
if let Some(position) = self.read_position(i)? {
if position.target_with_parameters.get_target() == *target
&& position.get_current_position(current_epoch, unlocking_duration)?
!= PositionState::UNLOCKED
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignore unlocked here

@@ -1385,6 +1409,13 @@ pub mod tests {
{
return false;
}

if (target == &TargetWithParameters::Voting && curr_state == &PositionState::UNLOCKED)
Copy link
Contributor Author

@guibescos guibescos Aug 27, 2024

Choose a reason for hiding this comment

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

this tests that slashing ignores unlocked governance positions, the new behavior

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need brackets here?

@@ -81,6 +81,9 @@ describe("fills a stake account with positions", async () => {
) {
await provider.sendAndConfirm(transaction, [], {});
transaction = new Transaction();
transaction.instructions.push(
ComputeBudgetProgram.setComputeUnitLimit({ units: 1_400_000 })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this PR made me find this bug, previously we were just requesting compute units in the first tx

@@ -351,7 +371,9 @@ impl<'a> DynamicPositionArray<'a> {
let current_state =
position.get_current_position(current_epoch, unlocking_duration)?;

if position.target_with_parameters == TargetWithParameters::Voting {
if position.target_with_parameters == TargetWithParameters::Voting
&& (current_state != PositionState::UNLOCKED)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need brackets here ()?

@guibescos guibescos merged commit 4d400e4 into main Aug 28, 2024
5 of 7 checks passed
@guibescos guibescos deleted the feat/allow-withdrawing-without-cleaning branch August 28, 2024 16:48
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.

2 participants