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

Move nonce into system program #7645

Merged
merged 12 commits into from
Jan 4, 2020

Conversation

t-nelson
Copy link
Contributor

Problem

The durable nonce feature being its own program adds complexity leading to issues like #7443 and complicating their resolution.

Summary of Changes

This will probably be easier to review by commit...

  1. Preemptive renaming where possible (First commit. Purely cosmetic)
  2. Move durable nonce to system program (Second commit. Bulk of change set. Relocations and deletions only. Logically inert)
  3. Add checks for account/instruction compatibility (Commits 3-4)
  4. Add checks to maintain nonce rent-exempt status (Commits 5-7)

Toward #7443

@t-nelson t-nelson requested a review from rob-solana December 31, 2019 04:03
@mvines mvines added the v0.22 label Dec 31, 2019
@codecov
Copy link

codecov bot commented Dec 31, 2019

Codecov Report

Merging #7645 into master will increase coverage by <.1%.
The diff coverage is 98.1%.

@@           Coverage Diff            @@
##           master   #7645     +/-   ##
========================================
+ Coverage    81.6%   81.7%   +<.1%     
========================================
  Files         245     243      -2     
  Lines       50230   50383    +153     
========================================
+ Hits        41021   41176    +155     
+ Misses       9209    9207      -2

@@ -621,6 +771,31 @@ mod tests {
);
}

#[test]
fn test_assign_from_nonce_account_fail() {
Copy link
Contributor

Choose a reason for hiding this comment

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

glad you're checking, but I think that verify_instruction also guards against this...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mind pointing to where you're talking about? git grep is failing me

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, was renamed to verify_account_changes()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it. The !is_zeroed() check gets us. So I guess what we're buying here is a bit of accuracy for the return code, InvalidArgument vs. ModifiedProgramId

Copy link
Contributor

@rob-solana rob-solana Jan 6, 2020

Choose a reason for hiding this comment

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

verify_account_changes() can be really explicit, have a ton of errors, all part of the base set. the rules apply to all programs, not just system. lean on it and make a followup PR?

legal under the current rules: the stake program can change account.owner if it first zeros the state memory. that's pretty cool and correct, right?

runtime/src/accounts.rs Outdated Show resolved Hide resolved
let res = accounts.load_accounts(
&ancestors,
&[tx],
None,
vec![(Ok(()), Some(HashAgeKind::Extant))],
&hash_queue,
error_counters,
&rent_collector,
rent_collector,
Copy link
Contributor

Choose a reason for hiding this comment

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

whoa! CC @ParthDesai

Copy link
Contributor

Choose a reason for hiding this comment

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

nevermind, is part of tests ;)

Copy link
Contributor

@rob-solana rob-solana left a comment

Choose a reason for hiding this comment

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

looking good, some important questions outstanding (see above)

also: where's the "refund the fee if the Nonce instruction fails" code? in here yet?

@t-nelson
Copy link
Contributor Author

t-nelson commented Dec 31, 2019

looking good, some important questions outstanding (see above)

🙏

also: where's the "refund the fee if the Nonce instruction fails" code? in here yet?

Next changeset. I wanted to pump the brakes on this one since the relocation blew up the diff so badly

rob-solana
rob-solana previously approved these changes Dec 31, 2019
Copy link
Contributor

@rob-solana rob-solana left a comment

Choose a reason for hiding this comment

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

nits, but otherwise lgtm

@t-nelson
Copy link
Contributor Author

t-nelson commented Jan 3, 2020

Rebased and ready to go by my eye

@t-nelson
Copy link
Contributor Author

t-nelson commented Jan 3, 2020

@rob-solana 5053407?w=1 look ok?

@t-nelson t-nelson added the automerge Merge this Pull Request automatically once CI passes label Jan 3, 2020
@solana-grimes solana-grimes merged commit 7e94cc2 into solana-labs:master Jan 4, 2020
mergify bot pushed a commit that referenced this pull request Jan 4, 2020
automerge

(cherry picked from commit 7e94cc2)

# Conflicts:
#	cli/src/nonce.rs
#	runtime/src/accounts.rs
#	runtime/src/system_instruction_processor.rs
t-nelson added a commit to t-nelson/solana that referenced this pull request Jan 4, 2020
@t-nelson t-nelson deleted the nonce-to-sysprog branch January 4, 2020 01:42
solana-grimes pushed a commit that referenced this pull request Jan 4, 2020
sakridge pushed a commit to sakridge/solana that referenced this pull request Jan 14, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants