Skip to content

Commit f3a5a32

Browse files
authored
receive_and_buffer with external_worker (anza-xyz#9212)
1 parent 70587a3 commit f3a5a32

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

core/src/banking_stage/consume_worker.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ pub(crate) mod external {
347347
.map(|()| true);
348348
}
349349

350+
let BankPair {
351+
root_bank,
352+
working_bank: _,
353+
} = self.sharable_banks.load();
354+
350355
// Loop here to avoid exposing internal error to external scheduler.
351356
// In the vast majority of cases, this will iterate a single time;
352357
// If we began execution when a slot was still in process, and could
@@ -385,7 +390,7 @@ pub(crate) mod external {
385390
)
386391
};
387392
let (translation_results, transactions, max_ages) =
388-
Self::translate_transaction_batch(&batch, bank);
393+
Self::translate_transaction_batch(&batch, bank, &root_bank);
389394

390395
// Enforce all or nothing on translation_results.
391396
let execution_flags = ExecutionFlags {
@@ -497,7 +502,7 @@ pub(crate) mod external {
497502

498503
// Do resolving next since we (currently) need resolved transactions for status checks.
499504
let (parsing_and_resolve_results, txs, max_ages) =
500-
Self::translate_transaction_batch(&batch, &root_bank);
505+
Self::translate_transaction_batch(&batch, &working_bank, &root_bank);
501506

502507
if message.flags & check_flags::LOAD_ADDRESS_LOOKUP_TABLES != 0 {
503508
self.check_resolve_pubkeys(
@@ -939,20 +944,22 @@ pub(crate) mod external {
939944
/// Translate batch of transactions into usable
940945
fn translate_transaction_batch(
941946
batch: &TransactionPtrBatch,
942-
bank: &Bank,
947+
working_bank: &Bank,
948+
root_bank: &Bank,
943949
) -> (Vec<Result<(), PacketHandlingError>>, Vec<Tx>, Vec<MaxAge>) {
944-
let enable_static_instruction_limit = bank
950+
let enable_static_instruction_limit = root_bank
945951
.feature_set
946952
.is_active(&agave_feature_set::static_instruction_limit::ID);
947-
let transaction_account_lock_limit = bank.get_transaction_account_lock_limit();
953+
let transaction_account_lock_limit = working_bank.get_transaction_account_lock_limit();
948954

949955
let mut translation_results = Vec::with_capacity(MAX_TRANSACTIONS_PER_MESSAGE);
950956
let mut transactions = Vec::with_capacity(MAX_TRANSACTIONS_PER_MESSAGE);
951957
let mut max_ages = Vec::with_capacity(MAX_TRANSACTIONS_PER_MESSAGE);
952958
for (transaction_ptr, _) in batch.iter() {
953959
match Self::translate_transaction(
954960
transaction_ptr,
955-
bank,
961+
working_bank,
962+
root_bank,
956963
enable_static_instruction_limit,
957964
transaction_account_lock_limit,
958965
) {
@@ -970,21 +977,23 @@ pub(crate) mod external {
970977

971978
fn translate_transaction(
972979
transaction_ptr: TransactionPtr,
973-
bank: &Bank,
980+
working_bank: &Bank,
981+
root_bank: &Bank,
974982
enable_static_instruction_limit: bool,
975983
transaction_account_lock_limit: usize,
976984
) -> Result<(Tx, MaxAge), PacketHandlingError> {
977985
translate_to_runtime_view(
978986
transaction_ptr,
979-
bank,
987+
working_bank,
988+
root_bank,
980989
enable_static_instruction_limit,
981990
transaction_account_lock_limit,
982991
)
983992
.map(|(view, deactivation_slot)| {
984993
(
985994
view,
986995
MaxAge {
987-
sanitized_epoch: bank.epoch(),
996+
sanitized_epoch: root_bank.epoch(),
988997
alt_invalidation_slot: deactivation_slot,
989998
},
990999
)
@@ -1138,6 +1147,7 @@ pub(crate) mod external {
11381147
translate_to_runtime_view(
11391148
&simple_tx[..],
11401149
&bank,
1150+
&bank,
11411151
true,
11421152
bank.get_transaction_account_lock_limit(),
11431153
)

core/src/banking_stage/transaction_scheduler/receive_and_buffer.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ impl TransactionViewReceiveAndBuffer {
412412
) -> Result<TransactionViewState, PacketHandlingError> {
413413
let (view, deactivation_slot) = translate_to_runtime_view(
414414
bytes,
415+
working_bank,
415416
root_bank,
416417
enable_static_instruction_limit,
417418
transaction_account_lock_limit,
@@ -445,7 +446,8 @@ impl TransactionViewReceiveAndBuffer {
445446
/// ALT deactivation, if any. If no minimum slot, Slot::MAX is returned.
446447
pub(crate) fn translate_to_runtime_view<D: TransactionData>(
447448
data: D,
448-
bank: &Bank,
449+
working_bank: &Bank,
450+
root_bank: &Bank,
449451
enable_static_instruction_limit: bool,
450452
transaction_account_lock_limit: usize,
451453
) -> Result<(RuntimeTransaction<ResolvedTransactionView<D>>, u64), PacketHandlingError> {
@@ -465,20 +467,20 @@ pub(crate) fn translate_to_runtime_view<D: TransactionData>(
465467
};
466468

467469
// Discard non-vote packets if in vote-only mode.
468-
if bank.vote_only_bank() && !view.is_simple_vote_transaction() {
470+
if working_bank.vote_only_bank() && !view.is_simple_vote_transaction() {
469471
return Err(PacketHandlingError::Sanitization);
470472
}
471473

472474
if usize::from(view.total_num_accounts()) > transaction_account_lock_limit {
473475
return Err(PacketHandlingError::LockValidation);
474476
}
475477

476-
let (loaded_addresses, deactivation_slot) = load_addresses_for_view(&view, bank)?;
478+
let (loaded_addresses, deactivation_slot) = load_addresses_for_view(&view, root_bank)?;
477479

478480
let Ok(view) = RuntimeTransaction::<ResolvedTransactionView<_>>::try_new(
479481
view,
480482
loaded_addresses,
481-
bank.get_reserved_account_keys(),
483+
root_bank.get_reserved_account_keys(),
482484
) else {
483485
return Err(PacketHandlingError::Sanitization);
484486
};

0 commit comments

Comments
 (0)