@@ -38,14 +38,20 @@ struct fd_snapin_tile {
38
38
manifest. */
39
39
fd_lthash_value_t lthash ;
40
40
41
+ /* stem pointer for snapshot parser callbacks */
42
+ fd_stem_context_t * stem ;
43
+
41
44
/* A shared dcache object between snapin and replay that holds the
42
45
decoded solana manifest.
43
46
TODO: remove when replay can receive the snapshot manifest. */
44
- uchar * replay_manifest_dcache ;
45
- ulong replay_manifest_dcache_obj_id ;
46
-
47
- /* TODO: remove when replay can receive the snapshot manifest. */
48
- ulong manifest_sz ;
47
+ struct {
48
+ fd_wksp_t * wksp ;
49
+ uchar * dcache ;
50
+ ulong chunk0 ;
51
+ ulong wmark ;
52
+ ulong chunk ;
53
+ ulong obj_id ;
54
+ } replay_manifest_dcache ;
49
55
50
56
struct {
51
57
fd_snapshot_parser_metrics_t full ;
@@ -106,10 +112,53 @@ metrics_write( fd_snapin_tile_t * ctx ) {
106
112
}
107
113
108
114
static void
109
- save_manifest ( fd_snapshot_parser_t * parser ,
110
- void * _ctx ,
111
- fd_solana_manifest_global_t * manifest ,
112
- ulong manifest_sz ) {
115
+ send_manifest ( fd_snapin_tile_t * ctx ,
116
+ ulong manifest_sz ) {
117
+ ulong sig = 0UL ;
118
+ ulong external_sig = 0UL ;
119
+ if ( ctx -> full ) {
120
+ sig = FD_FULL_SNAPSHOT_MANIFEST ;
121
+ external_sig = FD_FULL_SNAPSHOT_MANIFEST_EXTERNAL ;
122
+ } else {
123
+ sig = FD_INCREMENTAL_SNAPSHOT_MANIFEST ;
124
+ external_sig = FD_INCREMENTAL_SNAPSHOT_MANIFEST_EXTERNAL ;
125
+ }
126
+
127
+ /* Send snapshot manifest message over snap_out link */
128
+ fd_stem_publish ( ctx -> stem ,
129
+ 0UL ,
130
+ sig ,
131
+ ctx -> manifest_out .chunk ,
132
+ sizeof (fd_snapshot_manifest_t ),
133
+ 0UL ,
134
+ 0UL ,
135
+ 0UL );
136
+ ctx -> manifest_out .chunk = fd_dcache_compact_next ( ctx -> manifest_out .chunk ,
137
+ sizeof (fd_snapshot_manifest_t ),
138
+ ctx -> manifest_out .chunk0 ,
139
+ ctx -> manifest_out .wmark );
140
+
141
+ /* send manifest over replay manifest dcache */
142
+ fd_stem_publish ( ctx -> stem ,
143
+ 0UL ,
144
+ external_sig ,
145
+ ctx -> replay_manifest_dcache .chunk ,
146
+ manifest_sz ,
147
+ 0UL ,
148
+ ctx -> replay_manifest_dcache .obj_id ,
149
+ 0UL );
150
+ ctx -> replay_manifest_dcache .chunk = fd_dcache_compact_next ( ctx -> replay_manifest_dcache .chunk ,
151
+ manifest_sz ,
152
+ ctx -> replay_manifest_dcache .chunk0 ,
153
+ ctx -> replay_manifest_dcache .wmark );
154
+ FD_TEST ( ctx -> replay_manifest_dcache .chunk <= ctx -> replay_manifest_dcache .wmark );
155
+ }
156
+
157
+ static void
158
+ handle_manifest ( fd_snapshot_parser_t * parser ,
159
+ void * _ctx ,
160
+ fd_solana_manifest_global_t * manifest ,
161
+ ulong manifest_sz ) {
113
162
(void )parser ;
114
163
fd_snapin_tile_t * ctx = _ctx ;
115
164
@@ -119,8 +168,13 @@ save_manifest( fd_snapshot_parser_t * parser,
119
168
FD_LOG_NOTICE (( "Snapshot manifest loaded for slot %lu" , ssmanifest -> slot ));
120
169
121
170
/* Send decoded manifest to replay */
122
- fd_memcpy ( ctx -> replay_manifest_dcache , manifest , manifest_sz );
123
- ctx -> manifest_sz = manifest_sz ;
171
+ uchar * next_dcache_mem = fd_chunk_to_laddr ( ctx -> replay_manifest_dcache .wksp ,
172
+ ctx -> replay_manifest_dcache .chunk );
173
+ fd_memcpy ( next_dcache_mem ,
174
+ manifest ,
175
+ manifest_sz );
176
+
177
+ send_manifest ( ctx , manifest_sz );
124
178
}
125
179
126
180
static int
@@ -177,10 +231,11 @@ snapshot_insert_account( fd_snapshot_parser_t * parser,
177
231
}
178
232
179
233
static void
180
- snapshot_copy_acc_data ( fd_snapshot_parser_t * parser FD_PARAM_UNUSED ,
234
+ snapshot_copy_acc_data ( fd_snapshot_parser_t * parser ,
181
235
void * _ctx ,
182
236
uchar const * buf ,
183
237
ulong data_sz ) {
238
+ (void )parser ;
184
239
fd_snapin_tile_t * ctx = fd_type_pun ( _ctx );
185
240
186
241
if ( ctx -> acc_data ) {
@@ -190,8 +245,9 @@ snapshot_copy_acc_data( fd_snapshot_parser_t * parser FD_PARAM_UNUSED,
190
245
}
191
246
192
247
static void
193
- snapshot_reset_acc_data ( fd_snapshot_parser_t * parser FD_PARAM_UNUSED ,
248
+ snapshot_reset_acc_data ( fd_snapshot_parser_t * parser ,
194
249
void * _ctx ) {
250
+ (void )parser ;
195
251
fd_snapin_tile_t * ctx = fd_type_pun ( _ctx );
196
252
ctx -> acc_data = NULL ;
197
253
}
@@ -214,29 +270,6 @@ hard_reset_funk( fd_snapin_tile_t * ctx ) {
214
270
/* TODO: Assert that hard reset suceeded */
215
271
}
216
272
217
- static void
218
- send_manifest ( fd_snapin_tile_t * ctx ,
219
- fd_stem_context_t * stem ) {
220
- /* Assumes the manifest is already mem copied into the snap_out
221
- dcache and the replay_manifest_dcache from the save_manifest
222
- callback. */
223
- FD_TEST ( ctx -> manifest_sz );
224
-
225
- ulong sig = ctx -> full ? FD_FULL_SNAPSHOT_MANIFEST : FD_INCREMENTAL_SNAPSHOT_MANIFEST ;
226
- ulong external_sig = ctx -> full ? FD_FULL_SNAPSHOT_MANIFEST_EXTERNAL : FD_INCREMENTAL_SNAPSHOT_MANIFEST_EXTERNAL ;
227
-
228
- /* Send snapshot manifest message over snap_out link */
229
- fd_stem_publish ( stem , 0UL , sig , ctx -> manifest_out .chunk , sizeof (fd_snapshot_manifest_t ), 0UL , 0UL , 0UL );
230
- ctx -> manifest_out .chunk = fd_dcache_compact_next ( ctx -> manifest_out .chunk ,
231
- sizeof (fd_snapshot_manifest_t ),
232
- ctx -> manifest_out .chunk0 ,
233
- ctx -> manifest_out .wmark );
234
-
235
- /* send manifest over replay manifest dcache */
236
- ulong chunk = fd_dcache_compact_chunk0 ( fd_wksp_containing ( ctx -> replay_manifest_dcache ), ctx -> replay_manifest_dcache );
237
- fd_stem_publish ( stem , 0UL , external_sig , chunk , ctx -> manifest_sz , 0UL , ctx -> replay_manifest_dcache_obj_id , 0UL );
238
- }
239
-
240
273
static void
241
274
transition_malformed ( fd_snapin_tile_t * ctx ,
242
275
fd_stem_context_t * stem ) {
@@ -259,6 +292,8 @@ handle_data_frag( fd_snapin_tile_t * ctx,
259
292
return ;
260
293
}
261
294
295
+ ctx -> stem = stem ;
296
+
262
297
uchar const * const chunk_start = fd_chunk_to_laddr_const ( ctx -> in .wksp , chunk );
263
298
uchar const * const chunk_end = chunk_start + sz ;
264
299
uchar const * cur = chunk_start ;
@@ -312,10 +347,6 @@ handle_control_frag( fd_snapin_tile_t * ctx,
312
347
/* Publish any outstanding funk txn. */
313
348
if ( FD_LIKELY ( ctx -> funk_txn ) ) fd_funk_txn_publish_into_parent ( ctx -> funk , ctx -> funk_txn , 0 );
314
349
315
- /* Once the snapshot is fully loaded, we can send the manifest
316
- message over. */
317
- send_manifest ( ctx , stem );
318
-
319
350
/* Notify consumers of manifest out that the snapshot is fully
320
351
loaded. */
321
352
fd_stem_publish ( stem , 0UL , FD_SNAPSHOT_DONE , 0UL , 0UL , 0UL , 0UL , 0UL );
@@ -377,7 +408,7 @@ unprivileged_init( fd_topo_t * topo,
377
408
378
409
fd_snapshot_parser_process_manifest_fn_t manifest_cb = NULL ;
379
410
if ( 0 == strcmp ( topo -> links [tile -> out_link_id [ 0UL ]].name , "snap_out" ) ) {
380
- manifest_cb = save_manifest ;
411
+ manifest_cb = handle_manifest ;
381
412
}
382
413
383
414
ctx -> parser = fd_snapshot_parser_new ( parser_mem ,
@@ -395,10 +426,6 @@ unprivileged_init( fd_topo_t * topo,
395
426
396
427
fd_memset ( & ctx -> metrics , 0 , sizeof (ctx -> metrics ) );
397
428
398
- ctx -> replay_manifest_dcache = fd_topo_obj_laddr ( topo , tile -> snapin .manifest_dcache_obj_id );
399
- ctx -> replay_manifest_dcache_obj_id = tile -> snapin .manifest_dcache_obj_id ;
400
- ctx -> manifest_sz = 0UL ;
401
-
402
429
if ( FD_UNLIKELY ( tile -> kind_id ) ) FD_LOG_ERR (( "There can only be one `" NAME "` tile" ));
403
430
if ( FD_UNLIKELY ( tile -> in_cnt != 1UL ) ) FD_LOG_ERR (( "tile `" NAME "` has %lu ins, expected 1" , tile -> in_cnt ));
404
431
if ( FD_UNLIKELY ( tile -> out_cnt != 2UL ) ) FD_LOG_ERR (( "tile `" NAME "` has %lu outs, expected 2" , tile -> out_cnt ));
@@ -409,6 +436,16 @@ unprivileged_init( fd_topo_t * topo,
409
436
ctx -> manifest_out .wmark = fd_dcache_compact_wmark ( ctx -> manifest_out .wksp , writer_link -> dcache , writer_link -> mtu );
410
437
ctx -> manifest_out .chunk = ctx -> manifest_out .chunk0 ;
411
438
439
+ /* join replay manifest dcache */
440
+ ctx -> replay_manifest_dcache .dcache = fd_topo_obj_laddr ( topo , tile -> snapin .manifest_dcache_obj_id );
441
+ ctx -> replay_manifest_dcache .wksp = fd_wksp_containing ( ctx -> replay_manifest_dcache .dcache );
442
+ ctx -> replay_manifest_dcache .obj_id = tile -> snapin .manifest_dcache_obj_id ;
443
+ ctx -> replay_manifest_dcache .chunk0 = fd_dcache_compact_chunk0 ( ctx -> replay_manifest_dcache .wksp , ctx -> replay_manifest_dcache .dcache );
444
+ ctx -> replay_manifest_dcache .chunk = ctx -> replay_manifest_dcache .chunk0 ;
445
+ ctx -> replay_manifest_dcache .wmark = fd_dcache_compact_wmark ( ctx -> replay_manifest_dcache .wksp ,
446
+ ctx -> replay_manifest_dcache .dcache ,
447
+ writer_link -> mtu );
448
+
412
449
fd_topo_link_t const * in_link = & topo -> links [ tile -> in_link_id [ 0UL ] ];
413
450
fd_topo_wksp_t const * in_wksp = & topo -> workspaces [ topo -> objs [ in_link -> dcache_obj_id ].wksp_id ];
414
451
ctx -> in .wksp = in_wksp -> wksp ;;
0 commit comments