-
Notifications
You must be signed in to change notification settings - Fork 168
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
banking_stage: calculate stake by vote account instead of node pubkey #3049
Conversation
60b1b25
to
e33eaf7
Compare
votes.filter(move |vote| { | ||
let stake = staked_nodes.get(&vote.pubkey()).copied().unwrap_or(0); | ||
let stake = epoch_stakes.vote_account_stake(&vote.vote_pubkey()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now matches fork choice:
.map(|epoch_stakes| epoch_stakes.vote_account_stake(pubkey)) |
@@ -87,10 +87,16 @@ impl LatestValidatorVotePacket { | |||
Ok(vote_state_update_instruction) | |||
if instruction_filter(&vote_state_update_instruction) => | |||
{ | |||
let &pubkey = message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starry pointed out that this method of identifying the voter is brittle, as it relies on the node id being the first signer.
Grabbing the vote pubkey instead should be safe, as it is required to be the first account on the instruction:
agave/sdk/program/src/vote/instruction.rs
Lines 153 to 154 in 1805924
/// # Account references | |
/// 0. `[Write]` Vote account to vote with |
e33eaf7
to
eb6dc10
Compare
eb6dc10
to
5b78efb
Compare
cached_staked_nodes: RwLock::new(bank.current_epoch_staked_nodes().clone()), | ||
latest_votes_per_pubkey: RwLock::new(HashMap::default()), | ||
num_unprocessed_votes: AtomicUsize::new(0), | ||
cached_epoch_stakes: RwLock::new(bank.current_epoch_stakes().clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a note here; cloning is "cheap" since EpochStakes holds 3 Arc
s and a u64 internally.
this won't clone the relatively large underlying data
5b78efb
to
3f1fcd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, this looks much better!
3f1fcd6
to
8171af5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still some places where latest_votes_per_pubkey
is used but I was more concerned about the field being named explicitly so I'm happy
I can't unsee it now 😅 , renamed the remaining occurrences |
245080e
to
eb5cb40
Compare
Problem
latest_unprocessed_votes
uses the bank'sstaked_nodes
in order to calculate the voter's stake. This structure is based off of thenode_pubkey
to account for validators with multiple vote accounts.Fork choice and other consensus stake operations use
EpochStakes
instead, which calculates stake per vote account.Summary of Changes
Use the
vote_pubkey
instead, and calculate stake based on thevote_account
.