Skip to content

Conversation

crypto-vincent
Copy link
Contributor

@crypto-vincent crypto-vincent commented Dec 19, 2024

Summary

This PR attempts to simplify and de-risk the flow of the undelegate and finalize IXs.

Details

Before this PR, the undelegate IX effectively was a superset of the finalize IX.
Now we expect the finalize IX to be called right before the undelegate (in order for it to succeed)

Additionally this PR simplifies the lamport settling code, while also clarifying the difference between the "undelegation_buffer" used only during the undelegate IX and the regular "buffer" used during the delegate IX.

Greptile Summary

This PR simplifies the delegation program's state management by removing commit-related functionality and consolidating lamports handling logic.

  • Removed commit state/record PDAs from undelegate instruction and processing, streamlining the undelegation flow
  • Added new undelegation_buffer_seeds_from_delegated_account macro and PDA function in src/pda.rs for clearer buffer management
  • Moved settle_lamports_balance function from utils into finalize.rs where it's primarily used
  • Removed lamports.rs utility module as part of consolidating lamports handling logic
  • Simplified CPI process for external program calls in undelegation

@crypto-vincent crypto-vincent self-assigned this Dec 19, 2024
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

6 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

@crypto-vincent crypto-vincent changed the title wip: undelegate/finalize simplification chore: undelegate/finalize simplification Dec 23, 2024
Copy link
Contributor

@GabrielePicco GabrielePicco left a comment

Choose a reason for hiding this comment

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

Left few comments, but LGTM overall! Thanks @crypto-vincent

@GabrielePicco GabrielePicco merged commit d442e13 into main Jan 2, 2025
3 checks passed
@GabrielePicco GabrielePicco deleted the vbrunet/2024_12_19-finalize branch January 2, 2025 10:23
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