Connect one-shot Linux updater worker flow behind the census gate
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-15 00:18:43 +01:00
parent d77279fb84
commit a56474805c
7 changed files with 1033 additions and 20 deletions
+71 -20
View File
@@ -53,7 +53,7 @@ pub struct BridgeContext<'a> {
}
pub struct FullBridge<'a> {
context: BridgeContext<'a>,
prefix: UpdateInflightProof,
prefix: Option<UpdateInflightProof>,
poisoned: bool,
finalized: bool,
}
@@ -76,7 +76,27 @@ impl<'a> FullBridge<'a> {
);
Ok(Self {
context,
prefix,
prefix: Some(prefix),
poisoned: false,
finalized: false,
})
}
/// First read obtains the actual original prefix from the authenticated
/// Full process/ledger. No event is synthesized from a caller's header.
pub fn original(context: BridgeContext<'a>) -> Result<Self> {
ensure!(
context.generation == Generation::Original,
"UPDATE_BRIDGE_ORIGINAL_ONLY"
);
context.handoff.validate()?;
ensure!(
context.delegation.handoff_sha256 == rmm_domain::jobs::hash(&context.handoff.bytes()?)
&& context.delegation.owner_nonce == context.handoff.owner_nonce,
"UPDATE_BRIDGE_ORIGINAL_HEADER"
);
Ok(Self {
context,
prefix: None,
poisoned: false,
finalized: false,
})
@@ -87,8 +107,21 @@ impl<'a> FullBridge<'a> {
.updater
.verify_delegation(context.delegation, context.budget)?;
context.budget.check()?;
let (_, journal) = verify_inflight_proof(&self.prefix, context.health_public_key)
.map_err(anyhow::Error::msg)?;
if self.prefix.is_none() {
ensure!(
matches!(method, NativeControlOperation::ReadOriginal),
"UPDATE_BRIDGE_ORIGINAL_READ_REQUIRED"
);
}
let journal = self
.prefix
.as_ref()
.map(|prefix| {
verify_inflight_proof(prefix, context.health_public_key)
.map(|(_, journal)| journal)
.map_err(anyhow::Error::msg)
})
.transpose()?;
match &method {
NativeControlOperation::ReadOriginal => {}
NativeControlOperation::ClaimStop {
@@ -96,31 +129,43 @@ impl<'a> FullBridge<'a> {
..
} => ensure!(
context.generation == Generation::Original
&& journal.phase() == Phase::StopIntent
&& *expected_head_sha256 == self.prefix.head_sha256,
&& journal
.as_ref()
.is_some_and(|j| j.phase() == Phase::StopIntent)
&& Some(expected_head_sha256.as_str())
== self.prefix.as_ref().map(|p| p.head_sha256.as_str()),
"UPDATE_BRIDGE_CLAIM_PHASE"
),
NativeControlOperation::ObserveStarts { .. } => ensure!(
context.generation == Generation::Replacement
&& journal.phase() == Phase::LedgerReturnIntent,
&& journal
.as_ref()
.is_some_and(|j| j.phase() == Phase::LedgerReturnIntent),
"UPDATE_BRIDGE_START_PHASE"
),
NativeControlOperation::Health { receipt } => {
ensure!(
context.generation == Generation::Replacement
&& journal.phase() == Phase::ServicesStarted,
&& journal
.as_ref()
.is_some_and(|j| j.phase() == Phase::ServicesStarted),
"UPDATE_BRIDGE_HEALTH_PHASE"
);
journal.prepare(
u64::try_from(context.clock.now()?.timestamp())?,
rmm_updater_handoff::Evidence::HealthVerified {
receipt: receipt.clone(),
},
)?;
journal
.as_ref()
.context("UPDATE_BRIDGE_ORIGINAL_READ_REQUIRED")?
.prepare(
u64::try_from(context.clock.now()?.timestamp())?,
rmm_updater_handoff::Evidence::HealthVerified {
receipt: receipt.clone(),
},
)?;
}
NativeControlOperation::Finalize => ensure!(
context.generation == Generation::Replacement
&& journal.phase() == Phase::HealthVerified,
&& journal
.as_ref()
.is_some_and(|j| j.phase() == Phase::HealthVerified),
"UPDATE_BRIDGE_FINAL_PHASE"
),
}
@@ -270,8 +315,11 @@ impl<'a> FullBridge<'a> {
ensure!(
handoff.bytes()? == context.handoff.bytes()?
&& proof.delegation == *context.delegation
&& proof.events.len() >= self.prefix.events.len()
&& proof.events[..self.prefix.events.len()] == self.prefix.events,
&& self
.prefix
.as_ref()
.is_none_or(|prior| proof.events.len() >= prior.events.len()
&& proof.events[..prior.events.len()] == prior.events),
"UPDATE_BRIDGE_PROOF_ROLLBACK_OR_CHANGED"
);
match request.method {
@@ -315,7 +363,7 @@ impl<'a> FullBridge<'a> {
),
NativeControlOperation::Finalize => unreachable!(),
}
self.prefix = proof.clone();
self.prefix = Some(proof.clone());
}
context.budget.check()?;
if matches!(request.method, NativeControlOperation::Finalize) {
@@ -331,8 +379,11 @@ impl<'a> FullBridge<'a> {
original_outcome,
})
}
pub fn head_sha256(&self) -> &str {
&self.prefix.head_sha256
pub fn head_sha256(&self) -> Result<&str> {
self.prefix
.as_ref()
.map(|p| p.head_sha256.as_str())
.context("UPDATE_BRIDGE_ORIGINAL_READ_REQUIRED")
}
pub fn observe_starts(
&mut self,