-
Notifications
You must be signed in to change notification settings - Fork 2
[LST-343] StartRebalance and EndRebalance instructions #89
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
[LST-343] StartRebalance and EndRebalance instructions #89
Conversation
billythedummy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of clutter
billythedummy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think theres also some confusion between Pubkey and [u8; 32]
Pubkeyis just a simple newtype of[u8; 32]and you can always convert from one to the other easily- we're only using
Pubkeybecause the solana dev deps (mollusk-svm,solana-instructionetc) use it. Otherwise, just stick with[u8; 32]
| // Filter out executable accounts (programs and sysvars) which are not | ||
| // relevant for rent-exemption checks - only user accounts matter | ||
| let mut result_for_check = result.clone(); | ||
| result_for_check | ||
| .resulting_accounts | ||
| .retain(|(_, acc)| !acc.executable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which program account is not rent-exempt tho?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the filter i would get this #89 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#89 (comment) seems like it affects the balanced check, not the rent exemption check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Token Program starts with 934M lamports from fixtures in accs_bef, but after Mollusk executes the tx it appears in resulting_accounts with 0 lamports (token program account is reset in tests here? is that expected?). so we need to filter it out here before we do rent-exempt check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no this isnt rly expected lol wtf, guess we can check some other simpler tests that involve the token program to see whats going on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesnt happen in withdraw_protocol_fees_test_correct_basic. Im guessing theres somewhere where you've mutated bef or aft and youre not checking the actual input/output to svm.process_instruction_(chain). Or maybe mollusk is weird and only outputs the accounts that the last instruction involves in InstructionResult
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resulting_accounts: The resulting accounts after the last instruction.
https://docs.rs/mollusk-svm/latest/mollusk_svm/struct.Mollusk.html#method.process_instruction_chain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i thought so too but if you look at the impl for process_instruction (_chain just calls this in a loop): the resulting accounts is always whatever was input to the function, not just the ones that are involved in the instruction (theres no filter in sight): https://github.com/anza-xyz/mollusk/blob/8029da5304e78fcf1d4396515f1e43422ad550a9/harness/src/lib.rs#L776-L806
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this is happening on the second token transfer instruction
billythedummy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets just do the <acc>_checked functions and then do other cleanups in subsequent PRs
| // Filter out executable accounts (programs and sysvars) which are not | ||
| // relevant for rent-exemption checks - only user accounts matter | ||
| let mut result_for_check = result.clone(); | ||
| result_for_check | ||
| .resulting_accounts | ||
| .retain(|(_, acc)| !acc.executable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no this isnt rly expected lol wtf, guess we can check some other simpler tests that involve the token program to see whats going on
|
|
||
| const _ACC_DATA_ALIGN: usize = 8; | ||
|
|
||
| const _POOL_STATE_ALIGN_CHECK: () = assert!(core::mem::align_of::<PoolState>() <= _ACC_DATA_ALIGN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whyd you delete this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy little accident
This PR contains the
StartRebalanceandEndRebalanceinstructions reimplementation with jiminy.