Fence Windows sync until the helper confirms the signed decision
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -284,6 +284,15 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
old == h.journal_id && h.checkpoint >= meta.helper_checkpoint,
|
||||
"HELPER_JOURNAL_ROLLBACK"
|
||||
);
|
||||
if self.helper_identity == HelperIdentity::System {
|
||||
// A locally committed Windows decision is not proof of its
|
||||
// application by SYSTEM. Never advance either checkpoint
|
||||
// from an older helper head, including after process loss.
|
||||
ensure!(
|
||||
meta.decision.is_some() && h.previous_decision_id == meta.decision,
|
||||
"SYSTEM_HELPER_APPLY_UNCONFIRMED"
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ensure!(meta.helper_id.is_none(), "HELPER_JOURNAL_DISAPPEARED");
|
||||
|
||||
@@ -1026,6 +1026,72 @@ fn helper_gate_requires_exact_signed_instruction_and_applied_checkpoint() {
|
||||
assert!(!c.can_start(&f.channel, true, &f.clock));
|
||||
}
|
||||
#[test]
|
||||
fn windows_unconfirmed_helper_head_cannot_replace_a_committed_decision() {
|
||||
let mut f = Fixture::new();
|
||||
f.helper_identity = HelperIdentity::System;
|
||||
let mut client = f.client();
|
||||
let mut helper = HelperSnapshot {
|
||||
journal_id: Uuid::new_v4(),
|
||||
checkpoint: 1,
|
||||
previous_decision_id: None,
|
||||
attempts: vec![],
|
||||
};
|
||||
let first = client
|
||||
.prepare(
|
||||
&mut f.db,
|
||||
&f.ledger,
|
||||
f.channel.clone(),
|
||||
Some(&helper),
|
||||
&f.clock,
|
||||
)
|
||||
.unwrap();
|
||||
let decision = f.decision(&first, true);
|
||||
f.apply(&mut client, &decision).unwrap();
|
||||
client.apply_consumption(&mut f.ledger, &f.clock).unwrap();
|
||||
|
||||
for previous in [None, Some(Uuid::new_v4())] {
|
||||
let mut reopened = f.client();
|
||||
helper.previous_decision_id = previous;
|
||||
assert_eq!(
|
||||
reopened
|
||||
.prepare(
|
||||
&mut f.db,
|
||||
&f.ledger,
|
||||
f.channel.clone(),
|
||||
Some(&helper),
|
||||
&f.clock
|
||||
)
|
||||
.err()
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
"SYSTEM_HELPER_APPLY_UNCONFIRMED"
|
||||
);
|
||||
assert!(!reopened.can_start(&f.channel, false, &f.clock));
|
||||
let count: u64 =
|
||||
f.db.query_row("SELECT count(*) FROM reconcile_requests", [], |r| r.get(0))
|
||||
.unwrap();
|
||||
assert_eq!(count, 1);
|
||||
}
|
||||
helper.previous_decision_id = Some(decision.decision_id);
|
||||
helper.checkpoint += 1;
|
||||
f.channel.connection_generation += 1;
|
||||
let mut reopened = f.client();
|
||||
let next = reopened
|
||||
.prepare(
|
||||
&mut f.db,
|
||||
&f.ledger,
|
||||
f.channel.clone(),
|
||||
Some(&helper),
|
||||
&f.clock,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
next.request.helper_previous_decision_id,
|
||||
decision.decision_id.to_string()
|
||||
);
|
||||
assert!(!reopened.can_start(&f.channel, false, &f.clock));
|
||||
}
|
||||
#[test]
|
||||
fn independent_helper_checkpoint_regression_is_sticky() {
|
||||
let mut f = Fixture::new();
|
||||
let mut c = f.client();
|
||||
|
||||
Reference in New Issue
Block a user