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