agave_scheduling_utils/
error.rs1use {
2 agave_scheduler_bindings::worker_message_types::not_included_reasons,
3 solana_transaction_error::TransactionError,
4};
5
6pub fn transaction_result_to_not_included_reason(result: &Result<(), TransactionError>) -> u8 {
8 match result {
9 Ok(()) => not_included_reasons::NONE,
10 Err(err) => transaction_error_to_not_included_reason(err),
11 }
12}
13
14pub fn transaction_error_to_not_included_reason(error: &TransactionError) -> u8 {
15 match error {
16 TransactionError::AccountInUse => not_included_reasons::ACCOUNT_IN_USE,
17 TransactionError::AccountLoadedTwice => not_included_reasons::ACCOUNT_LOADED_TWICE,
18 TransactionError::AccountNotFound => not_included_reasons::ACCOUNT_NOT_FOUND,
19 TransactionError::ProgramAccountNotFound => not_included_reasons::PROGRAM_ACCOUNT_NOT_FOUND,
20 TransactionError::InsufficientFundsForFee => {
21 not_included_reasons::INSUFFICIENT_FUNDS_FOR_FEE
22 }
23 TransactionError::InvalidAccountForFee => not_included_reasons::INVALID_ACCOUNT_FOR_FEE,
24 TransactionError::AlreadyProcessed => not_included_reasons::ALREADY_PROCESSED,
25 TransactionError::BlockhashNotFound => not_included_reasons::BLOCKHASH_NOT_FOUND,
26 TransactionError::InstructionError(_, _) => not_included_reasons::INSTRUCTION_ERROR,
27 TransactionError::CallChainTooDeep => not_included_reasons::CALL_CHAIN_TOO_DEEP,
28 TransactionError::MissingSignatureForFee => not_included_reasons::MISSING_SIGNATURE_FOR_FEE,
29 TransactionError::InvalidAccountIndex => not_included_reasons::INVALID_ACCOUNT_INDEX,
30 TransactionError::SignatureFailure => not_included_reasons::SIGNATURE_FAILURE,
31 TransactionError::InvalidProgramForExecution => {
32 not_included_reasons::INVALID_PROGRAM_FOR_EXECUTION
33 }
34 TransactionError::SanitizeFailure => not_included_reasons::SANITIZE_FAILURE,
35 TransactionError::ClusterMaintenance => not_included_reasons::CLUSTER_MAINTENANCE,
36 TransactionError::AccountBorrowOutstanding => {
37 not_included_reasons::ACCOUNT_BORROW_OUTSTANDING
38 }
39 TransactionError::WouldExceedMaxBlockCostLimit => {
40 not_included_reasons::WOULD_EXCEED_MAX_BLOCK_COST_LIMIT
41 }
42 TransactionError::UnsupportedVersion => not_included_reasons::UNSUPPORTED_VERSION,
43 TransactionError::InvalidWritableAccount => not_included_reasons::INVALID_WRITABLE_ACCOUNT,
44 TransactionError::WouldExceedMaxAccountCostLimit => {
45 not_included_reasons::WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT
46 }
47 TransactionError::WouldExceedAccountDataBlockLimit => {
48 not_included_reasons::WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT
49 }
50 TransactionError::TooManyAccountLocks => not_included_reasons::TOO_MANY_ACCOUNT_LOCKS,
51 TransactionError::AddressLookupTableNotFound => {
52 not_included_reasons::ADDRESS_LOOKUP_TABLE_NOT_FOUND
53 }
54 TransactionError::InvalidAddressLookupTableOwner => {
55 not_included_reasons::INVALID_ADDRESS_LOOKUP_TABLE_OWNER
56 }
57 TransactionError::InvalidAddressLookupTableData => {
58 not_included_reasons::INVALID_ADDRESS_LOOKUP_TABLE_DATA
59 }
60 TransactionError::InvalidAddressLookupTableIndex => {
61 not_included_reasons::INVALID_ADDRESS_LOOKUP_TABLE_INDEX
62 }
63 TransactionError::InvalidRentPayingAccount => {
64 not_included_reasons::INVALID_RENT_PAYING_ACCOUNT
65 }
66 TransactionError::WouldExceedMaxVoteCostLimit => {
67 not_included_reasons::WOULD_EXCEED_MAX_VOTE_COST_LIMIT
68 }
69 TransactionError::WouldExceedAccountDataTotalLimit => {
70 not_included_reasons::WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT
71 }
72 TransactionError::DuplicateInstruction(_) => not_included_reasons::DUPLICATE_INSTRUCTION,
73 TransactionError::InsufficientFundsForRent { .. } => {
74 not_included_reasons::INSUFFICIENT_FUNDS_FOR_RENT
75 }
76 TransactionError::MaxLoadedAccountsDataSizeExceeded => {
77 not_included_reasons::MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED
78 }
79 TransactionError::InvalidLoadedAccountsDataSizeLimit => {
80 not_included_reasons::INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT
81 }
82 TransactionError::ResanitizationNeeded => not_included_reasons::RESANITIZATION_NEEDED,
83 TransactionError::ProgramExecutionTemporarilyRestricted { .. } => {
84 not_included_reasons::PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED
85 }
86 TransactionError::UnbalancedTransaction => not_included_reasons::UNBALANCED_TRANSACTION,
87 TransactionError::ProgramCacheHitMaxLimit => {
88 not_included_reasons::PROGRAM_CACHE_HIT_MAX_LIMIT
89 }
90
91 TransactionError::CommitCancelled => not_included_reasons::ALL_OR_NOTHING_BATCH_FAILURE,
93 }
94}