Line data Source code
1 : #include "../../disco/tiles.h"
2 : #include "generated/fd_exec_tile_seccomp.h"
3 :
4 : #include "../../util/pod/fd_pod_format.h"
5 : #include "../../discof/replay/fd_exec.h"
6 : #include "../../flamenco/capture/fd_capture_ctx.h"
7 : #include "../../flamenco/runtime/fd_bank.h"
8 : #include "../../flamenco/runtime/fd_runtime.h"
9 : #include "../../flamenco/accdb/fd_accdb_impl_v1.h"
10 : #include "../../flamenco/progcache/fd_progcache_user.h"
11 : #include "../../flamenco/log_collector/fd_log_collector.h"
12 : #include "../../disco/metrics/fd_metrics.h"
13 :
14 : /* The exec tile is responsible for executing single transactions. The
15 : tile recieves a parsed transaction (fd_txn_p_t) and an identifier to
16 : which bank to execute against (index into the bank pool). With this,
17 : the exec tile is able to identify the correct bank and accounts db
18 : handle (funk_txn) to execute the transaction against. The exec tile
19 : then commits the results of the transaction to the accounts db and
20 : makes any necessary updates to the bank. */
21 :
22 : typedef struct link_ctx {
23 : ulong idx;
24 : fd_wksp_t * mem;
25 : ulong chunk;
26 : ulong chunk0;
27 : ulong wmark;
28 : } link_ctx_t;
29 :
30 : typedef struct fd_exec_tile_ctx {
31 : ulong tile_idx;
32 :
33 : /* link-related data structures. */
34 : link_ctx_t replay_in[ 1 ];
35 : link_ctx_t exec_replay_out[ 1 ]; /* TODO: Remove with solcap v2 */
36 : link_ctx_t exec_sig_out[ 1 ];
37 :
38 : fd_sha512_t sha_mem[ FD_TXN_ACTUAL_SIG_MAX ];
39 : fd_sha512_t * sha_lj[ FD_TXN_ACTUAL_SIG_MAX ];
40 :
41 : /* Capture context for debugging runtime execution. */
42 : fd_capture_ctx_t * capture_ctx;
43 : fd_capture_link_buf_t cap_exec_out[1];
44 :
45 : /* A transaction can be executed as long as there is a valid handle to
46 : a funk_txn and a bank. These are queried from fd_banks_t and
47 : fd_funk_t. */
48 : fd_banks_t * banks;
49 : fd_accdb_user_t accdb[1];
50 : fd_progcache_t progcache[1];
51 :
52 : fd_txncache_t * txncache;
53 :
54 : ulong txn_idx;
55 : ulong slot;
56 : ulong dispatch_time_comp;
57 :
58 : fd_exec_accounts_t exec_accounts;
59 : fd_log_collector_t log_collector;
60 :
61 : fd_bank_t * bank;
62 :
63 : fd_txn_in_t txn_in;
64 : fd_txn_out_t txn_out;
65 :
66 : /* tracing_mem is staging memory to dump instructions/transactions
67 : into protobuf files. tracing_mem is staging memory to output vm
68 : execution traces.
69 : TODO: This should not be compiled in prod. */
70 : uchar dumping_mem[ FD_SPAD_FOOTPRINT( 1UL<<28UL ) ] __attribute__((aligned(FD_SPAD_ALIGN)));
71 : uchar tracing_mem[ FD_MAX_INSTRUCTION_STACK_DEPTH ][ FD_RUNTIME_VM_TRACE_STATIC_FOOTPRINT ] __attribute__((aligned(FD_RUNTIME_VM_TRACE_STATIC_ALIGN)));
72 :
73 : fd_runtime_t runtime[1];
74 :
75 : } fd_exec_tile_ctx_t;
76 :
77 : FD_FN_CONST static inline ulong
78 0 : scratch_align( void ) {
79 0 : return 128UL;
80 0 : }
81 :
82 : FD_FN_PURE static inline ulong
83 0 : scratch_footprint( fd_topo_tile_t const * tile ) {
84 0 : ulong l = FD_LAYOUT_INIT;
85 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_exec_tile_ctx_t), sizeof(fd_exec_tile_ctx_t) );
86 0 : l = FD_LAYOUT_APPEND( l, fd_capture_ctx_align(), fd_capture_ctx_footprint() );
87 0 : l = FD_LAYOUT_APPEND( l, fd_txncache_align(), fd_txncache_footprint( tile->exec.max_live_slots ) );
88 0 : l = FD_LAYOUT_APPEND( l, FD_PROGCACHE_SCRATCH_ALIGN, FD_PROGCACHE_SCRATCH_FOOTPRINT );
89 0 : return FD_LAYOUT_FINI( l, scratch_align() );
90 0 : }
91 :
92 : static void
93 0 : metrics_write( fd_exec_tile_ctx_t * ctx ) {
94 0 : fd_progcache_t * progcache = ctx->progcache;
95 0 : FD_MCNT_SET( EXEC, PROGCACHE_MISSES, progcache->metrics->miss_cnt );
96 0 : FD_MCNT_SET( EXEC, PROGCACHE_HITS, progcache->metrics->hit_cnt );
97 0 : FD_MCNT_SET( EXEC, PROGCACHE_FILLS, progcache->metrics->fill_cnt );
98 0 : FD_MCNT_SET( EXEC, PROGCACHE_FILL_TOT_SZ, progcache->metrics->fill_tot_sz );
99 0 : FD_MCNT_SET( EXEC, PROGCACHE_INVALIDATIONS, progcache->metrics->invalidate_cnt );
100 0 : FD_MCNT_SET( EXEC, PROGCACHE_DUP_INSERTS, progcache->metrics->dup_insert_cnt );
101 :
102 0 : fd_accdb_user_t * accdb = ctx->accdb;
103 0 : FD_MCNT_SET( EXEC, ACCDB_CREATED, accdb->base.created_cnt );
104 0 : }
105 :
106 : /* Publish the txn finalized message to the replay tile */
107 : static void
108 : publish_txn_finalized_msg( fd_exec_tile_ctx_t * ctx,
109 0 : fd_stem_context_t * stem ) {
110 0 : fd_exec_task_done_msg_t * msg = fd_chunk_to_laddr( ctx->exec_replay_out->mem, ctx->exec_replay_out->chunk );
111 0 : msg->bank_idx = ctx->bank->idx;
112 0 : msg->txn_exec->txn_idx = ctx->txn_idx;
113 0 : msg->txn_exec->err = !ctx->txn_out.err.is_committable;
114 0 : msg->txn_exec->slot = ctx->slot;
115 0 : msg->txn_exec->start_shred_idx = ctx->txn_in.txn->start_shred_idx;
116 0 : msg->txn_exec->end_shred_idx = ctx->txn_in.txn->end_shred_idx;
117 0 : if( FD_UNLIKELY( msg->txn_exec->err ) ) {
118 0 : uchar * signature = (uchar *)ctx->txn_in.txn->payload + TXN( ctx->txn_in.txn )->signature_off;
119 0 : FD_LOG_WARNING(( "txn failed to execute, bad block detected err=%d signature=%s", ctx->txn_out.err.txn_err, FD_BASE58_ENC_64_ALLOCA( signature ) ));
120 0 : }
121 :
122 0 : fd_stem_publish( stem, ctx->exec_replay_out->idx, (FD_EXEC_TT_TXN_EXEC<<32)|ctx->tile_idx, ctx->exec_replay_out->chunk, sizeof(*msg), 0UL, ctx->dispatch_time_comp, fd_frag_meta_ts_comp( fd_tickcount() ) );
123 :
124 0 : ctx->exec_replay_out->chunk = fd_dcache_compact_next( ctx->exec_replay_out->chunk, sizeof(*msg), ctx->exec_replay_out->chunk0, ctx->exec_replay_out->wmark );
125 0 : }
126 :
127 : static inline int
128 : returnable_frag( fd_exec_tile_ctx_t * ctx,
129 : ulong in_idx,
130 : ulong seq FD_PARAM_UNUSED,
131 : ulong sig,
132 : ulong chunk,
133 : ulong sz,
134 : ulong ctl FD_PARAM_UNUSED,
135 : ulong tsorig FD_PARAM_UNUSED,
136 : ulong tspub,
137 0 : fd_stem_context_t * stem ) {
138 :
139 0 : if( (sig&0xFFFFFFFFUL)!=ctx->tile_idx ) return 0;
140 :
141 0 : if( FD_LIKELY( in_idx==ctx->replay_in->idx ) ) {
142 0 : if( FD_UNLIKELY( chunk < ctx->replay_in->chunk0 || chunk > ctx->replay_in->wmark ) ) {
143 0 : FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu]", chunk, sz, ctx->replay_in->chunk0, ctx->replay_in->wmark ));
144 0 : }
145 0 : switch( sig>>32 ) {
146 0 : case FD_EXEC_TT_TXN_EXEC: {
147 : /* Execute. */
148 0 : fd_exec_txn_exec_msg_t * msg = fd_chunk_to_laddr( ctx->replay_in->mem, chunk );
149 0 : ctx->bank = fd_banks_bank_query( ctx->banks, msg->bank_idx );
150 0 : FD_TEST( ctx->bank );
151 0 : ctx->txn_in.txn = &msg->txn;
152 0 : ctx->txn_in.exec_accounts = &ctx->exec_accounts;
153 :
154 : /* Set the capture txn index from the message so account updates
155 : during commit are recorded with the correct transaction index. */
156 0 : if( FD_UNLIKELY( ctx->capture_ctx ) ) {
157 0 : ctx->capture_ctx->current_txn_idx = msg->capture_txn_idx;
158 0 : }
159 :
160 0 : fd_runtime_prepare_and_execute_txn( ctx->runtime, ctx->bank, &ctx->txn_in, &ctx->txn_out );
161 :
162 : /* Commit. */
163 0 : if( FD_LIKELY( ctx->txn_out.err.is_committable ) ) {
164 0 : fd_runtime_commit_txn( ctx->runtime, ctx->bank, &ctx->txn_in, &ctx->txn_out );
165 0 : }
166 :
167 0 : if( FD_LIKELY( ctx->exec_sig_out->idx!=ULONG_MAX ) ) {
168 : /* Copy the txn signature to the signature out link so the
169 : dedup/pack tiles can drop already executed transactions. */
170 0 : memcpy( fd_chunk_to_laddr( ctx->exec_sig_out->mem, ctx->exec_sig_out->chunk ),
171 0 : (uchar *)ctx->txn_in.txn->payload + TXN( ctx->txn_in.txn )->signature_off,
172 0 : 64UL );
173 0 : fd_stem_publish( stem, ctx->exec_sig_out->idx, 0UL, ctx->exec_sig_out->chunk, 64UL, 0UL, 0UL, 0UL );
174 0 : ctx->exec_sig_out->chunk = fd_dcache_compact_next( ctx->exec_sig_out->chunk, 64UL, ctx->exec_sig_out->chunk0, ctx->exec_sig_out->wmark );
175 0 : }
176 :
177 : /* Notify replay. */
178 0 : ctx->txn_idx = msg->txn_idx;
179 0 : ctx->dispatch_time_comp = tspub;
180 0 : ctx->slot = fd_bank_slot_get( ctx->bank );
181 0 : publish_txn_finalized_msg( ctx, stem );
182 :
183 0 : break;
184 0 : }
185 0 : case FD_EXEC_TT_TXN_SIGVERIFY: {
186 0 : fd_exec_txn_sigverify_msg_t * msg = fd_chunk_to_laddr( ctx->replay_in->mem, chunk );
187 0 : int res = fd_executor_txn_verify( &msg->txn, ctx->sha_lj );
188 0 : fd_exec_task_done_msg_t * out_msg = fd_chunk_to_laddr( ctx->exec_replay_out->mem, ctx->exec_replay_out->chunk );
189 0 : out_msg->bank_idx = msg->bank_idx;
190 0 : out_msg->txn_sigverify->txn_idx = msg->txn_idx;
191 0 : out_msg->txn_sigverify->err = (res!=FD_RUNTIME_EXECUTE_SUCCESS);
192 0 : fd_stem_publish( stem, ctx->exec_replay_out->idx, (FD_EXEC_TT_TXN_SIGVERIFY<<32)|ctx->tile_idx, ctx->exec_replay_out->chunk, sizeof(*out_msg), 0UL, 0UL, 0UL );
193 0 : ctx->exec_replay_out->chunk = fd_dcache_compact_next( ctx->exec_replay_out->chunk, sizeof(*out_msg), ctx->exec_replay_out->chunk0, ctx->exec_replay_out->wmark );
194 0 : break;
195 0 : }
196 0 : default: FD_LOG_CRIT(( "unexpected signature %lu", sig ));
197 0 : }
198 0 : } else FD_LOG_CRIT(( "invalid in_idx %lu", in_idx ));
199 :
200 0 : return 0;
201 0 : }
202 :
203 : static void
204 : unprivileged_init( fd_topo_t * topo,
205 0 : fd_topo_tile_t * tile ) {
206 :
207 : /********************************************************************/
208 : /* validate allocations */
209 : /********************************************************************/
210 :
211 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
212 :
213 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
214 0 : fd_exec_tile_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_exec_tile_ctx_t), sizeof(fd_exec_tile_ctx_t) );
215 :
216 0 : void * capture_ctx_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_capture_ctx_align(), fd_capture_ctx_footprint() );
217 0 : void * _txncache = FD_SCRATCH_ALLOC_APPEND( l, fd_txncache_align(), fd_txncache_footprint( tile->exec.max_live_slots ) );
218 0 : uchar * pc_scratch = FD_SCRATCH_ALLOC_APPEND( l, FD_PROGCACHE_SCRATCH_ALIGN, FD_PROGCACHE_SCRATCH_FOOTPRINT );
219 0 : ulong scratch_alloc_mem = FD_SCRATCH_ALLOC_FINI( l, scratch_align() );
220 :
221 0 : if( FD_UNLIKELY( scratch_alloc_mem - (ulong)scratch - scratch_footprint( tile ) ) ) {
222 0 : FD_LOG_ERR( ( "Scratch_alloc_mem did not match scratch_footprint diff: %lu alloc: %lu footprint: %lu",
223 0 : scratch_alloc_mem - (ulong)scratch - scratch_footprint( tile ),
224 0 : scratch_alloc_mem,
225 0 : (ulong)scratch + scratch_footprint( tile ) ) );
226 0 : }
227 :
228 0 : for( ulong i=0UL; i<FD_TXN_ACTUAL_SIG_MAX; i++ ) {
229 0 : fd_sha512_t * sha = fd_sha512_join( fd_sha512_new( ctx->sha_mem+i ) );
230 0 : FD_TEST( sha );
231 0 : ctx->sha_lj[i] = sha;
232 0 : }
233 :
234 : /********************************************************************/
235 : /* validate links */
236 : /********************************************************************/
237 :
238 0 : ctx->tile_idx = tile->kind_id;
239 :
240 : /* First find and setup the in-link from replay to exec. */
241 0 : ctx->replay_in->idx = fd_topo_find_tile_in_link( topo, tile, "replay_exec", 0UL );
242 0 : FD_TEST( ctx->replay_in->idx!=ULONG_MAX );
243 0 : fd_topo_link_t * replay_in_link = &topo->links[ tile->in_link_id[ ctx->replay_in->idx ] ];
244 0 : FD_TEST( replay_in_link!=NULL );
245 0 : ctx->replay_in->mem = topo->workspaces[ topo->objs[ replay_in_link->dcache_obj_id ].wksp_id ].wksp;
246 0 : ctx->replay_in->chunk0 = fd_dcache_compact_chunk0( ctx->replay_in->mem, replay_in_link->dcache );
247 0 : ctx->replay_in->wmark = fd_dcache_compact_wmark( ctx->replay_in->mem, replay_in_link->dcache, replay_in_link->mtu );
248 0 : ctx->replay_in->chunk = ctx->replay_in->chunk0;
249 :
250 0 : ctx->exec_replay_out->idx = fd_topo_find_tile_out_link( topo, tile, "exec_replay", ctx->tile_idx );
251 0 : if( FD_LIKELY( ctx->exec_replay_out->idx!=ULONG_MAX ) ) {
252 0 : fd_topo_link_t * exec_replay_link = &topo->links[ tile->out_link_id[ ctx->exec_replay_out->idx ] ];
253 0 : ctx->exec_replay_out->mem = topo->workspaces[ topo->objs[ exec_replay_link->dcache_obj_id ].wksp_id ].wksp;
254 0 : ctx->exec_replay_out->chunk0 = fd_dcache_compact_chunk0( ctx->exec_replay_out->mem, exec_replay_link->dcache );
255 0 : ctx->exec_replay_out->wmark = fd_dcache_compact_wmark( ctx->exec_replay_out->mem, exec_replay_link->dcache, exec_replay_link->mtu );
256 0 : ctx->exec_replay_out->chunk = ctx->exec_replay_out->chunk0;
257 0 : }
258 :
259 0 : ctx->exec_sig_out->idx = fd_topo_find_tile_out_link( topo, tile, "exec_sig", ctx->tile_idx );
260 0 : if( FD_LIKELY( ctx->exec_sig_out->idx!=ULONG_MAX ) ) {
261 0 : fd_topo_link_t * exec_sig_link = &topo->links[ tile->out_link_id[ ctx->exec_sig_out->idx ] ];
262 0 : ctx->exec_sig_out->mem = topo->workspaces[ topo->objs[ exec_sig_link->dcache_obj_id ].wksp_id ].wksp;
263 0 : ctx->exec_sig_out->chunk0 = fd_dcache_compact_chunk0( ctx->exec_sig_out->mem, exec_sig_link->dcache );
264 0 : ctx->exec_sig_out->wmark = fd_dcache_compact_wmark( ctx->exec_sig_out->mem, exec_sig_link->dcache, exec_sig_link->mtu );
265 0 : ctx->exec_sig_out->chunk = ctx->exec_sig_out->chunk0;
266 0 : }
267 :
268 : /********************************************************************/
269 : /* banks */
270 : /********************************************************************/
271 :
272 0 : ulong banks_obj_id = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "banks" );
273 0 : if( FD_UNLIKELY( banks_obj_id==ULONG_MAX ) ) {
274 0 : FD_LOG_ERR(( "Could not find topology object for banks" ));
275 0 : }
276 :
277 0 : ctx->banks = fd_banks_join( fd_topo_obj_laddr( topo, banks_obj_id ) );
278 0 : if( FD_UNLIKELY( !ctx->banks ) ) {
279 0 : FD_LOG_ERR(( "Failed to join banks" ));
280 0 : }
281 :
282 0 : void * shfunk = fd_topo_obj_laddr( topo, tile->exec.funk_obj_id );
283 0 : if( FD_UNLIKELY( !fd_accdb_user_v1_init( ctx->accdb, shfunk ) ) ) {
284 0 : FD_LOG_CRIT(( "fd_accdb_user_v1_init() failed" ));
285 0 : }
286 :
287 0 : void * shprogcache = fd_topo_obj_laddr( topo, tile->exec.progcache_obj_id );
288 0 : if( FD_UNLIKELY( !fd_progcache_join( ctx->progcache, shprogcache, pc_scratch, FD_PROGCACHE_SCRATCH_FOOTPRINT ) ) ) {
289 0 : FD_LOG_CRIT(( "fd_progcache_join() failed" ));
290 0 : }
291 :
292 0 : void * _txncache_shmem = fd_topo_obj_laddr( topo, tile->exec.txncache_obj_id );
293 0 : fd_txncache_shmem_t * txncache_shmem = fd_txncache_shmem_join( _txncache_shmem );
294 0 : FD_TEST( txncache_shmem );
295 0 : ctx->txncache = fd_txncache_join( fd_txncache_new( _txncache, txncache_shmem ) );
296 0 : FD_TEST( ctx->txncache );
297 :
298 0 : ctx->txn_in.bundle.is_bundle = 0;
299 :
300 : /********************************************************************/
301 : /* Capture context */
302 : /********************************************************************/
303 :
304 0 : ctx->capture_ctx = NULL;
305 0 : if( FD_UNLIKELY( strlen( tile->exec.solcap_capture ) || strlen( tile->exec.dump_proto_dir ) ) ) {
306 :
307 0 : ulong tile_idx = tile->kind_id;
308 0 : ulong idx = fd_topo_find_tile_out_link( topo, tile, "cap_exec", tile_idx );
309 0 : FD_TEST( idx!=ULONG_MAX );
310 0 : fd_topo_link_t * link = &topo->links[ tile->out_link_id[ idx ] ];
311 0 : fd_capture_link_buf_t * cap_exec_out = ctx->cap_exec_out;
312 0 : cap_exec_out->base.vt = &fd_capture_link_buf_vt;
313 0 : cap_exec_out->idx = idx;
314 0 : cap_exec_out->mem = topo->workspaces[ topo->objs[ link->dcache_obj_id ].wksp_id ].wksp;
315 0 : cap_exec_out->chunk0 = fd_dcache_compact_chunk0( cap_exec_out->mem, link->dcache );
316 0 : cap_exec_out->wmark = fd_dcache_compact_wmark( cap_exec_out->mem, link->dcache, link->mtu );
317 0 : cap_exec_out->chunk = cap_exec_out->chunk0;
318 0 : cap_exec_out->mcache = link->mcache;
319 0 : cap_exec_out->depth = fd_mcache_depth( link->mcache );
320 0 : cap_exec_out->seq = 0UL;
321 :
322 0 : ulong consumer_tile_idx = fd_topo_find_tile(topo, "solcap", 0UL);
323 0 : fd_topo_tile_t * consumer_tile = &topo->tiles[ consumer_tile_idx ];
324 0 : cap_exec_out->fseq = NULL;
325 0 : for( ulong j = 0UL; j < consumer_tile->in_cnt; j++ ) {
326 0 : if( FD_UNLIKELY( consumer_tile->in_link_id[ j ] == link->id ) ) {
327 0 : cap_exec_out->fseq = fd_fseq_join( fd_topo_obj_laddr( topo, consumer_tile->in_link_fseq_obj_id[ j ] ) );
328 0 : FD_TEST( cap_exec_out->fseq );
329 0 : break;
330 0 : }
331 0 : }
332 :
333 0 : ctx->capture_ctx = fd_capture_ctx_join( fd_capture_ctx_new( capture_ctx_mem ) );
334 0 : ctx->capture_ctx->solcap_start_slot = tile->exec.capture_start_slot;
335 :
336 0 : if( strlen( tile->exec.dump_proto_dir ) ) {
337 0 : ctx->capture_ctx->dump_proto_output_dir = tile->exec.dump_proto_dir;
338 0 : ctx->capture_ctx->dump_proto_start_slot = tile->exec.capture_start_slot;
339 0 : ctx->capture_ctx->dump_instr_to_pb = tile->exec.dump_instr_to_pb;
340 0 : ctx->capture_ctx->dump_txn_to_pb = tile->exec.dump_txn_to_pb;
341 0 : ctx->capture_ctx->dump_syscall_to_pb = tile->exec.dump_syscall_to_pb;
342 0 : ctx->capture_ctx->dump_elf_to_pb = tile->exec.dump_elf_to_pb;
343 0 : }
344 :
345 0 : ctx->capture_ctx->capctx_type.buf = cap_exec_out;
346 0 : ctx->capture_ctx->capture_link = &cap_exec_out->base;
347 0 : }
348 :
349 : /********************************************************************/
350 : /* Runtime */
351 : /********************************************************************/
352 :
353 0 : ctx->runtime->accdb = ctx->accdb;
354 0 : ctx->runtime->funk = fd_accdb_user_v1_funk( ctx->accdb );
355 0 : ctx->runtime->progcache = ctx->progcache;
356 0 : ctx->runtime->status_cache = ctx->txncache;
357 0 : ctx->runtime->log.log_collector = &ctx->log_collector;
358 0 : ctx->runtime->log.enable_log_collector = 0;
359 0 : ctx->runtime->log.dumping_mem = ctx->dumping_mem;
360 0 : ctx->runtime->log.enable_vm_tracing = 0;
361 0 : ctx->runtime->log.tracing_mem = &ctx->tracing_mem[0][0];
362 0 : ctx->runtime->log.capture_ctx = ctx->capture_ctx;
363 0 : }
364 :
365 : static ulong
366 : populate_allowed_seccomp( fd_topo_t const * topo FD_PARAM_UNUSED,
367 : fd_topo_tile_t const * tile FD_PARAM_UNUSED,
368 : ulong out_cnt,
369 0 : struct sock_filter * out ) {
370 0 : populate_sock_filter_policy_fd_exec_tile( out_cnt, out, (uint)fd_log_private_logfile_fd() );
371 0 : return sock_filter_policy_fd_exec_tile_instr_cnt;
372 0 : }
373 :
374 : static ulong
375 : populate_allowed_fds( fd_topo_t const * topo FD_PARAM_UNUSED,
376 : fd_topo_tile_t const * tile FD_PARAM_UNUSED,
377 : ulong out_fds_cnt,
378 0 : int * out_fds ) {
379 :
380 0 : if( FD_UNLIKELY( out_fds_cnt<2UL ) ) FD_LOG_ERR(( "out_fds_cnt %lu", out_fds_cnt ));
381 :
382 0 : ulong out_cnt = 0UL;
383 0 : out_fds[ out_cnt++ ] = 2; /* stderr */
384 0 : if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) )
385 0 : out_fds[ out_cnt++ ] = fd_log_private_logfile_fd(); /* logfile */
386 0 : return out_cnt;
387 0 : }
388 :
389 0 : #define STEM_BURST (2UL)
390 : /* Right now, depth of the replay_exec link and depth of the exec_replay
391 : links is 16K. At 1M TPS, that's ~16ms to fill. But we also want to
392 : be conservative here, so we use 1ms. */
393 0 : #define STEM_LAZY (1000000UL)
394 :
395 0 : #define STEM_CALLBACK_CONTEXT_TYPE fd_exec_tile_ctx_t
396 0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_exec_tile_ctx_t)
397 :
398 0 : #define STEM_CALLBACK_RETURNABLE_FRAG returnable_frag
399 0 : #define STEM_CALLBACK_METRICS_WRITE metrics_write
400 :
401 : #include "../../disco/stem/fd_stem.c"
402 :
403 : fd_topo_run_tile_t fd_tile_execor = {
404 : .name = "exec",
405 : .loose_footprint = 0UL,
406 : .populate_allowed_seccomp = populate_allowed_seccomp,
407 : .populate_allowed_fds = populate_allowed_fds,
408 : .scratch_align = scratch_align,
409 : .scratch_footprint = scratch_footprint,
410 : .unprivileged_init = unprivileged_init,
411 : .run = stem_run,
412 : };
|