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

"solana program set-upgrade-authority" uses SetAuthorityChecked instruction by default #29190

Merged
merged 6 commits into from
Dec 16, 2022

Conversation

0xripleys
Copy link
Contributor

@0xripleys 0xripleys commented Dec 9, 2022

Problem

Accompanying CLI change for #28424
(Original issue: #27932)

Summary of Changes

  • solana program set-upgrade-authority requires the new authority to sign by default. this behavior can be overwritten by the flag --no-sign-with-new-authority

Added a basic unit test and also did some manual testing, note that the feature gate for SetAuthorityChecked doesn't seem to have been enabled yet.

# provide new authority as pubkey only, the cli fails and complains about no signer
cargo run program set-upgrade-authority  GxSxDvJb7BEe32r93btUXgU41JEVYRr1YgHwZg94fHSk --new-upgrade-authority Gmwr4u7qyjtzbjwmk4XrWEWyn6aA6rWhAA6BUoFNdikG -u d

Error: Dynamic program error: missing signature for supplied pubkey: Gmwr4u7qyjtzbjwmk4XrWEWyn6aA6rWhAA6BUoFNdikG

# provide new authority as keypair, the transaction lands on devnet (but fails as expected since feature gate is disabled)
# https://solscan.io/tx/iKdbztjZXfQAhHa8eBPZfr5sMArVEdqRAFY14aNAvMogpY2q8Mtijd6BGMEUkyHgnceCCJmo76TXdxu3fdKSdup?cluster=devnet
cargo run program set-upgrade-authority  GxSxDvJb7BEe32r93btUXgU41JEVYRr1YgHwZg94fHSk --new-upgrade-authority test_1.json -u d
Error: Setting authority failed: Error processing Instruction 0: invalid instruction data

@0xripleys 0xripleys changed the title set-upgrade-authority uses checked instruction by default "solana program set-upgrade-authority" uses SetAuthorityChecked instruction by default Dec 9, 2022
@mergify mergify bot added the community Community contribution label Dec 9, 2022
@mergify mergify bot requested a review from a team December 9, 2022 23:26
@0xripleys 0xripleys marked this pull request as ready for review December 9, 2022 23:37
Copy link
Member

@jstarry jstarry left a comment

Choose a reason for hiding this comment

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

Looks great! Just a few nits

@@ -288,6 +293,13 @@ impl ProgramSubCommands for App<'_, '_> {
.conflicts_with("new_upgrade_authority")
.help("The program will not be upgradeable")
)
.arg(
Copy link
Member

Choose a reason for hiding this comment

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

The new_upgrade_authority arg above (can't comment directly) should be updated to match how the upgrade_authority arg is defined

.arg(
Arg::with_name("no_sign_with_new_authority")
.long("no-sign-with-new-authority")
.conflicts_with("final")
Copy link
Member

Choose a reason for hiding this comment

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

final already conflicts with new_upgrade_authority so I think it's more clear to define this as requiring new_upgrade_authority to be present.

.long("no-sign-with-new-authority")
.conflicts_with("final")
.takes_value(false)
.help("Set this flag if you don't want the new authority to sign the set-upgrade-authority transaction."),
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain more that the default behavior requires the new authority to sign to prevent mistakes in setting the upgrade authority? You can also warn that by opting out of this default behavior, users must be confident that they are setting the correct authority. Furthermore, if they intentionally are setting a new authority that can never sign, they should be instructed to use final instead.

@@ -288,6 +293,13 @@ impl ProgramSubCommands for App<'_, '_> {
.conflicts_with("new_upgrade_authority")
.help("The program will not be upgradeable")
)
.arg(
Arg::with_name("no_sign_with_new_authority")
.long("no-sign-with-new-authority")
Copy link
Member

Choose a reason for hiding this comment

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

How about skip-new-upgrade-authority-signer-check?

program_pubkey,
upgrade_authority_index: signer_info
.index_of(upgrade_authority_pubkey)
.unwrap(),
Copy link
Member

Choose a reason for hiding this comment

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

Can you use expect here and say "upgrade authority is missing from signers" or something to that effect? Ditto for new_upgrade_authority unwrap below

&tx,
config.commitment,
RpcSendTransactionConfig {
skip_preflight: true,
Copy link
Member

Choose a reason for hiding this comment

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

I see that other bpf loader transactions use true here but I don't see any reason for that. It'd be better to fail the transaction in preflight if the action isn't authorized or valid for some reason.

@jstarry jstarry added the CI Pull Request is ready to enter CI label Dec 12, 2022
@solana-grimes solana-grimes removed the CI Pull Request is ready to enter CI label Dec 12, 2022
jstarry
jstarry previously approved these changes Dec 12, 2022
@jstarry jstarry added the automerge Merge this Pull Request automatically once CI passes label Dec 12, 2022
@mergify mergify bot removed the automerge Merge this Pull Request automatically once CI passes label Dec 12, 2022
@mergify
Copy link
Contributor

mergify bot commented Dec 12, 2022

automerge label removed due to a CI failure

@0xripleys
Copy link
Contributor Author

@jstarry build failure seems unrelated to my PR? unclear.

error: unused attribute
--
  | --> runtime/src/bank.rs:14958:5
  | \|
  | 14958 \|     #[ignore] // this test only works when not using the write cache
  | \|     ^^^^^^^^^ help: remove this attribute
  | \|
  | = note: `-D unused-attributes` implied by `-D warnings`
  | note: attribute also specified here
  | --> runtime/src/bank.rs:14956:5
  | \|
  | 14956 \|     #[ignore]
  | \|     ^^^^^^^^^

error: could not compile `solana-runtime` due to previous error

@jstarry
Copy link
Member

jstarry commented Dec 13, 2022

@0xripleys please merge master into your branch, the fix is in master already

@mergify mergify bot dismissed jstarry’s stale review December 13, 2022 02:04

Pull request has been modified.

@0xripleys
Copy link
Contributor Author

done

@jstarry jstarry added the CI Pull Request is ready to enter CI label Dec 15, 2022
@solana-grimes solana-grimes removed the CI Pull Request is ready to enter CI label Dec 15, 2022
@jstarry jstarry added the automerge Merge this Pull Request automatically once CI passes label Dec 15, 2022
@mergify
Copy link
Contributor

mergify bot commented Dec 15, 2022

automerge label removed due to a CI failure

@mergify mergify bot removed the automerge Merge this Pull Request automatically once CI passes label Dec 15, 2022
@0xripleys
Copy link
Contributor Author

seemed like another flake to me so i just updated the branch. lmk if there's something else i should do

@jstarry jstarry added the CI Pull Request is ready to enter CI label Dec 16, 2022
@solana-grimes solana-grimes removed the CI Pull Request is ready to enter CI label Dec 16, 2022
@jstarry
Copy link
Member

jstarry commented Dec 16, 2022

Thanks, but most times there's no need to update the branch because most of the CI failures just require retrying an individual job. @yihau do you mind helping make sure this PR gets through CI? I don't have buildkite access at the moment

@jstarry jstarry added the automerge Merge this Pull Request automatically once CI passes label Dec 16, 2022
@yihau
Copy link
Member

yihau commented Dec 16, 2022

sure. will keep my eyes on this 👁️

@mergify mergify bot merged commit ec06cf7 into solana-labs:master Dec 16, 2022
nickfrosty pushed a commit to nickfrosty/solana that referenced this pull request Jan 4, 2023
…uction by default (solana-labs#29190)

* set-upgrade-authority uses checked instruction by default

* remove print statements

* PR fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants