From ab2df8a7359f250d0d748b4dc09689fa6ba03dda Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Wed, 17 Apr 2024 14:25:13 -0500 Subject: [PATCH] bugfix: fill early exit with transaction errors (#325) --- runtime/src/bank.rs | 2 +- sdk/src/transaction/error.rs | 4 ++++ storage-proto/proto/transaction_by_addr.proto | 1 + storage-proto/src/convert.rs | 4 ++++ svm/src/transaction_processor.rs | 8 ++++++-- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e85190991..1639186d3 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -244,7 +244,7 @@ struct RentMetrics { } pub type BankStatusCache = StatusCache>; -#[frozen_abi(digest = "EzAXfE2xG3ZqdAj8KMC8CeqoSxjo5hxrEaP7fta8LT9u")] +#[frozen_abi(digest = "9Pf3NTGr1AEzB4nKaVBY24uNwoQR4aJi8vc96W6kGvNk")] pub type BankSlotDelta = SlotDelta>; #[derive(Default, Copy, Clone, Debug, PartialEq, Eq)] diff --git a/sdk/src/transaction/error.rs b/sdk/src/transaction/error.rs index 539e40ab9..ffd4e7079 100644 --- a/sdk/src/transaction/error.rs +++ b/sdk/src/transaction/error.rs @@ -169,6 +169,10 @@ pub enum TransactionError { /// 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")] UnbalancedTransaction, + + /// Program cache hit max limit. + #[error("Program cache hit max limit")] + ProgramCacheHitMaxLimit, } impl From for TransactionError { diff --git a/storage-proto/proto/transaction_by_addr.proto b/storage-proto/proto/transaction_by_addr.proto index 8ebeeb91b..d0fa74a21 100644 --- a/storage-proto/proto/transaction_by_addr.proto +++ b/storage-proto/proto/transaction_by_addr.proto @@ -62,6 +62,7 @@ enum TransactionErrorType { RESANITIZATION_NEEDED = 34; PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 35; UNBALANCED_TRANSACTION = 36; + PROGRAM_CACHE_HIT_MAX_LIMIT = 37; } message InstructionError { diff --git a/storage-proto/src/convert.rs b/storage-proto/src/convert.rs index e90709519..754afc8a1 100644 --- a/storage-proto/src/convert.rs +++ b/storage-proto/src/convert.rs @@ -818,6 +818,7 @@ impl TryFrom for TransactionError { 33 => TransactionError::InvalidLoadedAccountsDataSizeLimit, 34 => TransactionError::ResanitizationNeeded, 36 => TransactionError::UnbalancedTransaction, + 37 => TransactionError::ProgramCacheHitMaxLimit, _ => return Err("Invalid TransactionError"), }) } @@ -936,6 +937,9 @@ impl From for tx_by_addr::TransactionError { TransactionError::UnbalancedTransaction => { tx_by_addr::TransactionErrorType::UnbalancedTransaction } + TransactionError::ProgramCacheHitMaxLimit => { + tx_by_addr::TransactionErrorType::ProgramCacheHitMaxLimit + } } as i32, instruction_error: match transaction_error { TransactionError::InstructionError(index, ref instruction_error) => { diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 8cd0eb6dd..6041500e6 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -238,9 +238,13 @@ impl TransactionBatchProcessor { ))); 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 { - loaded_transactions: vec![], - execution_results: vec![], + loaded_transactions, + execution_results, }; } program_cache_time.stop();