Skip to content

Commit c35535c

Browse files
authored
Merge pull request #210 from grumbach/fix/capacity-check-lmdb-reuse
fix(storage): treat a node as full only when disk and store are both out of room
2 parents 661e68a + 0a85404 commit c35535c

2 files changed

Lines changed: 882 additions & 68 deletions

File tree

src/storage/handler.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,18 +1180,24 @@ mod tests {
11801180
}
11811181
}
11821182

1183-
/// V2-411: a disk-full node must reject a PUT with the disk-space error
1184-
/// *before* running payment verification.
1183+
/// A node that is genuinely full must reject a PUT with the disk-space
1184+
/// error *before* running payment verification (`V2-411`).
1185+
///
1186+
/// "Full" now means both halves of the predicate: the volume is below the
1187+
/// reserve **and** the store has no reusable space. A freshly created store
1188+
/// has no freed pages, so both hold and the pre-check short-circuits, as it
1189+
/// always did. The companion cases in `storage::lmdb::tests` cover the half
1190+
/// that changed, where pruning has left reusable pages and the node must be
1191+
/// admitted rather than refused on `statvfs` alone.
11851192
///
11861193
/// The chunk is intentionally **not** cache-inserted, so if the handler
1187-
/// reached `verify_payment` it would return `PaymentRequired`/`PaymentFailed`
1188-
/// (an uncached chunk with no proof). Observing the `StorageFailed` disk
1189-
/// error instead proves the disk pre-check short-circuited ahead of
1190-
/// verification — there is no on-chain path to reach.
1194+
/// reached `verify_payment` it would return `PaymentFailed` (an uncached
1195+
/// chunk with no proof). Observing the `StorageFailed` disk error instead
1196+
/// proves the pre-check short-circuited ahead of verification.
11911197
#[tokio::test]
1192-
async fn test_put_rejected_on_insufficient_disk_before_verification() {
1193-
// u64::MAX reserve guarantees `available < reserve`, so the cached
1194-
// disk-space check always fails.
1198+
async fn test_put_rejected_on_insufficient_capacity_before_verification() {
1199+
// u64::MAX reserve guarantees `available < reserve`, and a fresh store
1200+
// has no reusable pages, so the node is full on both halves.
11951201
let (protocol, _temp) = create_test_protocol_with_reserve(u64::MAX).await;
11961202

11971203
let content = b"chunk for a disk-full node";

0 commit comments

Comments
 (0)