Skip to content

Commit 376f477

Browse files
committed
don't inherit locally proposed status for conflicting certs
1 parent 13aab1c commit 376f477

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

  • consensus/src/simplex/actors/voter

consensus/src/simplex/actors/voter/round.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl<S: Scheme, D: Digest> Round<S, D> {
376376
None
377377
}
378378
ProposalChange::Equivocated { dropped, retained } => {
379-
self.proposal.set_proposed_locally(proposed_locally);
379+
self.proposal.set_proposed_locally(false);
380380
// Receiving a certificate for a conflicting proposal means the
381381
// leader signed two different payloads for the same (epoch,
382382
// view).
@@ -1162,6 +1162,40 @@ mod tests {
11621162
assert!(round.proposed_locally());
11631163
}
11641164

1165+
#[test]
1166+
fn recovered_conflicting_certificate_clears_local_marker() {
1167+
let mut rng = test_rng();
1168+
let namespace = b"ns";
1169+
let Fixture {
1170+
schemes, verifier, ..
1171+
} = ed25519::fixture(&mut rng, namespace, 4);
1172+
let local_scheme = schemes[0].clone();
1173+
1174+
let now = SystemTime::UNIX_EPOCH;
1175+
let round_info = Rnd::new(Epoch::new(1), View::new(1));
1176+
let local_proposal = Proposal::new(round_info, View::new(0), Sha256Digest::from([5u8; 32]));
1177+
let conflicting = Proposal::new(round_info, View::new(0), Sha256Digest::from([6u8; 32]));
1178+
1179+
let mut round = Round::new(local_scheme, round_info, now);
1180+
round.set_leader(Participant::new(0));
1181+
assert!(round.proposed(local_proposal));
1182+
assert!(round.proposed_locally());
1183+
1184+
let notarization_votes: Vec<_> = schemes
1185+
.iter()
1186+
.map(|scheme| Notarize::sign(scheme, conflicting.clone()).unwrap())
1187+
.collect();
1188+
let notarization =
1189+
Notarization::from_notarizes(&verifier, notarization_votes.iter(), &Sequential)
1190+
.unwrap();
1191+
let (added, equivocator) = round.add_notarization(notarization);
1192+
assert!(added);
1193+
assert!(equivocator.is_some());
1194+
1195+
assert_eq!(round.proposal.status(), ProposalStatus::Equivocated);
1196+
assert!(!round.proposed_locally());
1197+
}
1198+
11651199
#[test]
11661200
fn certified_after_abort_handles_race_condition() {
11671201
let mut rng = test_rng();

0 commit comments

Comments
 (0)