From 85755142357ff69294e2de90248a3e8df5b62bb3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 20 Aug 2020 02:00:32 +0000 Subject: [PATCH] Allow votes to timestamp subsequent slots with the same timestamp (#11715) (#11719) (cherry picked from commit b1bc901a669269d8682bf08a48e3b4b8ce2a219c) Co-authored-by: Tyera Eulberg --- programs/vote/src/vote_state/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/programs/vote/src/vote_state/mod.rs b/programs/vote/src/vote_state/mod.rs index 22ebff2798..b3b56d5bd5 100644 --- a/programs/vote/src/vote_state/mod.rs +++ b/programs/vote/src/vote_state/mod.rs @@ -544,7 +544,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) { @@ -1729,10 +1729,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) @@ -1742,14 +1738,22 @@ mod tests { vote_state.last_timestamp, BlockTimestamp { slot, timestamp } ); + assert_eq!(vote_state.process_timestamp(slot + 1, timestamp), Ok(())); assert_eq!( - vote_state.process_timestamp(slot + 1, timestamp + 1), + vote_state.last_timestamp, + BlockTimestamp { + slot: slot + 1, + timestamp + } + ); + assert_eq!( + 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 } );