fix(indexer): seed breakpoint meta only on fresh store

`RISC0_DEV_MODE=1 RISC0_SKIP_BUILD=1 cargo test -p storage -p indexer_core`
This commit is contained in:
erhant 2026-07-09 11:32:37 +03:00
parent 14da3e04c8
commit 3a86bcaf37
2 changed files with 16 additions and 3 deletions

View File

@ -88,9 +88,11 @@ impl RocksDBIO {
let dbio = Self { db };
// First breakpoint setup
dbio.put_breakpoint(0, initial_state)?;
dbio.put_meta_last_breakpoint_id(0)?;
// Seed the genesis snapshot once; reopening must not clobber breakpoint meta.
if dbio.get_meta_last_breakpoint_id()?.is_none() {
dbio.put_breakpoint(0, initial_state)?;
dbio.put_meta_last_breakpoint_id(0)?;
}
Ok(dbio)
}

View File

@ -471,3 +471,14 @@ fn account_map() {
assert_eq!(acc1_tx_limited_hashes.as_slice(), &tx_hash_res[1..5]);
}
#[test]
fn reopen_preserves_breakpoint_meta() {
let temp_dir = tempdir().unwrap();
{
let dbio = RocksDBIO::open_or_create(temp_dir.path(), &initial_state()).unwrap();
dbio.put_meta_last_breakpoint_id(5).unwrap();
} // drop releases the RocksDB lock
let dbio = RocksDBIO::open_or_create(temp_dir.path(), &initial_state()).unwrap();
assert_eq!(dbio.get_meta_last_breakpoint_id().unwrap(), Some(5));
}