Skip to content

Commit 77ea96d

Browse files
ibhatt-jumptradingmmcgee-jump
authored andcommitted
bank: do rebate prepare per transaction
1 parent 0348a45 commit 77ea96d

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/disco/pack/fd_pack_rebate_sum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ fd_pack_rebate_sum_add_txn( fd_pack_rebate_sum_t * s,
9191
}
9292
in_table->rebate_cus += rebated_cus;
9393
}
94-
accts = adtl_writable[i];
9594
if( FD_LIKELY( txn->flags & FD_TXN_P_FLAGS_SANITIZE_SUCCESS ) ) {
95+
accts = adtl_writable[i];
9696
for( ulong j=0UL; j<(ulong)TXN(txn)->addr_table_adtl_writable_cnt; j++ ) {
9797
fd_pack_rebate_entry_t * in_table = rmap_query( s->map, accts[j], NULL );
9898
if( FD_UNLIKELY( !in_table ) ) {

src/discof/bank/fd_bank_tile.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ handle_microblock( fd_bank_ctx_t * ctx,
157157
ulong bank_slot = fd_bank_slot_get( bank );
158158
FD_TEST( bank_slot==slot );
159159

160-
fd_acct_addr_t const * writable_alt[ MAX_TXN_PER_MICROBLOCK ] = { NULL };
161-
162160
for( ulong i=0UL; i<txn_cnt; i++ ) {
163161
fd_txn_p_t * txn = (fd_txn_p_t *)( dst + (i*sizeof(fd_txn_p_t)) );
164162
fd_exec_txn_ctx_t * txn_ctx = ctx->txn_ctx;
@@ -177,17 +175,23 @@ handle_microblock( fd_bank_ctx_t * ctx,
177175

178176
txn_ctx->exec_err = fd_runtime_prepare_and_execute_txn( ctx->banks, ctx->_bank_idx, txn_ctx, txn, NULL );
179177
if( FD_UNLIKELY( !(txn_ctx->flags & FD_TXN_P_FLAGS_SANITIZE_SUCCESS ) ) ) {
178+
fd_pack_rebate_sum_add_txn( ctx->rebater, txn, NULL, 1UL );
180179
ctx->metrics.txn_result[ fd_bank_err_from_runtime_err( txn_ctx->exec_err ) ]++;
181180
continue;
182181
}
183182

183+
/* TXN_P_FLAGS_EXECUTE_SUCCESS means that it should be included in
184+
the block. It's a bit of a misnomer now that there are fee-only
185+
transactions. */
186+
FD_TEST( txn_ctx->flags & FD_TXN_P_FLAGS_EXECUTE_SUCCESS );
187+
txn->flags |= FD_TXN_P_FLAGS_EXECUTE_SUCCESS | FD_TXN_P_FLAGS_SANITIZE_SUCCESS;
188+
184189
/* The account keys in the transaction context are laid out such
185190
that first the non-alt accounts are laid out, then the writable
186191
alt accounts, and finally the read-only alt accounts. */
187192
fd_txn_t * txn_descriptor = TXN( &txn_ctx->txn );
188-
writable_alt[ i ] = fd_type_pun_const( txn_ctx->account_keys+txn_descriptor->acct_addr_cnt );
189-
190-
txn->flags |= FD_TXN_P_FLAGS_SANITIZE_SUCCESS;
193+
fd_acct_addr_t const * writable_alt = fd_type_pun_const( txn_ctx->account_keys+txn_descriptor->acct_addr_cnt );
194+
fd_pack_rebate_sum_add_txn( ctx->rebater, txn, &writable_alt, 1UL );
191195

192196
/* Stash the result in the flags value so that pack can inspect it. */
193197
/* TODO: Need to translate the err to a hacky Frankendancer style err
@@ -215,12 +219,6 @@ handle_microblock( fd_bank_ctx_t * ctx,
215219
txn->bank_cu.rebated_cus = requested_exec_plus_acct_data_cus - ( actual_execution_cus + actual_acct_data_cus );
216220
txn->bank_cu.actual_consumed_cus = non_execution_cus + actual_execution_cus + actual_acct_data_cus;
217221

218-
/* TXN_P_FLAGS_EXECUTE_SUCCESS means that it should be included in
219-
the block. It's a bit of a misnomer now that there are fee-only
220-
transactions. */
221-
FD_TEST( txn_ctx->flags & FD_TXN_P_FLAGS_EXECUTE_SUCCESS );
222-
txn->flags |= FD_TXN_P_FLAGS_EXECUTE_SUCCESS;
223-
224222
/* The VM will stop executing and fail an instruction immediately if
225223
it exceeds its requested CUs. A transaction which requests less
226224
account data than it actually consumes will fail in the account
@@ -270,9 +268,6 @@ handle_microblock( fd_bank_ctx_t * ctx,
270268
it can pack new microblocks using these accounts. */
271269
fd_fseq_update( ctx->busy_fseq, seq );
272270

273-
/* Prepare the rebate */
274-
fd_pack_rebate_sum_add_txn( ctx->rebater, (fd_txn_p_t const *)dst, writable_alt, txn_cnt );
275-
276271
/* Now produce the merkle hash of the transactions for inclusion
277272
(mixin) to the PoH hash. This is done on the bank tile because
278273
it shards / scales horizontally here, while PoH does not. */

0 commit comments

Comments
 (0)