Skip to content

Commit 84c19e2

Browse files
committed
mirror_worker: discard trailing add-entries bytes instead of 400
The spec says the mirror discards any partial bytes after the last successfully authenticated entry package; the only defined 400 is when no package was authenticated at all. The trailing-byte 400 also ran after persist_entries and advance_next_entry had already committed and advanced the frontier, so it told the client nothing was saved when everything was, with no next_entry to resume from. Drop the check. Addresses bonk #264 review on add_entries.rs trailing-data handling.
1 parent 76a297a commit 84c19e2

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

crates/mirror_worker/src/add_entries.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,12 @@ async fn verify_and_persist(
313313
));
314314
}
315315

316-
// Complete upload: no trailing bytes may remain after the last package.
317-
let pos = usize::try_from(cursor.position()).unwrap_or(usize::MAX);
318-
if pos < cursor.get_ref().len() {
319-
log::warn!("add-entries: trailing data after the last entry package");
320-
return Err(AppError::BadRequest(
321-
"trailing data after the last entry package".to_owned(),
322-
));
323-
}
316+
// Every canonical package was received. Any bytes past the last one
317+
// are discarded, not rejected: the spec says "the mirror discards any
318+
// partial bytes after the last successfully authenticated entry
319+
// package", and the only defined 400 is when no package authenticated
320+
// at all (handled above). Rejecting here would also be dishonest, since
321+
// the entries were already persisted and the frontier advanced.
324322

325323
// When we persisted new entries, the recomputed tree MUST match the
326324
// pending checkpoint the packages were proven against. A mismatch means

0 commit comments

Comments
 (0)