Getting prioritization fees data for jito bundle
This commit is contained in:
parent
d9492aa7a9
commit
9b4a13eaba
|
@ -1,5 +1,3 @@
|
|||
use solana_sdk::{compute_budget::{self, ComputeBudgetInstruction}, borsh0_10::try_from_slice_unchecked};
|
||||
|
||||
use {
|
||||
super::{
|
||||
committer::{CommitTransactionDetails, Committer},
|
||||
|
@ -26,7 +24,9 @@ use {
|
|||
transaction_error_metrics::TransactionErrorMetrics,
|
||||
},
|
||||
solana_sdk::{
|
||||
borsh0_10::try_from_slice_unchecked,
|
||||
clock::{Slot, FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET, MAX_PROCESSING_AGE},
|
||||
compute_budget::{self, ComputeBudgetInstruction},
|
||||
feature_set,
|
||||
pubkey::Pubkey,
|
||||
saturating_add_assign,
|
||||
|
@ -595,20 +595,20 @@ impl Consumer {
|
|||
match try_from_slice_unchecked(&instruction.data) {
|
||||
Ok(ComputeBudgetInstruction::SetComputeUnitPrice(micro_lamports)) => {
|
||||
return Some(micro_lamports);
|
||||
},
|
||||
}
|
||||
Ok(ComputeBudgetInstruction::RequestUnitsDeprecated {
|
||||
additional_fee,
|
||||
..
|
||||
}) => {
|
||||
return Some(additional_fee as u64);
|
||||
}
|
||||
_ => {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}).minmax();
|
||||
})
|
||||
.minmax();
|
||||
let (scheduled_min_prioritization_fees, scheduled_max_prioritization_fees) =
|
||||
min_max.into_option().unwrap_or_default();
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ use {
|
|||
tip_manager::TipManager,
|
||||
unprocessed_transaction_storage::UnprocessedTransactionStorage,
|
||||
},
|
||||
itertools::Itertools,
|
||||
solana_bundle::{
|
||||
bundle_execution::{load_and_execute_bundle, BundleExecutionMetrics},
|
||||
BundleExecutionError, BundleExecutionResult, TipError,
|
||||
|
@ -27,8 +28,10 @@ use {
|
|||
bank::Bank, cost_model::TransactionCost, transaction_error_metrics::TransactionErrorMetrics,
|
||||
},
|
||||
solana_sdk::{
|
||||
borsh0_10::try_from_slice_unchecked,
|
||||
bundle::SanitizedBundle,
|
||||
clock::{Slot, MAX_PROCESSING_AGE},
|
||||
compute_budget::{self, ComputeBudgetInstruction},
|
||||
feature_set,
|
||||
pubkey::Pubkey,
|
||||
transaction::{self},
|
||||
|
@ -508,6 +511,33 @@ impl BundleConsumer {
|
|||
sanitized_bundle.transactions.len()
|
||||
);
|
||||
|
||||
let minmax = sanitized_bundle
|
||||
.transactions
|
||||
.iter()
|
||||
.filter_map(|transaction| {
|
||||
let message = transaction.message();
|
||||
for (program_id, instruction) in message.program_instructions_iter() {
|
||||
if compute_budget::check_id(program_id) {
|
||||
match try_from_slice_unchecked(&instruction.data) {
|
||||
Ok(ComputeBudgetInstruction::SetComputeUnitPrice(micro_lamports)) => {
|
||||
return Some(micro_lamports as usize);
|
||||
}
|
||||
Ok(ComputeBudgetInstruction::RequestUnitsDeprecated {
|
||||
additional_fee,
|
||||
..
|
||||
}) => {
|
||||
return Some(additional_fee as usize);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
.minmax();
|
||||
let (scheduled_max_prioritization_fees, scheduled_min_prioritization_fees) =
|
||||
minmax.into_option().unwrap_or_default();
|
||||
|
||||
let (
|
||||
(transaction_qos_cost_results, _cost_model_throttled_transactions_count),
|
||||
cost_model_elapsed_us,
|
||||
|
|
|
@ -2,6 +2,7 @@ use {
|
|||
crate::{
|
||||
immutable_deserialized_packet::ImmutableDeserializedPacket, packet_bundle::PacketBundle,
|
||||
},
|
||||
itertools::{Itertools, MinMaxResult},
|
||||
solana_perf::sigverify::verify_packet,
|
||||
solana_runtime::{bank::Bank, transaction_error_metrics::TransactionErrorMetrics},
|
||||
solana_sdk::{
|
||||
|
@ -164,6 +165,10 @@ impl ImmutableDeserializedBundle {
|
|||
bundle_id: self.bundle_id.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_minmax_priorization_fees(&self) -> MinMaxResult<u64> {
|
||||
self.packets.iter().map(|packet| packet.priority()).minmax()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -16,7 +16,7 @@ use {
|
|||
DeserializedPacket, PacketBatchInsertionMetrics, UnprocessedPacketBatches,
|
||||
},
|
||||
},
|
||||
itertools::Itertools,
|
||||
itertools::{Itertools, MinMaxResult},
|
||||
min_max_heap::MinMaxHeap,
|
||||
solana_bundle::BundleExecutionError,
|
||||
solana_measure::measure,
|
||||
|
@ -299,6 +299,10 @@ impl UnprocessedTransactionStorage {
|
|||
Self::LocalTransactionStorage(transaction_storage) => {
|
||||
transaction_storage.get_min_priority()
|
||||
}
|
||||
Self::BundleStorage(bundle_storage) => bundle_storage
|
||||
.get_minmax_priorization_fees()
|
||||
.into_option()
|
||||
.map(|x| x.0),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,6 +312,10 @@ impl UnprocessedTransactionStorage {
|
|||
Self::LocalTransactionStorage(transaction_storage) => {
|
||||
transaction_storage.get_max_priority()
|
||||
}
|
||||
Self::BundleStorage(bundle_storage) => bundle_storage
|
||||
.get_minmax_priorization_fees()
|
||||
.into_option()
|
||||
.map(|x| x.1),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1391,4 +1399,34 @@ impl BundleStorage {
|
|||
|
||||
sanitized_bundles
|
||||
}
|
||||
|
||||
pub fn get_minmax_priorization_fees(&self) -> MinMaxResult<u64> {
|
||||
let (min, max) = self
|
||||
.unprocessed_bundle_storage
|
||||
.iter()
|
||||
.map(|bundle| {
|
||||
bundle
|
||||
.get_minmax_priorization_fees()
|
||||
.into_option()
|
||||
.unwrap_or((u64::MAX, u64::MIN))
|
||||
})
|
||||
.fold((u64::MAX, u64::MIN), |(a, b), (c, d)| {
|
||||
(std::cmp::min(a, c), std::cmp::max(b, d))
|
||||
});
|
||||
|
||||
let (min_c, max_c) = self
|
||||
.cost_model_buffered_bundle_storage
|
||||
.iter()
|
||||
.map(|bundle| {
|
||||
bundle
|
||||
.get_minmax_priorization_fees()
|
||||
.into_option()
|
||||
.unwrap_or((u64::MAX, u64::MIN))
|
||||
})
|
||||
.fold((u64::MAX, u64::MIN), |(a, b), (c, d)| {
|
||||
(std::cmp::min(a, c), std::cmp::max(b, d))
|
||||
});
|
||||
|
||||
MinMaxResult::MinMax(std::cmp::min(min, min_c), std::cmp::max(max, max_c))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,7 @@ use {
|
|||
transfer_hook::*,
|
||||
},
|
||||
serde_json::{json, Map, Value},
|
||||
solana_account_decoder::parse_token::{
|
||||
pubkey_from_spl_token, token_amount_to_ui_amount, UiAccountState,
|
||||
},
|
||||
solana_account_decoder::parse_token::{token_amount_to_ui_amount, UiAccountState},
|
||||
solana_sdk::{
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction},
|
||||
message::AccountKeys,
|
||||
|
|
Loading…
Reference in New Issue