LCOV - code coverage report
Current view: top level - discof/restore - fd_snapla_tile.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 275 0.0 %
Date: 2026-03-19 18:19:27 Functions: 0 14 0.0 %

          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 "../../ballet/lthash/fd_lthash_adder.h"
       5             : 
       6             : #include "generated/fd_snapla_tile_seccomp.h"
       7             : 
       8             : #include "utils/fd_ssctrl.h"
       9             : #include "utils/fd_ssparse.h"
      10             : #include "utils/fd_ssmanifest_parser.h"
      11             : 
      12             : #define NAME "snapla"
      13             : 
      14           0 : #define FD_SNAPLA_OUT_CTRL 0UL
      15             : 
      16             : struct fd_snapla_tile {
      17             :   int state;
      18             :   int full;
      19             : 
      20             :   ulong seed;
      21             :   int   hash_account;
      22             :   ulong num_hash_tiles;
      23             :   ulong hash_tile_idx;
      24             :   ulong accounts_seen;
      25             : 
      26             :   fd_lthash_adder_t adder[1];
      27             :   uchar             data[ FD_RUNTIME_ACC_SZ_MAX ];
      28             :   ulong             acc_data_sz;
      29             : 
      30             :   fd_ssparse_t *           ssparse;
      31             :   fd_ssmanifest_parser_t * manifest_parser;
      32             :   fd_lthash_value_t        running_lthash;
      33             : 
      34             :   struct {
      35             :     uchar pubkey[ FD_HASH_FOOTPRINT ];
      36             :     uchar owner[ FD_HASH_FOOTPRINT ];
      37             :     ulong data_len;
      38             :     ulong lamports;
      39             :     int   executable;
      40             :   } account_hdr;
      41             : 
      42             :   struct {
      43             :     struct {
      44             :       ulong accounts_hashed;
      45             :     } full;
      46             : 
      47             :     struct {
      48             :       ulong accounts_hashed;
      49             :     } incremental;
      50             :   } metrics;
      51             : 
      52             :   struct {
      53             :     fd_wksp_t * wksp;
      54             :     ulong       chunk0;
      55             :     ulong       wmark;
      56             :     ulong       mtu;
      57             :     ulong       pos;
      58             :   } in;
      59             : 
      60             :   struct {
      61             :     fd_wksp_t * wksp;
      62             :     ulong       chunk0;
      63             :     ulong       wmark;
      64             :     ulong       chunk;
      65             :     ulong       mtu;
      66             :   } out;
      67             : 
      68             :   fd_snapshot_manifest_t manifest[1];
      69             : };
      70             : 
      71             : typedef struct fd_snapla_tile fd_snapla_tile_t;
      72             : 
      73             : static inline int
      74           0 : should_shutdown( fd_snapla_tile_t * ctx ) {
      75           0 :   return ctx->state==FD_SNAPSHOT_STATE_SHUTDOWN;
      76           0 : }
      77             : 
      78             : static ulong
      79           0 : scratch_align( void ) {
      80           0 :   return fd_ulong_max( alignof(fd_snapla_tile_t),
      81           0 :                        fd_ulong_max( fd_ssparse_align(), fd_ssmanifest_parser_align() ) );
      82           0 : }
      83             : 
      84             : static ulong
      85           0 : scratch_footprint( fd_topo_tile_t const * tile ) {
      86           0 :   (void)tile;
      87           0 :   ulong l = FD_LAYOUT_INIT;
      88           0 :   l = FD_LAYOUT_APPEND( l, alignof(fd_snapla_tile_t),    sizeof(fd_snapla_tile_t)         );
      89           0 :   l = FD_LAYOUT_APPEND( l, fd_ssparse_align(),           fd_ssparse_footprint( 1UL<<24UL ) );
      90           0 :   l = FD_LAYOUT_APPEND( l, fd_ssmanifest_parser_align(), fd_ssmanifest_parser_footprint()  );
      91           0 :   return FD_LAYOUT_FINI( l, alignof(fd_snapla_tile_t) );
      92           0 : }
      93             : 
      94             : static void
      95           0 : metrics_write( fd_snapla_tile_t * ctx ) {
      96           0 :   FD_MGAUGE_SET( SNAPLA, FULL_ACCOUNTS_HASHED,        ctx->metrics.full.accounts_hashed );
      97           0 :   FD_MGAUGE_SET( SNAPLA, INCREMENTAL_ACCOUNTS_HASHED, ctx->metrics.incremental.accounts_hashed );
      98           0 :   FD_MGAUGE_SET( SNAPLA, STATE,                       (ulong)(ctx->state) );
      99           0 : }
     100             : 
     101             : static void
     102             : transition_malformed( fd_snapla_tile_t *  ctx,
     103           0 :                       fd_stem_context_t * stem ) {
     104           0 :   if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) return;
     105           0 :   ctx->state = FD_SNAPSHOT_STATE_ERROR;
     106           0 :   fd_stem_publish( stem, FD_SNAPLA_OUT_CTRL, FD_SNAPSHOT_MSG_CTRL_ERROR, 0UL, 0UL, 0UL, 0UL, 0UL );
     107           0 : }
     108             : 
     109             : static int
     110           0 : should_hash_account( fd_snapla_tile_t * ctx ) {
     111           0 :   return ctx->accounts_seen%ctx->num_hash_tiles==ctx->hash_tile_idx;
     112           0 : }
     113             : 
     114             : static void
     115             : streamlined_hash( fd_snapla_tile_t * ctx,
     116           0 :                   uchar const *      frame ) {
     117           0 :   ulong data_len   = fd_ulong_load_8_fast( frame+0x08UL );
     118           0 :   uchar pubkey[32];  memcpy( pubkey, frame+0x10UL, 32UL );
     119           0 :   ulong lamports   = fd_ulong_load_8_fast( frame+0x30UL );
     120           0 :   ulong rent_epoch = fd_ulong_load_8_fast( frame+0x38UL ); (void)rent_epoch;
     121           0 :   uchar owner[32];   memcpy( owner, frame+0x40UL, 32UL );
     122           0 :   _Bool executable = !!frame[ 0x60UL ];
     123             : 
     124           0 :   if( FD_UNLIKELY( data_len > FD_RUNTIME_ACC_SZ_MAX ) ) FD_LOG_ERR(( "Found unusually large account (data_sz=%lu), aborting", data_len ));
     125           0 :   if( FD_UNLIKELY( lamports==0UL ) ) return;
     126             : 
     127           0 :   uchar executable_flag = executable & 0x1;
     128             : 
     129           0 :   fd_lthash_adder_push_solana_account( ctx->adder,
     130           0 :                                        &ctx->running_lthash,
     131           0 :                                        pubkey,
     132           0 :                                        frame+0x88UL,
     133           0 :                                        data_len,
     134           0 :                                        lamports,
     135           0 :                                        executable_flag,
     136           0 :                                        owner );
     137             : 
     138           0 :   if( FD_LIKELY( ctx->full ) ) ctx->metrics.full.accounts_hashed++;
     139           0 :   else                         ctx->metrics.incremental.accounts_hashed++;
     140           0 : }
     141             : 
     142             : static int
     143             : handle_data_frag( fd_snapla_tile_t *  ctx,
     144             :                   ulong               chunk,
     145             :                   ulong               sig,
     146             :                   ulong               sz,
     147           0 :                   fd_stem_context_t * stem ) {
     148           0 :   if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_FINISHING ) ) {
     149           0 :     FD_LOG_WARNING(( "received data fragment while in finishing state" ));
     150           0 :     transition_malformed( ctx, stem );
     151           0 :     return 0;
     152           0 :   } else if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) {
     153             :     /* Ignore all data frags after observing an error in the stream until
     154             :        we receive fail & init control messages to restart processing. */
     155           0 :     return 0;
     156           0 :   } else if( FD_UNLIKELY( ctx->state!=FD_SNAPSHOT_STATE_PROCESSING ) ) {
     157           0 :     FD_LOG_ERR(( "received unexpected data frag %s (%lu) in state %s (%lu)",
     158           0 :                  fd_ssctrl_msg_ctrl_str( sig ), sig,
     159           0 :                  fd_ssctrl_state_str( (ulong)ctx->state ), (ulong)ctx->state ));
     160           0 :   }
     161             : 
     162           0 :   FD_TEST( chunk>=ctx->in.chunk0 && chunk<=ctx->in.wmark && sz<=ctx->in.mtu );
     163             : 
     164           0 :   for(;;) {
     165           0 :     if( FD_UNLIKELY( sz-ctx->in.pos==0UL ) ) break;
     166           0 :     uchar const * data = (uchar const *)fd_chunk_to_laddr_const( ctx->in.wksp, chunk ) + ctx->in.pos;
     167             : 
     168           0 :     fd_ssparse_advance_result_t result[1];
     169           0 :     int res = fd_ssparse_advance( ctx->ssparse, data, sz-ctx->in.pos, result );
     170           0 :     switch( res ) {
     171           0 :       case FD_SSPARSE_ADVANCE_ERROR:
     172           0 :         FD_LOG_WARNING(( "error while parsing snapshot stream" ));
     173           0 :         transition_malformed( ctx, stem );
     174           0 :         return 0;
     175           0 :       case FD_SSPARSE_ADVANCE_AGAIN:
     176           0 :         break;
     177           0 :       case FD_SSPARSE_ADVANCE_STATUS_CACHE:
     178             :         /* ignore */
     179           0 :         break;
     180           0 :       case FD_SSPARSE_ADVANCE_MANIFEST: {
     181           0 :         int res = fd_ssmanifest_parser_consume( ctx->manifest_parser,
     182           0 :           result->manifest.data,
     183           0 :           result->manifest.data_sz,
     184           0 :           result->manifest.acc_vec_map,
     185           0 :           result->manifest.acc_vec_pool );
     186           0 :         if( FD_UNLIKELY( res==FD_SSMANIFEST_PARSER_ADVANCE_ERROR ) ) {
     187           0 :           FD_LOG_WARNING(( "error while parsing snapshot manifest" ));
     188           0 :           transition_malformed( ctx, stem );
     189           0 :           return 0;
     190           0 :         }
     191           0 :         break;
     192           0 :       }
     193           0 :       case FD_SSPARSE_ADVANCE_ACCOUNT_HEADER:
     194           0 :         if( FD_LIKELY( should_hash_account( ctx ) && result->account_header.lamports!=0UL ) ) {
     195           0 :           FD_TEST( ctx->acc_data_sz==0UL );
     196           0 :           ctx->hash_account = 1;
     197           0 :           fd_memcpy( ctx->account_hdr.pubkey, result->account_header.pubkey, FD_HASH_FOOTPRINT );
     198           0 :           fd_memcpy( ctx->account_hdr.owner,  result->account_header.owner,  FD_HASH_FOOTPRINT );
     199           0 :           ctx->account_hdr.data_len   = result->account_header.data_len;
     200           0 :           ctx->account_hdr.executable = result->account_header.executable;
     201           0 :           ctx->account_hdr.lamports   = result->account_header.lamports;
     202           0 :         }
     203           0 :         ctx->accounts_seen++;
     204           0 :         break;
     205           0 :       case FD_SSPARSE_ADVANCE_ACCOUNT_DATA:
     206           0 :         if( FD_LIKELY( ctx->hash_account ) ) {
     207           0 :           fd_memcpy( ctx->data + ctx->acc_data_sz, result->account_data.data, result->account_data.data_sz );
     208           0 :           ctx->acc_data_sz += result->account_data.data_sz;
     209           0 :         }
     210           0 :         break;
     211           0 :       case FD_SSPARSE_ADVANCE_ACCOUNT_BATCH: {
     212           0 :         for( ulong i=0UL; i<result->account_batch.batch_cnt; i++ ) {
     213           0 :           if( FD_LIKELY( should_hash_account( ctx ) ) ) streamlined_hash( ctx, result->account_batch.batch[ i ] );
     214           0 :           ctx->accounts_seen++;
     215           0 :         }
     216           0 :         break;
     217           0 :       }
     218           0 :       case FD_SSPARSE_ADVANCE_DONE:
     219           0 :         ctx->state = FD_SNAPSHOT_STATE_FINISHING;
     220           0 :         break;
     221           0 :       default:
     222           0 :         FD_LOG_ERR(( "unexpected fd_ssparse_advance result %d", res ));
     223           0 :         break;
     224           0 :     }
     225             : 
     226           0 :     ctx->in.pos += result->bytes_consumed;
     227           0 :     if( FD_LIKELY( ctx->hash_account && ctx->acc_data_sz==ctx->account_hdr.data_len ) ) {
     228           0 :       fd_lthash_adder_push_solana_account( ctx->adder,
     229           0 :                                            &ctx->running_lthash,
     230           0 :                                            ctx->account_hdr.pubkey,
     231           0 :                                            ctx->data,
     232           0 :                                            ctx->account_hdr.data_len,
     233           0 :                                            ctx->account_hdr.lamports,
     234           0 :                                            (uchar)ctx->account_hdr.executable,
     235           0 :                                            ctx->account_hdr.owner );
     236           0 :       ctx->acc_data_sz  = 0UL;
     237           0 :       ctx->hash_account = 0;
     238             : 
     239           0 :       if( FD_LIKELY( ctx->full ) ) ctx->metrics.full.accounts_hashed++;
     240           0 :       else                         ctx->metrics.incremental.accounts_hashed++;
     241           0 :     }
     242           0 :   }
     243             : 
     244           0 :   int reprocess_frag = ctx->in.pos<sz;
     245           0 :   if( FD_LIKELY( !reprocess_frag ) ) ctx->in.pos = 0UL;
     246           0 :   return reprocess_frag;
     247           0 : }
     248             : 
     249             : static void
     250             : handle_control_frag( fd_snapla_tile_t *  ctx,
     251             :                      fd_stem_context_t *  stem,
     252           0 :                      ulong                sig ) {
     253           0 :   if( ctx->state==FD_SNAPSHOT_STATE_ERROR && sig!=FD_SNAPSHOT_MSG_CTRL_FAIL ) {
     254             :     /* Control messages move along the snapshot load pipeline.  Since
     255             :        error conditions can be triggered by any tile in the pipeline,
     256             :        it is possible to be in error state and still receive otherwise
     257             :        valid messages.  Only a fail message can revert this. */
     258           0 :     return;
     259           0 :   };
     260             : 
     261           0 :   switch( sig ) {
     262           0 :     case FD_SNAPSHOT_MSG_CTRL_INIT_FULL:
     263           0 :     case FD_SNAPSHOT_MSG_CTRL_INIT_INCR: {
     264           0 :       FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
     265           0 :       ctx->full          = sig==FD_SNAPSHOT_MSG_CTRL_INIT_FULL;
     266           0 :       ctx->state         = FD_SNAPSHOT_STATE_PROCESSING;
     267           0 :       ctx->accounts_seen = 0UL;
     268           0 :       ctx->hash_account  = 0;
     269           0 :       ctx->acc_data_sz   = 0UL;
     270           0 :       fd_memset( &ctx->account_hdr, 0, sizeof(ctx->account_hdr) );
     271           0 :       fd_lthash_zero( &ctx->running_lthash );
     272           0 :       fd_ssparse_reset( ctx->ssparse );
     273           0 :       fd_ssmanifest_parser_init( ctx->manifest_parser, ctx->manifest );
     274           0 :       fd_lthash_adder_new( ctx->adder );
     275           0 :       if( ctx->full ) ctx->metrics.full.accounts_hashed = 0UL;
     276           0 :       ctx->metrics.incremental.accounts_hashed = 0UL;
     277           0 :       break;
     278           0 :     }
     279             : 
     280           0 :     case FD_SNAPSHOT_MSG_CTRL_FINI: {
     281             :       /* This is a special case: handle_data_frag must have already
     282             :          processed FD_SSPARSE_ADVANCE_DONE and moved the state into
     283             :          FD_SNAPSHOT_STATE_FINISHING. */
     284           0 :       FD_TEST( ctx->state==FD_SNAPSHOT_STATE_FINISHING );
     285           0 :       ctx->state = FD_SNAPSHOT_STATE_FINISHING;
     286           0 :       fd_lthash_adder_flush( ctx->adder, &ctx->running_lthash );
     287           0 :       uchar * lthash_out = fd_chunk_to_laddr( ctx->out.wksp, ctx->out.chunk );
     288           0 :       fd_memcpy( lthash_out, &ctx->running_lthash, sizeof(fd_lthash_value_t) );
     289           0 :       fd_stem_publish( stem, 0UL, FD_SNAPSHOT_HASH_MSG_RESULT_ADD, ctx->out.chunk, FD_LTHASH_LEN_BYTES, 0UL, 0UL, 0UL );
     290           0 :       ctx->out.chunk = fd_dcache_compact_next( ctx->out.chunk, FD_LTHASH_LEN_BYTES, ctx->out.chunk0, ctx->out.wmark );
     291           0 :       break;
     292           0 :     }
     293             : 
     294           0 :     case FD_SNAPSHOT_MSG_CTRL_NEXT:
     295           0 :     case FD_SNAPSHOT_MSG_CTRL_DONE: {
     296           0 :       FD_TEST( ctx->state==FD_SNAPSHOT_STATE_FINISHING );
     297           0 :       ctx->state = FD_SNAPSHOT_STATE_IDLE;
     298           0 :       break;
     299           0 :     }
     300             : 
     301           0 :     case FD_SNAPSHOT_MSG_CTRL_ERROR: {
     302           0 :       FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
     303           0 :       ctx->state = FD_SNAPSHOT_STATE_ERROR;
     304           0 :       break;
     305           0 :     }
     306             : 
     307           0 :     case FD_SNAPSHOT_MSG_CTRL_FAIL: {
     308           0 :       FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
     309           0 :       ctx->state = FD_SNAPSHOT_STATE_IDLE;
     310           0 :       break;
     311           0 :     }
     312             : 
     313           0 :     case FD_SNAPSHOT_MSG_CTRL_SHUTDOWN: {
     314           0 :       FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
     315           0 :       ctx->state = FD_SNAPSHOT_STATE_SHUTDOWN;
     316           0 :       break;
     317           0 :     }
     318             : 
     319           0 :     default: {
     320           0 :       FD_LOG_ERR(( "unexpected control frag %s (%lu) in state %s (%lu)",
     321           0 :                    fd_ssctrl_msg_ctrl_str( sig ), sig,
     322           0 :                    fd_ssctrl_state_str( (ulong)ctx->state ), (ulong)ctx->state ));
     323           0 :       break;
     324           0 :     }
     325           0 :   }
     326             : 
     327             :   /* Forward the control message down the pipeline */
     328           0 :   fd_stem_publish( stem, FD_SNAPLA_OUT_CTRL, sig, 0UL, 0UL, 0UL, 0UL, 0UL );
     329           0 : }
     330             : 
     331             : static inline int
     332             : returnable_frag( fd_snapla_tile_t *  ctx,
     333             :                  ulong                in_idx FD_PARAM_UNUSED,
     334             :                  ulong                seq    FD_PARAM_UNUSED,
     335             :                  ulong                sig,
     336             :                  ulong                chunk,
     337             :                  ulong                sz,
     338             :                  ulong                ctl    FD_PARAM_UNUSED,
     339             :                  ulong                tsorig FD_PARAM_UNUSED,
     340             :                  ulong                tspub  FD_PARAM_UNUSED,
     341           0 :                  fd_stem_context_t *  stem ) {
     342           0 :   FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
     343             : 
     344           0 :   if( FD_UNLIKELY( sig==FD_SNAPSHOT_MSG_DATA ) ) return handle_data_frag( ctx, chunk, sig, sz, stem );
     345           0 :   else                                           handle_control_frag( ctx, stem, sig );
     346             : 
     347           0 :   return 0;
     348           0 : }
     349             : 
     350             : static ulong
     351             : populate_allowed_fds( fd_topo_t      const * topo FD_PARAM_UNUSED,
     352             :                       fd_topo_tile_t const * tile FD_PARAM_UNUSED,
     353             :                       ulong                  out_fds_cnt,
     354           0 :                       int *                  out_fds ) {
     355           0 :   if( FD_UNLIKELY( out_fds_cnt<2UL ) ) FD_LOG_ERR(( "out_fds_cnt %lu", out_fds_cnt ));
     356             : 
     357           0 :   ulong out_cnt = 0;
     358           0 :   out_fds[ out_cnt++ ] = 2UL; /* stderr */
     359           0 :   if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) ) {
     360           0 :     out_fds[ out_cnt++ ] = fd_log_private_logfile_fd(); /* logfile */
     361           0 :   }
     362             : 
     363           0 :   return out_cnt;
     364           0 : }
     365             : 
     366             : static ulong
     367             : populate_allowed_seccomp( fd_topo_t const *      topo FD_PARAM_UNUSED,
     368             :                           fd_topo_tile_t const * tile FD_PARAM_UNUSED,
     369             :                           ulong                  out_cnt,
     370           0 :                           struct sock_filter *   out ) {
     371           0 :   populate_sock_filter_policy_fd_snapla_tile( out_cnt, out, (uint)fd_log_private_logfile_fd() );
     372           0 :   return sock_filter_policy_fd_snapla_tile_instr_cnt;
     373           0 : }
     374             : 
     375             : static void
     376             : privileged_init( fd_topo_t *      topo,
     377           0 :                  fd_topo_tile_t * tile ) {
     378           0 :   void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
     379             : 
     380           0 :   FD_SCRATCH_ALLOC_INIT( l, scratch );
     381           0 :   fd_snapla_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapla_tile_t), sizeof(fd_snapla_tile_t) );
     382             : 
     383           0 :   FD_TEST( fd_rng_secure( &ctx->seed, 8UL ) );
     384           0 : }
     385             : 
     386             : static void
     387             : unprivileged_init( fd_topo_t *      topo,
     388           0 :                    fd_topo_tile_t * tile ) {
     389           0 :   void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
     390             : 
     391           0 :   FD_SCRATCH_ALLOC_INIT( l, scratch );
     392           0 :   fd_snapla_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapla_tile_t),   sizeof(fd_snapla_tile_t)        );
     393           0 :   void * _ssparse         = FD_SCRATCH_ALLOC_APPEND( l, fd_ssparse_align(),           fd_ssparse_footprint( 1UL<<24UL ));
     394           0 :   void * _manifest_parser = FD_SCRATCH_ALLOC_APPEND( l, fd_ssmanifest_parser_align(), fd_ssmanifest_parser_footprint() );
     395             : 
     396           0 :   if( FD_UNLIKELY( tile->in_cnt!=1UL ) )  FD_LOG_ERR(( "tile `" NAME "` has %lu ins, expected 1",  tile->in_cnt  ));
     397           0 :   if( FD_UNLIKELY( tile->out_cnt!=1UL ) ) FD_LOG_ERR(( "tile `" NAME "` has %lu outs, expected 1", tile->out_cnt  ));
     398             : 
     399           0 :   fd_topo_link_t const * in_link = &topo->links[ tile->in_link_id[ 0UL ] ];
     400           0 :   fd_topo_wksp_t const * in_wksp = &topo->workspaces[ topo->objs[ in_link->dcache_obj_id ].wksp_id ];
     401           0 :   ctx->in.wksp                   = in_wksp->wksp;;
     402           0 :   ctx->in.chunk0                 = fd_dcache_compact_chunk0( ctx->in.wksp, in_link->dcache );
     403           0 :   ctx->in.wmark                  = fd_dcache_compact_wmark( ctx->in.wksp, in_link->dcache, in_link->mtu );
     404           0 :   ctx->in.mtu                    = in_link->mtu;
     405           0 :   ctx->in.pos                    = 0UL;
     406             : 
     407           0 :   fd_topo_link_t * out_link = &topo->links[ tile->out_link_id[ 0UL ] ];
     408           0 :   ctx->out.wksp    = topo->workspaces[ topo->objs[ out_link->dcache_obj_id ].wksp_id ].wksp;
     409           0 :   ctx->out.chunk0  = fd_dcache_compact_chunk0( fd_wksp_containing( out_link->dcache ), out_link->dcache );
     410           0 :   ctx->out.wmark   = fd_dcache_compact_wmark ( ctx->out.wksp, out_link->dcache, out_link->mtu );
     411           0 :   ctx->out.chunk   = ctx->out.chunk0;
     412           0 :   ctx->out.mtu     = out_link->mtu;
     413           0 :   FD_TEST( 0==strcmp( out_link->name, "snapla_ls" ) );
     414             : 
     415           0 :   ctx->ssparse = fd_ssparse_new( _ssparse, 1UL<<24UL, 0UL );
     416           0 :   FD_TEST( ctx->ssparse );
     417             : 
     418           0 :   ctx->manifest_parser = fd_ssmanifest_parser_join( fd_ssmanifest_parser_new( _manifest_parser ) );
     419           0 :   FD_TEST( ctx->manifest_parser );
     420             : 
     421           0 :   fd_ssparse_batch_enable( ctx->ssparse, 1 );
     422           0 :   fd_lthash_adder_new( ctx->adder );
     423           0 :   fd_ssmanifest_parser_init( ctx->manifest_parser, ctx->manifest );
     424             : 
     425           0 :   ctx->metrics.full.accounts_hashed        = 0UL;
     426           0 :   ctx->metrics.incremental.accounts_hashed = 0UL;
     427             : 
     428           0 :   ctx->state                   = FD_SNAPSHOT_STATE_IDLE;
     429           0 :   ctx->full                    = 1;
     430           0 :   ctx->acc_data_sz             = 0UL;
     431           0 :   ctx->hash_account            = 0;
     432           0 :   ctx->num_hash_tiles          = fd_topo_tile_name_cnt( topo, "snapla" );
     433           0 :   ctx->hash_tile_idx           = tile->kind_id;
     434           0 :   ctx->accounts_seen           = 0UL;
     435           0 :   fd_lthash_zero( &ctx->running_lthash );
     436           0 : }
     437             : 
     438           0 : #define STEM_BURST 2UL /* one control message and one malformed message or one hash result message */
     439           0 : #define STEM_LAZY  1000L
     440             : 
     441           0 : #define STEM_CALLBACK_CONTEXT_TYPE  fd_snapla_tile_t
     442           0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_snapla_tile_t)
     443             : 
     444             : #define STEM_CALLBACK_SHOULD_SHUTDOWN should_shutdown
     445           0 : #define STEM_CALLBACK_METRICS_WRITE   metrics_write
     446           0 : #define STEM_CALLBACK_RETURNABLE_FRAG returnable_frag
     447             : 
     448             : #include "../../disco/stem/fd_stem.c"
     449             : 
     450             : fd_topo_run_tile_t fd_tile_snapla = {
     451             :   .name                     = NAME,
     452             :   .populate_allowed_fds     = populate_allowed_fds,
     453             :   .populate_allowed_seccomp = populate_allowed_seccomp,
     454             :   .scratch_align            = scratch_align,
     455             :   .scratch_footprint        = scratch_footprint,
     456             :   .privileged_init          = privileged_init,
     457             :   .unprivileged_init        = unprivileged_init,
     458             :   .run                      = stem_run,
     459             : };
     460             : 
     461             : #undef NAME

Generated by: LCOV version 1.14