-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Implement VoteInstruction::AuthorizeWithSeed
& VoteInstruction::AuthorizeWithSeedChecked
#25928
Implement VoteInstruction::AuthorizeWithSeed
& VoteInstruction::AuthorizeWithSeedChecked
#25928
Conversation
@steveluscher , looks like clippy has some opinions about some unnecessary |
Me: furiously Googles why PR Updated! |
Try |
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.
Looking good! Just a handful of suggestions, primarily around readability.
Can you please add an implementation for VoteInstruction::AuthorizeCheckedWithSeed
? 🙏 🙏 It should look like VoteInstruction::AuthorizeWithSeed
, plus checking that the new authority is a signer, as per
solana/programs/vote/src/vote_processor.rs
Line 137 in bc3fb7c
if !instruction_context.is_signer(first_instruction_account + 3)? { |
Alright! Everything except for |
Let's add it to this one. I'll review the current set of commits in the meantime! |
VoteInstruction::AuthorizeWithSeed
VoteInstruction::AuthorizeWithSeed
& VoteInstruction::AuthorizeWithSeedChecked
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.
Current set of commits look great! Nothing more from me on those
Codecov Report
@@ Coverage Diff @@
## master #25928 +/- ##
=========================================
- Coverage 82.1% 82.0% -0.1%
=========================================
Files 628 631 +3
Lines 171471 173158 +1687
=========================================
+ Hits 140878 142133 +1255
- Misses 30593 31025 +432 |
…ity if it's a derived key for which you control the base key
…hose authorities are derived keys
…eInstruction::AuthorizeWithSeed`
…zeWithSeed` processor
…o transaction status parser
…ity (while checking that the new authority has signed) if it's a derived key for which you control the base key
…Seed` to transaction status parser
…eInstruction::AuthorizeCheckedWithSeed`
Pull request has been modified.
Alright! Sprinkled in |
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.
Nice, lgtm. Thanks, @steveluscher !
…thorizeWithSeedChecked` (#25928) * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` * [vote_authorize_with_seed] You can now update a vote account's authority if it's a derived key for which you control the base key * [vote_authorize_with_seed] Add test helper to create a vote account whose authorities are derived keys * [vote_authorize_with_seed] Write tests to assert the behavior of `VoteInstruction::AuthorizeWithSeed` * [vote_authorize_with_seed] Feature gate the `VoteInstruction::AuthorizeWithSeed` processor * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` to transaction status parser * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` to docs * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeCheckedWithSeed` * [vote_authorize_with_seed] You can now update a vote account's authority (while checking that the new authority has signed) if it's a derived key for which you control the base key * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeCheckedWithSeed` to transaction status parser * [vote_authorize_with_seed] Write tests to assert the behavior of `VoteInstruction::AuthorizeCheckedWithSeed` (cherry picked from commit 45d11f3) # Conflicts: # programs/vote/src/vote_processor.rs
…thorizeWithSeedChecked` (backport #25928) (#25956) * Implement `VoteInstruction::AuthorizeWithSeed` & `VoteInstruction::AuthorizeWithSeedChecked` (#25928) * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` * [vote_authorize_with_seed] You can now update a vote account's authority if it's a derived key for which you control the base key * [vote_authorize_with_seed] Add test helper to create a vote account whose authorities are derived keys * [vote_authorize_with_seed] Write tests to assert the behavior of `VoteInstruction::AuthorizeWithSeed` * [vote_authorize_with_seed] Feature gate the `VoteInstruction::AuthorizeWithSeed` processor * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` to transaction status parser * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` to docs * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeCheckedWithSeed` * [vote_authorize_with_seed] You can now update a vote account's authority (while checking that the new authority has signed) if it's a derived key for which you control the base key * [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeCheckedWithSeed` to transaction status parser * [vote_authorize_with_seed] Write tests to assert the behavior of `VoteInstruction::AuthorizeCheckedWithSeed` (cherry picked from commit 45d11f3) # Conflicts: # programs/vote/src/vote_processor.rs * Fix conflicts and accommodate v1.10 api Co-authored-by: Steven Luscher <[email protected]> Co-authored-by: Tyera Eulberg <[email protected]>
Background
Given a base key, a seed (arbitrary data, like the string
"VOTER_SEED"
) and the address of a program, you can create a derived key for that program. This key can never sign for anything, because it has no associated secret key.The vote program lets you authorize an account to be the ‘withdrawer.’
Problem
There's nothing stopping you from authorizing a derived key to be the ‘withdrawer’ authority on a vote account, but if you do, you'll never be able to withdraw funds, since nobody can sign for the derived key.
Summary of Changes
AuthorizeWithSeed
instruction/implementation/tests to the vote program. Now someone who can sign for the base key of a derived key can at least change such a ‘withdrawer’ authority to something else.AuthorizeWithSeedChecked
instruction/implementation/tests to the vote program. Does the same asAuthorizeWithSeed
except that it also checks that the base key of the new authority has signed the transaction.AuthorizeWithSeed
command to web3.js libraryAuthorizeWithSeedChecked
command to web3.js libraryFixes #25860.
Feature Gate Issue: #25930.