Skip to content

Commit f97aaae

Browse files
runtime: clean up dead executor code
1 parent bc7a3b6 commit f97aaae

File tree

9 files changed

+210
-381
lines changed

9 files changed

+210
-381
lines changed

src/discof/exec/fd_exec_tile.c

Lines changed: 49 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ scratch_footprint( fd_topo_tile_t const * tile FD_PARAM_UNUSED ) {
9595
/* clang-format on */
9696
}
9797

98-
static void
99-
execute_txn( fd_exec_tile_ctx_t * ctx ) {
100-
101-
FD_SPAD_FRAME_BEGIN( ctx->exec_spad ) {
102-
103-
/* Query the funk transaction for the given slot. */
98+
static fd_funk_txn_t *
99+
funk_txn_get( fd_exec_tile_ctx_t * ctx ) {
100+
/* Query the funk transaction for the given slot. */
104101
fd_funk_txn_map_t * txn_map = fd_funk_txn_map( ctx->funk );
105102
if( FD_UNLIKELY( !txn_map->map ) ) {
106103
FD_LOG_ERR(( "Could not find valid funk transaction map" ));
@@ -112,33 +109,45 @@ execute_txn( fd_exec_tile_ctx_t * ctx ) {
112109
FD_LOG_ERR(( "Could not find valid funk transaction" ));
113110
}
114111
fd_funk_txn_end_read( ctx->funk );
115-
ctx->txn_ctx->funk_txn = funk_txn;
112+
return funk_txn;
113+
}
114+
115+
static fd_bank_t *
116+
bank_get( fd_exec_tile_ctx_t * ctx ) {
117+
return fd_banks_get_bank( ctx->banks, ctx->slot );
118+
}
119+
120+
static void
121+
execute_txn( fd_exec_tile_ctx_t * ctx ) {
122+
123+
FD_SPAD_FRAME_BEGIN( ctx->exec_spad ) {
124+
125+
ctx->exec_res = 0;
126+
127+
ctx->txn_ctx->funk_txn = funk_txn_get( ctx );
128+
if( FD_UNLIKELY( !ctx->txn_ctx->funk_txn ) ) {
129+
FD_LOG_CRIT(( "Could not get funk transaction for slot %lu", ctx->slot ));
130+
}
116131

117132
/* Get the bank for the given slot. */
118133
fd_banks_lock( ctx->banks );
119-
ctx->bank = fd_banks_get_bank( ctx->banks, ctx->slot );
134+
ctx->bank = bank_get( ctx );
120135
if( FD_UNLIKELY( !ctx->bank ) ) {
121-
FD_LOG_ERR(( "Could not get bank for slot %lu", ctx->slot ));
136+
FD_LOG_CRIT(( "Could not get bank for slot %lu", ctx->slot ));
122137
}
123138

124-
/* Setup and execute the transaction.*/
139+
/* Setup and execute the transaction. */
125140
ctx->txn_ctx->bank = ctx->bank;
126141
ctx->txn_ctx->slot = fd_bank_slot_get( ctx->bank );
127142
ctx->txn_ctx->features = fd_bank_features_get( ctx->bank );
128143

129-
fd_execute_txn_task_info_t task_info = {
130-
.txn_ctx = ctx->txn_ctx,
131-
.exec_res = 0,
132-
.txn = &ctx->txn,
133-
};
134-
135-
fd_txn_t const * txn_descriptor = TXN( task_info.txn );
144+
fd_txn_t const * txn_descriptor = TXN( &ctx->txn );
136145
fd_rawtxn_b_t raw_txn = {
137-
.raw = task_info.txn->payload,
138-
.txn_sz = (ushort)task_info.txn->payload_sz
146+
.raw = ctx->txn.payload,
147+
.txn_sz = (ushort)ctx->txn.payload_sz
139148
};
140149

141-
task_info.txn->flags = FD_TXN_P_FLAGS_SANITIZE_SUCCESS;
150+
ctx->txn.flags = FD_TXN_P_FLAGS_SANITIZE_SUCCESS;
142151

143152
fd_exec_txn_ctx_setup( ctx->txn_ctx, txn_descriptor, &raw_txn );
144153
ctx->txn_ctx->capture_ctx = ctx->capture_ctx;
@@ -151,24 +160,27 @@ execute_txn( fd_exec_tile_ctx_t * ctx ) {
151160

152161
if( FD_UNLIKELY( fd_executor_txn_verify( ctx->txn_ctx )!=0 ) ) {
153162
FD_LOG_WARNING(( "sigverify failed: %s", FD_BASE58_ENC_64_ALLOCA( (uchar *)ctx->txn_ctx->_txn_raw->raw+ctx->txn_ctx->txn_descriptor->signature_off ) ));
154-
task_info.txn->flags = 0U;
155-
task_info.exec_res = FD_RUNTIME_TXN_ERR_SIGNATURE_FAILURE;
163+
ctx->txn.flags = 0U;
164+
ctx->exec_res = FD_RUNTIME_TXN_ERR_SIGNATURE_FAILURE;
156165
fd_banks_unlock( ctx->banks );
157166
return;
158167
}
159168

160-
fd_runtime_pre_execute_check( &task_info );
161-
if( FD_UNLIKELY( !( task_info.txn->flags & FD_TXN_P_FLAGS_SANITIZE_SUCCESS ) ) ) {
169+
ctx->exec_res = fd_runtime_pre_execute_check( &ctx->txn, ctx->txn_ctx );
170+
if( FD_UNLIKELY( !( ctx->txn.flags & FD_TXN_P_FLAGS_SANITIZE_SUCCESS ) ) ) {
162171
fd_banks_unlock( ctx->banks );
163172
return;
164173
}
165174

166175
/* Execute */
167-
task_info.txn->flags |= FD_TXN_P_FLAGS_EXECUTE_SUCCESS;
168-
ctx->exec_res = fd_execute_txn( &task_info );
176+
ctx->txn.flags |= FD_TXN_P_FLAGS_EXECUTE_SUCCESS;
177+
178+
if( FD_LIKELY( !(ctx->txn.flags & FD_TXN_P_FLAGS_FEES_ONLY) ) ) {
179+
ctx->exec_res = fd_execute_txn( ctx->txn_ctx );
180+
}
169181

170182
if( FD_LIKELY( ctx->exec_res==FD_EXECUTOR_INSTR_SUCCESS ) ) {
171-
fd_txn_reclaim_accounts( task_info.txn_ctx );
183+
fd_txn_reclaim_accounts( ctx->txn_ctx );
172184
}
173185
fd_banks_unlock( ctx->banks );
174186

@@ -233,33 +245,6 @@ hash_accounts( fd_exec_tile_ctx_t * ctx,
233245
fd_banks_unlock( ctx->banks );
234246
}
235247

236-
static void
237-
snap_hash_count( fd_exec_tile_ctx_t * ctx ) {
238-
ctx->pairs_len = fd_accounts_sorted_subrange_count( ctx->funk, (uint)ctx->tile_idx, (uint)ctx->tile_cnt );
239-
}
240-
241-
static void
242-
snap_hash_gather( fd_exec_tile_ctx_t * ctx,
243-
fd_runtime_public_snap_hash_msg_t * msg ) {
244-
245-
ulong * num_pairs = fd_wksp_laddr_fast( ctx->runtime_public_wksp, msg->num_pairs_out_gaddr );
246-
if( FD_UNLIKELY( !num_pairs ) ) {
247-
FD_LOG_ERR(( "Unable to join num_pairs" ));
248-
}
249-
fd_pubkey_hash_pair_t * pairs = fd_wksp_laddr_fast( ctx->runtime_public_wksp, msg->pairs_gaddr );
250-
if( FD_UNLIKELY( !pairs ) ) {
251-
FD_LOG_ERR(( "Unable to join pairs" ));
252-
}
253-
fd_lthash_value_t * lthash_value = fd_wksp_laddr_fast( ctx->runtime_public_wksp, msg->lt_hash_value_out_gaddr );
254-
if( FD_UNLIKELY( !lthash_value ) ) {
255-
FD_LOG_ERR(( "Unable to join lthash values" ));
256-
}
257-
258-
fd_accounts_sorted_subrange_gather( ctx->funk, (uint)ctx->tile_idx, (uint)ctx->tile_cnt,
259-
num_pairs, lthash_value,
260-
pairs, &ctx->runtime_public->features );
261-
}
262-
263248
static void
264249
during_frag( fd_exec_tile_ctx_t * ctx,
265250
ulong in_idx,
@@ -289,15 +274,8 @@ during_frag( fd_exec_tile_ctx_t * ctx,
289274
FD_LOG_DEBUG(( "hash accs=%lu msg recvd", msg->end_idx - msg->start_idx ));
290275
hash_accounts( ctx, msg );
291276
return;
292-
} else if( sig==EXEC_SNAP_HASH_ACCS_CNT_SIG ) {
293-
FD_LOG_DEBUG(( "snap hash count msg recvd" ));
294-
snap_hash_count( ctx );
295-
} else if( sig==EXEC_SNAP_HASH_ACCS_GATHER_SIG ) {
296-
fd_runtime_public_snap_hash_msg_t * msg = fd_chunk_to_laddr( ctx->replay_in_mem, chunk );
297-
FD_LOG_DEBUG(( "snap hash gather msg recvd" ));
298-
snap_hash_gather( ctx, msg );
299277
} else {
300-
FD_LOG_ERR(( "Unknown signature" ));
278+
FD_LOG_CRIT(( "Unknown signature" ));
301279
}
302280
}
303281
}
@@ -326,14 +304,15 @@ after_frag( fd_exec_tile_ctx_t * ctx,
326304
msg->exec_tile_id = (uchar)ctx->tile_idx;
327305
msg->txn_id = ctx->txn_id;
328306

329-
fd_stem_publish( stem,
330-
exec_out->idx,
331-
FD_WRITER_TXN_SIG,
332-
exec_out->chunk,
333-
sizeof(*msg),
334-
0UL,
335-
tsorig,
336-
tspub );
307+
fd_stem_publish(
308+
stem,
309+
exec_out->idx,
310+
FD_WRITER_TXN_SIG,
311+
exec_out->chunk,
312+
sizeof(*msg),
313+
0UL,
314+
tsorig,
315+
tspub );
337316
exec_out->chunk = fd_dcache_compact_next( exec_out->chunk, sizeof(*msg), exec_out->chunk0, exec_out->wmark );
338317

339318
/* Make sure that the txn/bpf id can never be equal to the sentinel
@@ -345,22 +324,11 @@ after_frag( fd_exec_tile_ctx_t * ctx,
345324
} else if( sig==EXEC_HASH_ACCS_SIG ) {
346325
FD_LOG_DEBUG(( "Sending ack for hash accs msg" ));
347326
fd_fseq_update( ctx->exec_fseq, fd_exec_fseq_set_hash_done( ctx->slot ) );
348-
} else if( sig==EXEC_SNAP_HASH_ACCS_CNT_SIG ) {
349-
FD_LOG_NOTICE(( "Sending ack for snap hash count msg pairs_len=%lu", ctx->pairs_len ));
350-
fd_fseq_update( ctx->exec_fseq, fd_exec_fseq_set_snap_hash_cnt_done( (uint)ctx->pairs_len ) );
351-
} else if( sig==EXEC_SNAP_HASH_ACCS_GATHER_SIG ) {
352-
FD_LOG_NOTICE(("Sending ack for snap hash gather msg" ));
353-
fd_fseq_update( ctx->exec_fseq, fd_exec_fseq_set_snap_hash_gather_done() );
354327
} else {
355328
FD_LOG_ERR(( "Unknown message signature" ));
356329
}
357330
}
358331

359-
static void
360-
privileged_init( fd_topo_t * topo FD_PARAM_UNUSED,
361-
fd_topo_tile_t * tile FD_PARAM_UNUSED ) {
362-
}
363-
364332
static void
365333
unprivileged_init( fd_topo_t * topo,
366334
fd_topo_tile_t * tile ) {
@@ -629,8 +597,6 @@ populate_allowed_fds( fd_topo_t const * topo,
629597
return out_cnt;
630598
}
631599

632-
/* The stem burst is bound by the max number of exec tiles that are
633-
posible. */
634600
#define STEM_BURST (1UL)
635601

636602
#define STEM_CALLBACK_CONTEXT_TYPE fd_exec_tile_ctx_t
@@ -649,7 +615,6 @@ fd_topo_run_tile_t fd_tile_execor = {
649615
.populate_allowed_fds = populate_allowed_fds,
650616
.scratch_align = scratch_align,
651617
.scratch_footprint = scratch_footprint,
652-
.privileged_init = privileged_init,
653618
.unprivileged_init = unprivileged_init,
654619
.run = stem_run,
655620
};

src/discof/writer/fd_writer_tile.c

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ before_frag( fd_writer_tile_ctx_t * ctx,
104104
until transaction finalization has been done. In other words, exec
105105
tiles block on writer tiles, rather than truly pipelining. As a
106106
result, when all the exec tiles publish to seq 0, the 0th writer
107-
tile becomes busy, and all exec tiles block on it. Then writer tile
108-
1 becomes busy, while all other writer tiles sit idle. So on and so
109-
forth.
107+
tile becomes busy, and all exec tiles block on it. Then writer
108+
tile 1 becomes busy, while all other writer tiles sit idle. So on
109+
and so forth.
110110
111111
So we offset by in_idx to try to mitigate this.
112112
*/
@@ -116,17 +116,14 @@ before_frag( fd_writer_tile_ctx_t * ctx,
116116
static void
117117
during_frag( fd_writer_tile_ctx_t * ctx,
118118
ulong in_idx,
119-
ulong seq,
119+
ulong seq FD_PARAM_UNUSED,
120120
ulong sig,
121121
ulong chunk,
122122
ulong sz,
123-
ulong ctl ) {
124-
125-
(void)seq;
126-
(void)ctl;
123+
ulong ctl FD_PARAM_UNUSED ) {
127124

128-
/* exec_writer is a reliable flow controlled link so we are not gonna
129-
bother with copying the incoming frag. */
125+
/* exec_writer is a reliable flow controlled link so we are not going
126+
to bother with copying the incoming frag. */
130127

131128
fd_writer_tile_in_ctx_t * in_ctx = &(ctx->exec_writer_in[ in_idx ]);
132129

@@ -159,17 +156,16 @@ during_frag( fd_writer_tile_ctx_t * ctx,
159156
if( FD_UNLIKELY( msg->exec_tile_id!=in_idx ) ) {
160157
FD_LOG_CRIT(( "exec_tile_id %u should be == in_idx %lu", msg->exec_tile_id, in_idx ));
161158
}
162-
fd_execute_txn_task_info_t info = {0};
163-
info.txn_ctx = ctx->txn_ctx[ in_idx ];
164-
info.exec_res = info.txn_ctx->exec_err;
159+
fd_exec_txn_ctx_t * txn_ctx = ctx->txn_ctx[ in_idx ];
160+
int exec_res = txn_ctx->exec_err;
165161

166162
fd_banks_lock( ctx->banks );
167-
ctx->bank = fd_banks_get_bank( ctx->banks, info.txn_ctx->slot );
163+
ctx->bank = fd_banks_get_bank( ctx->banks, txn_ctx->slot );
168164
if( FD_UNLIKELY( !ctx->bank ) ) {
169-
FD_LOG_CRIT(( "Could not find bank for slot %lu", info.txn_ctx->slot ));
165+
FD_LOG_CRIT(( "Could not find bank for slot %lu", txn_ctx->slot ));
170166
}
171167

172-
if( !ctx->funk_txn || info.txn_ctx->slot != ctx->funk_txn->xid.ul[0] ) {
168+
if( !ctx->funk_txn || txn_ctx->slot != ctx->funk_txn->xid.ul[0] ) {
173169
fd_funk_txn_map_t * txn_map = fd_funk_txn_map( ctx->funk );
174170
if( FD_UNLIKELY( !txn_map->map ) ) {
175171
FD_LOG_CRIT(( "Could not find valid funk transaction map" ));
@@ -183,18 +179,23 @@ during_frag( fd_writer_tile_ctx_t * ctx,
183179
fd_funk_txn_end_read( ctx->funk );
184180
}
185181

186-
if( FD_LIKELY( info.txn_ctx->flags & FD_TXN_P_FLAGS_EXECUTE_SUCCESS ) ) {
182+
if( FD_LIKELY( txn_ctx->flags & FD_TXN_P_FLAGS_EXECUTE_SUCCESS ) ) {
187183
FD_SPAD_FRAME_BEGIN( ctx->spad ) {
188184
if( FD_UNLIKELY( !ctx->bank ) ) {
189-
FD_LOG_CRIT(( "No bank for slot %lu", info.txn_ctx->slot ));
185+
FD_LOG_CRIT(( "No bank for slot %lu", txn_ctx->slot ));
190186
}
191187

192-
fd_runtime_finalize_txn( ctx->funk, ctx->funk_txn, &info, ctx->spad, ctx->bank );
188+
fd_runtime_finalize_txn(
189+
ctx->funk,
190+
ctx->funk_txn,
191+
txn_ctx,
192+
exec_res,
193+
ctx->spad,
194+
ctx->bank );
193195
} FD_SPAD_FRAME_END;
194196
fd_banks_unlock( ctx->banks );
195197
while( fd_writer_fseq_get_state( fd_fseq_query( ctx->fseq ) )!=FD_WRITER_STATE_READY ) {
196-
/* Spin to wait for the replay tile to ack the previous txn
197-
done. */
198+
/* Spin for the replay tile to ack the previous txn done. */
198199
FD_SPIN_PAUSE();
199200
}
200201
}
@@ -206,13 +207,6 @@ during_frag( fd_writer_tile_ctx_t * ctx,
206207
FD_LOG_CRIT(( "Unknown sig %lu", sig ));
207208
}
208209

209-
static void
210-
privileged_init( fd_topo_t * topo,
211-
fd_topo_tile_t * tile ) {
212-
(void)topo;
213-
(void)tile;
214-
}
215-
216210
static void
217211
unprivileged_init( fd_topo_t * topo,
218212
fd_topo_tile_t * tile ) {
@@ -387,7 +381,6 @@ fd_topo_run_tile_t fd_tile_writer = {
387381
.populate_allowed_fds = populate_allowed_fds,
388382
.scratch_align = scratch_align,
389383
.scratch_footprint = scratch_footprint,
390-
.privileged_init = privileged_init,
391384
.unprivileged_init = unprivileged_init,
392385
.run = stem_run,
393386
};

src/flamenco/runtime/context/fd_exec_txn_ctx.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ struct fd_exec_txn_ctx {
132132

133133
uint num_instructions; /* Counter for number of instructions in txn */
134134
fd_txn_return_data_t return_data; /* Data returned from `return_data` syscalls */
135-
fd_vote_account_cache_t * vote_accounts_map; /* Cache of bank's deserialized vote accounts to support fork choice */
136-
fd_vote_account_cache_entry_t * vote_accounts_pool; /* Memory pool for deserialized vote account cache */
137135
ulong accounts_resize_delta; /* Transaction level tracking for account resizing */
138136
fd_hash_t blake_txn_msg_hash; /* Hash of raw transaction message used by the status cache */
139137
ulong execution_fee; /* Execution fee paid by the fee payer in the transaction */

src/flamenco/runtime/fd_executor.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,16 +1621,9 @@ fd_executor_txn_verify( fd_exec_txn_ctx_t * txn_ctx ) {
16211621
}
16221622

16231623
int
1624-
fd_execute_txn( fd_execute_txn_task_info_t * task_info ) {
1625-
/* Don't execute transactions that are fee only.
1626-
https://github.com/anza-xyz/agave/blob/v2.1.6/svm/src/transaction_processor.rs#L341-L357 */
1627-
if( FD_UNLIKELY( task_info->txn->flags & FD_TXN_P_FLAGS_FEES_ONLY ) ) {
1628-
/* return the existing error */
1629-
return task_info->exec_res;
1630-
}
1624+
fd_execute_txn( fd_exec_txn_ctx_t * txn_ctx ) {
16311625

1632-
fd_exec_txn_ctx_t * txn_ctx = task_info->txn_ctx;
1633-
bool dump_insn = txn_ctx->capture_ctx && txn_ctx->slot >= txn_ctx->capture_ctx->dump_proto_start_slot && txn_ctx->capture_ctx->dump_instr_to_pb;
1626+
bool dump_insn = txn_ctx->capture_ctx && txn_ctx->slot >= txn_ctx->capture_ctx->dump_proto_start_slot && txn_ctx->capture_ctx->dump_instr_to_pb;
16341627

16351628
/* Initialize log collection */
16361629
fd_log_collector_init( &txn_ctx->log_collector, txn_ctx->enable_exec_recording );

src/flamenco/runtime/fd_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fd_execute_txn_prepare_start( fd_exec_slot_ctx_t const * slot_ctx,
8484
8585
Makes changes to the Funk accounts DB. */
8686
int
87-
fd_execute_txn( fd_execute_txn_task_info_t * task_info );
87+
fd_execute_txn( fd_exec_txn_ctx_t * txn_ctx );
8888

8989
int
9090
fd_executor_validate_transaction_fee_payer( fd_exec_txn_ctx_t * txn_ctx );

0 commit comments

Comments
 (0)