Allow votes to timestamp subsequent slots with the same timestamp (#11715)
This commit is contained in:
@ -556,7 +556,7 @@ impl VoteState {
|
|||||||
timestamp: UnixTimestamp,
|
timestamp: UnixTimestamp,
|
||||||
) -> Result<(), VoteError> {
|
) -> Result<(), VoteError> {
|
||||||
if (slot < self.last_timestamp.slot || timestamp < self.last_timestamp.timestamp)
|
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
|
&& BlockTimestamp { slot, timestamp } != self.last_timestamp
|
||||||
&& self.last_timestamp.slot != 0)
|
&& self.last_timestamp.slot != 0)
|
||||||
{
|
{
|
||||||
@ -1742,10 +1742,6 @@ mod tests {
|
|||||||
vote_state.process_timestamp(slot + 1, timestamp - 1),
|
vote_state.process_timestamp(slot + 1, timestamp - 1),
|
||||||
Err(VoteError::TimestampTooOld)
|
Err(VoteError::TimestampTooOld)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
|
||||||
vote_state.process_timestamp(slot + 1, timestamp),
|
|
||||||
Err(VoteError::TimestampTooOld)
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vote_state.process_timestamp(slot, timestamp + 1),
|
vote_state.process_timestamp(slot, timestamp + 1),
|
||||||
Err(VoteError::TimestampTooOld)
|
Err(VoteError::TimestampTooOld)
|
||||||
@ -1755,14 +1751,22 @@ mod tests {
|
|||||||
vote_state.last_timestamp,
|
vote_state.last_timestamp,
|
||||||
BlockTimestamp { slot, timestamp }
|
BlockTimestamp { slot, timestamp }
|
||||||
);
|
);
|
||||||
|
assert_eq!(vote_state.process_timestamp(slot + 1, timestamp), Ok(()));
|
||||||
assert_eq!(
|
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(())
|
Ok(())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vote_state.last_timestamp,
|
vote_state.last_timestamp,
|
||||||
BlockTimestamp {
|
BlockTimestamp {
|
||||||
slot: slot + 1,
|
slot: slot + 2,
|
||||||
timestamp: timestamp + 1
|
timestamp: timestamp + 1
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user