Skip to content

Commit 6e89780

Browse files
cleanup
1 parent 39f1dce commit 6e89780

18 files changed

Lines changed: 234 additions & 445 deletions

File tree

examples/sync/src/databases/current.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ where
141141

142142
async fn sync_boundary(&self) -> Location {
143143
self.sync_boundary()
144-
.expect("sync_boundary should not overflow")
145144
}
146145

147146
fn historical_proof(

storage/fuzz/fuzz_targets/current_crash_recovery.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,7 @@ fn fuzz(input: FuzzInput) {
265265
{
266266
break;
267267
}
268-
let Ok(boundary) = db.sync_boundary() else {
269-
break;
270-
};
271-
if db.prune(boundary).await.is_err() {
268+
if db.prune(db.sync_boundary()).await.is_err() {
272269
break;
273270
}
274271
}
@@ -327,9 +324,7 @@ fn fuzz(input: FuzzInput) {
327324
}
328325

329326
// Verify range proofs over the recovered DB.
330-
let floor = *db
331-
.sync_boundary()
332-
.expect("sync_boundary should not overflow");
327+
let floor = *db.sync_boundary();
333328
let size = *db.bounds().await.end;
334329
for i in floor..size {
335330
let loc = Location::new(i);

storage/fuzz/fuzz_targets/current_mmb_prune_grow.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,9 @@ async fn commit_pending(
215215
}
216216

217217
async fn prune_to_floor(db: &mut Db, reference_db: &Db, context: &str) {
218-
let boundary = db
219-
.sync_boundary()
220-
.expect("sync_boundary should not overflow");
221-
db.prune(boundary).await.expect("prune should not fail");
218+
db.prune(db.sync_boundary())
219+
.await
220+
.expect("prune should not fail");
222221
assert_matches_reference(db, reference_db, context).await;
223222
}
224223

storage/fuzz/fuzz_targets/current_ordered_operations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ fn fuzz(data: FuzzInput) {
215215
&mut pending_inserts, &mut pending_deletes,
216216
).await;
217217
committed_op_count = db.bounds().await.end;
218-
db.prune(db.sync_boundary().expect("sync_boundary should not overflow")).await.expect("Prune should not fail");
218+
db.prune(db.sync_boundary()).await.expect("Prune should not fail");
219219
}
220220

221221
CurrentOperation::Root => {
@@ -243,7 +243,7 @@ fn fuzz(data: FuzzInput) {
243243
let current_op_count = db.bounds().await.end;
244244
let start_loc = Location::new(start_loc % *current_op_count);
245245

246-
let oldest_loc = db.sync_boundary().expect("sync_boundary should not overflow");
246+
let oldest_loc = db.sync_boundary();
247247
if start_loc >= oldest_loc {
248248
let (proof, ops, chunks) = db
249249
.range_proof(&mut hasher, start_loc, *max_ops)

storage/fuzz/fuzz_targets/current_unordered_operations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn fuzz(data: FuzzInput) {
197197
CurrentOperation::Prune => {
198198
commit_pending(&mut db, &mut pending_writes, &mut committed_state, &mut pending_expected).await;
199199
committed_op_count = db.bounds().await.end;
200-
db.prune(db.sync_boundary().expect("sync_boundary should not overflow")).await.expect("Prune should not fail");
200+
db.prune(db.sync_boundary()).await.expect("Prune should not fail");
201201
}
202202

203203
CurrentOperation::Root => {
@@ -218,7 +218,7 @@ fn fuzz(data: FuzzInput) {
218218

219219
let current_op_count = db.bounds().await.end;
220220
let start_loc = Location::new(start_loc % *current_op_count);
221-
let oldest_loc = db.sync_boundary().expect("sync_boundary should not overflow");
221+
let oldest_loc = db.sync_boundary();
222222
if start_loc >= oldest_loc {
223223
let (proof, ops, chunks) = db
224224
.range_proof(&mut hasher, start_loc, *max_ops)

storage/src/qmdb/any/db.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,13 @@ where
100100
{
101101
/// Return the inactivity floor location. This is the location before which all operations are
102102
/// known to be inactive. Operations before this point can be safely pruned.
103-
///
104-
/// This is an implementation detail of the activity tracking; external callers should
105-
/// prefer [`Self::sync_boundary`] when constructing a sync target.
103+
#[cfg(any(test, feature = "test-traits"))]
106104
pub(crate) const fn inactivity_floor_loc(&self) -> Location<F> {
107105
self.inactivity_floor_loc
108106
}
109107

110-
/// Return the most recent location from which this database can safely be synced.
111-
///
112-
/// Callers constructing a sync [`Target`](crate::qmdb::sync::Target) may use this value, or
113-
/// any earlier retained location, as `range.start`. For `any` databases this equals the
114-
/// inactivity floor; the receiver's reconstruction does not require chunk alignment, so any
115-
/// retained earlier location is also valid.
108+
/// Return the most recent location from which this database can safely be synced, and the
109+
/// upper bound on [`Self::prune`]'s `loc`. For `any`, this equals the inactivity floor.
116110
pub const fn sync_boundary(&self) -> Location<F> {
117111
self.inactivity_floor_loc
118112
}

storage/src/qmdb/any/sync/mod.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@ pub(crate) mod tests;
5050
///
5151
/// Shared across [crate::qmdb::any] and [crate::qmdb::current] sync because both
5252
/// build on the same operations-MMR layout and share the same merkle partition.
53-
///
54-
/// # Caller contract
55-
///
56-
/// `target.range.start()` **must** equal the committed inactivity floor of the
57-
/// target state (i.e. the floor carried by the last `CommitFloor` op). Only the
58-
/// persisted tree size and root are checked; the merkle pruning boundary is not.
59-
/// Callers that set `target.range.start()` below the committed floor (or that
60-
/// prune their own database past the committed floor) can cause a later
61-
/// [`qmdb::sync::Database::from_sync_result`] rebuild to fail with `MissingNode`
62-
/// even though this function returned `true`.
53+
/// Verifies only that the persisted tree size and root match; the merkle pruning
54+
/// boundary is not re-checked. Callers must keep their local pruning point at or
55+
/// below `target.range.start()` or a later
56+
/// [`qmdb::sync::Database::from_sync_result`] rebuild may fail.
6357
pub async fn has_local_target_state<F, E, H>(
6458
context: E,
6559
merkle_config: journaled::Config,
@@ -78,7 +72,8 @@ where
7872
)
7973
.await;
8074
// Size + root match implies the last CommitFloor op (and therefore the
81-
// committed inactivity floor) matches, per the caller contract above.
75+
// size + root identify a unique state, so if they match the target's we can reuse
76+
// the persisted DB without fetching boundary pins.
8277
matches!(
8378
peek,
8479
Ok(Some((_, journal_leaves, root)))

0 commit comments

Comments
 (0)