Skip to content

Commit

Permalink
Allow votes to timestamp subsequent slots with the same timestamp (so…
Browse files Browse the repository at this point in the history
…lana-labs#11715) (solana-labs#11720)

(cherry picked from commit b1bc901)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
  • Loading branch information
mergify[bot] and CriesofCarrots committed Aug 20, 2020
1 parent abce60e commit 6c03e6c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ impl VoteState {
timestamp: UnixTimestamp,
) -> Result<(), VoteError> {
if (slot < self.last_timestamp.slot || timestamp < self.last_timestamp.timestamp)
|| ((slot == self.last_timestamp.slot || timestamp == self.last_timestamp.timestamp)
|| (slot == self.last_timestamp.slot
&& BlockTimestamp { slot, timestamp } != self.last_timestamp
&& self.last_timestamp.slot != 0)
{
Expand Down Expand Up @@ -1742,10 +1742,6 @@ mod tests {
vote_state.process_timestamp(slot + 1, timestamp - 1),
Err(VoteError::TimestampTooOld)
);
assert_eq!(
vote_state.process_timestamp(slot + 1, timestamp),
Err(VoteError::TimestampTooOld)
);
assert_eq!(
vote_state.process_timestamp(slot, timestamp + 1),
Err(VoteError::TimestampTooOld)
Expand All @@ -1755,14 +1751,22 @@ mod tests {
vote_state.last_timestamp,
BlockTimestamp { slot, timestamp }
);
assert_eq!(vote_state.process_timestamp(slot + 1, timestamp), Ok(()));
assert_eq!(
vote_state.last_timestamp,
BlockTimestamp {
slot: slot + 1,
timestamp
}
);
assert_eq!(
vote_state.process_timestamp(slot + 1, timestamp + 1),
vote_state.process_timestamp(slot + 2, timestamp + 1),
Ok(())
);
assert_eq!(
vote_state.last_timestamp,
BlockTimestamp {
slot: slot + 1,
slot: slot + 2,
timestamp: timestamp + 1
}
);
Expand Down

0 comments on commit 6c03e6c

Please sign in to comment.