LCOV - code coverage report
Current view: top level - discof/bank - fd_bank_err.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 80 0.0 %
Date: 2025-09-19 04:41:14 Functions: 0 4 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_bank_fd_bank_err_h
       2             : #define HEADER_fd_src_discof_bank_fd_bank_err_h
       3             : 
       4             : #include "../../util/log/fd_log.h"
       5             : #include "../../flamenco/runtime/fd_runtime_err.h"
       6             : 
       7           0 : #define FD_BANK_EXECUTE_SUCCESS                                     0
       8             : 
       9             : /* Preflight and execution errors.  This is just instruction error,
      10             :    which can occur both when loading the transaction, and when executing
      11             :    it.  When loading, it occurs when executing the compute budget
      12             :    program, or verifying precompiles. */
      13           0 : #define FD_BANK_TXN_ERR_INSTRUCTION_ERROR                          -1
      14             : 
      15             : /* Preflight errors.  These are errors in validation before we begin
      16             :    actually executing the transaction in the virtual machine. */
      17           0 : #define FD_BANK_TXN_ERR_ACCOUNT_NOT_FOUND                          -2 /* The transaction fee payer address was not found */
      18           0 : #define FD_BANK_TXN_ERR_PROGRAM_ACCOUNT_NOT_FOUND                  -3 /* A program account referenced by the transaction was not found */
      19           0 : #define FD_BANK_TXN_ERR_INSUFFICIENT_FUNDS_FOR_FEE                 -4 /* The transaction fee payer did not have balance to pay the fee */
      20           0 : #define FD_BANK_TXN_ERR_INVALID_ACCOUNT_FOR_FEE                    -5 /* The transaction fee payer account is not owned by the system program, or has data that is not a nonce */
      21           0 : #define FD_BANK_TXN_ERR_ALREADY_PROCESSED                          -6 /* The transaction has already been processed in a recent block */
      22           0 : #define FD_BANK_TXN_ERR_BLOCKHASH_NOT_FOUND                        -7 /* The transaction references a blockhash that is not recent, or advances a nonce with the wrong value */
      23           0 : #define FD_BANK_TXN_ERR_INVALID_PROGRAM_FOR_EXECUTION              -8 /* A program account referenced by the transaction was no executable. TODO: No longer needed with SIMD-0162 */
      24           0 : #define FD_BANK_TXN_ERR_ADDRESS_LOOKUP_TABLE_NOT_FOUND             -9 /* The transaction references an ALUT account that does not exist or is inactive */
      25           0 : #define FD_BANK_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER        -10 /* The transaction references an ALUT account that is not owned by the ALUT program account */
      26           0 : #define FD_BANK_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_DATA         -11 /* The transaction references an ALUT account that contains data which is not a valid ALUT */
      27           0 : #define FD_BANK_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX        -12 /* The transaction references an account offset from the ALUT which does not exist */
      28           0 : #define FD_BANK_TXN_ERR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED    -13 /* The total account data size of the loaded accounts exceeds the consensus limit */
      29           0 : #define FD_BANK_TXN_ERR_DUPLICATE_INSTRUCTION                     -14 /* A compute budget program instruction was invoked more than once */
      30           0 : #define FD_BANK_TXN_ERR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT   -15 /* The compute budget program was invoked and set the loaded accounts data size to zero */
      31             : 
      32             : /* Preflight errors during replay.  These are errors in validation
      33             :    before we begin executing the transaction, which can only occur
      34             :    during replay, as such transactions do not make it to execution when
      35             :    we are leader. */
      36           0 : #define FD_BANK_TXN_ERR_ACCOUNT_IN_USE                            -16 /* The transaction conflicts with another transaction in the microblock. TODO: No longer possible with smart dispatcher */
      37           0 : #define FD_BANK_TXN_ERR_ACCOUNT_LOADED_TWICE                      -17 /* The transaction references the same account twice */
      38           0 : #define FD_BANK_TXN_ERR_SIGNATURE_FAILURE                         -18 /* The transaction had an invalid signature */
      39           0 : #define FD_BANK_TXN_ERR_TOO_MANY_ACCOUNT_LOCKS                    -19 /* The transaction references too many accounts. TODO: No longer possible with smart dispatcher */
      40             : 
      41             : /* Execution errors.  These are errors which occur during actual
      42             :    execution of the transaction, after it has been validated. */
      43           0 : #define FD_BANK_TXN_ERR_INSUFFICIENT_FUNDS_FOR_RENT               -20 /* The transaction would leave an account with a lower balance than the rent-exempt minimum */
      44           0 : #define FD_BANK_TXN_ERR_UNBALANCED_TRANSACTION                    -21 /* The total referenced account lamports before and after the transaction was unbalanced */
      45             : 
      46             : /* Errors that aren't returned by the runtime execution itself, but are
      47             :    used by bank as an additional reason transactions might fail. */
      48             : #define FD_BANK_TXN_ERR_BUNDLE_PEER                               -22 /* The transaction was part of a bundle and an earlier transaction in the bundle failed */
      49             : 
      50             : /* Marker for the lowest error number, must be updated when new errors
      51             :    are added. */
      52             : #define FD_BANK_TXN_ERR_LAST                                      -22
      53             : 
      54             : static inline int
      55           0 : fd_bank_err_from_runtime_err( int err ) {
      56           0 :    switch( err ) {
      57           0 :       case FD_RUNTIME_EXECUTE_SUCCESS:                                 return FD_BANK_EXECUTE_SUCCESS;
      58             : 
      59           0 :       case FD_RUNTIME_TXN_ERR_INSTRUCTION_ERROR:                       return FD_BANK_TXN_ERR_INSTRUCTION_ERROR;
      60             : 
      61           0 :       case FD_RUNTIME_TXN_ERR_ACCOUNT_NOT_FOUND:                       return FD_BANK_TXN_ERR_ACCOUNT_NOT_FOUND;
      62           0 :       case FD_RUNTIME_TXN_ERR_PROGRAM_ACCOUNT_NOT_FOUND:               return FD_BANK_TXN_ERR_PROGRAM_ACCOUNT_NOT_FOUND;
      63           0 :       case FD_RUNTIME_TXN_ERR_INSUFFICIENT_FUNDS_FOR_FEE:              return FD_BANK_TXN_ERR_INSUFFICIENT_FUNDS_FOR_FEE;
      64           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ACCOUNT_FOR_FEE:                 return FD_BANK_TXN_ERR_INVALID_ACCOUNT_FOR_FEE;
      65           0 :       case FD_RUNTIME_TXN_ERR_ALREADY_PROCESSED:                       return FD_BANK_TXN_ERR_ALREADY_PROCESSED;
      66           0 :       case FD_RUNTIME_TXN_ERR_BLOCKHASH_NOT_FOUND:                     return FD_BANK_TXN_ERR_BLOCKHASH_NOT_FOUND;
      67           0 :       case FD_RUNTIME_TXN_ERR_INVALID_PROGRAM_FOR_EXECUTION:           return FD_BANK_TXN_ERR_INVALID_PROGRAM_FOR_EXECUTION;
      68           0 :       case FD_RUNTIME_TXN_ERR_ADDRESS_LOOKUP_TABLE_NOT_FOUND:          return FD_BANK_TXN_ERR_ADDRESS_LOOKUP_TABLE_NOT_FOUND;
      69           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER:      return FD_BANK_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER;
      70           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_DATA:       return FD_BANK_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_DATA;
      71           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX:      return FD_BANK_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX;
      72           0 :       case FD_RUNTIME_TXN_ERR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED:  return FD_BANK_TXN_ERR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED;
      73           0 :       case FD_RUNTIME_TXN_ERR_DUPLICATE_INSTRUCTION:                   return FD_BANK_TXN_ERR_DUPLICATE_INSTRUCTION;
      74           0 :       case FD_RUNTIME_TXN_ERR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT: return FD_BANK_TXN_ERR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT;
      75             : 
      76           0 :       case FD_RUNTIME_TXN_ERR_ACCOUNT_IN_USE:                          return FD_BANK_TXN_ERR_ACCOUNT_IN_USE;
      77           0 :       case FD_RUNTIME_TXN_ERR_ACCOUNT_LOADED_TWICE:                    return FD_BANK_TXN_ERR_ACCOUNT_LOADED_TWICE;
      78           0 :       case FD_RUNTIME_TXN_ERR_SIGNATURE_FAILURE:                       return FD_BANK_TXN_ERR_SIGNATURE_FAILURE;
      79           0 :       case FD_RUNTIME_TXN_ERR_TOO_MANY_ACCOUNT_LOCKS:                  return FD_BANK_TXN_ERR_TOO_MANY_ACCOUNT_LOCKS;
      80             : 
      81           0 :       case FD_RUNTIME_TXN_ERR_INSUFFICIENT_FUNDS_FOR_RENT:             return FD_BANK_TXN_ERR_INSUFFICIENT_FUNDS_FOR_RENT;
      82           0 :       case FD_RUNTIME_TXN_ERR_UNBALANCED_TRANSACTION:                  return FD_BANK_TXN_ERR_UNBALANCED_TRANSACTION;
      83             : 
      84           0 :       case FD_RUNTIME_TXN_ERR_CALL_CHAIN_TOO_DEEP:
      85           0 :       case FD_RUNTIME_TXN_ERR_MISSING_SIGNATURE_FOR_FEE:
      86           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ACCOUNT_INDEX:
      87           0 :       case FD_RUNTIME_TXN_ERR_SANITIZE_FAILURE:
      88           0 :       case FD_RUNTIME_TXN_ERR_CLUSTER_MAINTENANCE:
      89           0 :       case FD_RUNTIME_TXN_ERR_ACCOUNT_BORROW_OUTSTANDING:
      90           0 :       case FD_RUNTIME_TXN_ERR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT:
      91           0 :       case FD_RUNTIME_TXN_ERR_UNSUPPORTED_VERSION:
      92           0 :       case FD_RUNTIME_TXN_ERR_INVALID_WRITABLE_ACCOUNT:
      93           0 :       case FD_RUNTIME_TXN_ERR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT:
      94           0 :       case FD_RUNTIME_TXN_ERR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT:
      95           0 :       case FD_RUNTIME_TXN_ERR_INVALID_RENT_PAYING_ACCOUNT:
      96           0 :       case FD_RUNTIME_TXN_ERR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT:
      97           0 :       case FD_RUNTIME_TXN_ERR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT:
      98           0 :       case FD_RUNTIME_TXN_ERR_RESANITIZATION_NEEDED:
      99           0 :       case FD_RUNTIME_TXN_ERR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED:
     100           0 :       case FD_RUNTIME_TXN_ERR_PROGRAM_CACHE_HIT_MAX_LIMIT:
     101           0 :       default: FD_LOG_ERR(( "Unknown runtime error %d", err ));
     102           0 :     }
     103             : 
     104           0 :     return 0;
     105           0 : }
     106             : 
     107           0 : #define FD_BANK_LUT_ERR_ADDRESS_LOOKUP_TABLE_NOT_FOUND     (-1)
     108           0 : #define FD_BANK_LUT_ERR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER (-2)
     109           0 : #define FD_BANK_LUT_ERR_INVALID_ADDRESS_LOOKUP_TABLE_DATA  (-3)
     110           0 : #define FD_BANK_LUT_ERR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX (-5)
     111             : 
     112             : #define FD_BANK_LUT_ERR_LAST                               (-5)
     113             : 
     114             : static inline int
     115           0 : fd_bank_lut_err_from_runtime_err( int err ) {
     116           0 :    switch( err ) {
     117           0 :       case FD_RUNTIME_TXN_ERR_ADDRESS_LOOKUP_TABLE_NOT_FOUND: return FD_BANK_LUT_ERR_ADDRESS_LOOKUP_TABLE_NOT_FOUND;
     118           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER: return FD_BANK_LUT_ERR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER;
     119           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_DATA: return FD_BANK_LUT_ERR_INVALID_ADDRESS_LOOKUP_TABLE_DATA;
     120           0 :       case FD_RUNTIME_TXN_ERR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX: return FD_BANK_LUT_ERR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX;
     121           0 :       default: FD_LOG_ERR(( "Unknown runtime LUT error %d", err ));
     122           0 :    }
     123           0 : }
     124             : 
     125             : #endif /* HEADER_fd_src_discof_bank_fd_bank_err_h */

Generated by: LCOV version 1.14