@@ -41,11 +41,13 @@ static SnapshotPath parse_snapshot_path(const char* file_path) {
4141static void build_inverted_index_bundle_data (
4242 const SilkwormInvertedIndexSnapshot& snapshot,
4343 const Schema::EntityDef& entity_def,
44+ const datastore::StepToTimestampConverter& step_converter,
4445 SnapshotBundleEntityData& data) {
4546 data.kv_segments .emplace (
4647 Schema::kInvIdxKVSegmentName ,
4748 segment::KVSegmentFileReader{
4849 parse_snapshot_path (snapshot.segment .file_path ),
50+ step_converter,
4951 entity_def.kv_segment (Schema::kInvIdxKVSegmentName ).compression_kind (),
5052 make_region (snapshot.segment ),
5153 });
@@ -59,21 +61,24 @@ static void build_inverted_index_bundle_data(
5961
6062static snapshots::SnapshotBundleEntityData build_inverted_index_bundle_data (
6163 const SilkwormInvertedIndexSnapshot& snapshot,
62- const Schema::EntityDef& entity_def) {
64+ const Schema::EntityDef& entity_def,
65+ const datastore::StepToTimestampConverter& step_converter) {
6366 SnapshotBundleEntityData data;
64- build_inverted_index_bundle_data (snapshot, entity_def, data);
67+ build_inverted_index_bundle_data (snapshot, entity_def, step_converter, data);
6568 return data;
6669}
6770
6871static snapshots::SnapshotBundleEntityData build_domain_bundle_data (
6972 const SilkwormDomainSnapshot& snapshot,
7073 const Schema::EntityDef& entity_def,
74+ const datastore::StepToTimestampConverter& step_converter,
7175 uint32_t index_salt) {
7276 SnapshotBundleEntityData data;
7377 data.kv_segments .emplace (
7478 Schema::kDomainKVSegmentName ,
7579 segment::KVSegmentFileReader{
7680 parse_snapshot_path (snapshot.segment .file_path ),
81+ step_converter,
7782 entity_def.kv_segment (Schema::kDomainKVSegmentName ).compression_kind (),
7883 make_region (snapshot.segment ),
7984 });
@@ -102,12 +107,14 @@ static snapshots::SnapshotBundleEntityData build_domain_bundle_data(
102107
103108static snapshots::SnapshotBundleEntityData build_history_bundle_data (
104109 const SilkwormHistorySnapshot& snapshot,
105- const Schema::EntityDef& entity_def) {
110+ const Schema::EntityDef& entity_def,
111+ const datastore::StepToTimestampConverter& step_converter) {
106112 SnapshotBundleEntityData data;
107113 data.segments .emplace (
108114 Schema::kHistorySegmentName ,
109115 segment::SegmentFileReader{
110116 parse_snapshot_path (snapshot.segment .file_path ),
117+ step_converter,
111118 make_region (snapshot.segment ),
112119 });
113120 data.accessor_indexes .emplace (
@@ -117,7 +124,7 @@ static snapshots::SnapshotBundleEntityData build_history_bundle_data(
117124 make_region (snapshot.accessor_index ),
118125 });
119126
120- build_inverted_index_bundle_data (snapshot.inverted_index , entity_def, data);
127+ build_inverted_index_bundle_data (snapshot.inverted_index , entity_def, step_converter, data);
121128 return data;
122129}
123130
@@ -126,22 +133,24 @@ static snapshots::SnapshotBundle build_state_snapshot_bundle_latest(
126133 const Schema::RepositoryDef& schema,
127134 uint32_t salt) {
128135 SnapshotBundleData bundle_data;
136+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
137+
129138 bundle_data.entities .emplace (
130139 db::state::kDomainNameAccounts ,
131- build_domain_bundle_data (bundle->accounts , schema.domain (db::state::kDomainNameAccounts ), salt));
140+ build_domain_bundle_data (bundle->accounts , schema.domain (db::state::kDomainNameAccounts ), step_converter, salt));
132141 bundle_data.entities .emplace (
133142 db::state::kDomainNameStorage ,
134- build_domain_bundle_data (bundle->storage , schema.domain (db::state::kDomainNameStorage ), salt));
143+ build_domain_bundle_data (bundle->storage , schema.domain (db::state::kDomainNameStorage ), step_converter, salt));
135144 bundle_data.entities .emplace (
136145 db::state::kDomainNameCode ,
137- build_domain_bundle_data (bundle->code , schema.domain (db::state::kDomainNameCode ), salt));
146+ build_domain_bundle_data (bundle->code , schema.domain (db::state::kDomainNameCode ), step_converter, salt));
138147 // TODO(canepat): enable after fixing .kvi configuration with IndexList-like implementation
139148 // bundle_data.entities.emplace(
140149 // db::state::kDomainNameCommitment,
141- // build_domain_bundle_data(bundle->commitment, schema.domain(db::state::kDomainNameCommitment), salt));
150+ // build_domain_bundle_data(bundle->commitment, schema.domain(db::state::kDomainNameCommitment), step_converter, salt));
142151 bundle_data.entities .emplace (
143152 db::state::kDomainNameReceipts ,
144- build_domain_bundle_data (bundle->receipts , schema.domain (db::state::kDomainNameReceipts ), salt));
153+ build_domain_bundle_data (bundle->receipts , schema.domain (db::state::kDomainNameReceipts ), step_converter, salt));
145154
146155 return SnapshotBundle{
147156 parse_snapshot_path (bundle->accounts .segment .file_path ).step_range (),
@@ -153,32 +162,33 @@ static snapshots::SnapshotBundle build_state_snapshot_bundle_historical(
153162 const SilkwormStateSnapshotBundleHistorical* bundle,
154163 const Schema::RepositoryDef& schema) {
155164 SnapshotBundleData bundle_data;
165+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
156166
157167 bundle_data.entities .emplace (
158168 db::state::kDomainNameAccounts ,
159- build_history_bundle_data (bundle->accounts , schema.history (db::state::kDomainNameAccounts )));
169+ build_history_bundle_data (bundle->accounts , schema.history (db::state::kDomainNameAccounts ), step_converter ));
160170 bundle_data.entities .emplace (
161171 db::state::kDomainNameStorage ,
162- build_history_bundle_data (bundle->storage , schema.history (db::state::kDomainNameStorage )));
172+ build_history_bundle_data (bundle->storage , schema.history (db::state::kDomainNameStorage ), step_converter ));
163173 bundle_data.entities .emplace (
164174 db::state::kDomainNameCode ,
165- build_history_bundle_data (bundle->code , schema.history (db::state::kDomainNameCode )));
175+ build_history_bundle_data (bundle->code , schema.history (db::state::kDomainNameCode ), step_converter ));
166176 bundle_data.entities .emplace (
167177 db::state::kDomainNameReceipts ,
168- build_history_bundle_data (bundle->receipts , schema.history (db::state::kDomainNameReceipts )));
178+ build_history_bundle_data (bundle->receipts , schema.history (db::state::kDomainNameReceipts ), step_converter ));
169179
170180 bundle_data.entities .emplace (
171181 db::state::kInvIdxNameLogAddress ,
172- build_inverted_index_bundle_data (bundle->log_addresses , schema.inverted_index (db::state::kInvIdxNameLogAddress )));
182+ build_inverted_index_bundle_data (bundle->log_addresses , schema.inverted_index (db::state::kInvIdxNameLogAddress ), step_converter ));
173183 bundle_data.entities .emplace (
174184 db::state::kInvIdxNameLogTopics ,
175- build_inverted_index_bundle_data (bundle->log_topics , schema.inverted_index (db::state::kInvIdxNameLogTopics )));
185+ build_inverted_index_bundle_data (bundle->log_topics , schema.inverted_index (db::state::kInvIdxNameLogTopics ), step_converter ));
176186 bundle_data.entities .emplace (
177187 db::state::kInvIdxNameTracesFrom ,
178- build_inverted_index_bundle_data (bundle->traces_from , schema.inverted_index (db::state::kInvIdxNameTracesFrom )));
188+ build_inverted_index_bundle_data (bundle->traces_from , schema.inverted_index (db::state::kInvIdxNameTracesFrom ), step_converter ));
179189 bundle_data.entities .emplace (
180190 db::state::kInvIdxNameTracesTo ,
181- build_inverted_index_bundle_data (bundle->traces_to , schema.inverted_index (db::state::kInvIdxNameTracesTo )));
191+ build_inverted_index_bundle_data (bundle->traces_to , schema.inverted_index (db::state::kInvIdxNameTracesTo ), step_converter ));
182192
183193 return SnapshotBundle{
184194 parse_snapshot_path (bundle->accounts .segment .file_path ).step_range (),
@@ -278,13 +288,17 @@ SILKWORM_EXPORT int silkworm_build_recsplit_indexes(SilkwormHandle handle, struc
278288 return SILKWORM_OK;
279289}
280290
281- static snapshots::SnapshotBundle build_blocks_snapshot_bundle (const SilkwormBlocksSnapshotBundle* bundle) {
291+ static snapshots::SnapshotBundle build_blocks_snapshot_bundle (
292+ const SilkwormBlocksSnapshotBundle* bundle,
293+ const Schema::RepositoryDef& schema) {
282294 snapshots::SnapshotBundleEntityData data;
295+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
283296
284297 data.segments .emplace (
285298 db::blocks::kHeaderSegmentName ,
286299 snapshots::segment::SegmentFileReader{
287300 parse_snapshot_path (bundle->headers .segment .file_path ),
301+ step_converter,
288302 make_region (bundle->headers .segment ),
289303 });
290304 data.accessor_indexes .emplace (
@@ -298,6 +312,7 @@ static snapshots::SnapshotBundle build_blocks_snapshot_bundle(const SilkwormBloc
298312 db::blocks::kBodySegmentName ,
299313 snapshots::segment::SegmentFileReader{
300314 parse_snapshot_path (bundle->bodies .segment .file_path ),
315+ step_converter,
301316 make_region (bundle->bodies .segment ),
302317 });
303318 data.accessor_indexes .emplace (
@@ -311,6 +326,7 @@ static snapshots::SnapshotBundle build_blocks_snapshot_bundle(const SilkwormBloc
311326 db::blocks::kTxnSegmentName ,
312327 snapshots::segment::SegmentFileReader{
313328 parse_snapshot_path (bundle->transactions .segment .file_path ),
329+ step_converter,
314330 make_region (bundle->transactions .segment ),
315331 });
316332 data.accessor_indexes .emplace (
@@ -348,7 +364,7 @@ SILKWORM_EXPORT int silkworm_add_blocks_snapshot_bundle(
348364
349365 auto & repository = *handle->blocks_repository ;
350366
351- repository.add_snapshot_bundle (build_blocks_snapshot_bundle (bundle));
367+ repository.add_snapshot_bundle (build_blocks_snapshot_bundle (bundle, repository. schema () ));
352368 return SILKWORM_OK;
353369 } catch (const InvalidSnapshotPathException&) {
354370 return SILKWORM_INVALID_PATH;
0 commit comments