Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

adds system instruction to upgrade legacy nonce versions (backport #25789) #25890

Merged
merged 3 commits into from
Jun 10, 2022

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jun 10, 2022

This is an automatic backport of pull request #25789 done by Mergify.
Cherry-pick of b419031 has failed:

On branch mergify/bp/v1.9/pr-25789
Your branch is up to date with 'origin/v1.9'.

You are currently cherry-picking commit b4190319a.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   cli/src/cli.rs
	modified:   cli/src/nonce.rs
	modified:   docs/src/developing/clients/javascript-api.md
	modified:   sdk/program/src/nonce/state/mod.rs
	modified:   transaction-status/src/parse_system.rs

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   runtime/src/system_instruction_processor.rs
	both modified:   sdk/program/src/system_instruction.rs
	both modified:   web3.js/src/system-program.ts

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

…#25789)

#25788
permanently disables durable transactions with legacy nonce versions
which are within chain blockhash domain.

This commit adds a new system instruction for a one-time idempotent
upgrade of legacy nonce accounts in order to bump them out of chain
blockhash domain.

(cherry picked from commit b419031)

# Conflicts:
#	runtime/src/system_instruction_processor.rs
#	sdk/program/src/system_instruction.rs
#	web3.js/src/system-program.ts
@mergify mergify bot added the conflicts label Jun 10, 2022
@mergify mergify bot added automerge Merge this Pull Request automatically once CI passes and removed automerge Merge this Pull Request automatically once CI passes labels Jun 10, 2022
@mergify
Copy link
Contributor Author

mergify bot commented Jun 10, 2022

automerge label removed due to a CI failure

@behzadnouri behzadnouri force-pushed the mergify/bp/v1.9/pr-25789 branch from 6f50a58 to 908488f Compare June 10, 2022 00:19
@mergify mergify bot added automerge Merge this Pull Request automatically once CI passes and removed automerge Merge this Pull Request automatically once CI passes labels Jun 10, 2022
@mergify
Copy link
Contributor Author

mergify bot commented Jun 10, 2022

automerge label removed due to a CI failure

@mergify mergify bot added the automerge Merge this Pull Request automatically once CI passes label Jun 10, 2022
@mergify
Copy link
Contributor Author

mergify bot commented Jun 10, 2022

automerge label removed due to a CI failure

@mergify mergify bot removed the automerge Merge this Pull Request automatically once CI passes label Jun 10, 2022
@behzadnouri behzadnouri force-pushed the mergify/bp/v1.9/pr-25789 branch from af426df to d72a228 Compare June 10, 2022 12:03
@mergify mergify bot added automerge Merge this Pull Request automatically once CI passes and removed automerge Merge this Pull Request automatically once CI passes labels Jun 10, 2022
@mergify
Copy link
Contributor Author

mergify bot commented Jun 10, 2022

automerge label removed due to a CI failure

@behzadnouri behzadnouri force-pushed the mergify/bp/v1.9/pr-25789 branch from d72a228 to 79d0e39 Compare June 10, 2022 12:06
@mergify mergify bot added the automerge Merge this Pull Request automatically once CI passes label Jun 10, 2022
@mergify
Copy link
Contributor Author

mergify bot commented Jun 10, 2022

automerge label removed due to a CI failure

@mergify mergify bot added automerge Merge this Pull Request automatically once CI passes and removed automerge Merge this Pull Request automatically once CI passes labels Jun 10, 2022
Comment on lines +423 to +442
SystemInstruction::UpgradeNonceAccount => {
let separate_nonce_from_blockhash = invoke_context
.feature_set
.is_active(&feature_set::separate_nonce_from_blockhash::id());
if !separate_nonce_from_blockhash {
return Err(InstructionError::InvalidInstructionData);
}
let nonce_account = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
if !system_program::check_id(&nonce_account.owner()?) {
return Err(InstructionError::InvalidAccountOwner);
}
if !nonce_account.is_writable() {
return Err(InstructionError::InvalidArgument);
}
let nonce_versions: nonce::state::Versions = nonce_account.state()?;
match nonce_versions.upgrade() {
None => Err(InstructionError::InvalidArgument),
Some(nonce_versions) => nonce_account.set_state(&nonce_versions),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@Lichtso @jackcmay Backporting #25789 to v1.9 was not straightforward given the KeyedAccount changes.
Would you please double check if this code is precisely equivalent to master:
https://github.com/solana-labs/solana/blob/98176fad7/runtime/src/system_instruction_processor.rs#L486-L507

e.g. that failure conditions and resulting kinds of error has not changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

Choose a reason for hiding this comment

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

There is only one instruction account so at least there can be no borrow collision by account aliasing. The only tricky part here is the index of keyed_account_at_index(keyed_accounts, first_instruction_account)?
vs instruction_context.try_borrow_instruction_account(transaction_context, 0)? and that is correct.

@behzadnouri behzadnouri merged commit 53c4b80 into v1.9 Jun 10, 2022
@behzadnouri behzadnouri deleted the mergify/bp/v1.9/pr-25789 branch June 10, 2022 17:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes conflicts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants