Integrate independent signed Windows clocks with native Linux lease guards
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -881,7 +881,8 @@ impl<V: Ed25519Verifier> HelperSync<V> {
|
||||
) -> bool {
|
||||
let result = (|| -> Result<bool> {
|
||||
guard.check(db)?;
|
||||
let now = clock.now()?;
|
||||
let reading = clock.reading()?;
|
||||
let now = reading.own_wall;
|
||||
let Some(lease) = &self.lease else {
|
||||
return Ok(false);
|
||||
};
|
||||
@@ -899,6 +900,7 @@ impl<V: Ed25519Verifier> HelperSync<V> {
|
||||
&& meta.decision == Some(lease.decision_id)
|
||||
&& generation == lease.generation
|
||||
&& now < lease.until
|
||||
&& reading.upper < lease.until
|
||||
&& now >= self.born
|
||||
&& boot.current_boot()? == lease.boot_id
|
||||
&& ledger_fingerprint(db)? == lease.fingerprint
|
||||
|
||||
@@ -21,8 +21,23 @@ use rusqlite::{Connection, OptionalExtension, TransactionBehavior, params};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use uuid::Uuid;
|
||||
|
||||
/// A fresh observation returned by the trusted local clock implementation,
|
||||
/// never an IPC DTO or an execution permit. Callers must not retain it as a lease.
|
||||
pub struct ClockReading {
|
||||
pub own_wall: DateTime<Utc>,
|
||||
pub upper: DateTime<Utc>,
|
||||
}
|
||||
pub trait SyncClock {
|
||||
fn now(&self) -> Result<DateTime<Utc>>;
|
||||
/// Existing providers retain their existing point-clock contract. Providers
|
||||
/// with an independently verified interval override this atomically.
|
||||
fn reading(&self) -> Result<ClockReading> {
|
||||
let own_wall = self.now()?;
|
||||
Ok(ClockReading {
|
||||
own_wall,
|
||||
upper: own_wall,
|
||||
})
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Channel {
|
||||
@@ -108,14 +123,15 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
self.gate.as_ref().map(|gate| gate.until)
|
||||
}
|
||||
pub fn can_start(&self, channel: &Channel, root: bool, clock: &impl SyncClock) -> bool {
|
||||
let Ok(now) = clock.now() else {
|
||||
let Ok(reading) = clock.reading() else {
|
||||
return false;
|
||||
};
|
||||
self.gate.as_ref().is_some_and(|g| {
|
||||
g.channel == *channel
|
||||
&& g.ready
|
||||
&& g.local_applied
|
||||
&& now < g.until
|
||||
&& reading.own_wall < g.until
|
||||
&& reading.upper < g.until
|
||||
&& (!root || (g.helper_ready && g.helper.is_none()))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user