This reverts commit eaa8c67bde
.
This commit is contained in:
@ -13,7 +13,6 @@ use {
|
||||
TransactionExecutionResult,
|
||||
},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
cost_model::ExecutionCost,
|
||||
rent_collector::RentCollector,
|
||||
system_instruction_processor::{get_system_account_kind, SystemAccountKind},
|
||||
},
|
||||
@ -115,7 +114,6 @@ pub struct LoadedTransaction {
|
||||
pub program_indices: TransactionProgramIndices,
|
||||
pub rent: TransactionRent,
|
||||
pub rent_debits: RentDebits,
|
||||
pub estimated_execution_cost: ExecutionCost,
|
||||
}
|
||||
|
||||
pub type TransactionLoadResult = (Result<LoadedTransaction>, Option<NonceFull>);
|
||||
@ -233,7 +231,6 @@ impl Accounts {
|
||||
error_counters: &mut ErrorCounters,
|
||||
rent_collector: &RentCollector,
|
||||
feature_set: &FeatureSet,
|
||||
estimated_execution_cost: ExecutionCost,
|
||||
) -> Result<LoadedTransaction> {
|
||||
// Copy all the accounts
|
||||
let message = tx.message();
|
||||
@ -377,7 +374,6 @@ impl Accounts {
|
||||
program_indices,
|
||||
rent: tx_rent,
|
||||
rent_debits,
|
||||
estimated_execution_cost,
|
||||
})
|
||||
} else {
|
||||
error_counters.account_not_found += 1;
|
||||
@ -471,7 +467,7 @@ impl Accounts {
|
||||
txs.iter()
|
||||
.zip(lock_results)
|
||||
.map(|etx| match etx {
|
||||
(tx, (Ok(execution_cost), nonce)) => {
|
||||
(tx, (Ok(()), nonce)) => {
|
||||
let lamports_per_signature = nonce
|
||||
.as_ref()
|
||||
.map(|nonce| nonce.lamports_per_signature())
|
||||
@ -491,7 +487,6 @@ impl Accounts {
|
||||
error_counters,
|
||||
rent_collector,
|
||||
feature_set,
|
||||
execution_cost,
|
||||
) {
|
||||
Ok(loaded_transaction) => loaded_transaction,
|
||||
Err(e) => return (Err(e), None),
|
||||
@ -983,14 +978,11 @@ impl Accounts {
|
||||
pub fn lock_accounts<'a>(
|
||||
&self,
|
||||
txs: impl Iterator<Item = &'a SanitizedTransaction>,
|
||||
) -> Vec<Result<ExecutionCost>> {
|
||||
) -> Vec<Result<()>> {
|
||||
let keys: Vec<_> = txs.map(|tx| tx.get_account_locks()).collect();
|
||||
let account_locks = &mut self.account_locks.lock().unwrap();
|
||||
keys.into_iter()
|
||||
.map(|keys| {
|
||||
self.lock_account(account_locks, keys.writable, keys.readonly)
|
||||
.map(|_| 0)
|
||||
})
|
||||
.map(|keys| self.lock_account(account_locks, keys.writable, keys.readonly))
|
||||
.collect()
|
||||
}
|
||||
|
||||
@ -999,12 +991,12 @@ impl Accounts {
|
||||
pub fn lock_accounts_with_results<'a>(
|
||||
&self,
|
||||
txs: impl Iterator<Item = &'a SanitizedTransaction>,
|
||||
results: impl Iterator<Item = Result<ExecutionCost>>,
|
||||
) -> Vec<Result<ExecutionCost>> {
|
||||
results: impl Iterator<Item = Result<()>>,
|
||||
) -> Vec<Result<()>> {
|
||||
let key_results: Vec<_> = txs
|
||||
.zip(results)
|
||||
.map(|(tx, result)| match result {
|
||||
Ok(execution_cost) => Ok((tx.get_account_locks(), execution_cost)),
|
||||
Ok(()) => Ok(tx.get_account_locks()),
|
||||
Err(e) => Err(e),
|
||||
})
|
||||
.collect();
|
||||
@ -1012,9 +1004,7 @@ impl Accounts {
|
||||
key_results
|
||||
.into_iter()
|
||||
.map(|key_result| match key_result {
|
||||
Ok((keys, execution_cost)) => self
|
||||
.lock_account(account_locks, keys.writable, keys.readonly)
|
||||
.map(|_| execution_cost),
|
||||
Ok(keys) => self.lock_account(account_locks, keys.writable, keys.readonly),
|
||||
Err(e) => Err(e),
|
||||
})
|
||||
.collect()
|
||||
@ -1025,7 +1015,7 @@ impl Accounts {
|
||||
pub fn unlock_accounts<'a>(
|
||||
&self,
|
||||
txs: impl Iterator<Item = &'a SanitizedTransaction>,
|
||||
results: &[Result<ExecutionCost>],
|
||||
results: &[Result<()>],
|
||||
) {
|
||||
let keys: Vec<_> = txs
|
||||
.zip(results)
|
||||
@ -1310,7 +1300,7 @@ mod tests {
|
||||
accounts.load_accounts(
|
||||
&ancestors,
|
||||
&[sanitized_tx],
|
||||
vec![(Ok(0), None)],
|
||||
vec![(Ok(()), None)],
|
||||
&hash_queue,
|
||||
error_counters,
|
||||
rent_collector,
|
||||
@ -2458,9 +2448,9 @@ mod tests {
|
||||
let txs = vec![tx0, tx1, tx2];
|
||||
|
||||
let qos_results = vec![
|
||||
Ok(0),
|
||||
Ok(()),
|
||||
Err(TransactionError::WouldExceedMaxBlockCostLimit),
|
||||
Ok(0),
|
||||
Ok(()),
|
||||
];
|
||||
|
||||
let results = accounts.lock_accounts_with_results(txs.iter(), qos_results.into_iter());
|
||||
@ -2553,7 +2543,6 @@ mod tests {
|
||||
program_indices: vec![],
|
||||
rent: 0,
|
||||
rent_debits: RentDebits::default(),
|
||||
estimated_execution_cost: 0,
|
||||
}),
|
||||
None,
|
||||
);
|
||||
@ -2564,7 +2553,6 @@ mod tests {
|
||||
program_indices: vec![],
|
||||
rent: 0,
|
||||
rent_debits: RentDebits::default(),
|
||||
estimated_execution_cost: 0,
|
||||
}),
|
||||
None,
|
||||
);
|
||||
@ -2658,7 +2646,7 @@ mod tests {
|
||||
accounts.load_accounts(
|
||||
&ancestors,
|
||||
&[tx],
|
||||
vec![(Ok(0), None)],
|
||||
vec![(Ok(()), None)],
|
||||
&hash_queue,
|
||||
&mut error_counters,
|
||||
&rent_collector,
|
||||
@ -2994,7 +2982,6 @@ mod tests {
|
||||
program_indices: vec![],
|
||||
rent: 0,
|
||||
rent_debits: RentDebits::default(),
|
||||
estimated_execution_cost: 0,
|
||||
}),
|
||||
nonce.clone(),
|
||||
);
|
||||
@ -3105,7 +3092,6 @@ mod tests {
|
||||
program_indices: vec![],
|
||||
rent: 0,
|
||||
rent_debits: RentDebits::default(),
|
||||
estimated_execution_cost: 0,
|
||||
}),
|
||||
nonce.clone(),
|
||||
);
|
||||
|
@ -47,7 +47,6 @@ use {
|
||||
ancestors::{Ancestors, AncestorsForSerialization},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
builtins::{self, ActivationType, Builtin, Builtins},
|
||||
cost_model::ExecutionCost,
|
||||
cost_tracker::CostTracker,
|
||||
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
||||
inline_spl_token,
|
||||
@ -504,7 +503,7 @@ impl StatusCacheRc {
|
||||
}
|
||||
}
|
||||
|
||||
pub type TransactionCheckResult<'a> = (Result<ExecutionCost>, Option<NoncePartial>);
|
||||
pub type TransactionCheckResult = (Result<()>, Option<NoncePartial>);
|
||||
pub type TransactionExecutionResult = (Result<()>, Option<NonceFull>);
|
||||
pub struct TransactionResults {
|
||||
pub fee_collection_results: Vec<Result<()>>,
|
||||
@ -3108,7 +3107,7 @@ impl Bank {
|
||||
pub fn prepare_sanitized_batch_with_results<'a, 'b>(
|
||||
&'a self,
|
||||
transactions: &'b [SanitizedTransaction],
|
||||
transaction_results: impl Iterator<Item = Result<ExecutionCost>>,
|
||||
transaction_results: impl Iterator<Item = Result<()>>,
|
||||
) -> TransactionBatch<'a, 'b> {
|
||||
// this lock_results could be: Ok, AccountInUse, WouldExceedBlockMaxLimit or WouldExceedAccountMaxLimit
|
||||
let lock_results = self
|
||||
@ -3123,7 +3122,7 @@ impl Bank {
|
||||
&'a self,
|
||||
transaction: SanitizedTransaction,
|
||||
) -> TransactionBatch<'a, '_> {
|
||||
let mut batch = TransactionBatch::new(vec![Ok(0)], self, Cow::Owned(vec![transaction]));
|
||||
let mut batch = TransactionBatch::new(vec![Ok(())], self, Cow::Owned(vec![transaction]));
|
||||
batch.needs_unlock = false;
|
||||
batch
|
||||
}
|
||||
@ -3219,29 +3218,23 @@ impl Bank {
|
||||
self.rc.accounts.accounts_db.set_shrink_paths(paths);
|
||||
}
|
||||
|
||||
fn check_age<'a, T>(
|
||||
fn check_age<'a>(
|
||||
&self,
|
||||
txs: impl Iterator<Item = &'a SanitizedTransaction>,
|
||||
lock_results: impl Iterator<Item = T>,
|
||||
lock_results: &[Result<()>],
|
||||
max_age: usize,
|
||||
error_counters: &mut ErrorCounters,
|
||||
) -> Vec<TransactionCheckResult>
|
||||
where
|
||||
T: std::borrow::Borrow<Result<ExecutionCost>>,
|
||||
{
|
||||
) -> Vec<TransactionCheckResult> {
|
||||
let hash_queue = self.blockhash_queue.read().unwrap();
|
||||
txs.zip(lock_results)
|
||||
.map(|(tx, lock_res)| match lock_res.borrow() {
|
||||
Ok(execution_cost) => {
|
||||
.map(|(tx, lock_res)| match lock_res {
|
||||
Ok(()) => {
|
||||
let recent_blockhash = tx.message().recent_blockhash();
|
||||
let hash_age = hash_queue.check_hash_age(recent_blockhash, max_age);
|
||||
if hash_age == Some(true) {
|
||||
(Ok(*execution_cost), None)
|
||||
(Ok(()), None)
|
||||
} else if let Some((address, account)) = self.check_transaction_for_nonce(tx) {
|
||||
(
|
||||
Ok(*execution_cost),
|
||||
Some(NoncePartial::new(address, account)),
|
||||
)
|
||||
(Ok(()), Some(NoncePartial::new(address, account)))
|
||||
} else if hash_age == Some(false) {
|
||||
error_counters.blockhash_too_old += 1;
|
||||
(Err(TransactionError::BlockhashNotFound), None)
|
||||
@ -3311,16 +3304,13 @@ impl Bank {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn check_transactions<T>(
|
||||
pub fn check_transactions(
|
||||
&self,
|
||||
sanitized_txs: &[SanitizedTransaction],
|
||||
lock_results: impl Iterator<Item = T>,
|
||||
lock_results: &[Result<()>],
|
||||
max_age: usize,
|
||||
error_counters: &mut ErrorCounters,
|
||||
) -> Vec<TransactionCheckResult>
|
||||
where
|
||||
T: std::borrow::Borrow<Result<ExecutionCost>>,
|
||||
{
|
||||
) -> Vec<TransactionCheckResult> {
|
||||
let age_results =
|
||||
self.check_age(sanitized_txs.iter(), lock_results, max_age, error_counters);
|
||||
self.check_status_cache(sanitized_txs, age_results, error_counters)
|
||||
@ -3516,7 +3506,7 @@ impl Bank {
|
||||
let mut check_time = Measure::start("check_transactions");
|
||||
let check_results = self.check_transactions(
|
||||
sanitized_txs,
|
||||
batch.lock_results().iter(),
|
||||
batch.lock_results(),
|
||||
max_age,
|
||||
&mut error_counters,
|
||||
);
|
||||
@ -3598,7 +3588,6 @@ impl Bank {
|
||||
&self.builtin_programs.vec,
|
||||
legacy_message,
|
||||
&loaded_transaction.program_indices,
|
||||
loaded_transaction.estimated_execution_cost,
|
||||
&transaction_context,
|
||||
self.rent_collector.rent,
|
||||
log_collector.clone(),
|
||||
|
@ -18,7 +18,6 @@ use {
|
||||
};
|
||||
|
||||
const MAX_WRITABLE_ACCOUNTS: usize = 256;
|
||||
pub type ExecutionCost = u64;
|
||||
|
||||
// costs are stored in number of 'compute unit's
|
||||
#[derive(Debug)]
|
||||
@ -27,7 +26,7 @@ pub struct TransactionCost {
|
||||
pub signature_cost: u64,
|
||||
pub write_lock_cost: u64,
|
||||
pub data_bytes_cost: u64,
|
||||
pub execution_cost: ExecutionCost,
|
||||
pub execution_cost: u64,
|
||||
// `cost_weight` is a multiplier could be applied to transaction cost,
|
||||
// if set to zero allows the transaction to bypass cost limit check.
|
||||
pub cost_weight: u32,
|
||||
|
@ -1,10 +1,9 @@
|
||||
use {
|
||||
crate::cost_model::ExecutionCost,
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_measure::measure::Measure,
|
||||
solana_program_runtime::{
|
||||
instruction_recorder::InstructionRecorder,
|
||||
invoke_context::{BuiltinProgram, Executors, InvokeContext, ProcessInstructionResult},
|
||||
invoke_context::{BuiltinProgram, Executors, InvokeContext},
|
||||
log_collector::LogCollector,
|
||||
timings::ExecuteDetailsTimings,
|
||||
},
|
||||
@ -54,7 +53,6 @@ impl MessageProcessor {
|
||||
builtin_programs: &[BuiltinProgram],
|
||||
message: &Message,
|
||||
program_indices: &[Vec<usize>],
|
||||
estimated_execution_cost: ExecutionCost,
|
||||
transaction_context: &TransactionContext,
|
||||
rent: Rent,
|
||||
log_collector: Option<Rc<RefCell<LogCollector>>>,
|
||||
@ -129,26 +127,21 @@ impl MessageProcessor {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let mut time = Measure::start("execute_instruction");
|
||||
let ProcessInstructionResult {
|
||||
compute_units_consumed,
|
||||
result,
|
||||
} = invoke_context.process_instruction(
|
||||
&instruction.data,
|
||||
&instruction_accounts,
|
||||
None,
|
||||
program_indices,
|
||||
);
|
||||
let compute_meter_consumption = invoke_context
|
||||
.process_instruction(
|
||||
&instruction.data,
|
||||
&instruction_accounts,
|
||||
None,
|
||||
program_indices,
|
||||
)
|
||||
.map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?;
|
||||
time.stop();
|
||||
timings.accumulate_program(
|
||||
instruction.program_id(&message.account_keys),
|
||||
time.as_us(),
|
||||
compute_units_consumed,
|
||||
estimated_execution_cost,
|
||||
result.is_err(),
|
||||
compute_meter_consumption,
|
||||
);
|
||||
timings.accumulate(&invoke_context.timings);
|
||||
result
|
||||
.map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?;
|
||||
}
|
||||
Ok(ProcessedMessageInfo {
|
||||
accounts_data_len: invoke_context.get_accounts_data_meter().current(),
|
||||
@ -265,7 +258,6 @@ mod tests {
|
||||
builtin_programs,
|
||||
&message,
|
||||
&program_indices,
|
||||
0,
|
||||
&transaction_context,
|
||||
rent_collector.rent,
|
||||
None,
|
||||
@ -307,7 +299,6 @@ mod tests {
|
||||
builtin_programs,
|
||||
&message,
|
||||
&program_indices,
|
||||
0,
|
||||
&transaction_context,
|
||||
rent_collector.rent,
|
||||
None,
|
||||
@ -341,7 +332,6 @@ mod tests {
|
||||
builtin_programs,
|
||||
&message,
|
||||
&program_indices,
|
||||
0,
|
||||
&transaction_context,
|
||||
rent_collector.rent,
|
||||
None,
|
||||
@ -486,7 +476,6 @@ mod tests {
|
||||
builtin_programs,
|
||||
&message,
|
||||
&program_indices,
|
||||
0,
|
||||
&transaction_context,
|
||||
rent_collector.rent,
|
||||
None,
|
||||
@ -521,7 +510,6 @@ mod tests {
|
||||
builtin_programs,
|
||||
&message,
|
||||
&program_indices,
|
||||
0,
|
||||
&transaction_context,
|
||||
rent_collector.rent,
|
||||
None,
|
||||
@ -553,7 +541,6 @@ mod tests {
|
||||
builtin_programs,
|
||||
&message,
|
||||
&program_indices,
|
||||
0,
|
||||
&transaction_context,
|
||||
rent_collector.rent,
|
||||
None,
|
||||
@ -627,7 +614,6 @@ mod tests {
|
||||
builtin_programs,
|
||||
&message,
|
||||
&[vec![0], vec![1]],
|
||||
0,
|
||||
&transaction_context,
|
||||
RentCollector::default().rent,
|
||||
None,
|
||||
|
@ -1,12 +1,12 @@
|
||||
use {
|
||||
crate::{bank::Bank, cost_model::ExecutionCost},
|
||||
crate::bank::Bank,
|
||||
solana_sdk::transaction::{Result, SanitizedTransaction},
|
||||
std::borrow::Cow,
|
||||
};
|
||||
|
||||
// Represents the results of trying to lock a set of accounts
|
||||
pub struct TransactionBatch<'a, 'b> {
|
||||
lock_results: Vec<Result<ExecutionCost>>,
|
||||
lock_results: Vec<Result<()>>,
|
||||
bank: &'a Bank,
|
||||
sanitized_txs: Cow<'b, [SanitizedTransaction]>,
|
||||
pub(crate) needs_unlock: bool,
|
||||
@ -14,7 +14,7 @@ pub struct TransactionBatch<'a, 'b> {
|
||||
|
||||
impl<'a, 'b> TransactionBatch<'a, 'b> {
|
||||
pub fn new(
|
||||
lock_results: Vec<Result<ExecutionCost>>,
|
||||
lock_results: Vec<Result<()>>,
|
||||
bank: &'a Bank,
|
||||
sanitized_txs: Cow<'b, [SanitizedTransaction]>,
|
||||
) -> Self {
|
||||
@ -27,7 +27,7 @@ impl<'a, 'b> TransactionBatch<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lock_results(&self) -> &Vec<Result<ExecutionCost>> {
|
||||
pub fn lock_results(&self) -> &Vec<Result<()>> {
|
||||
&self.lock_results
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user