-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
token-2022: [OS-SPL-ADV-00] Enable and fix account ordering on confidential transfer with split proofs #5931
token-2022: [OS-SPL-ADV-00] Enable and fix account ordering on confidential transfer with split proofs #5931
Conversation
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.
The core logic looks good! Just some suggestions to make the tests better
let close_split_context_state_accounts = CloseSplitContextStateAccounts { | ||
lamport_destination: &alice.pubkey(), | ||
zk_token_proof_program: &zk_token_proof_program::id(), | ||
}; |
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.
Can you add checks at the end to make sure that the context accounts are cleaned up and alice is credited?
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.
Yes that is good point. I added test to check for AccountNotFound
, but let me know if there is a better way to test it.
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.
Those checks are great! Can you also check that the lamports were properly added to the destination?
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.
Sorry I missed it! I followed how it is done in close_account.rs
and checked that the lamport destination has positive number of lamports.
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.
Great!
let close_split_context_state_accounts = CloseSplitContextStateAccounts { | ||
lamport_destination: &alice.pubkey(), | ||
zk_token_proof_program: &zk_token_proof_program::id(), | ||
}; |
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.
Same here, please add a check that it worked
Problem
The accounts that are required for a confidential transfer with split proof are as follows:
However, the actual instruction processor assumes that
7. [signer] The source account owner
is assumed to be last in the order.This issue with the ordering of the accounts was left undetected because there were no tests for auto-close of context accounts. There were no tests for auto-close because auto-close was not enabled.
Solution