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

Clean up opt conf verifier and vote state tracker#13081

Merged
ryoqun merged 3 commits intosolana-labs:masterfrom
ryoqun:opt-conf-verifier-vote-state-tracker-cleanup
Oct 24, 2020
Merged

Clean up opt conf verifier and vote state tracker#13081
ryoqun merged 3 commits intosolana-labs:masterfrom
ryoqun:opt-conf-verifier-vote-state-tracker-cleanup

Conversation

@ryoqun
Copy link
Copy Markdown
Contributor

@ryoqun ryoqun commented Oct 22, 2020

Various cleanups when I skimmed the code when working on #10718. I've constantly missing some time to finish this pr off. No more before more bit rot. :)

For example, I had been struggling with too generic function names...

before:

Screenshot from 2020-10-22 16-38-51

after:

Screenshot from 2020-10-22 16-26-50

And various nits.

And, there should be no functional changes.

FYI:

@carllin For my thought on the implementation of this kill switch for mismatched vote hash (#12690 (comment)), I'm planning to augment these facilities. Wdyt? So, this is also kind of a preparation for it.

@ryoqun ryoqun requested a review from carllin October 22, 2020 07:56
}

let root_bank = bank_forks.read().unwrap().root_bank().clone();
if last_process_root.elapsed().as_millis() > 400 {
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.

maybe is 400 for DEFAULT_MS_PER_SLOT?

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.

yup!

}
}
} else {
let optimistic_confirmed_slots = optimistic_confirmed_slots.unwrap();
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.

idiomatic rust and less unwrap().

// if we don't have stake information, ignore it
let epoch = root_bank.epoch_schedule().get_epoch(slot);
let epoch_stakes = root_bank.epoch_stakes(epoch);
if *slot <= root || epoch_stakes.is_none() {
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.

move looping-related to its proper place

let total_stake = epoch_stakes.total_stake();

// If this vote for this slot qualifies for optimistic confirmation
if let Some((stake, hash)) = update_optimistic_confirmation_info {
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.

putting this into Option isn't needed first of all.

Comment on lines -574 to -575
let epoch_vote_accounts = Stakes::vote_accounts(epoch_stakes.stakes());
let total_epoch_stake = epoch_stakes.total_stake();
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.

epoch here isn't particularly significant information. So, I removed it and moved close to its use.

let new_stake = self.stake + stake;
self.stake = new_stake;
(
previous_stake <= supermajority_stake && self.stake > supermajority_stake,
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.

let's make these transitive in this inequality more explicit.

@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Oct 22, 2020

@carllin FYI, another local test tower related test failure: https://buildkite.com/solana-labs/solana/builds/33430#874e4bfa-3cef-4b01-bb4f-9d944810c9a6/170-370

Well, this pr broke ci, it seems....

@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Oct 22, 2020

@carllin FYI, another local test tower related test failure: https://buildkite.com/solana-labs/solana/builds/33430#874e4bfa-3cef-4b01-bb4f-9d944810c9a6/170-370

Well, this pr broke ci, it seems....

;) 45a995c

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 22, 2020

Codecov Report

Merging #13081 into master will decrease coverage by 0.0%.
The diff coverage is 91.7%.

@@            Coverage Diff            @@
##           master   #13081     +/-   ##
=========================================
- Coverage    82.1%    82.1%   -0.1%     
=========================================
  Files         366      366             
  Lines       86335    86340      +5     
=========================================
+ Hits        70958    70960      +2     
- Misses      15377    15380      +3     

Comment thread core/src/cluster_info_vote_listener.rs Outdated
}

fn update_new_root(&self, root_bank: &Bank) {
fn progress_slot(&self, root_bank: &Bank) {
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.

how about something more descriptive like purge_stale_state()?

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.

ok!: 648ac4d

carllin
carllin previously approved these changes Oct 23, 2020
@carllin
Copy link
Copy Markdown
Contributor

carllin commented Oct 23, 2020

Thanks for the cleanup!

FYI:

@carllin For my thought on the implementation of this kill switch for mismatched vote hash (#12690 (comment)), I'm planning to augment these facilities. Wdyt? So, this is also kind of a preparation for it.

I think that makes sense! Since the confirmed hash is being tracked already, it should be a natural extension to also check for a mismatch.

@mergify mergify Bot dismissed carllin’s stale review October 23, 2020 23:46

Pull request has been modified.

@ryoqun ryoqun merged commit 0264147 into solana-labs:master Oct 24, 2020
mergify Bot pushed a commit that referenced this pull request Oct 24, 2020
* Clean up opt conf verifier and vote state tracker

* Update test to follow new message and some knob

* Rename

(cherry picked from commit 0264147)
mergify Bot pushed a commit that referenced this pull request Oct 24, 2020
* Clean up opt conf verifier and vote state tracker

* Update test to follow new message and some knob

* Rename

(cherry picked from commit 0264147)
@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Oct 24, 2020

ryoqun added v1.3 v1.4 labels 2 minutes ago

Thanks for the cleanup!

FYI:
@carllin For my thought on the implementation of this kill switch for mismatched vote hash (#12690 (comment)), I'm planning to augment these facilities. Wdyt? So, this is also kind of a preparation for it.

I think that makes sense! Since the confirmed hash is being tracked already, it should be a natural extension to also check for a mismatch.

I'm backporting this in the hope of implementing this rather easily and backport this kill switch to v1.3 and v1.4

mergify Bot added a commit that referenced this pull request Oct 24, 2020
* Clean up opt conf verifier and vote state tracker

* Update test to follow new message and some knob

* Rename

(cherry picked from commit 0264147)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
mergify Bot added a commit that referenced this pull request Oct 24, 2020
* Clean up opt conf verifier and vote state tracker

* Update test to follow new message and some knob

* Rename

(cherry picked from commit 0264147)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
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.

2 participants