From 85a0e31c6052f63102dffc03653a0db00690ee42 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 6 Jun 2023 16:13:41 -0500 Subject: [PATCH] add ProgramExecutionTemporarilyRestricted error (#31796) * add StakeProgramUnavailable error * rename to ProgramExecutionTemporarilyRestricted * Update sdk/src/transaction/error.rs Co-authored-by: Trent Nelson * fmt * update frozen abi hash * add account_index to ProgramExecutionTemporarilyRestricted error * Update sdk/src/transaction/error.rs Co-authored-by: mvines * populate transaction_details from transaction_error for ProgramExecutionTemporarilyRestricted error * fix a test * update abi digest * Update sdk/src/transaction/error.rs Co-authored-by: Brooks --------- Co-authored-by: Trent Nelson Co-authored-by: HaoranYi Co-authored-by: HaoranYi Co-authored-by: mvines Co-authored-by: Brooks --- runtime/src/bank.rs | 2 +- runtime/src/transaction_error_metrics.rs | 10 ++++++++++ sdk/src/transaction/error.rs | 4 ++++ storage-proto/proto/transaction_by_addr.proto | 1 + storage-proto/src/convert.rs | 18 +++++++++++++++++- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index fb40449af..3c439e8f0 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -222,7 +222,7 @@ struct RentMetrics { } pub type BankStatusCache = StatusCache>; -#[frozen_abi(digest = "4uKZVBUbS5wkMK6vSzUoeQjAKbXd7AGeNakBeaBG9f4i")] +#[frozen_abi(digest = "3FiwE61TtjxHenszm3oFTzmHtGQGohJz3YN3TSTwcbUM")] pub type BankSlotDelta = SlotDelta>; #[derive(Default, Copy, Clone, Debug, PartialEq, Eq)] diff --git a/runtime/src/transaction_error_metrics.rs b/runtime/src/transaction_error_metrics.rs index 62a3d2e8f..a0df079e8 100644 --- a/runtime/src/transaction_error_metrics.rs +++ b/runtime/src/transaction_error_metrics.rs @@ -24,6 +24,7 @@ pub struct TransactionErrorMetrics { pub would_exceed_max_vote_cost_limit: usize, pub would_exceed_account_data_block_limit: usize, pub max_loaded_accounts_data_size_exceeded: usize, + pub program_execution_temporarily_restricted: usize, } impl TransactionErrorMetrics { @@ -81,6 +82,10 @@ impl TransactionErrorMetrics { self.max_loaded_accounts_data_size_exceeded, other.max_loaded_accounts_data_size_exceeded ); + saturating_add_assign!( + self.program_execution_temporarily_restricted, + other.program_execution_temporarily_restricted + ); } pub fn report(&self, id: u32, slot: Slot) { @@ -162,6 +167,11 @@ impl TransactionErrorMetrics { self.max_loaded_accounts_data_size_exceeded as i64, i64 ), + ( + "program_execution_temporarily_restricted", + self.program_execution_temporarily_restricted as i64, + i64 + ), ); } } diff --git a/sdk/src/transaction/error.rs b/sdk/src/transaction/error.rs index f26e0189c..9bc57e765 100644 --- a/sdk/src/transaction/error.rs +++ b/sdk/src/transaction/error.rs @@ -161,6 +161,10 @@ pub enum TransactionError { /// Sanitized transaction differed before/after feature activiation. Needs to be resanitized. #[error("ResanitizationNeeded")] ResanitizationNeeded, + + /// Program execution is temporarily restricted on an account. + #[error("Execution of the program referenced by account at index {account_index} is temporarily restricted.")] + ProgramExecutionTemporarilyRestricted { account_index: u8 }, } impl From for TransactionError { diff --git a/storage-proto/proto/transaction_by_addr.proto b/storage-proto/proto/transaction_by_addr.proto index 8b4d6d572..d26814842 100644 --- a/storage-proto/proto/transaction_by_addr.proto +++ b/storage-proto/proto/transaction_by_addr.proto @@ -60,6 +60,7 @@ enum TransactionErrorType { MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 32; INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 33; RESANITIZATION_NEEDED = 34; + PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 35; } message InstructionError { diff --git a/storage-proto/src/convert.rs b/storage-proto/src/convert.rs index 0817e0553..dac4b697f 100644 --- a/storage-proto/src/convert.rs +++ b/storage-proto/src/convert.rs @@ -768,6 +768,12 @@ impl TryFrom for TransactionError { account_index: transaction_details.index as u8, }); } + + 35 => { + return Ok(TransactionError::ProgramExecutionTemporarilyRestricted { + account_index: transaction_details.index as u8, + }); + } _ => {} } } @@ -917,6 +923,9 @@ impl From for tx_by_addr::TransactionError { TransactionError::ResanitizationNeeded => { tx_by_addr::TransactionErrorType::ResanitizationNeeded } + TransactionError::ProgramExecutionTemporarilyRestricted { .. } => { + tx_by_addr::TransactionErrorType::ProgramExecutionTemporarilyRestricted + } } as i32, instruction_error: match transaction_error { TransactionError::InstructionError(index, ref instruction_error) => { @@ -1105,6 +1114,12 @@ impl From for tx_by_addr::TransactionError { index: account_index as u32, }) } + TransactionError::ProgramExecutionTemporarilyRestricted { account_index } => { + Some(tx_by_addr::TransactionDetails { + index: account_index as u32, + }) + } + _ => None, }, } @@ -1799,7 +1814,8 @@ mod test { for error in all::() { match error { tx_by_addr::TransactionErrorType::DuplicateInstruction - | tx_by_addr::TransactionErrorType::InsufficientFundsForRent => { + | tx_by_addr::TransactionErrorType::InsufficientFundsForRent + | tx_by_addr::TransactionErrorType::ProgramExecutionTemporarilyRestricted => { let tx_by_addr_error = tx_by_addr::TransactionError { transaction_error: error as i32, instruction_error: None,