aboutsummaryrefslogtreecommitdiffstats
path: root/src/remake
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-08 13:54:07 +0000
committertv <tv@krebsco.de>2026-11-08 15:04:04 +0100
commit5fe7653a2e86bfbee0bcbe536bb74287ab47498f (patch)
tree88bffac257742671dd9103ceff5304c88aa74b82 /src/remake
parent1769f30038c62c999cfb91be0868c740fb1c0eba (diff)
rules: a carried remake record taken from the coordinator its snapshot names
Review finding 7, second part: a record carried into a new epoch whole (proposal and decision in one change) was taken from any member, for any remake ID. A member could write a forged record, decision included, for a fresh ID in a single change. The snapshot's epoch metadata now names the remake's coordinator, as the quorum built it. The carried-record exception holds only in a later epoch, only for the remake that made it, and only from the coordinator its snapshot names, where there is no record yet. Wire version 43: the snapshot, and so the epoch ID, changes. The review suggested carrying the record inside the snapshot instead. The snapshot can't hold the decision, which names the snapshot's own hash. So the snapshot vouches for who may carry the record instead.
Diffstat (limited to 'src/remake')
-rw-r--r--src/remake/catchup.rs1
-rw-r--r--src/remake/records.rs1
-rw-r--r--src/remake/snapshot.rs6
-rw-r--r--src/remake/switch.rs3
4 files changed, 10 insertions, 1 deletions
diff --git a/src/remake/catchup.rs b/src/remake/catchup.rs
index 9830c33..4df5c90 100644
--- a/src/remake/catchup.rs
+++ b/src/remake/catchup.rs
@@ -718,6 +718,7 @@ mod tests {
&mut old,
&SnapshotParams {
remake_id: "c-1",
+ coordinator: "a",
previous: Epoch::GENESIS,
base_heads: &base,
policy,
diff --git a/src/remake/records.rs b/src/remake/records.rs
index 21b383c..21cf0ae 100644
--- a/src/remake/records.rs
+++ b/src/remake/records.rs
@@ -306,6 +306,7 @@ impl Record {
) -> Option<SnapshotRequest> {
Some(SnapshotRequest {
remake_id: id.to_owned(),
+ coordinator: self.proposal.coordinator.clone(),
previous: self.proposal.from_epoch.to_epoch()?,
base_heads: base,
policy: serde_json::to_value(&self.proposal.policy).ok()?,
diff --git a/src/remake/snapshot.rs b/src/remake/snapshot.rs
index 220989e..7938b53 100644
--- a/src/remake/snapshot.rs
+++ b/src/remake/snapshot.rs
@@ -36,6 +36,8 @@ use crate::document::store::{self, StoreError};
pub(crate) struct SnapshotParams<'a> {
/// ID of the committed remake; seeds the snapshot actor.
pub(crate) remake_id: &'a str,
+ /// The node coordinating it: the one that carries its record into the new epoch.
+ pub(crate) coordinator: &'a str,
/// The epoch being compacted. The snapshot starts generation `previous + 1`.
pub(crate) previous: Epoch,
/// Heads of the base. Every node must hold all of these changes.
@@ -84,6 +86,7 @@ pub(crate) enum SnapshotError {
#[derive(Clone, Debug)]
pub(crate) struct SnapshotRequest {
pub(crate) remake_id: String,
+ pub(crate) coordinator: String,
pub(crate) previous: Epoch,
pub(crate) base_heads: Vec<ChangeHash>,
pub(crate) policy: JsonValue,
@@ -97,6 +100,7 @@ impl SnapshotRequest {
pub(crate) fn params(&self) -> SnapshotParams<'_> {
SnapshotParams {
remake_id: &self.remake_id,
+ coordinator: &self.coordinator,
previous: self.previous,
base_heads: &self.base_heads,
policy: &self.policy,
@@ -311,6 +315,7 @@ pub(crate) fn build(
let metadata = canonical(json!({
"generation": generation,
"remakeId": params.remake_id,
+ "coordinator": params.coordinator,
"previous": {
"generation": params.previous.generation,
"id": params.previous.id_hex(),
@@ -391,6 +396,7 @@ mod tests {
fn params<'a>(heads: &'a [ChangeHash], policy: &'a JsonValue) -> SnapshotParams<'a> {
SnapshotParams {
remake_id: "c-1",
+ coordinator: "a",
previous: Epoch::GENESIS,
base_heads: heads,
policy,
diff --git a/src/remake/switch.rs b/src/remake/switch.rs
index 34c492f..bd40d72 100644
--- a/src/remake/switch.rs
+++ b/src/remake/switch.rs
@@ -200,7 +200,8 @@ async fn switch<H: Host>(
// Only the coordinator carries the record into the new epoch: one writer, so the
// nodes don't all write the same path concurrently right after switching (a merge
// conflict, plus one change per node to sync). The epoch metadata in the snapshot
- // keeps the essentials on every node anyway.
+ // keeps the essentials on every node anyway, and names the coordinator: the rules
+ // take the record from it only (`access::rules`).
let carry_record = record.proposal.coordinator == host.node_id();
let record_path = records::record_path(id, "");