Module rpc_store_restore_source

Module rpc_store_restore_source 

Source
Expand description

[RestoreSource] backed by a validator’s AuthorityPerpetualTables.

Streams every LiveObject::Normal in the perpetual store into the sui-consistent-store restore driver, sharded by ObjectID prefix so multiple shards can iterate in parallel.

§Sharding

The ObjectID space is split into 32 shards by the top SHARD_BITS = 5 bits of the first byte (matching the split used by par_index_live_object_set). Each shard yields chunks of CHUNK_SIZE objects; the RestoreChunk::cursor is the 32-byte ObjectID of the last object in that chunk, so resuming with Some(c) starts the next iteration immediately after that id.

§Snapshot consistency

Each shard’s stream opens exactly one RocksDB iterator and drives it to completion from a single spawn_blocking task, pushing chunks back over a tokio mpsc. RocksDB iterators created without an explicit snapshot implicitly pin one at construction time, so a shard sees a single point-in-time view for its full run — including the merge-based balance pipeline, which is safe against concurrent execution.

Different shards take their snapshots at the moments their spawn_blocking tasks start, so cross-shard skew can still exist if the validator commits between shard launches. This does not affect any of the sui-rpc-store pipelines because every object lives in exactly one shard.

A side-effect of holding open one iterator per shard for the full restore is that the SSTs it references stay pinned and cannot compact away for the duration. That is acceptable for a one-shot bootstrap.

Structs§

PerpetualStoreRestoreSource
[RestoreSource] over an AuthorityPerpetualTables. Construct via PerpetualStoreRestoreSource::new.

Constants§

CHUNK_SIZE
Default objects per [RestoreChunk]. Tuned to keep the per-pipeline batch comfortably under a few MB of writes while still amortising the per-chunk commit overhead.