@@ -44,11 +44,13 @@ static SnapshotPath parse_snapshot_path(const char* file_path) {
4444static void build_inverted_index_bundle_data (
4545 const SilkwormInvertedIndexSnapshot& snapshot,
4646 const Schema::EntityDef& entity_def,
47+ const datastore::StepToTimestampConverter& step_converter,
4748 SnapshotBundleEntityData& data) {
4849 data.kv_segments .emplace (
4950 Schema::kInvIdxKVSegmentName ,
5051 segment::KVSegmentFileReader{
5152 parse_snapshot_path (snapshot.segment .file_path ),
53+ step_converter,
5254 entity_def.kv_segment (Schema::kInvIdxKVSegmentName ).compression_kind (),
5355 make_region (snapshot.segment ),
5456 });
@@ -62,21 +64,24 @@ static void build_inverted_index_bundle_data(
6264
6365static snapshots::SnapshotBundleEntityData build_inverted_index_bundle_data (
6466 const SilkwormInvertedIndexSnapshot& snapshot,
65- const Schema::EntityDef& entity_def) {
67+ const Schema::EntityDef& entity_def,
68+ const datastore::StepToTimestampConverter& step_converter) {
6669 SnapshotBundleEntityData data;
67- build_inverted_index_bundle_data (snapshot, entity_def, data);
70+ build_inverted_index_bundle_data (snapshot, entity_def, step_converter, data);
6871 return data;
6972}
7073
7174static snapshots::SnapshotBundleEntityData build_domain_bundle_data (
7275 const SilkwormDomainSnapshot& snapshot,
7376 const Schema::EntityDef& entity_def,
77+ const datastore::StepToTimestampConverter& step_converter,
7478 uint32_t index_salt) {
7579 SnapshotBundleEntityData data;
7680 data.kv_segments .emplace (
7781 Schema::kDomainKVSegmentName ,
7882 segment::KVSegmentFileReader{
7983 parse_snapshot_path (snapshot.segment .file_path ),
84+ step_converter,
8085 entity_def.kv_segment (Schema::kDomainKVSegmentName ).compression_kind (),
8186 make_region (snapshot.segment ),
8287 });
@@ -105,12 +110,14 @@ static snapshots::SnapshotBundleEntityData build_domain_bundle_data(
105110
106111static snapshots::SnapshotBundleEntityData build_history_bundle_data (
107112 const SilkwormHistorySnapshot& snapshot,
108- const Schema::EntityDef& entity_def) {
113+ const Schema::EntityDef& entity_def,
114+ const datastore::StepToTimestampConverter& step_converter) {
109115 SnapshotBundleEntityData data;
110116 data.segments .emplace (
111117 Schema::kHistorySegmentName ,
112118 segment::SegmentFileReader{
113119 parse_snapshot_path (snapshot.segment .file_path ),
120+ step_converter,
114121 make_region (snapshot.segment ),
115122 });
116123 data.accessor_indexes .emplace (
@@ -120,7 +127,7 @@ static snapshots::SnapshotBundleEntityData build_history_bundle_data(
120127 make_region (snapshot.accessor_index ),
121128 });
122129
123- build_inverted_index_bundle_data (snapshot.inverted_index , entity_def, data);
130+ build_inverted_index_bundle_data (snapshot.inverted_index , entity_def, step_converter, data);
124131 return data;
125132}
126133
@@ -129,22 +136,24 @@ static snapshots::SnapshotBundle build_state_snapshot_bundle_latest(
129136 const Schema::RepositoryDef& schema,
130137 uint32_t salt) {
131138 SnapshotBundleData bundle_data;
139+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
140+
132141 bundle_data.entities .emplace (
133142 db::state::kDomainNameAccounts ,
134- build_domain_bundle_data (bundle->accounts , schema.domain (db::state::kDomainNameAccounts ), salt));
143+ build_domain_bundle_data (bundle->accounts , schema.domain (db::state::kDomainNameAccounts ), step_converter, salt));
135144 bundle_data.entities .emplace (
136145 db::state::kDomainNameStorage ,
137- build_domain_bundle_data (bundle->storage , schema.domain (db::state::kDomainNameStorage ), salt));
146+ build_domain_bundle_data (bundle->storage , schema.domain (db::state::kDomainNameStorage ), step_converter, salt));
138147 bundle_data.entities .emplace (
139148 db::state::kDomainNameCode ,
140- build_domain_bundle_data (bundle->code , schema.domain (db::state::kDomainNameCode ), salt));
149+ build_domain_bundle_data (bundle->code , schema.domain (db::state::kDomainNameCode ), step_converter, salt));
141150 // TODO(canepat): enable after fixing .kvi configuration with IndexList-like implementation
142151 // bundle_data.entities.emplace(
143152 // db::state::kDomainNameCommitment,
144- // build_domain_bundle_data(bundle->commitment, schema.domain(db::state::kDomainNameCommitment), salt));
153+ // build_domain_bundle_data(bundle->commitment, schema.domain(db::state::kDomainNameCommitment), step_converter, salt));
145154 bundle_data.entities .emplace (
146155 db::state::kDomainNameReceipts ,
147- build_domain_bundle_data (bundle->receipts , schema.domain (db::state::kDomainNameReceipts ), salt));
156+ build_domain_bundle_data (bundle->receipts , schema.domain (db::state::kDomainNameReceipts ), step_converter, salt));
148157
149158 return SnapshotBundle{
150159 parse_snapshot_path (bundle->accounts .segment .file_path ).step_range (),
@@ -156,32 +165,33 @@ static snapshots::SnapshotBundle build_state_snapshot_bundle_historical(
156165 const SilkwormStateSnapshotBundleHistorical* bundle,
157166 const Schema::RepositoryDef& schema) {
158167 SnapshotBundleData bundle_data;
168+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
159169
160170 bundle_data.entities .emplace (
161171 db::state::kDomainNameAccounts ,
162- build_history_bundle_data (bundle->accounts , schema.history (db::state::kDomainNameAccounts )));
172+ build_history_bundle_data (bundle->accounts , schema.history (db::state::kDomainNameAccounts ), step_converter ));
163173 bundle_data.entities .emplace (
164174 db::state::kDomainNameStorage ,
165- build_history_bundle_data (bundle->storage , schema.history (db::state::kDomainNameStorage )));
175+ build_history_bundle_data (bundle->storage , schema.history (db::state::kDomainNameStorage ), step_converter ));
166176 bundle_data.entities .emplace (
167177 db::state::kDomainNameCode ,
168- build_history_bundle_data (bundle->code , schema.history (db::state::kDomainNameCode )));
178+ build_history_bundle_data (bundle->code , schema.history (db::state::kDomainNameCode ), step_converter ));
169179 bundle_data.entities .emplace (
170180 db::state::kDomainNameReceipts ,
171- build_history_bundle_data (bundle->receipts , schema.history (db::state::kDomainNameReceipts )));
181+ build_history_bundle_data (bundle->receipts , schema.history (db::state::kDomainNameReceipts ), step_converter ));
172182
173183 bundle_data.entities .emplace (
174184 db::state::kInvIdxNameLogAddress ,
175- build_inverted_index_bundle_data (bundle->log_addresses , schema.inverted_index (db::state::kInvIdxNameLogAddress )));
185+ build_inverted_index_bundle_data (bundle->log_addresses , schema.inverted_index (db::state::kInvIdxNameLogAddress ), step_converter ));
176186 bundle_data.entities .emplace (
177187 db::state::kInvIdxNameLogTopics ,
178- build_inverted_index_bundle_data (bundle->log_topics , schema.inverted_index (db::state::kInvIdxNameLogTopics )));
188+ build_inverted_index_bundle_data (bundle->log_topics , schema.inverted_index (db::state::kInvIdxNameLogTopics ), step_converter ));
179189 bundle_data.entities .emplace (
180190 db::state::kInvIdxNameTracesFrom ,
181- build_inverted_index_bundle_data (bundle->traces_from , schema.inverted_index (db::state::kInvIdxNameTracesFrom )));
191+ build_inverted_index_bundle_data (bundle->traces_from , schema.inverted_index (db::state::kInvIdxNameTracesFrom ), step_converter ));
182192 bundle_data.entities .emplace (
183193 db::state::kInvIdxNameTracesTo ,
184- build_inverted_index_bundle_data (bundle->traces_to , schema.inverted_index (db::state::kInvIdxNameTracesTo )));
194+ build_inverted_index_bundle_data (bundle->traces_to , schema.inverted_index (db::state::kInvIdxNameTracesTo ), step_converter ));
185195
186196 return SnapshotBundle{
187197 parse_snapshot_path (bundle->accounts .segment .file_path ).step_range (),
@@ -281,13 +291,17 @@ SILKWORM_EXPORT int silkworm_build_recsplit_indexes(SilkwormHandle handle, struc
281291 return SILKWORM_OK;
282292}
283293
284- static snapshots::SnapshotBundle build_blocks_snapshot_bundle (const SilkwormBlocksSnapshotBundle* bundle) {
294+ static snapshots::SnapshotBundle build_blocks_snapshot_bundle (
295+ const SilkwormBlocksSnapshotBundle* bundle,
296+ const Schema::RepositoryDef& schema) {
285297 snapshots::SnapshotBundleEntityData data;
298+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
286299
287300 data.segments .emplace (
288301 db::blocks::kHeaderSegmentName ,
289302 snapshots::segment::SegmentFileReader{
290303 parse_snapshot_path (bundle->headers .segment .file_path ),
304+ step_converter,
291305 make_region (bundle->headers .segment ),
292306 });
293307 data.accessor_indexes .emplace (
@@ -301,6 +315,7 @@ static snapshots::SnapshotBundle build_blocks_snapshot_bundle(const SilkwormBloc
301315 db::blocks::kBodySegmentName ,
302316 snapshots::segment::SegmentFileReader{
303317 parse_snapshot_path (bundle->bodies .segment .file_path ),
318+ step_converter,
304319 make_region (bundle->bodies .segment ),
305320 });
306321 data.accessor_indexes .emplace (
@@ -314,6 +329,7 @@ static snapshots::SnapshotBundle build_blocks_snapshot_bundle(const SilkwormBloc
314329 db::blocks::kTxnSegmentName ,
315330 snapshots::segment::SegmentFileReader{
316331 parse_snapshot_path (bundle->transactions .segment .file_path ),
332+ step_converter,
317333 make_region (bundle->transactions .segment ),
318334 });
319335 data.accessor_indexes .emplace (
@@ -351,7 +367,7 @@ SILKWORM_EXPORT int silkworm_add_blocks_snapshot_bundle(
351367
352368 auto & repository = handle->db ->blocks_repository ;
353369
354- repository.add_snapshot_bundle (build_blocks_snapshot_bundle (bundle));
370+ repository.add_snapshot_bundle (build_blocks_snapshot_bundle (bundle, repository. schema () ));
355371 return SILKWORM_OK;
356372 } catch (const InvalidSnapshotPathException&) {
357373 return SILKWORM_INVALID_PATH;
0 commit comments