bugfix: fill early exit with transaction errors (#325)

This commit is contained in:
Andrew Fitzgerald 2024-04-17 14:25:13 -05:00 committed by GitHub
parent 613256e18f
commit ab2df8a735
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 3 deletions

View File

@ -244,7 +244,7 @@ struct RentMetrics {
} }
pub type BankStatusCache = StatusCache<Result<()>>; pub type BankStatusCache = StatusCache<Result<()>>;
#[frozen_abi(digest = "EzAXfE2xG3ZqdAj8KMC8CeqoSxjo5hxrEaP7fta8LT9u")] #[frozen_abi(digest = "9Pf3NTGr1AEzB4nKaVBY24uNwoQR4aJi8vc96W6kGvNk")]
pub type BankSlotDelta = SlotDelta<Result<()>>; pub type BankSlotDelta = SlotDelta<Result<()>>;
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)] #[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]

View File

@ -169,6 +169,10 @@ pub enum TransactionError {
/// The total balance before the transaction does not equal the total balance after the transaction /// The total balance before the transaction does not equal the total balance after the transaction
#[error("Sum of account balances before and after transaction do not match")] #[error("Sum of account balances before and after transaction do not match")]
UnbalancedTransaction, UnbalancedTransaction,
/// Program cache hit max limit.
#[error("Program cache hit max limit")]
ProgramCacheHitMaxLimit,
} }
impl From<SanitizeError> for TransactionError { impl From<SanitizeError> for TransactionError {

View File

@ -62,6 +62,7 @@ enum TransactionErrorType {
RESANITIZATION_NEEDED = 34; RESANITIZATION_NEEDED = 34;
PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 35; PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 35;
UNBALANCED_TRANSACTION = 36; UNBALANCED_TRANSACTION = 36;
PROGRAM_CACHE_HIT_MAX_LIMIT = 37;
} }
message InstructionError { message InstructionError {

View File

@ -818,6 +818,7 @@ impl TryFrom<tx_by_addr::TransactionError> for TransactionError {
33 => TransactionError::InvalidLoadedAccountsDataSizeLimit, 33 => TransactionError::InvalidLoadedAccountsDataSizeLimit,
34 => TransactionError::ResanitizationNeeded, 34 => TransactionError::ResanitizationNeeded,
36 => TransactionError::UnbalancedTransaction, 36 => TransactionError::UnbalancedTransaction,
37 => TransactionError::ProgramCacheHitMaxLimit,
_ => return Err("Invalid TransactionError"), _ => return Err("Invalid TransactionError"),
}) })
} }
@ -936,6 +937,9 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
TransactionError::UnbalancedTransaction => { TransactionError::UnbalancedTransaction => {
tx_by_addr::TransactionErrorType::UnbalancedTransaction tx_by_addr::TransactionErrorType::UnbalancedTransaction
} }
TransactionError::ProgramCacheHitMaxLimit => {
tx_by_addr::TransactionErrorType::ProgramCacheHitMaxLimit
}
} as i32, } as i32,
instruction_error: match transaction_error { instruction_error: match transaction_error {
TransactionError::InstructionError(index, ref instruction_error) => { TransactionError::InstructionError(index, ref instruction_error) => {

View File

@ -238,9 +238,13 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
))); )));
if programs_loaded_for_tx_batch.borrow().hit_max_limit { if programs_loaded_for_tx_batch.borrow().hit_max_limit {
const ERROR: TransactionError = TransactionError::ProgramCacheHitMaxLimit;
let loaded_transactions = vec![(Err(ERROR), None); sanitized_txs.len()];
let execution_results =
vec![TransactionExecutionResult::NotExecuted(ERROR); sanitized_txs.len()];
return LoadAndExecuteSanitizedTransactionsOutput { return LoadAndExecuteSanitizedTransactionsOutput {
loaded_transactions: vec![], loaded_transactions,
execution_results: vec![], execution_results,
}; };
} }
program_cache_time.stop(); program_cache_time.stop();