diff --git a/src/prover_disk.hpp b/src/prover_disk.hpp index a38f85f0f..68808abc2 100644 --- a/src/prover_disk.hpp +++ b/src/prover_disk.hpp @@ -110,10 +110,21 @@ class DiskProver { // The list of C2 entries is small enough to keep in memory. When proving, we can // read from disk the C1 and C3 entries. + uint64_t prev_c2_f7 = 0; auto* c2_buf = new uint8_t[c2_size]; for (uint32_t i = 0; i < c2_entries - 1; i++) { SafeRead(disk_file, c2_buf, c2_size); - this->C2.push_back(Bits(c2_buf, c2_size, c2_size * 8).Slice(0, k).GetValue()); + + const uint64_t f7 = Bits(c2_buf, c2_size, c2_size * 8).Slice(0, k).GetValue(); + + // Short-circuit reading of the C2 table as soon as we encounter an f7 entry whose + // value is lesser than the previous f7 read. This ensures that we don't read + // empty space from C2 tables that are written with file system block-alignment (like bladebit v1 does). + if (f7 < prev_c2_f7) + break; + + this->C2.push_back(f7); + prev_c2_f7 = f7; } delete[] c2_buf;