-
Notifications
You must be signed in to change notification settings - Fork 19
feat: Impl RequestUndelegation and UndelegateWithRollbackAfterTimeout #183
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
bf93ac1
feat: Impl RequestUndelegation
snawaz 4d45bec
add CarryOverRequestedUndelegation
snawaz fc36480
address rabbit's feedback
snawaz 723ead0
fix lint issues
snawaz 4ac27be
address rabbit's feedback
snawaz 3cd51cc
Use 30min as timeout for validator
snawaz 2f367f4
add `df -h` to CI
snawaz 7cdfee4
rename CarryOverRequestedUndelegation -> UndelegateAfterRequestTimeout
snawaz 4c1531e
Use requires macros where possible
snawaz f87a7e5
replace parse_timeout_slots with RequestUndelegationArgs
snawaz 607a737
rename UndelegateAfterRequestTimeout -> UndelegateWithRollbackAfterTi…
snawaz 28bc3c1
revert unrelated changes regaring name changes
snawaz 9449732
Remove request undelegation timeout args; timeout not configurable now
snawaz 23fdbe8
remove wheels
snawaz 7f6c793
Require owner-program authorization for rollback
snawaz fb47f7c
remove is_writable checks
snawaz ba823bb
rename is_undelegatable to undelegatable and replace bool with enum U…
snawaz 0cca5a6
rename last_update_nonce -> last_commit_id
snawaz 3f0768b
make request_undelegation truly idempotent
snawaz 9301d09
rename undelegatable -> undelegation_requester
snawaz fb847a7
be compatible with borsh 0.10
snawaz ac0600f
increase timeout slots and remove stale test
snawaz ac3af3b
Allow UndelegationRequester::OwnerProgram to go through and fail iff …
snawaz db7ad48
remove else-block in process_request_undelegation()
snawaz 6284135
use config-driven undelegation request setup in tests
snawaz 212d344
require undelegation request accounts for owner-program requests in U…
snawaz 074a1a4
ensure rent_payer is same as the delegation rent payer
snawaz 2ab3a15
cleanup
snawaz 26d01c4
Shrink undelegation request state, removing fields present in metadat…
snawaz a5cb190
Require allow_undelegation = true for owner-requested commits
snawaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| use dlp::{ | ||
| discriminator::DlpDiscriminator, | ||
| pda::{ | ||
| delegation_metadata_pda_from_delegated_account, | ||
| delegation_record_pda_from_delegated_account, | ||
| undelegation_request_pda_from_delegated_account, | ||
| }, | ||
| total_size_budget, AccountSizeClass, DLP_PROGRAM_DATA_SIZE_CLASS, | ||
| }; | ||
| use solana_program::{ | ||
| instruction::{AccountMeta, Instruction}, | ||
| pubkey::Pubkey, | ||
| }; | ||
| use solana_sdk_ids::system_program; | ||
|
|
||
| use crate::compat::{Compatize, Modernize}; | ||
|
|
||
| /// Builds a request undelegation instruction. | ||
| /// | ||
| /// `delegation_rent_payer` must match the rent payer stored in the delegation | ||
| /// metadata PDA. | ||
| /// See [dlp::processor::process_request_undelegation] for docs. | ||
| pub fn request_undelegation( | ||
| delegation_rent_payer: Pubkey, | ||
| delegated_account: Pubkey, | ||
| owner_program: Pubkey, | ||
| ) -> Instruction { | ||
| let delegated_account_compat = delegated_account.compatize(); | ||
| let undelegation_request_pda = | ||
| undelegation_request_pda_from_delegated_account( | ||
| &delegated_account_compat, | ||
| ) | ||
| .modernize(); | ||
| let delegation_record_pda = | ||
| delegation_record_pda_from_delegated_account(&delegated_account_compat) | ||
| .modernize(); | ||
| let delegation_metadata_pda = | ||
| delegation_metadata_pda_from_delegated_account( | ||
| &delegated_account_compat, | ||
| ) | ||
| .modernize(); | ||
| Instruction { | ||
| program_id: dlp::id().modernize(), | ||
| accounts: vec![ | ||
| AccountMeta::new(delegation_rent_payer, true), | ||
| AccountMeta::new_readonly(delegated_account, true), | ||
| AccountMeta::new_readonly(owner_program, false), | ||
| AccountMeta::new(undelegation_request_pda, false), | ||
| AccountMeta::new_readonly(delegation_record_pda, false), | ||
| AccountMeta::new(delegation_metadata_pda, false), | ||
| AccountMeta::new_readonly(system_program::id(), false), | ||
| ], | ||
| data: DlpDiscriminator::RequestUndelegation.to_vec(), | ||
| } | ||
| } | ||
|
|
||
| /// | ||
| /// Returns accounts-data-size budget for request undelegation instruction. | ||
| /// | ||
| /// This value can be used with ComputeBudgetInstruction::SetLoadedAccountsDataSizeLimit | ||
| /// | ||
| pub fn request_undelegation_size_budget( | ||
| delegated_account: AccountSizeClass, | ||
| ) -> u32 { | ||
| total_size_budget(&[ | ||
| DLP_PROGRAM_DATA_SIZE_CLASS, | ||
| AccountSizeClass::Tiny, // delegation_rent_payer | ||
| delegated_account, // delegated_account | ||
| AccountSizeClass::Tiny, // owner_program | ||
| AccountSizeClass::Tiny, // undelegation_request_pda | ||
| AccountSizeClass::Tiny, // delegation_record_pda | ||
| AccountSizeClass::Tiny, // delegation_metadata_pda | ||
| AccountSizeClass::Tiny, // system_program | ||
| ]) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.