LCOV - code coverage report
Current view: top level - discof/replay - fd_execrp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 12 0.0 %
Date: 2026-11-26 02:16:43 Functions: 0 12 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_replay_fd_exec_h
       2             : #define HEADER_fd_src_discof_replay_fd_exec_h
       3             : 
       4             : #include "../../disco/fd_txn_p.h"
       5             : #include "../../tango/fd_tango_base.h"
       6             : #include "../../flamenco/fd_flamenco_base.h"
       7             : #include "../../flamenco/alpenglow/fd_block_marker.h"
       8             : #include "../../flamenco/alpenglow/fd_alpenglow.h"
       9             : #include "../../ballet/lthash/fd_lthash.h"
      10             : #include "../../ballet/ed25519/fd_ed25519_verifier.h"
      11             : 
      12             : /* Exec tile task types. */
      13           0 : #define FD_EXECRP_TT_TXN_EXEC      (1UL) /* Transaction execution. */
      14           0 : #define FD_EXECRP_TT_TXN_SIGVERIFY (2UL) /* Transaction sigverify. */
      15           0 : #define FD_EXECRP_TT_POH_HASH      (3UL) /* PoH hashing. */
      16           0 : #define FD_EXECRP_TT_LTHASH_SUB    (4UL) /* Hash accounts as they are in the parent bank's fork. */
      17           0 : #define FD_EXECRP_TT_LTHASH_ADD    (5UL) /* Hash accounts as they are in this bank's fork. */
      18           0 : #define FD_EXECRP_TT_CERT_VERIFY   (6UL) /* Alpenglow footer cert verify. */
      19           0 : #define FD_EXECRP_TT_REWARDS       (7UL) /* Alpenglow footer vote rewards, one slice of the signers. */
      20             : 
      21             : /* Sent from the replay tile to the exec tiles.  These describe one of
      22             :    several types of tasks for an exec tile.  An idx to the bank in the
      23             :    bank pool must be sent over because the key of the bank will change
      24             :    as FEC sets are processed. */
      25             : 
      26             : struct fd_execrp_txn_exec_msg {
      27             :   ulong      bank_idx;
      28             :   ulong      txn_idx;
      29             :   fd_txn_p_t txn[ 1 ];
      30             : 
      31             :   /* Used currently by solcap to maintain ordering of messages
      32             :      this will change to using txn sigs eventually */
      33             :   ulong      capture_txn_idx;
      34             : 
      35             :   /* FEC-set merkle root at dispatch time. */
      36             :   uchar      fec_merkle_root[ 32 ];
      37             : 
      38             :   /* 0-indexed position of this transaction within its block. */
      39             :   ulong      index_in_slot;
      40             : 
      41             :   /* Non-zero asks the exec tile to leave the transaction's expanded
      42             :      writable address lookup table accounts in its result entry. */
      43             :   int        want_alts;
      44             : };
      45             : typedef struct fd_execrp_txn_exec_msg fd_execrp_txn_exec_msg_t;
      46             : 
      47             : /* A sigverify task carries up to FD_EXECRP_SIGVERIFY_SIG_PARA
      48             :    consecutive transactions of one bank, whose signatures fill the
      49             :    group the exec tile verifies together.  Every transaction carries a
      50             :    signature, so a group holds at most FD_ED25519_VERIFIER_GROUP
      51             :    transactions. */
      52           0 : #define FD_EXECRP_SIGVERIFY_SIG_PARA FD_ED25519_VERIFIER_GROUP
      53             : struct fd_execrp_txn_sigverify_msg {
      54             :   ulong      bank_idx;
      55             :   ulong      cnt;
      56             :   ulong      txn_idx[ FD_EXECRP_SIGVERIFY_SIG_PARA ];
      57             :   fd_txn_p_t txn    [ FD_EXECRP_SIGVERIFY_SIG_PARA ];
      58             : };
      59             : typedef struct fd_execrp_txn_sigverify_msg fd_execrp_txn_sigverify_msg_t;
      60             : 
      61           0 : #define FD_EXECRP_POH_PARA 16
      62             : struct fd_execrp_poh_hash_msg {
      63             :   ulong     bank_idx;
      64             :   ulong     cnt;     /* In [1,FD_EXECRP_POH_PARA] */
      65             :   ulong     hashcnt; /* 0 or 1, same for every element of the batch */
      66             :   fd_hash_t hash[ FD_EXECRP_POH_PARA ];
      67             : };
      68             : typedef struct fd_execrp_poh_hash_msg fd_execrp_poh_hash_msg_t;
      69             : 
      70             : struct fd_execrp_cert_verify_msg {
      71             :   ulong                  bank_idx;
      72             :   ulong                  quorum;        /* quorum numerator, 0 for a reward cert */
      73             :   uint                   tag;           /* vote tag */
      74             :   ushort                 shred_version;
      75             :   int                    has_hm;        /* hm is the payload's H(m), from replay's memo */
      76             :   fd_bls_hash_t         hm;
      77             :   fd_block_footer_cert_t cert[ 1 ];
      78             : };
      79             : typedef struct fd_execrp_cert_verify_msg fd_execrp_cert_verify_msg_t;
      80             : 
      81             : /* This is the largest power of two at which the LtHash task still fits
      82             :    the task union below. */
      83             : 
      84             : #define FD_EXECRP_LTHASH_BATCH_MAX (128UL)
      85             : 
      86             : struct fd_execrp_lthash_msg {
      87             :   ulong          bank_idx;
      88             :   ulong          cnt; /* In [1, FD_EXECRP_LTHASH_BATCH_MAX] */
      89             :   fd_acct_addr_t acct[ FD_EXECRP_LTHASH_BATCH_MAX ];
      90             : };
      91             : typedef struct fd_execrp_lthash_msg fd_execrp_lthash_msg_t;
      92             : 
      93             : struct fd_execrp_rewards_msg {
      94             :   ulong                       bank_idx;
      95             :   ulong                       slice_idx; /* in [0, slice_cnt) */
      96             :   ulong                       slice_cnt;
      97             :   fd_alpenglow_rewards_plan_t plan;
      98             : };
      99             : typedef struct fd_execrp_rewards_msg fd_execrp_rewards_msg_t;
     100             : 
     101             : union fd_execrp_task_msg {
     102             :   fd_execrp_txn_exec_msg_t      txn_exec;
     103             :   fd_execrp_txn_sigverify_msg_t txn_sigverify;
     104             :   fd_execrp_poh_hash_msg_t      poh_hash;
     105             :   fd_execrp_cert_verify_msg_t   cert_verify;
     106             :   fd_execrp_lthash_msg_t        lthash;
     107             :   fd_execrp_rewards_msg_t       rewards;
     108             : };
     109             : 
     110             : typedef union fd_execrp_task_msg fd_execrp_task_msg_t;
     111             : 
     112             : FD_STATIC_ASSERT( sizeof(fd_execrp_lthash_msg_t) <=sizeof(fd_execrp_txn_exec_msg_t), execrp_lthash_msg_sz  );
     113             : FD_STATIC_ASSERT( sizeof(fd_execrp_rewards_msg_t)<=sizeof(fd_execrp_txn_exec_msg_t), execrp_rewards_msg_sz );
     114             : 
     115             : /* Sent from exec tiles to the replay tile, notifying the replay tile
     116             :    that a task has been completed.  That is, if the task has any
     117             :    observable side effects, such as updates to accounts, then those side
     118             :    effects are fully visible on any other exec tile. */
     119             : 
     120             : struct fd_execrp_txn_exec_done_msg {
     121             :   ulong txn_idx;
     122             : 
     123             :   /* These flags form a nested series of if statements.
     124             :      if( is_committable ) {
     125             :        if( is_fees_only ) {
     126             :          instructions will not be executed
     127             :          txn_err will be non-zero and will be one of the account loader errors
     128             :        } else if( is_noop ) {
     129             :          instructions will not be executed and no fees charged
     130             :          txn_err will be non-zero and will be a fee payer validation error
     131             :        } else {
     132             :          instructions will execute
     133             :          if( txn_err is non-zero ) {
     134             :            there's likely an instruction error
     135             :          } else {
     136             :            transaction executed successfully
     137             :            https://github.com/anza-xyz/agave/blob/v3.1.8/svm/src/transaction_execution_result.rs#L26
     138             :          }
     139             :        }
     140             :      } else {
     141             :        either failed before account loading, or failed cost tracker
     142             :      }
     143             :   */
     144             :   int is_committable;
     145             :   int is_fees_only;
     146             :   int is_noop;
     147             :   int txn_err;
     148             : 
     149             :   /* Number of the transaction's expanded writable address lookup table
     150             :      accounts the exec tile left in its result entry, in transaction
     151             :      order.  0 unless the request had want_alts set and the expansion
     152             :      succeeded. */
     153             :   uchar alt_writable_cnt;
     154             : 
     155             :   /* LONG_MAX if stage was not reached */
     156             :   long tick_load_start;
     157             :   long tick_check_start;
     158             :   long tick_exec_start;
     159             :   long tick_commit_start;
     160             :   long tick_commit_end;
     161             : 
     162             :   uint  compute_units_consumed; /* possibly zero if is_committable is zero */
     163             :   ulong transaction_fee;
     164             :   ulong priority_fee;
     165             :   ulong tips;
     166             : 
     167             :   /* used by monitoring tools */
     168             :   ulong  slot;
     169             :   ulong  bank_seq;
     170             :   ushort start_shred_idx;
     171             :   ushort end_shred_idx;
     172             : };
     173             : typedef struct fd_execrp_txn_exec_done_msg fd_execrp_txn_exec_done_msg_t;
     174             : 
     175             : struct fd_execrp_txn_sigverify_done_msg {
     176             :   ulong cnt;
     177             :   ulong txn_idx[ FD_EXECRP_SIGVERIFY_SIG_PARA ];
     178             :   int   err; /* Non-zero if a signature of the task failed */
     179             : };
     180             : typedef struct fd_execrp_txn_sigverify_done_msg fd_execrp_txn_sigverify_done_msg_t;
     181             : 
     182             : struct fd_execrp_poh_hash_done_msg {
     183             :   ulong     cnt;
     184             :   fd_hash_t hash[ FD_EXECRP_POH_PARA ];
     185             : };
     186             : typedef struct fd_execrp_poh_hash_done_msg fd_execrp_poh_hash_done_msg_t;
     187             : 
     188             : struct fd_execrp_cert_verify_done_msg {
     189             :   int            err;
     190             :   int            has_hm; /* hm is the H(m) the tile hashed, for replay's memo */
     191             :   fd_bls_hash_t hm;
     192             : };
     193             : typedef struct fd_execrp_cert_verify_done_msg fd_execrp_cert_verify_done_msg_t;
     194             : 
     195             : struct fd_execrp_lthash_done_msg {
     196             :   ulong cnt;
     197             : };
     198             : typedef struct fd_execrp_lthash_done_msg fd_execrp_lthash_done_msg_t;
     199             : 
     200             : struct fd_execrp_rewards_done_msg {
     201             :   int   err;
     202             :   ulong leader_credits; /* The slice's share of the leader's credits.  Its lthash delta is in the tile's result entry. */
     203             : };
     204             : typedef struct fd_execrp_rewards_done_msg fd_execrp_rewards_done_msg_t;
     205             : 
     206             : struct fd_execrp_task_done_msg {
     207             :   ulong bank_idx;
     208             :   union {
     209             :     fd_execrp_txn_exec_done_msg_t      txn_exec[ 1 ];
     210             :     fd_execrp_txn_sigverify_done_msg_t txn_sigverify[ 1 ];
     211             :     fd_execrp_poh_hash_done_msg_t      poh_hash[ 1 ];
     212             :     fd_execrp_cert_verify_done_msg_t   cert_verify[ 1 ];
     213             :     fd_execrp_lthash_done_msg_t        lthash[ 1 ];
     214             :     fd_execrp_rewards_done_msg_t       rewards[ 1 ];
     215             :   };
     216             : };
     217             : typedef struct fd_execrp_task_done_msg fd_execrp_task_done_msg_t;
     218             : 
     219             : /* Task results too large for the done message.  There is one entry per
     220             :    exec tile.  The exec tile fills its entry before it publishes the
     221             :    done message, and the task type in the sig says which member is
     222             :    valid. */
     223             : 
     224             : struct fd_execrp_result {
     225             :   union {
     226             :     fd_lthash_value_t lthash;                                   /* LTHASH_SUB, LTHASH_ADD, REWARDS. */
     227             :     fd_pubkey_t       alt_writable[ FD_TXN_ACCT_ADDR_MAX-1UL ]; /* TXN_EXEC.  alt_writable_cnt of these are valid. */
     228             :   };
     229             : };
     230             : typedef struct fd_execrp_result fd_execrp_result_t;
     231             : 
     232             : FD_STATIC_ASSERT( sizeof(fd_execrp_result_t)==sizeof(fd_lthash_value_t), execrp_result_sz );
     233             : 
     234             : FD_PROTOTYPES_BEGIN
     235             : 
     236             : FD_FN_CONST static inline ulong
     237           0 : fd_execrp_lthash_msg_sz( ulong cnt ) {
     238           0 :   return offsetof(fd_execrp_lthash_msg_t, acct) + cnt*sizeof(fd_acct_addr_t);
     239           0 : }
     240             : 
     241             : FD_PROTOTYPES_END
     242             : 
     243             : #endif /* HEADER_fd_src_discof_replay_fd_execrp_h */

Generated by: LCOV version 1.14