Line data Source code
1 : #include "../../disco/topo/fd_topo.h"
2 : #include "../../disco/metrics/fd_metrics.h"
3 : #include "../../ballet/lthash/fd_lthash.h"
4 : #include "../../flamenco/runtime/fd_hashes.h"
5 :
6 : #include "utils/fd_ssctrl.h"
7 :
8 : #include "generated/fd_snapls_tile_seccomp.h"
9 :
10 : #define NAME "snapls"
11 :
12 0 : #define IN_KIND_SNAPIN (0)
13 0 : #define IN_KIND_SNAPLA (1)
14 : #define MAX_IN_LINKS (1 + FD_SNAPSHOT_MAX_SNAPLA_TILES)
15 :
16 : struct fd_snapls_tile {
17 : int state;
18 : int full;
19 :
20 : fd_lthash_value_t running_lthash;
21 :
22 : struct {
23 : fd_lthash_value_t full_lthash;
24 : } recovery;
25 :
26 : fd_blake3_t b3[1];
27 : ulong acc_data_sz;
28 : int hash_account;
29 : ulong num_hash_tiles;
30 :
31 : uchar in_kind[ MAX_IN_LINKS ];
32 : ulong adder_in_offset;
33 :
34 : ulong pending_ctrl_sig;
35 : ulong num_acks;
36 : uchar acks[ 1 + FD_SNAPSHOT_MAX_SNAPLA_TILES ];
37 : int pending_ack_init;
38 :
39 : struct {
40 : fd_lthash_value_t expected_lthash;
41 : fd_lthash_value_t calculated_lthash;
42 : } hash_accum;
43 :
44 : struct {
45 : uchar pubkey[ FD_HASH_FOOTPRINT ];
46 : uchar owner[ FD_HASH_FOOTPRINT ];
47 : ulong data_len;
48 : int executable;
49 : } account_hdr;
50 :
51 : struct {
52 : struct {
53 : ulong accounts_hashed;
54 : } full;
55 :
56 : struct {
57 : ulong accounts_hashed;
58 : } incremental;
59 : } metrics;
60 :
61 : struct {
62 : fd_wksp_t * wksp;
63 : ulong chunk0;
64 : ulong wmark;
65 : ulong mtu;
66 : ulong pos;
67 : } in;
68 :
69 : struct {
70 : fd_wksp_t * wksp;
71 : ulong chunk0;
72 : ulong wmark;
73 : ulong mtu;
74 : } adder_in[ FD_SNAPSHOT_MAX_SNAPLA_TILES ];
75 : };
76 :
77 : typedef struct fd_snapls_tile fd_snapls_tile_t;
78 :
79 : static inline int
80 0 : should_shutdown( fd_snapls_tile_t * ctx ) {
81 0 : return ctx->state==FD_SNAPSHOT_STATE_SHUTDOWN;
82 0 : }
83 :
84 : static ulong
85 0 : scratch_align( void ) {
86 0 : return alignof(fd_snapls_tile_t);
87 0 : }
88 :
89 : static ulong
90 0 : scratch_footprint( fd_topo_tile_t const * tile ) {
91 0 : (void)tile;
92 0 : ulong l = FD_LAYOUT_INIT;
93 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_snapls_tile_t), sizeof(fd_snapls_tile_t) );
94 0 : return FD_LAYOUT_FINI( l, alignof(fd_snapls_tile_t) );
95 0 : }
96 :
97 : static void
98 0 : metrics_write( fd_snapls_tile_t * ctx ) {
99 0 : FD_MGAUGE_SET( SNAPLS, FULL_ACCOUNTS_HASHED, ctx->metrics.full.accounts_hashed );
100 0 : FD_MGAUGE_SET( SNAPLS, INCREMENTAL_ACCOUNTS_HASHED, ctx->metrics.incremental.accounts_hashed );
101 0 : FD_MGAUGE_SET( SNAPLS, STATE, (ulong)(ctx->state) );
102 0 : }
103 :
104 : static void
105 : transition_malformed( fd_snapls_tile_t * ctx,
106 0 : fd_stem_context_t * stem ) {
107 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) return;
108 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
109 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_ERROR, 0UL, 0UL, 0UL, 0UL, 0UL );
110 0 : }
111 :
112 : static void
113 : handle_data_frag( fd_snapls_tile_t * ctx,
114 : ulong sig,
115 : ulong chunk,
116 0 : ulong sz ) {
117 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) return;
118 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_PROCESSING );
119 :
120 0 : switch( sig ) {
121 0 : case FD_SNAPSHOT_HASH_MSG_SUB: {
122 0 : fd_snapshot_full_account_t const * prev_acc = fd_chunk_to_laddr_const( ctx->in.wksp, chunk );
123 :
124 0 : fd_lthash_value_t prev_lthash[1];
125 0 : fd_hashes_account_lthash_simple( prev_acc->hdr.pubkey,
126 0 : prev_acc->hdr.owner,
127 0 : prev_acc->hdr.lamports,
128 0 : prev_acc->hdr.executable,
129 0 : prev_acc->data,
130 0 : prev_acc->hdr.data_len,
131 0 : prev_lthash );
132 0 : fd_lthash_add( &ctx->running_lthash, prev_lthash );
133 :
134 0 : if( FD_LIKELY( ctx->full ) ) ctx->metrics.full.accounts_hashed++;
135 0 : else ctx->metrics.incremental.accounts_hashed++;
136 0 : break;
137 0 : }
138 0 : case FD_SNAPSHOT_HASH_MSG_SUB_HDR: {
139 0 : fd_snapshot_account_hdr_t const * acc = fd_chunk_to_laddr_const( ctx->in.wksp, chunk );
140 :
141 0 : if( acc->lamports!=0UL ) {
142 0 : ctx->hash_account = 1;
143 0 : fd_blake3_init( ctx->b3 );
144 0 : fd_blake3_append( ctx->b3, &acc->lamports, sizeof(ulong) );
145 0 : ctx->account_hdr.data_len = acc->data_len;
146 0 : ctx->account_hdr.executable = acc->executable;
147 0 : memcpy( ctx->account_hdr.owner, acc->owner, FD_HASH_FOOTPRINT );
148 0 : memcpy( ctx->account_hdr.pubkey, acc->pubkey, FD_HASH_FOOTPRINT );
149 0 : }
150 0 : break;
151 0 : }
152 0 : case FD_SNAPSHOT_HASH_MSG_SUB_DATA: {
153 0 : if( FD_LIKELY( !ctx->hash_account ) ) break;
154 :
155 0 : uchar const * acc_data = fd_chunk_to_laddr_const( ctx->in.wksp, chunk );
156 0 : fd_blake3_append( ctx->b3, acc_data, sz );
157 0 : ctx->acc_data_sz += sz;
158 0 : break;
159 0 : }
160 0 : default:
161 0 : FD_LOG_ERR(( "unexpected sig %lu in handle_data_frag", sig ));
162 0 : return;
163 0 : }
164 :
165 0 : if( FD_LIKELY( ctx->hash_account && ctx->acc_data_sz==ctx->account_hdr.data_len ) ) {
166 0 : fd_lthash_value_t account_lthash[1];
167 0 : fd_lthash_zero( account_lthash );
168 :
169 0 : uchar executable_flag = ctx->account_hdr.executable & 0x1;
170 0 : fd_blake3_append( ctx->b3, &executable_flag, sizeof(uchar) );
171 0 : fd_blake3_append( ctx->b3, ctx->account_hdr.owner, FD_HASH_FOOTPRINT );
172 0 : fd_blake3_append( ctx->b3, ctx->account_hdr.pubkey, FD_HASH_FOOTPRINT );
173 0 : fd_blake3_fini_2048( ctx->b3, account_lthash->bytes );
174 0 : fd_lthash_add( &ctx->running_lthash, account_lthash );
175 :
176 0 : ctx->acc_data_sz = 0UL;
177 0 : ctx->hash_account = 0;
178 :
179 0 : if( FD_LIKELY( ctx->full ) ) ctx->metrics.full.accounts_hashed++;
180 0 : else ctx->metrics.incremental.accounts_hashed++;
181 0 : }
182 0 : }
183 :
184 : static int
185 : recv_acks( fd_snapls_tile_t * ctx,
186 : ulong in_idx,
187 0 : ulong sig ) {
188 0 : if( FD_UNLIKELY( !ctx->pending_ctrl_sig ) ) {
189 0 : ctx->pending_ctrl_sig = sig;
190 0 : ctx->num_acks = 0UL;
191 0 : fd_memset( ctx->acks, 0, sizeof(ctx->acks) );
192 0 : } else FD_TEST( ctx->pending_ctrl_sig==sig );
193 :
194 0 : FD_TEST( ctx->acks[ in_idx ]==0 );
195 0 : ctx->acks[ in_idx ] = 1;
196 0 : ctx->num_acks++;
197 :
198 0 : FD_TEST( ctx->num_acks<=1UL+ctx->num_hash_tiles );
199 0 : if( FD_LIKELY( ctx->num_acks<1UL+ctx->num_hash_tiles ) ) return 0;
200 :
201 0 : ctx->pending_ctrl_sig = 0UL;
202 0 : ctx->num_acks = 0UL;
203 0 : fd_memset( ctx->acks, 0, sizeof(ctx->acks) );
204 0 : return 1;
205 0 : }
206 :
207 : static void
208 : handle_control_frag( fd_snapls_tile_t * ctx,
209 : fd_stem_context_t * stem,
210 : ulong sig,
211 0 : ulong in_idx ) {
212 0 : if( ctx->state==FD_SNAPSHOT_STATE_ERROR && sig!=FD_SNAPSHOT_MSG_CTRL_FAIL ) {
213 : /* Control messages move along the snapshot load pipeline. Since
214 : error conditions can be triggered by any tile in the pipeline,
215 : it is possible to be in error state and still receive otherwise
216 : valid messages. Only a fail message can revert this. */
217 0 : return;
218 0 : };
219 :
220 0 : int forward_msg = 1;
221 :
222 0 : switch( sig ) {
223 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_FULL:
224 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_INCR: {
225 0 : ulong num_acks = ctx->num_acks;
226 0 : forward_msg = recv_acks( ctx, in_idx, sig ); /* returns 0 or 1 */
227 : /* The first data frag may be received before snapls has been
228 : able to process the ack from every hash tile. This requires
229 : snapls to initialize and transition into processing state
230 : once, but forward the message after processing all acks. */
231 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_PROCESSING ) ) {
232 : /* Processing state is only allowed with a pending ack on init.
233 : Once the message is forwarded, init is completed. */
234 0 : FD_TEST( ctx->pending_ack_init );
235 0 : ctx->pending_ack_init = !forward_msg;
236 0 : break;
237 0 : }
238 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
239 0 : FD_TEST( !num_acks );
240 0 : ctx->state = FD_SNAPSHOT_STATE_PROCESSING;
241 0 : ctx->full = sig==FD_SNAPSHOT_MSG_CTRL_INIT_FULL;
242 0 : ctx->hash_account = 0;
243 0 : ctx->acc_data_sz = 0UL;
244 0 : fd_lthash_zero( &ctx->running_lthash );
245 0 : if( sig==FD_SNAPSHOT_MSG_CTRL_INIT_FULL ) {
246 0 : fd_lthash_zero( &ctx->hash_accum.calculated_lthash );
247 0 : fd_lthash_zero( &ctx->recovery.full_lthash );
248 0 : } else {
249 : /* The lthash for the incremental snapshot is computed starting
250 : from the full snapshot lthash. Since an init message may
251 : be received after a fail message, always start from the
252 : recovery value. */
253 0 : ctx->hash_accum.calculated_lthash = ctx->recovery.full_lthash;
254 0 : }
255 0 : ctx->pending_ack_init = !forward_msg;
256 0 : break;
257 0 : }
258 :
259 0 : case FD_SNAPSHOT_MSG_CTRL_FINI: {
260 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_PROCESSING );
261 0 : if( !recv_acks( ctx, in_idx, sig ) ) { forward_msg = 0; break; }
262 0 : ctx->state = FD_SNAPSHOT_STATE_FINISHING;
263 0 : fd_lthash_sub( &ctx->hash_accum.calculated_lthash, &ctx->running_lthash );
264 0 : if( FD_UNLIKELY( memcmp( &ctx->hash_accum.expected_lthash, &ctx->hash_accum.calculated_lthash, sizeof(fd_lthash_value_t) ) ) ) {
265 : /* SnapshotError::MismatchedHash
266 : https://github.com/anza-xyz/agave/blob/v3.1.8/runtime/src/snapshot_bank_utils.rs#L479 */
267 0 : FD_LOG_WARNING(( "calculated accounts lthash %s does not match accounts lthash %s in snapshot manifest",
268 0 : FD_LTHASH_ENC_32_ALLOCA( &ctx->hash_accum.calculated_lthash ),
269 0 : FD_LTHASH_ENC_32_ALLOCA( &ctx->hash_accum.expected_lthash ) ));
270 0 : transition_malformed( ctx, stem );
271 0 : forward_msg = 0;
272 0 : break;
273 0 : } else {
274 0 : FD_LOG_INFO(( "calculated accounts lthash %s matches accounts lthash %s in snapshot manifest",
275 0 : FD_LTHASH_ENC_32_ALLOCA( &ctx->hash_accum.calculated_lthash ),
276 0 : FD_LTHASH_ENC_32_ALLOCA( &ctx->hash_accum.expected_lthash ) ));
277 0 : }
278 0 : break;
279 0 : }
280 :
281 0 : case FD_SNAPSHOT_MSG_CTRL_NEXT:
282 0 : case FD_SNAPSHOT_MSG_CTRL_DONE: {
283 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_FINISHING );
284 0 : if( !recv_acks( ctx, in_idx, sig ) ) { forward_msg = 0; break; }
285 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
286 : /* back up full_lthash for future recovery. */
287 0 : if( sig==FD_SNAPSHOT_MSG_CTRL_NEXT ) {
288 0 : ctx->recovery.full_lthash = ctx->hash_accum.calculated_lthash;
289 0 : }
290 0 : break;
291 0 : }
292 :
293 0 : case FD_SNAPSHOT_MSG_CTRL_ERROR: {
294 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
295 : /* Reset tracking for received acks because we will now be waiting
296 : for a fail control message. */
297 0 : ctx->pending_ctrl_sig = 0UL;
298 0 : ctx->num_acks = 0UL;
299 0 : fd_memset( ctx->acks, 0, sizeof(ctx->acks) );
300 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
301 0 : break;
302 0 : }
303 :
304 0 : case FD_SNAPSHOT_MSG_CTRL_FAIL: {
305 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
306 0 : if( !recv_acks( ctx, in_idx, sig ) ) { forward_msg = 0; break; }
307 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
308 0 : break;
309 0 : }
310 :
311 0 : case FD_SNAPSHOT_MSG_CTRL_SHUTDOWN: {
312 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
313 0 : if( !recv_acks( ctx, in_idx, sig ) ) { forward_msg = 0; break; }
314 0 : ctx->state = FD_SNAPSHOT_STATE_SHUTDOWN;
315 0 : break;
316 0 : }
317 :
318 0 : default: {
319 0 : FD_LOG_ERR(( "unexpected control sig %lu", sig ));
320 0 : break;
321 0 : }
322 0 : }
323 :
324 : /* Forward the control message down the pipeline */
325 0 : if( FD_LIKELY( forward_msg ) ) {
326 0 : fd_stem_publish( stem, 0UL, sig, 0UL, 0UL, 0UL, 0UL, 0UL );
327 0 : }
328 0 : }
329 :
330 : static void
331 : handle_hash_frag( fd_snapls_tile_t * ctx,
332 : ulong in_idx,
333 : ulong sig,
334 : ulong chunk,
335 0 : ulong sz ) {
336 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) return;
337 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_PROCESSING );
338 0 : switch( sig ) {
339 0 : case FD_SNAPSHOT_HASH_MSG_RESULT_ADD: {
340 0 : FD_TEST( sz==sizeof(fd_lthash_value_t) );
341 0 : fd_lthash_value_t const * result = fd_chunk_to_laddr_const( ctx->adder_in[ in_idx-ctx->adder_in_offset ].wksp, chunk );
342 0 : fd_lthash_add( &ctx->hash_accum.calculated_lthash, result );
343 0 : break;
344 0 : }
345 0 : case FD_SNAPSHOT_HASH_MSG_EXPECTED: {
346 0 : FD_TEST( sz==sizeof(fd_lthash_value_t) );
347 0 : FD_TEST( ctx->in_kind[ in_idx ]==IN_KIND_SNAPIN );
348 0 : fd_lthash_value_t const * result = fd_chunk_to_laddr_const( ctx->in.wksp, chunk );
349 0 : ctx->hash_accum.expected_lthash = *result;
350 0 : break;
351 0 : }
352 0 : default:
353 0 : FD_LOG_ERR(( "unexpected hash sig %lu", sig ));
354 0 : break;
355 0 : }
356 0 : }
357 :
358 : static inline int
359 : returnable_frag( fd_snapls_tile_t * ctx,
360 : ulong in_idx FD_PARAM_UNUSED,
361 : ulong seq FD_PARAM_UNUSED,
362 : ulong sig,
363 : ulong chunk,
364 : ulong sz,
365 : ulong ctl FD_PARAM_UNUSED,
366 : ulong tsorig FD_PARAM_UNUSED,
367 : ulong tspub FD_PARAM_UNUSED,
368 0 : fd_stem_context_t * stem ) {
369 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
370 :
371 0 : if( FD_LIKELY( sig==FD_SNAPSHOT_HASH_MSG_SUB ||
372 0 : sig==FD_SNAPSHOT_HASH_MSG_SUB_HDR ||
373 0 : sig==FD_SNAPSHOT_HASH_MSG_SUB_DATA ) ) handle_data_frag( ctx, sig, chunk, sz );
374 0 : else if( FD_LIKELY( sig==FD_SNAPSHOT_HASH_MSG_RESULT_ADD ||
375 0 : sig==FD_SNAPSHOT_HASH_MSG_EXPECTED ) ) handle_hash_frag( ctx, in_idx, sig, chunk, sz );
376 0 : else handle_control_frag( ctx, stem, sig, in_idx );
377 :
378 0 : return 0;
379 0 : }
380 :
381 : static ulong
382 : populate_allowed_fds( fd_topo_t const * topo FD_PARAM_UNUSED,
383 : fd_topo_tile_t const * tile FD_PARAM_UNUSED,
384 : ulong out_fds_cnt,
385 0 : int * out_fds ) {
386 0 : if( FD_UNLIKELY( out_fds_cnt<2UL ) ) FD_LOG_ERR(( "out_fds_cnt %lu", out_fds_cnt ));
387 :
388 0 : ulong out_cnt = 0;
389 0 : out_fds[ out_cnt++ ] = 2UL; /* stderr */
390 0 : if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) ) {
391 0 : out_fds[ out_cnt++ ] = fd_log_private_logfile_fd(); /* logfile */
392 0 : }
393 :
394 0 : return out_cnt;
395 0 : }
396 :
397 : static ulong
398 : populate_allowed_seccomp( fd_topo_t const * topo FD_PARAM_UNUSED,
399 : fd_topo_tile_t const * tile FD_PARAM_UNUSED,
400 : ulong out_cnt,
401 0 : struct sock_filter * out ) {
402 0 : populate_sock_filter_policy_fd_snapls_tile( out_cnt, out, (uint)fd_log_private_logfile_fd() );
403 0 : return sock_filter_policy_fd_snapls_tile_instr_cnt;
404 0 : }
405 :
406 : static void
407 : unprivileged_init( fd_topo_t * topo,
408 0 : fd_topo_tile_t * tile ) {
409 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
410 :
411 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
412 0 : fd_snapls_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapls_tile_t), sizeof(fd_snapls_tile_t) );
413 :
414 0 : ulong expected_in_cnt = 1UL + fd_topo_tile_name_cnt( topo, "snapla" );
415 0 : if( FD_UNLIKELY( tile->in_cnt!=expected_in_cnt ) ) FD_LOG_ERR(( "tile `" NAME "` has %lu ins, expected %lu", tile->in_cnt, expected_in_cnt ));
416 0 : if( FD_UNLIKELY( tile->out_cnt!=1UL ) ) FD_LOG_ERR(( "tile `" NAME "` has %lu outs, expected 1", tile->out_cnt ));
417 :
418 0 : ulong adder_idx = 0UL;
419 0 : for( ulong i=0UL; i<(tile->in_cnt); i++ ) {
420 0 : fd_topo_link_t * in_link = &topo->links[ tile->in_link_id[ i ] ];
421 0 : fd_topo_wksp_t const * in_wksp = &topo->workspaces[ topo->objs[ in_link->dcache_obj_id ].wksp_id ];
422 0 : if( FD_LIKELY( 0==strcmp( in_link->name, "snapin_ls" ) ) ) {
423 0 : ctx->in.wksp = in_wksp->wksp;;
424 0 : ctx->in.chunk0 = fd_dcache_compact_chunk0( ctx->in.wksp, in_link->dcache );
425 0 : ctx->in.wmark = fd_dcache_compact_wmark( ctx->in.wksp, in_link->dcache, in_link->mtu );
426 0 : ctx->in.mtu = in_link->mtu;
427 0 : ctx->in.pos = 0UL;
428 0 : ctx->in_kind[ i ] = IN_KIND_SNAPIN;
429 0 : } else if( FD_LIKELY( 0==strcmp( in_link->name, "snapla_ls" ) ) ) {
430 0 : ctx->adder_in[ adder_idx ].wksp = in_wksp->wksp;
431 0 : ctx->adder_in[ adder_idx ].chunk0 = fd_dcache_compact_chunk0( ctx->adder_in[ adder_idx ].wksp, in_link->dcache );
432 0 : ctx->adder_in[ adder_idx ].wmark = fd_dcache_compact_wmark ( ctx->adder_in[ adder_idx ].wksp, in_link->dcache, in_link->mtu );
433 0 : ctx->adder_in[ adder_idx ].mtu = in_link->mtu;
434 0 : ctx->in_kind[ i ] = IN_KIND_SNAPLA;
435 0 : if( FD_LIKELY( adder_idx==0UL ) ) ctx->adder_in_offset = i;
436 0 : adder_idx++;
437 0 : } else {
438 0 : FD_LOG_ERR(( "tile `" NAME "` has unexpected in link name `%s`", in_link->name ));
439 0 : }
440 0 : }
441 :
442 0 : fd_topo_link_t * out_link = &topo->links[ tile->out_link_id[ 0UL ] ];
443 0 : FD_TEST( 0==strcmp( out_link->name, "snapls_ct" ) );
444 :
445 0 : ctx->metrics.full.accounts_hashed = 0UL;
446 0 : ctx->metrics.incremental.accounts_hashed = 0UL;
447 :
448 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
449 0 : ctx->full = 1;
450 0 : ctx->hash_account = 0;
451 0 : ctx->acc_data_sz = 0UL;
452 0 : fd_memset( &ctx->account_hdr, 0, sizeof(ctx->account_hdr) );
453 :
454 0 : ctx->num_hash_tiles = fd_topo_tile_name_cnt( topo, "snapla" );
455 :
456 0 : ctx->pending_ctrl_sig = 0UL;
457 0 : ctx->num_acks = 0UL;
458 0 : fd_memset( ctx->acks, 0, sizeof(ctx->acks) );
459 0 : ctx->pending_ack_init = 0;
460 :
461 0 : fd_lthash_zero( &ctx->hash_accum.expected_lthash );
462 0 : fd_lthash_zero( &ctx->hash_accum.calculated_lthash );
463 0 : fd_lthash_zero( &ctx->running_lthash );
464 0 : fd_lthash_zero( &ctx->recovery.full_lthash );
465 0 : }
466 :
467 0 : #define STEM_BURST 2UL /* one control message and one malformed message */
468 0 : #define STEM_LAZY 1000L
469 :
470 0 : #define STEM_CALLBACK_CONTEXT_TYPE fd_snapls_tile_t
471 0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_snapls_tile_t)
472 :
473 : #define STEM_CALLBACK_SHOULD_SHUTDOWN should_shutdown
474 0 : #define STEM_CALLBACK_METRICS_WRITE metrics_write
475 0 : #define STEM_CALLBACK_RETURNABLE_FRAG returnable_frag
476 :
477 : #include "../../disco/stem/fd_stem.c"
478 :
479 : fd_topo_run_tile_t fd_tile_snapls = {
480 : .name = NAME,
481 : .populate_allowed_fds = populate_allowed_fds,
482 : .populate_allowed_seccomp = populate_allowed_seccomp,
483 : .scratch_align = scratch_align,
484 : .scratch_footprint = scratch_footprint,
485 : .unprivileged_init = unprivileged_init,
486 : .run = stem_run,
487 : };
488 :
489 : #undef NAME
|