remove dated cost checking feature (#29598)
This commit is contained in:
parent
544b9745c2
commit
3d63f93bb0
|
@ -28,7 +28,6 @@ use {
|
||||||
},
|
},
|
||||||
bank_forks::BankForks,
|
bank_forks::BankForks,
|
||||||
bank_utils,
|
bank_utils,
|
||||||
block_cost_limits::*,
|
|
||||||
commitment::VOTE_THRESHOLD_SIZE,
|
commitment::VOTE_THRESHOLD_SIZE,
|
||||||
cost_model::CostModel,
|
cost_model::CostModel,
|
||||||
epoch_accounts_hash::EpochAccountsHash,
|
epoch_accounts_hash::EpochAccountsHash,
|
||||||
|
@ -40,7 +39,6 @@ use {
|
||||||
},
|
},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
clock::{Slot, MAX_PROCESSING_AGE},
|
clock::{Slot, MAX_PROCESSING_AGE},
|
||||||
feature_set,
|
|
||||||
genesis_config::GenesisConfig,
|
genesis_config::GenesisConfig,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
|
@ -66,35 +64,6 @@ use {
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
// it tracks the block cost available capacity - number of compute-units allowed
|
|
||||||
// by max block cost limit.
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct BlockCostCapacityMeter {
|
|
||||||
pub capacity: u64,
|
|
||||||
pub accumulated_cost: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for BlockCostCapacityMeter {
|
|
||||||
fn default() -> Self {
|
|
||||||
BlockCostCapacityMeter::new(MAX_BLOCK_UNITS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BlockCostCapacityMeter {
|
|
||||||
pub fn new(capacity_limit: u64) -> Self {
|
|
||||||
Self {
|
|
||||||
capacity: capacity_limit,
|
|
||||||
accumulated_cost: 0_u64,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the remaining capacity
|
|
||||||
pub fn accumulate(&mut self, cost: u64) -> u64 {
|
|
||||||
self.accumulated_cost += cost;
|
|
||||||
self.capacity.saturating_sub(self.accumulated_cost)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TransactionBatchWithIndexes<'a, 'b> {
|
struct TransactionBatchWithIndexes<'a, 'b> {
|
||||||
pub batch: TransactionBatch<'a, 'b>,
|
pub batch: TransactionBatch<'a, 'b>,
|
||||||
pub transaction_indexes: Vec<usize>,
|
pub transaction_indexes: Vec<usize>,
|
||||||
|
@ -155,27 +124,12 @@ fn get_first_error(
|
||||||
first_err
|
first_err
|
||||||
}
|
}
|
||||||
|
|
||||||
fn aggregate_total_execution_units(execute_timings: &ExecuteTimings) -> u64 {
|
|
||||||
let mut execute_cost_units: u64 = 0;
|
|
||||||
for (program_id, timing) in &execute_timings.details.per_program_timings {
|
|
||||||
if timing.count < 1 {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
execute_cost_units =
|
|
||||||
execute_cost_units.saturating_add(timing.accumulated_units / timing.count as u64);
|
|
||||||
trace!("aggregated execution cost of {:?} {:?}", program_id, timing);
|
|
||||||
}
|
|
||||||
execute_cost_units
|
|
||||||
}
|
|
||||||
|
|
||||||
fn execute_batch(
|
fn execute_batch(
|
||||||
batch: &TransactionBatchWithIndexes,
|
batch: &TransactionBatchWithIndexes,
|
||||||
bank: &Arc<Bank>,
|
bank: &Arc<Bank>,
|
||||||
transaction_status_sender: Option<&TransactionStatusSender>,
|
transaction_status_sender: Option<&TransactionStatusSender>,
|
||||||
replay_vote_sender: Option<&ReplayVoteSender>,
|
replay_vote_sender: Option<&ReplayVoteSender>,
|
||||||
timings: &mut ExecuteTimings,
|
timings: &mut ExecuteTimings,
|
||||||
cost_capacity_meter: Arc<RwLock<BlockCostCapacityMeter>>,
|
|
||||||
tx_cost: u64,
|
|
||||||
log_messages_bytes_limit: Option<usize>,
|
log_messages_bytes_limit: Option<usize>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let TransactionBatchWithIndexes {
|
let TransactionBatchWithIndexes {
|
||||||
|
@ -192,8 +146,6 @@ fn execute_batch(
|
||||||
vec![]
|
vec![]
|
||||||
};
|
};
|
||||||
|
|
||||||
let pre_process_units: u64 = aggregate_total_execution_units(timings);
|
|
||||||
|
|
||||||
let (tx_results, balances) = batch.bank().load_execute_and_commit_transactions(
|
let (tx_results, balances) = batch.bank().load_execute_and_commit_transactions(
|
||||||
batch,
|
batch,
|
||||||
MAX_PROCESSING_AGE,
|
MAX_PROCESSING_AGE,
|
||||||
|
@ -205,30 +157,6 @@ fn execute_batch(
|
||||||
log_messages_bytes_limit,
|
log_messages_bytes_limit,
|
||||||
);
|
);
|
||||||
|
|
||||||
if bank
|
|
||||||
.feature_set
|
|
||||||
.is_active(&feature_set::gate_large_block::id())
|
|
||||||
{
|
|
||||||
let execution_cost_units = aggregate_total_execution_units(timings) - pre_process_units;
|
|
||||||
let remaining_block_cost_cap = cost_capacity_meter
|
|
||||||
.write()
|
|
||||||
.unwrap()
|
|
||||||
.accumulate(execution_cost_units + tx_cost);
|
|
||||||
|
|
||||||
debug!(
|
|
||||||
"bank {} executed a batch, number of transactions {}, total execute cu {}, total additional cu {}, remaining block cost cap {}",
|
|
||||||
bank.slot(),
|
|
||||||
batch.sanitized_transactions().len(),
|
|
||||||
execution_cost_units,
|
|
||||||
tx_cost,
|
|
||||||
remaining_block_cost_cap,
|
|
||||||
);
|
|
||||||
|
|
||||||
if remaining_block_cost_cap == 0_u64 {
|
|
||||||
return Err(TransactionError::WouldExceedMaxBlockCostLimit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bank_utils::find_and_send_votes(
|
bank_utils::find_and_send_votes(
|
||||||
batch.sanitized_transactions(),
|
batch.sanitized_transactions(),
|
||||||
&tx_results,
|
&tx_results,
|
||||||
|
@ -281,8 +209,6 @@ fn execute_batches_internal(
|
||||||
entry_callback: Option<&ProcessCallback>,
|
entry_callback: Option<&ProcessCallback>,
|
||||||
transaction_status_sender: Option<&TransactionStatusSender>,
|
transaction_status_sender: Option<&TransactionStatusSender>,
|
||||||
replay_vote_sender: Option<&ReplayVoteSender>,
|
replay_vote_sender: Option<&ReplayVoteSender>,
|
||||||
cost_capacity_meter: Arc<RwLock<BlockCostCapacityMeter>>,
|
|
||||||
tx_costs: &[u64],
|
|
||||||
log_messages_bytes_limit: Option<usize>,
|
log_messages_bytes_limit: Option<usize>,
|
||||||
) -> Result<ExecuteBatchesInternalMetrics> {
|
) -> Result<ExecuteBatchesInternalMetrics> {
|
||||||
assert!(!batches.is_empty());
|
assert!(!batches.is_empty());
|
||||||
|
@ -294,23 +220,18 @@ fn execute_batches_internal(
|
||||||
let results: Vec<Result<()>> = PAR_THREAD_POOL.install(|| {
|
let results: Vec<Result<()>> = PAR_THREAD_POOL.install(|| {
|
||||||
batches
|
batches
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.enumerate()
|
.map(|transaction_batch| {
|
||||||
.map(|(index, transaction_batch_with_indexes)| {
|
let transaction_count =
|
||||||
let transaction_count = transaction_batch_with_indexes
|
transaction_batch.batch.sanitized_transactions().len() as u64;
|
||||||
.batch
|
|
||||||
.sanitized_transactions()
|
|
||||||
.len() as u64;
|
|
||||||
let mut timings = ExecuteTimings::default();
|
let mut timings = ExecuteTimings::default();
|
||||||
let (result, execute_batches_time): (Result<()>, Measure) = measure!(
|
let (result, execute_batches_time): (Result<()>, Measure) = measure!(
|
||||||
{
|
{
|
||||||
let result = execute_batch(
|
let result = execute_batch(
|
||||||
transaction_batch_with_indexes,
|
transaction_batch,
|
||||||
bank,
|
bank,
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
replay_vote_sender,
|
replay_vote_sender,
|
||||||
&mut timings,
|
&mut timings,
|
||||||
cost_capacity_meter.clone(),
|
|
||||||
tx_costs[index],
|
|
||||||
log_messages_bytes_limit,
|
log_messages_bytes_limit,
|
||||||
);
|
);
|
||||||
if let Some(entry_callback) = entry_callback {
|
if let Some(entry_callback) = entry_callback {
|
||||||
|
@ -385,7 +306,6 @@ fn execute_batches(
|
||||||
transaction_status_sender: Option<&TransactionStatusSender>,
|
transaction_status_sender: Option<&TransactionStatusSender>,
|
||||||
replay_vote_sender: Option<&ReplayVoteSender>,
|
replay_vote_sender: Option<&ReplayVoteSender>,
|
||||||
confirmation_timing: &mut ConfirmationTiming,
|
confirmation_timing: &mut ConfirmationTiming,
|
||||||
cost_capacity_meter: Arc<RwLock<BlockCostCapacityMeter>>,
|
|
||||||
log_messages_bytes_limit: Option<usize>,
|
log_messages_bytes_limit: Option<usize>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if batches.is_empty() {
|
if batches.is_empty() {
|
||||||
|
@ -428,7 +348,6 @@ fn execute_batches(
|
||||||
let target_batch_count = get_thread_count() as u64;
|
let target_batch_count = get_thread_count() as u64;
|
||||||
|
|
||||||
let mut tx_batches: Vec<TransactionBatchWithIndexes> = vec![];
|
let mut tx_batches: Vec<TransactionBatchWithIndexes> = vec![];
|
||||||
let mut tx_batch_costs: Vec<u64> = vec![];
|
|
||||||
let rebatched_txs = if total_cost > target_batch_count.saturating_mul(minimal_tx_cost) {
|
let rebatched_txs = if total_cost > target_batch_count.saturating_mul(minimal_tx_cost) {
|
||||||
let target_batch_cost = total_cost / target_batch_count;
|
let target_batch_cost = total_cost / target_batch_count;
|
||||||
let mut batch_cost: u64 = 0;
|
let mut batch_cost: u64 = 0;
|
||||||
|
@ -452,17 +371,12 @@ fn execute_batches(
|
||||||
);
|
);
|
||||||
slice_start = next_index;
|
slice_start = next_index;
|
||||||
tx_batches.push(tx_batch);
|
tx_batches.push(tx_batch);
|
||||||
tx_batch_costs.push(batch_cost_without_bpf);
|
|
||||||
batch_cost = 0;
|
batch_cost = 0;
|
||||||
batch_cost_without_bpf = 0;
|
batch_cost_without_bpf = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
&tx_batches[..]
|
&tx_batches[..]
|
||||||
} else {
|
} else {
|
||||||
// Ensure that the total cost attributed to this batch is essentially correct
|
|
||||||
// batches.is_empty() check at top of function ensures that n > 0 for following divide
|
|
||||||
let n = batches.len();
|
|
||||||
tx_batch_costs = vec![total_cost_without_bpf / (n as u64); n];
|
|
||||||
batches
|
batches
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -472,8 +386,6 @@ fn execute_batches(
|
||||||
entry_callback,
|
entry_callback,
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
replay_vote_sender,
|
replay_vote_sender,
|
||||||
cost_capacity_meter,
|
|
||||||
&tx_batch_costs,
|
|
||||||
log_messages_bytes_limit,
|
log_messages_bytes_limit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -529,7 +441,6 @@ pub fn process_entries_for_tests(
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
replay_vote_sender,
|
replay_vote_sender,
|
||||||
&mut confirmation_timing,
|
&mut confirmation_timing,
|
||||||
Arc::new(RwLock::new(BlockCostCapacityMeter::default())),
|
|
||||||
None,
|
None,
|
||||||
&_ignored_prioritization_fee_cache,
|
&_ignored_prioritization_fee_cache,
|
||||||
);
|
);
|
||||||
|
@ -548,7 +459,6 @@ fn process_entries_with_callback(
|
||||||
transaction_status_sender: Option<&TransactionStatusSender>,
|
transaction_status_sender: Option<&TransactionStatusSender>,
|
||||||
replay_vote_sender: Option<&ReplayVoteSender>,
|
replay_vote_sender: Option<&ReplayVoteSender>,
|
||||||
confirmation_timing: &mut ConfirmationTiming,
|
confirmation_timing: &mut ConfirmationTiming,
|
||||||
cost_capacity_meter: Arc<RwLock<BlockCostCapacityMeter>>,
|
|
||||||
log_messages_bytes_limit: Option<usize>,
|
log_messages_bytes_limit: Option<usize>,
|
||||||
prioritization_fee_cache: &PrioritizationFeeCache,
|
prioritization_fee_cache: &PrioritizationFeeCache,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
@ -576,7 +486,6 @@ fn process_entries_with_callback(
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
replay_vote_sender,
|
replay_vote_sender,
|
||||||
confirmation_timing,
|
confirmation_timing,
|
||||||
cost_capacity_meter.clone(),
|
|
||||||
log_messages_bytes_limit,
|
log_messages_bytes_limit,
|
||||||
)?;
|
)?;
|
||||||
batches.clear();
|
batches.clear();
|
||||||
|
@ -643,7 +552,6 @@ fn process_entries_with_callback(
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
replay_vote_sender,
|
replay_vote_sender,
|
||||||
confirmation_timing,
|
confirmation_timing,
|
||||||
cost_capacity_meter.clone(),
|
|
||||||
log_messages_bytes_limit,
|
log_messages_bytes_limit,
|
||||||
)?;
|
)?;
|
||||||
batches.clear();
|
batches.clear();
|
||||||
|
@ -659,7 +567,6 @@ fn process_entries_with_callback(
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
replay_vote_sender,
|
replay_vote_sender,
|
||||||
confirmation_timing,
|
confirmation_timing,
|
||||||
cost_capacity_meter,
|
|
||||||
log_messages_bytes_limit,
|
log_messages_bytes_limit,
|
||||||
)?;
|
)?;
|
||||||
for hash in tick_hashes {
|
for hash in tick_hashes {
|
||||||
|
@ -1252,7 +1159,6 @@ fn confirm_slot_entries(
|
||||||
assert!(entries.is_some());
|
assert!(entries.is_some());
|
||||||
|
|
||||||
let mut replay_elapsed = Measure::start("replay_elapsed");
|
let mut replay_elapsed = Measure::start("replay_elapsed");
|
||||||
let cost_capacity_meter = Arc::new(RwLock::new(BlockCostCapacityMeter::default()));
|
|
||||||
let mut replay_entries: Vec<_> = entries
|
let mut replay_entries: Vec<_> = entries
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -1271,7 +1177,6 @@ fn confirm_slot_entries(
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
replay_vote_sender,
|
replay_vote_sender,
|
||||||
timing,
|
timing,
|
||||||
cost_capacity_meter,
|
|
||||||
log_messages_bytes_limit,
|
log_messages_bytes_limit,
|
||||||
prioritization_fee_cache,
|
prioritization_fee_cache,
|
||||||
)
|
)
|
||||||
|
@ -1872,6 +1777,7 @@ pub mod tests {
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::{AccountSharedData, WritableAccount},
|
account::{AccountSharedData, WritableAccount},
|
||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
|
feature_set,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
native_token::LAMPORTS_PER_SOL,
|
native_token::LAMPORTS_PER_SOL,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
|
|
|
@ -137,10 +137,6 @@ pub mod stake_merge_with_unmatched_credits_observed {
|
||||||
solana_sdk::declare_id!("meRgp4ArRPhD3KtCY9c5yAf2med7mBLsjKTPeVUHqBL");
|
solana_sdk::declare_id!("meRgp4ArRPhD3KtCY9c5yAf2med7mBLsjKTPeVUHqBL");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod gate_large_block {
|
|
||||||
solana_sdk::declare_id!("2ry7ygxiYURULZCrypHhveanvP5tzZ4toRwVp89oCNSj");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod zk_token_sdk_enabled {
|
pub mod zk_token_sdk_enabled {
|
||||||
solana_sdk::declare_id!("zk1snxsc6Fh3wsGNbbHAJNHiJoYgF29mMnTSusGx5EJ");
|
solana_sdk::declare_id!("zk1snxsc6Fh3wsGNbbHAJNHiJoYgF29mMnTSusGx5EJ");
|
||||||
}
|
}
|
||||||
|
@ -611,7 +607,6 @@ lazy_static! {
|
||||||
(merge_nonce_error_into_system_error::id(), "merge NonceError into SystemError"),
|
(merge_nonce_error_into_system_error::id(), "merge NonceError into SystemError"),
|
||||||
(disable_fees_sysvar::id(), "disable fees sysvar"),
|
(disable_fees_sysvar::id(), "disable fees sysvar"),
|
||||||
(stake_merge_with_unmatched_credits_observed::id(), "allow merging active stakes with unmatched credits_observed #18985"),
|
(stake_merge_with_unmatched_credits_observed::id(), "allow merging active stakes with unmatched credits_observed #18985"),
|
||||||
(gate_large_block::id(), "validator checks block cost against max limit in realtime, reject if exceeds."),
|
|
||||||
(zk_token_sdk_enabled::id(), "enable Zk Token proof program and syscalls"),
|
(zk_token_sdk_enabled::id(), "enable Zk Token proof program and syscalls"),
|
||||||
(curve25519_syscall_enabled::id(), "enable curve25519 syscalls"),
|
(curve25519_syscall_enabled::id(), "enable curve25519 syscalls"),
|
||||||
(versioned_tx_message_enabled::id(), "enable versioned transaction message processing"),
|
(versioned_tx_message_enabled::id(), "enable versioned transaction message processing"),
|
||||||
|
|
Loading…
Reference in New Issue