Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit ece3f9d

Browse files
mergify[bot]apfitzge
authored andcommitted
v1.18: scheduler optimization - worker precompile verification (backport of #1531) (#1535)
* scheduler optimization - worker precompile verification (#1531) (cherry picked from commit 0d34a1a) # Conflicts: # core/src/banking_stage/consumer.rs * resolve conflicts --------- Co-authored-by: Andrew Fitzgerald <apfitzge@gmail.com>
1 parent 39a96d4 commit ece3f9d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

core/src/banking_stage/consumer.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,20 @@ impl Consumer {
403403
let pre_results = vec![Ok(()); txs.len()];
404404
let check_results =
405405
bank.check_transactions(txs, &pre_results, MAX_PROCESSING_AGE, &mut error_counters);
406-
let check_results = check_results.into_iter().map(|(result, _nonce)| result);
406+
// If checks passed, verify pre-compiles and continue processing on success.
407+
let check_results: Vec<_> = txs
408+
.iter()
409+
.zip(check_results)
410+
.map(|(tx, (result, _nonce))| match result {
411+
Ok(_) => tx.verify_precompiles(&bank.feature_set),
412+
Err(err) => Err(err),
413+
})
414+
.collect();
407415
let mut output = self.process_and_record_transactions_with_pre_results(
408416
bank,
409417
txs,
410418
chunk_offset,
411-
check_results,
419+
check_results.into_iter(),
412420
);
413421

414422
// Accumulate error counters from the initial checks into final results
@@ -425,11 +433,13 @@ impl Consumer {
425433
txs: &[SanitizedTransaction],
426434
max_slot_ages: &[Slot],
427435
) -> ProcessTransactionBatchOutput {
436+
// Verify pre-compiles.
428437
// Need to filter out transactions since they were sanitized earlier.
429438
// This means that the transaction may cross and epoch boundary (not allowed),
430439
// or account lookup tables may have been closed.
431440
let pre_results = txs.iter().zip(max_slot_ages).map(|(tx, max_slot_age)| {
432441
if *max_slot_age < bank.slot() {
442+
// Pre-compiles are verified here.
433443
// Attempt re-sanitization after epoch-cross.
434444
// Re-sanitized transaction should be equal to the original transaction,
435445
// but whether it will pass sanitization needs to be checked.
@@ -440,6 +450,8 @@ impl Consumer {
440450
return Err(TransactionError::ResanitizationNeeded);
441451
}
442452
} else {
453+
// Verify pre-compiles.
454+
tx.verify_precompiles(&bank.feature_set)?;
443455
// Any transaction executed between sanitization time and now may have closed the lookup table(s).
444456
// Above re-sanitization already loads addresses, so don't need to re-check in that case.
445457
let lookup_tables = tx.message().message_address_table_lookups();

core/src/banking_stage/immutable_deserialized_packet.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ impl ImmutableDeserializedPacket {
104104
}
105105

106106
// This function deserializes packets into transactions, computes the blake3 hash of transaction
107-
// messages, and verifies secp256k1 instructions.
107+
// messages.
108108
pub fn build_sanitized_transaction(
109109
&self,
110-
feature_set: &Arc<feature_set::FeatureSet>,
110+
_feature_set: &Arc<feature_set::FeatureSet>,
111111
votes_only: bool,
112112
address_loader: impl AddressLoader,
113113
) -> Option<SanitizedTransaction> {
@@ -121,7 +121,6 @@ impl ImmutableDeserializedPacket {
121121
address_loader,
122122
)
123123
.ok()?;
124-
tx.verify_precompiles(feature_set).ok()?;
125124
Some(tx)
126125
}
127126
}

0 commit comments

Comments
 (0)