33
44#include "../../util/pod/fd_pod_format.h"
55#include "../../discof/replay/fd_exec.h"
6+ #include "../../flamenco/fd_flamenco.h"
67#include "../../flamenco/runtime/context/fd_capture_ctx.h"
78#include "../../flamenco/runtime/fd_bank.h"
8- #include "../../flamenco/runtime/fd_exec_stack.h"
99#include "../../flamenco/runtime/fd_runtime.h"
10+ #include "../../flamenco/progcache/fd_progcache_user.h"
11+ #include "../../flamenco/log_collector/fd_log_collector.h"
1012#include "../../disco/metrics/fd_metrics.h"
1113
1214#include "../../funk/fd_funk.h"
@@ -38,14 +40,6 @@ typedef struct fd_exec_tile_ctx {
3840 fd_sha512_t sha_mem [ FD_TXN_ACTUAL_SIG_MAX ];
3941 fd_sha512_t * sha_lj [ FD_TXN_ACTUAL_SIG_MAX ];
4042
41- /* Data structures related to managing and executing the transaction.
42- The fd_txn_p_t is refreshed with every transaction and is sent
43- from the dispatch/replay tile. The fd_exec_txn_ctx_t * is a valid
44- local join that lives in the top-most frame of the spad that is
45- setup when the exec tile is booted; its members are refreshed on
46- the slot/epoch boundary. */
47- fd_exec_txn_ctx_t txn_ctx [1 ];
48-
4943 /* Capture context for debugging runtime execution. */
5044 fd_capture_ctx_t * capture_ctx ;
5145 uchar * solcap_publish_buffer_ptr ;
@@ -67,8 +61,13 @@ typedef struct fd_exec_tile_ctx {
6761 ulong slot ;
6862 ulong dispatch_time_comp ;
6963
70- fd_exec_stack_t exec_stack ;
7164 fd_exec_accounts_t exec_accounts ;
65+ fd_log_collector_t log_collector ;
66+
67+ fd_bank_t * bank ;
68+
69+ fd_txn_in_t txn_in ;
70+ fd_txn_out_t txn_out ;
7271
7372 /* tracing_mem is staging memory to dump instructions/transactions
7473 into protobuf files. tracing_mem is staging memory to output vm
@@ -77,6 +76,8 @@ typedef struct fd_exec_tile_ctx {
7776 uchar dumping_mem [ FD_SPAD_FOOTPRINT ( 1UL <<28UL ) ] __attribute__((aligned (FD_SPAD_ALIGN )));
7877 uchar tracing_mem [ FD_MAX_INSTRUCTION_STACK_DEPTH ][ FD_RUNTIME_VM_TRACE_STATIC_FOOTPRINT ] __attribute__((aligned (FD_RUNTIME_VM_TRACE_STATIC_ALIGN )));
7978
79+ fd_runtime_t runtime ;
80+
8081} fd_exec_tile_ctx_t ;
8182
8283FD_FN_CONST static inline ulong
@@ -127,37 +128,32 @@ returnable_frag( fd_exec_tile_ctx_t * ctx,
127128 case FD_EXEC_TT_TXN_EXEC : {
128129 /* Execute. */
129130 fd_exec_txn_exec_msg_t * msg = fd_chunk_to_laddr ( ctx -> replay_in -> mem , chunk );
130- fd_bank_t * bank = fd_banks_bank_query ( ctx -> banks , msg -> bank_idx );
131- FD_TEST ( bank );
132- ctx -> txn_ctx -> err .exec_err = fd_runtime_prepare_and_execute_txn ( bank ,
133- ctx -> txn_ctx ,
134- & msg -> txn ,
135- ctx -> capture_ctx ,
136- & ctx -> exec_stack ,
137- & ctx -> exec_accounts ,
138- ctx -> dumping_mem ,
139- & ctx -> tracing_mem [0 ][0 ] );
131+ ctx -> bank = fd_banks_bank_query ( ctx -> banks , msg -> bank_idx );
132+ FD_TEST ( ctx -> bank );
133+ ctx -> txn_in .txn = & msg -> txn ;
134+ ctx -> txn_in .exec_accounts = & ctx -> exec_accounts ;
135+
136+ fd_runtime_prepare_and_execute_txn ( & ctx -> runtime , ctx -> bank , & ctx -> txn_in , & ctx -> txn_out );
140137
141138 /* Commit. */
142- if ( FD_LIKELY ( ctx -> txn_ctx -> err .is_committable ) ) {
143- fd_funk_txn_xid_t xid = (fd_funk_txn_xid_t ){ .ul = { fd_bank_slot_get ( bank ), bank -> idx } };
144- fd_runtime_finalize_txn ( ctx -> funk , ctx -> progcache , ctx -> txncache , & xid , ctx -> txn_ctx , bank , ctx -> capture_ctx , NULL );
139+ if ( FD_LIKELY ( ctx -> txn_out .err .is_committable ) ) {
140+ fd_runtime_commit_txn ( & ctx -> runtime , ctx -> bank , & ctx -> txn_in , & ctx -> txn_out );
145141 }
146142
147143 if ( FD_LIKELY ( ctx -> exec_sig_out -> idx != ULONG_MAX ) ) {
148144 /* Copy the txn signature to the signature out link so the
149145 dedup/pack tiles can drop already executed transactions. */
150146 memcpy ( fd_chunk_to_laddr ( ctx -> exec_sig_out -> mem , ctx -> exec_sig_out -> chunk ),
151- (uchar * )ctx -> txn_ctx -> txn . payload + TXN ( & ctx -> txn_ctx -> txn )-> signature_off ,
147+ (uchar * )ctx -> txn_in . txn -> payload + TXN ( ctx -> txn_in . txn )-> signature_off ,
152148 64UL );
153149 fd_stem_publish ( stem , ctx -> exec_sig_out -> idx , 0UL , ctx -> exec_sig_out -> chunk , 64UL , 0UL , 0UL , 0UL );
154150 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 );
155151 }
156152
157153 /* Notify replay. */
158- ctx -> txn_idx = msg -> txn_idx ;
159- ctx -> dispatch_time_comp = tspub ;
160- ctx -> slot = fd_bank_slot_get ( bank );
154+ ctx -> txn_idx = msg -> txn_idx ;
155+ ctx -> dispatch_time_comp = tspub ;
156+ ctx -> slot = fd_bank_slot_get ( ctx -> bank );
161157 ctx -> pending_txn_finalized_msg = 1 ;
162158
163159 break ;
@@ -274,21 +270,7 @@ unprivileged_init( fd_topo_t * topo,
274270 ctx -> txncache = fd_txncache_join ( fd_txncache_new ( _txncache , txncache_shmem ) );
275271 FD_TEST ( ctx -> txncache );
276272
277- /********************************************************************/
278- /* setup txn ctx */
279- /********************************************************************/
280-
281- FD_TEST ( fd_exec_txn_ctx_join ( fd_exec_txn_ctx_new ( ctx -> txn_ctx ) ) );
282-
283- if ( FD_UNLIKELY ( !fd_funk_join ( ctx -> txn_ctx -> funk , shfunk ) ) ) {
284- FD_LOG_CRIT (( "fd_funk_join(accdb) failed" ));
285- }
286- ctx -> txn_ctx -> progcache = fd_progcache_join ( ctx -> txn_ctx -> _progcache , shprogcache , pc_scratch , FD_PROGCACHE_SCRATCH_FOOTPRINT );
287- if ( FD_UNLIKELY ( !ctx -> txn_ctx -> progcache ) ) {
288- FD_LOG_CRIT (( "fd_progcache_join() failed" ));
289- }
290- ctx -> txn_ctx -> status_cache = ctx -> txncache ;
291- ctx -> txn_ctx -> bundle .is_bundle = 0 ;
273+ ctx -> txn_in .bundle .is_bundle = 0 ;
292274
293275 /********************************************************************/
294276 /* Capture context */
@@ -318,6 +300,22 @@ unprivileged_init( fd_topo_t * topo,
318300 }
319301
320302 ctx -> pending_txn_finalized_msg = 0 ;
303+
304+ /********************************************************************/
305+ /* Runtime */
306+ /********************************************************************/
307+
308+ ctx -> runtime = (fd_runtime_t ) {
309+ .funk = ctx -> funk ,
310+ .status_cache = ctx -> txncache ,
311+ .progcache = ctx -> progcache ,
312+ .log = {
313+ .dumping_mem = ctx -> dumping_mem ,
314+ .tracing_mem = & ctx -> tracing_mem [0 ][0 ],
315+ .log_collector = & ctx -> log_collector ,
316+ .capture_ctx = ctx -> capture_ctx ,
317+ }
318+ };
321319}
322320
323321/* Publish the next account update event buffered in the capture tile to the replay tile
@@ -370,14 +368,14 @@ static void
370368publish_txn_finalized_msg ( fd_exec_tile_ctx_t * ctx ,
371369 fd_stem_context_t * stem ) {
372370 fd_exec_task_done_msg_t * msg = fd_chunk_to_laddr ( ctx -> exec_replay_out -> mem , ctx -> exec_replay_out -> chunk );
373- msg -> bank_idx = ctx -> txn_ctx -> bank -> idx ;
371+ msg -> bank_idx = ctx -> bank -> idx ;
374372 msg -> txn_exec -> txn_idx = ctx -> txn_idx ;
375- msg -> txn_exec -> err = !ctx -> txn_ctx -> err .is_committable ;
373+ msg -> txn_exec -> err = !ctx -> txn_out . err .is_committable ;
376374 msg -> txn_exec -> slot = ctx -> slot ;
377- msg -> txn_exec -> start_shred_idx = ctx -> txn_ctx -> txn . start_shred_idx ;
378- msg -> txn_exec -> end_shred_idx = ctx -> txn_ctx -> txn . end_shred_idx ;
375+ msg -> txn_exec -> start_shred_idx = ctx -> txn_in . txn -> start_shred_idx ;
376+ msg -> txn_exec -> end_shred_idx = ctx -> txn_in . txn -> end_shred_idx ;
379377 if ( FD_UNLIKELY ( msg -> txn_exec -> err ) ) {
380- FD_LOG_WARNING (( "txn failed to execute, bad block detected err=%d" , ctx -> txn_ctx -> err .txn_err ));
378+ FD_LOG_WARNING (( "txn failed to execute, bad block detected err=%d" , ctx -> txn_out . err .txn_err ));
381379 }
382380
383381 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 () ) );
0 commit comments