Line data Source code
1 : #ifndef HEADER_fd_src_disco_verify_fd_verify_tile_h 2 : #define HEADER_fd_src_disco_verify_fd_verify_tile_h 3 : 4 : /* The verify tile verifies that the cryptographic signatures of 5 : incoming transactions match the data being signed. Transactions with 6 : invalid signatures are filtered out of the frag stream. */ 7 : 8 : #include "../topo/fd_topo.h" 9 : #include "../../ballet/txn/fd_txn.h" 10 : #include "../../ballet/ed25519/fd_ed25519_verifier.h" 11 : #include "../metrics/generated/fd_metrics_enums.h" 12 : 13 : /* Signer precomputation cache entries per verify tile (gossip votes 14 : are signed by ~1.5k vote authorities) */ 15 0 : #define FD_VERIFY_ED25519_CACHE_ENT_CNT (2048UL) 16 : 17 : extern fd_topo_run_tile_t fd_tile_verify; 18 : 19 : /* fd_verify_in_ctx_t is a context object for each in (producer) mcache 20 : connected to the verify tile. */ 21 : 22 : typedef struct { 23 : fd_wksp_t * mem; 24 : ulong chunk0; 25 : ulong wmark; 26 : } fd_verify_in_ctx_t; 27 : 28 : /* Transactions are queued and their signatures verified in one batch. 29 : A transaction joins the batch while the signatures fit in 30 : batch_sig_max (FD_ED25519_VERIFIER_GROUP, what the verifier wants 31 : per call; tests may lower or raise it within 32 : FD_VERIFY_BATCH_SIG_MAX); one that would overflow it flushes the 33 : batch first, and one with more signatures than a batch goes alone 34 : (so a batch holds at most FD_VERIFY_BATCH_LANE_MAX lanes). A batch 35 : is also flushed when it is full, when no input has a fragment ready 36 : for this tile, or when its oldest transaction has waited 37 : FD_VERIFY_BATCH_MAX_AGE_NS. */ 38 : 39 0 : #define FD_VERIFY_BATCH_TXN_MAX (FD_ED25519_VERIFIER_BATCH) 40 0 : #define FD_VERIFY_BATCH_SIG_MAX (FD_ED25519_VERIFIER_BATCH) 41 : #define FD_VERIFY_BATCH_LANE_MAX (FD_TXN_SIG_MAX) 42 0 : #define FD_VERIFY_BATCH_MAX_AGE_NS (1000000L) 43 : 44 : typedef struct { 45 : ulong chunk; /* out chunk of the staged transaction */ 46 : ulong realized_sz; 47 : ulong tsorig; 48 : ulong dedup_tag; /* unused for a bundle transaction */ 49 : ulong bundle_id; /* 0 if not part of a bundle */ 50 : long enq_tick; 51 : uchar sig_cnt; 52 : } fd_verify_batch_txn_t; 53 : 54 : typedef struct { 55 : fd_ed25519_verifier_t * verifier; 56 : 57 : /* Last bundle seen, and whether one of its members failed */ 58 : int bundle_failed; 59 : ulong bundle_id; 60 : 61 : fd_verify_batch_txn_t batch_txn[ FD_VERIFY_BATCH_TXN_MAX ]; 62 : ulong batch_txn_cnt; 63 : ulong batch_sig_cnt; 64 : ulong batch_sig_max; 65 : long batch_max_age_ticks; 66 : 67 : /* Per input, a sequence number seen published for this tile */ 68 : ulong in_cnt; 69 : ulong in_ready_seq[ 32 ]; 70 : 71 : uchar const * batch_msg [ FD_VERIFY_BATCH_LANE_MAX ]; 72 : ulong batch_msg_sz[ FD_VERIFY_BATCH_LANE_MAX ]; 73 : uchar const * batch_sig [ FD_VERIFY_BATCH_LANE_MAX ]; 74 : uchar const * batch_pubkey[ FD_VERIFY_BATCH_LANE_MAX ]; 75 : int batch_result[ FD_VERIFY_BATCH_LANE_MAX ]; 76 : 77 : ulong round_robin_idx; 78 : ulong round_robin_cnt; 79 : 80 : ulong tcache_depth; 81 : ulong tcache_map_cnt; 82 : ulong * tcache_sync; 83 : ulong * tcache_ring; 84 : ulong * tcache_map; 85 : 86 : ulong in_kind[ 32 ]; 87 : fd_verify_in_ctx_t in[ 32 ]; 88 : 89 : fd_wksp_t * out_mem; 90 : ulong out_chunk0; 91 : ulong out_wmark; 92 : ulong out_chunk; 93 : 94 : ulong hashmap_seed; 95 : 96 : struct { 97 : ulong verify_tile_result[ FD_METRICS_ENUM_VERIFY_RESULT_CNT ]; 98 : } metrics; 99 : } fd_verify_ctx_t; 100 : 101 : #endif /* HEADER_fd_src_disco_verify_fd_verify_tile_h */