propagation: start without rereading and re-flushing every stored message

This commit is contained in:
DeFiDude committed 2026-10-20 19:53:20 -06:00
1 parent 580fe1deab
commit ecfb115027
5 files changed
+48 -3

No files matched your search

+2
View File
@@ -2,6 +2,8 @@
## Unreleased
- Start a propagation node without rereading and flushing every stored message, so restarts with large stores no longer delay announces and hosting. Each message is still verified when it is served.
## 1.4.0 - 2026-10-12
- Preserve each signed message exactly as received, including binary text and custom fields, and reject ambiguous field definitions.
+4 -1
View File
@@ -13,7 +13,10 @@ explicit offline migration. An incomplete migration, invalid committed record,
unsupported filesystem, or unavailable storage prevents hosting. Daemons fail
startup when required relay storage is unavailable. Applications retain the
user's hosting preference but show hosting as unavailable until recovery succeeds.
There is no automatic in-memory fallback for a durable host.
There is no automatic in-memory fallback for a durable host. Startup checks each
committed record's index, provenance, size and destination without rereading
whole message bodies; every read verifies the full body, and a body that fails
is not served.
Stop every process that can write the store, including service supervisors and
scheduled restarts. Then run the candidate daemon against the correct config:
+1 -1
View File
@@ -1000,7 +1000,7 @@ impl PropagationNode {
continue;
}
let (meta, _) = crate::propagation_store_v2::read_manifest(&object)?;
crate::propagation_store_v2::verify_committed_object(&object)?;
crate::propagation_store_v2::check_committed_on_load(&object, &meta)?;
if self.store.contains(&meta.transient_id) {
return Err(std::io::Error::other("duplicate relay TID"));
}
@@ -308,6 +308,25 @@ pub(crate) fn verify_committed_object(path: &Path) -> io::Result<()> {
check_index(path, &meta, &encoded)
}
/// Startup check for an indexed record: readable, committed size and
/// destination prefix. Publication completed its barriers before any proof,
/// duplicates renew them, and every read revalidates the body, so restart must
/// not reread and re-flush the whole store.
pub(crate) fn check_committed_on_load(path: &Path, meta: &EntryManifest) -> io::Result<()> {
let metadata = fs::symlink_metadata(path)?;
if !metadata.is_file() || metadata.len() != meta.size as u64 {
return Err(invalid("relay object does not match its committed size"));
}
let mut destination = [0u8; 16];
File::open(path)?.read_exact(&mut destination)?;
if destination != meta.destination {
return Err(invalid(
"relay object does not match its committed destination",
));
}
Ok(())
}
/// Both the manifest and complete bytes are checked at the final read boundary.
/// An unresolved durable deletion always defeats a previously prepared read.
pub(crate) fn read_validated_file(path: &Path) -> io::Result<Vec<u8>> {
+22 -1
View File
@@ -1,7 +1,7 @@
use bytes::Bytes;
use lxmf_core::propagation_node::{
PropagationAdmission, PropagationAdmissionOutcome, PropagationNode, PropagationNodeConfig,
ValidatedOpaquePropagationBlob,
ValidatedOpaquePropagationBlob, read_planned_messages,
};
use rmpv::Value;
fn payload(destination: [u8; 16]) -> Bytes {
@@ -68,6 +68,27 @@ async fn duplicate_waits_for_exact_commit_and_rechecks_retained_files() {
drop(node);
assert!(PropagationNode::with_storage(PropagationNodeConfig::default(), [1; 16], old).is_err());
}
#[test]
fn restart_skips_body_rereads_and_never_serves_a_damaged_body() {
let dir = tempfile::tempdir().unwrap();
let store = dir.path().join("store");
let mut node =
PropagationNode::with_storage(PropagationNodeConfig::default(), [1; 16], store.clone())
.unwrap();
let bytes = payload([2; 16]);
let tid = validated(bytes.clone()).transient_id();
let plan = reserve(&mut node, bytes);
assert!(node.commit_store_write(plan.persist().unwrap()));
let path = node.plan_message_reads(&[tid]).pop().unwrap().path;
drop(node);
let mut damaged = std::fs::read(&path).unwrap();
*damaged.last_mut().unwrap() ^= 0xff;
std::fs::write(&path, &damaged).unwrap();
let reopened =
PropagationNode::with_storage(PropagationNodeConfig::default(), [1; 16], store).unwrap();
assert_eq!(reopened.message_count(), 1);
assert!(read_planned_messages(&reopened.plan_message_reads(&[tid])).is_empty());
}
#[tokio::test]
async fn cancelled_reservation_releases_waiters_without_authority_and_can_retry() {
let dir = tempfile::tempdir().unwrap();