add ProgramExecutionTemporarilyRestricted error (#31796)
* add StakeProgramUnavailable error * rename to ProgramExecutionTemporarilyRestricted * Update sdk/src/transaction/error.rs Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com> * fmt * update frozen abi hash * add account_index to ProgramExecutionTemporarilyRestricted error * Update sdk/src/transaction/error.rs Co-authored-by: mvines <mvines@gmail.com> * 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 <brooks@prumo.org> --------- Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com> Co-authored-by: HaoranYi <haoran.yi@solana.com> Co-authored-by: HaoranYi <haoran.yi@gmail.com> Co-authored-by: mvines <mvines@gmail.com> Co-authored-by: Brooks <brooks@prumo.org>
This commit is contained in:
parent
71c78f7a21
commit
85a0e31c60
|
@ -222,7 +222,7 @@ struct RentMetrics {
|
|||
}
|
||||
|
||||
pub type BankStatusCache = StatusCache<Result<()>>;
|
||||
#[frozen_abi(digest = "4uKZVBUbS5wkMK6vSzUoeQjAKbXd7AGeNakBeaBG9f4i")]
|
||||
#[frozen_abi(digest = "3FiwE61TtjxHenszm3oFTzmHtGQGohJz3YN3TSTwcbUM")]
|
||||
pub type BankSlotDelta = SlotDelta<Result<()>>;
|
||||
|
||||
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
|
||||
|
|
|
@ -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
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SanitizeError> for TransactionError {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -768,6 +768,12 @@ impl TryFrom<tx_by_addr::TransactionError> 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<TransactionError> 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<TransactionError> 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::<tx_by_addr::TransactionErrorType>() {
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue