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

Various clean-ups before assert adjustment#13006

Merged
ryoqun merged 2 commits intosolana-labs:masterfrom
ryoqun:persisted-tower-asserts-cleanup
Oct 21, 2020
Merged

Various clean-ups before assert adjustment#13006
ryoqun merged 2 commits intosolana-labs:masterfrom
ryoqun:persisted-tower-asserts-cleanup

Conversation

@ryoqun
Copy link
Copy Markdown
Contributor

@ryoqun ryoqun commented Oct 20, 2020

Problem

Well, I've ended up collecting some cleanups I'd like to settle down before #12671.

Summary of Changes

Flush out various cleanups before really introducing assert adjustments for easier review.

This pr should be no functional change.

@ryoqun ryoqun added the v1.4 label Oct 20, 2020
@ryoqun ryoqun requested a review from carllin October 20, 2020 05:23
Comment thread core/src/consensus.rs

// return immediately if votes are empty...
if self.lockouts.votes.is_empty() {
return Ok(self);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't like my previous coding (especially regarding the branched-off early bail-out code flow with Ok(_))... Well, I found out that I can steamline these a bit.

Comment thread core/src/consensus.rs
// Unless we're voting since genesis, slots_in_tower must always be older than last checked_slot
// including all vote slot and the root slot.
assert!(*slot_in_tower < checked_slot)
assert!(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm adding tests before adjusting this assert!.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi! I'm catching this assertion when I'm running a new validator: #13128

Comment thread core/src/consensus.rs
);
}

#[test]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm adding tests before adjusting this assert!.

Comment thread core/src/consensus.rs
);

blockstore.set_roots(&new_roots)?
blockstore.set_roots(&new_roots)?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oddly enough, clippy and rustfmt doesn't seem to complain this. ;)

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 20, 2020

Codecov Report

Merging #13006 into master will increase coverage by 0.0%.
The diff coverage is 95.0%.

@@           Coverage Diff           @@
##           master   #13006   +/-   ##
=======================================
  Coverage    81.9%    81.9%           
=======================================
  Files         361      361           
  Lines       85272    85308   +36     
=======================================
+ Hits        69895    69928   +33     
- Misses      15377    15380    +3     

@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Oct 20, 2020

@carllin Could you review this? Thanks!

Comment thread core/src/consensus.rs
));
}
self.adjust_lockouts_with_slot_history(slot_history)?;
self.initialize_root(replayed_root);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cool, I think this looks equivalent to me, much easier to read 😄

@ryoqun ryoqun merged commit efdb560 into solana-labs:master Oct 21, 2020
mergify Bot pushed a commit that referenced this pull request Oct 21, 2020
* Various clean-ups before assert adjustment

* oops

(cherry picked from commit efdb560)
mergify Bot added a commit that referenced this pull request Oct 21, 2020
* Various clean-ups before assert adjustment

* oops

(cherry picked from commit efdb560)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
CriesofCarrots pushed a commit to CriesofCarrots/solana that referenced this pull request Dec 4, 2020
* Various clean-ups before assert adjustment

* oops
CriesofCarrots pushed a commit to CriesofCarrots/solana that referenced this pull request Dec 4, 2020
* Various clean-ups before assert adjustment

* oops
CriesofCarrots pushed a commit to CriesofCarrots/solana that referenced this pull request Dec 4, 2020
* Various clean-ups before assert adjustment

* oops
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants