LCOV - code coverage report
Current view: top level - flamenco/runtime/program - fd_precompiles.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 4 4 100.0 %
Date: 2026-03-19 18:19:27 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_runtime.h"
      16             : #include "../context/fd_exec_instr_ctx.h"
      17             : 
      18             : /* PrecompileError
      19             :    https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/precompiles.rs#L16
      20             :    Agave distinguishes between 5 errors and the returned one depends on
      21             :    the order they decided to write their code.
      22             :    These are all fatal errors, so the specific errors don't matter for
      23             :    consensus.
      24             :    To simplify our fuzzers, we return the same error code for all errors. */
      25             : #define FD_EXECUTOR_PRECOMPILE_ERR_PUBLIC_KEY                    ( 0 )
      26             : #define FD_EXECUTOR_PRECOMPILE_ERR_RECOVERY_ID                   ( 1 )
      27        1198 : #define FD_EXECUTOR_PRECOMPILE_ERR_SIGNATURE                     ( 2 )
      28          12 : #define FD_EXECUTOR_PRECOMPILE_ERR_DATA_OFFSET                   ( 3 )
      29          21 : #define FD_EXECUTOR_PRECOMPILE_ERR_INSTR_DATA_SIZE               ( 4 )
      30             : 
      31          48 : #define NO_ENABLE_FEATURE_ID ULONG_MAX
      32             : 
      33             : struct fd_precompile_program {
      34             :   fd_pubkey_t const * pubkey;
      35             :   ulong               feature_offset;
      36             :   int                 (* verify_fn )( fd_exec_instr_ctx_t * ctx );
      37             : };
      38             : typedef struct fd_precompile_program fd_precompile_program_t;
      39             : 
      40             : struct fd_native_prog_info {
      41             :   fd_pubkey_t        key;
      42             :   fd_exec_instr_fn_t fn;
      43             :   uchar              is_bpf_loader;
      44             :   ulong              feature_enable_offset; /* offset to the feature that enables this program, if any */
      45             : };
      46             : typedef struct fd_native_prog_info fd_native_prog_info_t;
      47             : 
      48             : FD_PROTOTYPES_BEGIN
      49             : 
      50             : /* High-level precompile API
      51             : 
      52             :    These symbols are always available.  If precompiles are requested but
      53             :    the user has not installed them / does not have necessary deps,
      54             :    terminates with FD_LOG_ERR. */
      55             : 
      56             : fd_precompile_program_t const *
      57             : fd_precompiles( void );
      58             : 
      59             : fd_exec_instr_fn_t
      60             : fd_executor_lookup_native_precompile_program( fd_pubkey_t const * pubkey );
      61             : 
      62             : /* Raw precompile symbols
      63             : 
      64             :    These might not be linked into the binary depending on build
      65             :    configuration. */
      66             : 
      67             : /* fd_precompile_ed25519_verify is the instruction processing entrypoint
      68             :    for the Ed25519 precompile. */
      69             : 
      70             : int
      71             : fd_precompile_ed25519_verify( fd_exec_instr_ctx_t * ctx );
      72             : 
      73             : /* fd_precompile_secp256k1_verify is the instruction processing entrypoint
      74             :    for the Secp256k1 precompile. */
      75             : 
      76             : int
      77             : fd_precompile_secp256k1_verify( fd_exec_instr_ctx_t * ctx );
      78             : 
      79             : /* fd_precompile_secp256r1_verify is the instruction processing entrypoint
      80             :    for the Secp256r1 precompile (SIMD-0075). */
      81             : 
      82             : int
      83             : fd_precompile_secp256r1_verify( fd_exec_instr_ctx_t * ctx );
      84             : 
      85             : FD_PROTOTYPES_END
      86             : 
      87             : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_precompiles_h */

Generated by: LCOV version 1.14