LCOV - code coverage report
Current view: top level - flamenco/runtime/program - fd_precompiles.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 1 4 25.0 %
Date: 2026-07-01 06:01:22 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_program_fd_precompiles_h
       2             : #define HEADER_fd_src_flamenco_runtime_program_fd_precompiles_h
       3             : 
       4             : /* fd_precompiles.h provides APIs for "precompiled"-type builtin
       5             :    programs.  These programs undergo special treatment during cost
       6             :    tracking and transaction execution.
       7             : 
       8             :    The current set of precompiles requires external cryptography code
       9             :    in Firedancer (installed via ./deps.sh), namely s2n-bignum.  In some
      10             :    testing scenarios, the developer may not have this dependency
      11             :    installed because it won't be used.  To avoid link errors in such a
      12             :    situation, precompiles are resolved at runtime (as opposed to
      13             :    compile-time). */
      14             : 
      15             : #include "../fd_executor.h"
      16             : 
      17             : /* PrecompileError
      18             :    https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/precompiles.rs#L16
      19             :    Agave distinguishes between 5 errors and the returned one depends on
      20             :    the order they decided to write their code.
      21             :    These are all fatal errors, so the specific errors don't matter for
      22             :    consensus.
      23             :    To simplify our fuzzers, we return the same error code for all errors. */
      24             : #define FD_EXECUTOR_PRECOMPILE_ERR_PUBLIC_KEY                    ( 0 )
      25             : #define FD_EXECUTOR_PRECOMPILE_ERR_RECOVERY_ID                   ( 1 )
      26           0 : #define FD_EXECUTOR_PRECOMPILE_ERR_SIGNATURE                     ( 2 )
      27           0 : #define FD_EXECUTOR_PRECOMPILE_ERR_DATA_OFFSET                   ( 3 )
      28           0 : #define FD_EXECUTOR_PRECOMPILE_ERR_INSTR_DATA_SIZE               ( 4 )
      29             : 
      30        4680 : #define NO_ENABLE_FEATURE_ID ULONG_MAX
      31             : 
      32             : struct fd_precompile_program {
      33             :   fd_pubkey_t const * pubkey;
      34             :   ulong               feature_offset;
      35             :   int                 (* verify_fn )( fd_exec_instr_ctx_t * ctx );
      36             : };
      37             : typedef struct fd_precompile_program fd_precompile_program_t;
      38             : 
      39             : struct fd_native_prog_info {
      40             :   fd_pubkey_t        key;
      41             :   fd_exec_instr_fn_t fn;
      42             :   uchar              is_bpf_loader;
      43             :   ulong              feature_enable_offset; /* offset to the feature that enables this program, if any */
      44             : };
      45             : typedef struct fd_native_prog_info fd_native_prog_info_t;
      46             : 
      47             : FD_PROTOTYPES_BEGIN
      48             : 
      49             : /* High-level precompile API
      50             : 
      51             :    These symbols are always available.  If precompiles are requested but
      52             :    the user has not installed them / does not have necessary deps,
      53             :    terminates with FD_LOG_ERR. */
      54             : 
      55             : fd_precompile_program_t const *
      56             : fd_precompiles( void );
      57             : 
      58             : fd_exec_instr_fn_t
      59             : fd_executor_lookup_native_precompile_program( fd_pubkey_t const * pubkey );
      60             : 
      61             : /* Raw precompile symbols
      62             : 
      63             :    These might not be linked into the binary depending on build
      64             :    configuration. */
      65             : 
      66             : /* fd_precompile_ed25519_verify is the instruction processing entrypoint
      67             :    for the Ed25519 precompile. */
      68             : 
      69             : int
      70             : fd_precompile_ed25519_verify( fd_exec_instr_ctx_t * ctx );
      71             : 
      72             : /* fd_precompile_secp256k1_verify is the instruction processing entrypoint
      73             :    for the Secp256k1 precompile. */
      74             : 
      75             : int
      76             : fd_precompile_secp256k1_verify( fd_exec_instr_ctx_t * ctx );
      77             : 
      78             : /* fd_precompile_secp256r1_verify is the instruction processing entrypoint
      79             :    for the Secp256r1 precompile (SIMD-0075). */
      80             : 
      81             : int
      82             : fd_precompile_secp256r1_verify( fd_exec_instr_ctx_t * ctx );
      83             : 
      84             : FD_PROTOTYPES_END
      85             : 
      86             : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_precompiles_h */

Generated by: LCOV version 1.14