Skip to content
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

clap-utils: Forbid multiple values for --signer #34482

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

joncinque
Copy link
Contributor

@joncinque joncinque commented Dec 15, 2023

Problem

The --signer arg doesn't exactly work as expected because it allows for multiple values. This means clap allows for someone to specify: --signer <PUBKEY>=<SIG> <PUBKEY>=<SIG>

This can be useful in some situations, but it's inconsistent with the documentation.

For example, https://docs.solana.com/offline-signing#submitting-offline-signed-transactions-to-the-network mentions to specify "--signer BASE58_PUBKEY=BASE58_SIGNATURE, one for each offline signer.", and the examples use multiple occurrences of --signer.

Also, the example command of:

solana@online$ solana transfer --blockhash 5Tx8F3jgSHx21CbtjwmdaKPLM5tWmreWAnPrbqHomSJF \
    --signer FhtzLVsmcV7S5XqGD79ErgoseCLhZYmEZnz9kQg1Rp7j=4vC38p4bz7XyiXrk6HtaooUqwxTWKocf45cstASGtmrD398biNJnmTcUCVEojE7wVQvgdYbjHJqRFZPpzfCQpmUN
    recipient-keypair.json 1

Does not work currently because --signer tries to parse multiple values. This means it tries to also parse recipient-keypair.json and 1. Practically, this means that --signer must always come last in the command, which contradicts the docs.

Side note: for your reading pleasure here are the docs for multiple_values https://docs.rs/clap/3.2.23/clap/builder/struct.Arg.html#method.multiple_values in clap v3 and for multiple in clap v2 https://docs.rs/clap/2.34.0/clap/struct.Arg.html#method.multiple

Summary of Changes

Cap the number of values to 1 (clap v2) and do not allow multiple values per occurrence (clap v3). I'm not sure if this breaks any existing users, so I've put in a changelog entry.

Fixes #34453

@joncinque joncinque requested a review from t-nelson December 15, 2023 15:22
Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

clap-v3-utils/src/offline.rs Show resolved Hide resolved
Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (47b4075) 81.8% compared to head (0f8756b) 81.8%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #34482   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         824      824           
  Lines      222486   222486           
=======================================
+ Hits       182090   182104   +14     
+ Misses      40396    40382   -14     

t-nelson
t-nelson previously approved these changes Dec 17, 2023
Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh thought i approved with the other review... now :shipit:

@joncinque
Copy link
Contributor Author

Sorry, had a merge conflict to resolve, can you approve again please?

t-nelson
t-nelson previously approved these changes Dec 22, 2023
@joncinque
Copy link
Contributor Author

Sorry, can I get one last approval here? I got scooped on the changelog again

@joncinque joncinque merged commit 08082df into solana-labs:master Jan 5, 2024
35 checks passed
@joncinque joncinque deleted the numvalues branch January 5, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Solana CLI Offline Transactions not working
2 participants