LCOV - code coverage report
Current view: top level - flamenco/runtime - fd_txn_account.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 3 3 100.0 %
Date: 2025-07-01 05:00:49 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_fd_txn_account_h
       2             : #define HEADER_fd_src_flamenco_runtime_fd_txn_account_h
       3             : 
       4             : #include "../../ballet/txn/fd_txn.h"
       5             : #include "program/fd_program_util.h"
       6             : #include "fd_txn_account_private.h"
       7             : #include "fd_txn_account_vtable.h"
       8             : 
       9             : struct fd_acc_mgr;
      10             : typedef struct fd_acc_mgr fd_acc_mgr_t;
      11             : 
      12             : struct __attribute__((aligned(8UL))) fd_txn_account {
      13             :   ulong                           magic;
      14             : 
      15             :   fd_pubkey_t                     pubkey[1];
      16             : 
      17             :   fd_txn_account_private_state_t  private_state;
      18             : 
      19             :   ulong                           starting_dlen;
      20             :   ulong                           starting_lamports;
      21             : 
      22             :   /* only used when obtaining a mutable fd_txn_account_t from funk */
      23             :   fd_funk_rec_prepare_t           prepared_rec;
      24             : 
      25             :   fd_txn_account_vtable_t const * vt;
      26             : };
      27             : typedef struct fd_txn_account fd_txn_account_t;
      28         102 : #define FD_TXN_ACCOUNT_FOOTPRINT (sizeof(fd_txn_account_t))
      29             : #define FD_TXN_ACCOUNT_ALIGN     (8UL)
      30         102 : #define FD_TXN_ACCOUNT_MAGIC     (0xF15EDF1C51F51AA1UL)
      31             : 
      32          54 : #define FD_TXN_ACCOUNT_DECL(_x)  fd_txn_account_t _x[1]; fd_txn_account_init( _x );
      33             : 
      34             : FD_PROTOTYPES_BEGIN
      35             : 
      36             : /* Initializes an fd_txn_account_t from a pointer to a region of memory */
      37             : fd_txn_account_t *
      38             : fd_txn_account_init( void * ptr );
      39             : 
      40             : /* Assigns account meta and data for a readonly txn account */
      41             : void
      42             : fd_txn_account_init_from_meta_and_data_mutable( fd_txn_account_t *  acct,
      43             :                                                 fd_account_meta_t * meta,
      44             :                                                 uchar *             data );
      45             : 
      46             : /* Assigns account meta and data for a mutable txn account */
      47             : void
      48             : fd_txn_account_init_from_meta_and_data_readonly( fd_txn_account_t *       acct,
      49             :                                                 fd_account_meta_t const * meta,
      50             :                                                 uchar const *             data );
      51             : 
      52             : /* Sets up a readonly sentinel account meta for the txn object.
      53             :    Allocates from the given spad and uses the spad_wksp to set the
      54             :    meta gaddr field.
      55             : 
      56             :    Intended for use in the executor tile only, where txn accounts
      57             :    must be setup readonly. */
      58             : void
      59             : fd_txn_account_setup_sentinel_meta_readonly( fd_txn_account_t * acct,
      60             :                                              fd_spad_t *        spad,
      61             :                                              fd_wksp_t *        spad_wksp );
      62             : 
      63             : /* Sets up a mutable account meta for the txn_account.
      64             :    Allocates a mutable account meta object from the given spad with the given sz. */
      65             : void
      66             : fd_txn_account_setup_meta_mutable( fd_txn_account_t * acct,
      67             :                                    fd_spad_t *        spad,
      68             :                                    ulong              sz );
      69             : 
      70             : /* Operators */
      71             : 
      72             : /* buf is a handle to the account shared data. Sets the account shared
      73             :    data as mutable. Also, gaddr aware pointers for account metadata and
      74             :    data are stored in the txn account. */
      75             : fd_txn_account_t *
      76             : fd_txn_account_make_mutable( fd_txn_account_t * acct,
      77             :                              void *             buf,
      78             :                              fd_wksp_t *        wksp );
      79             : 
      80             : /* Factory constructors from funk (Accounts DB) */
      81             : 
      82             : /* Initializes a fd_txn_account_t object with a readonly handle into
      83             :    its funk record.
      84             : 
      85             :    IMPORTANT: When we access the account metadata and data pointer later on in the
      86             :      execution pipeline, we assume that nothing else will change these.
      87             : 
      88             :      This is safe because we assume that we hold a read lock on the account, since
      89             :      we are inside a Solana transaction. */
      90             : int
      91             : fd_txn_account_init_from_funk_readonly( fd_txn_account_t *    acct,
      92             :                                         fd_pubkey_t const *   pubkey,
      93             :                                         fd_funk_t const *     funk,
      94             :                                         fd_funk_txn_t const * funk_txn );
      95             : 
      96             : /* Initializes a fd_txn_account_t object with a mutable handle into
      97             :    its funk record. Cannot be called in the executor tile. */
      98             : int
      99             : fd_txn_account_init_from_funk_mutable( fd_txn_account_t *  acct,
     100             :                                        fd_pubkey_t const * pubkey,
     101             :                                        fd_funk_t *         funk,
     102             :                                        fd_funk_txn_t *     funk_txn,
     103             :                                        int                 do_create,
     104             :                                        ulong               min_data_sz );
     105             : /* Funk Save and Publish helpers */
     106             : 
     107             : /* Save helper into Funk (Accounts DB)
     108             :    Saves the contents of a fd_txn_account_t object obtained from
     109             :    fd_txn_account_init_from_funk_readonly back into funk */
     110             : int
     111             : fd_txn_account_save( fd_txn_account_t * acct,
     112             :                      fd_funk_t *        funk,
     113             :                      fd_funk_txn_t *    txn,
     114             :                      fd_wksp_t *        acc_data_wksp );
     115             : 
     116             : /* Publishes the record contents of a mutable fd_txn_account_t object
     117             :    obtained from fd_txn_account_init_from_funk_mutable into funk
     118             :    if the record does not yet exist in the current funk txn.
     119             :    ie. the record was created / cloned from an ancestor funk txn
     120             :    by fd_txn_account_init_from_funk_mutable */
     121             : void
     122             : fd_txn_account_mutable_fini( fd_txn_account_t * acct,
     123             :                              fd_funk_t *        funk,
     124             :                              fd_funk_txn_t *    txn );
     125             : 
     126             : FD_PROTOTYPES_END
     127             : 
     128             : #endif /* HEADER_fd_src_flamenco_runtime_fd_txn_account_h */

Generated by: LCOV version 1.14