CLI: Support offline and nonced stake subcommands#7831
Conversation
|
lgtm |
| stake_account_pubkey, | ||
| new_authorized_pubkey: nonced_authority_pubkey, | ||
| stake_authorize: StakeAuthorize::Staker, | ||
| // We need to be able to specify the authority by pubkey/sig pair here |
There was a problem hiding this comment.
@rob-solana I'm thinking the best option here is to build a wrapper implementing KeypairUtil that resolves the command line arg to either a Keypair, or maps from a supplied Pubkey supplied by --*-authority to a (Pubkey, Signature) tuple supplied with the --signer arg. sign_message() would then do a normal signing in the Keypair case and in the (Pubkey, Signature) case verify+return the signature. Caveat being that sign_message() is currently infallible, so would probably need to panic in case of verify failing.
Something like
enum SigningAuthority {
Online(Keypair),
Offline(Pubkey, Signature),
}
impl KeypairUtil for SigningAuthority {
...
fn sign_message(&self, msg: &[u8]) {
match self {
SigningAuthority::Online(keypair) => keypair.sign_message(msg),
SigningAuthority::Offline(pubkey, signature) => {
if signature.verify(pubkey, msg) {
signature
} else {
panic!("Signature verification failed!");
}
}
}
}
}
There was a problem hiding this comment.
Only thing: last time I tried to make a slice of KeypairUtils from 2 instances of different types, I failed (Rust newb).
There was a problem hiding this comment.
Fun! I'll definitely be prototyping outside the codebase. It's food for another PR in any case
There was a problem hiding this comment.
Only thing: last time I tried to make a slice of KeypairUtils from 2 instances of different types, I failed (Rust newb).
Checkout #8318 😉
Codecov Report
@@ Coverage Diff @@
## master #7831 +/- ##
========================================
+ Coverage 81.9% 81.9% +<.1%
========================================
Files 242 239 -3
Lines 51401 51569 +168
========================================
+ Hits 42114 42253 +139
- Misses 9287 9316 +29 |
|
Anything holding us up here? |
* Support durable nonce for staker-authorize-* * CLI: Factor out sign-only reply parsing to helper * Support offline signing for staker-authorize-* (cherry picked from commit 0de35fd)
* Support durable nonce for staker-authorize-* * CLI: Factor out sign-only reply parsing to helper * Support offline signing for staker-authorize-* (cherry picked from commit 0de35fd)
Problem
CLI's stake management subcommands do not support offline or nonced transactions
Summary of Changes
Plumb offline signing and durable nonces throughout