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

Implement locktower voting #3251

Merged
merged 9 commits into from
Mar 18, 2019

Conversation

aeyakovenko
Copy link
Member

Problem

Fork selection in replay_stage does not use a sensible fork selection algorithm.

Summary of Changes

Implement locktower voting as described in the fork selection section of the book.

Fixes #

@aeyakovenko aeyakovenko marked this pull request as ready for review March 14, 2019 22:36
@codecov
Copy link

codecov bot commented Mar 15, 2019

Codecov Report

Merging #3251 into master will increase coverage by 3.9%.
The diff coverage is 92.5%.

@@           Coverage Diff            @@
##           master   #3251     +/-   ##
========================================
+ Coverage    78.2%   82.2%   +3.9%     
========================================
  Files         153     133     -20     
  Lines       21746   20523   -1223     
========================================
- Hits        17024   16883    -141     
+ Misses       4722    3640   -1082

core/src/replay_stage.rs Show resolved Hide resolved
core/src/bank_forks.rs Show resolved Hide resolved
core/src/locktower.rs Show resolved Hide resolved
core/src/locktower.rs Outdated Show resolved Hide resolved
@carllin carllin force-pushed the locktower_voting branch 6 times, most recently from f2b8778 to 1ac80cc Compare March 17, 2019 02:20
@carllin carllin self-requested a review March 17, 2019 22:17
@aeyakovenko
Copy link
Member Author

@garious, any objections?

core/src/bank_forks.rs Outdated Show resolved Hide resolved
}

//produce a flat map of banks to all of its children
pub fn flat_children(&self) -> HashMap<u64, HashSet<u64>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function name and the doc description need work.

core/src/locktower.rs Outdated Show resolved Hide resolved
core/src/locktower.rs Outdated Show resolved Hide resolved
core/src/locktower.rs Outdated Show resolved Hide resolved
core/src/locktower.rs Outdated Show resolved Hide resolved
fn insert_fork_tree_lockouts(
stake_lockouts: &mut HashMap<u64, StakeLockout>,
vote: &Lockout,
flat_parents: &HashMap<u64, HashSet<u64>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually name HashMaps after the names of their values. In this case, I think that'd be parent_slots, but I can't tell for sure. That HashSet<u64> could use a type alias.

Copy link
Member Author

Choose a reason for hiding this comment

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

it's such a simple hashset, i feel like an alias would just obscure it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it's the u64 that really needs the type alias then.

Copy link
Contributor

Choose a reason for hiding this comment

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

The combination of a bad parameter name and no alias for either HashSet or its contents makes this code pretty unreadable. Also, the function name itself is pretty tough on the brain to get the right context. Is it inserting "fork, tree-lockouts" or "fork-tree lockouts"?

core/src/locktower.rs Outdated Show resolved Hide resolved
core/src/locktower.rs Outdated Show resolved Hide resolved
core/src/locktower.rs Outdated Show resolved Hide resolved
@aeyakovenko
Copy link
Member Author

@garious, Thanks! What do you think of the names? I think the naming could still use some work. can we handle it in another PR and have the fork-selection design doc reflect the naming?

Copy link
Contributor

@garious garious left a comment

Choose a reason for hiding this comment

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

Much better thanks. The motivation to focus on names is to expand the number of people that can contribute without needing to converse with you directly. If the names are no good, it'd likely end up back on you to maintain this code.

@aeyakovenko aeyakovenko merged commit 61a4b99 into solana-labs:master Mar 18, 2019
pgarg66 pushed a commit to pgarg66/solana that referenced this pull request Mar 21, 2019
* locktower components and tests

* integrate locktower into replay stage

* track locktower duration

* make sure threshold is checked after simulating the vote

* check vote lockouts using the VoteState program

* duplicate vote test

* epoch stakes

* disable impossible to verify tests
solana-grimes pushed a commit that referenced this pull request Mar 21, 2019
* locktower components and tests

* integrate locktower into replay stage

* track locktower duration

* make sure threshold is checked after simulating the vote

* check vote lockouts using the VoteState program

* duplicate vote test

* epoch stakes

* disable impossible to verify tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants