LCOV - code coverage report
Current view: top level - funk - fd_funk.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 146 313 46.6 %
Date: 2026-03-19 18:19:27 Functions: 8 10 80.0 %

          Line data    Source code
       1             : #include "fd_funk.h"
       2             : #include "fd_funk_base.h"
       3             : #include <stdio.h>
       4             : 
       5             : ulong
       6         132 : fd_funk_align( void ) {
       7         132 :   return FD_FUNK_ALIGN;
       8         132 : }
       9             : 
      10             : ulong
      11             : fd_funk_shmem_footprint( ulong txn_max,
      12          24 :                          ulong rec_max ) {
      13          24 :   if( FD_UNLIKELY( rec_max>UINT_MAX ) ) return 0UL;
      14             : 
      15          24 :   ulong l = FD_LAYOUT_INIT;
      16             : 
      17          24 :   l = FD_LAYOUT_APPEND( l, alignof(fd_funk_shmem_t), sizeof(fd_funk_shmem_t) );
      18             : 
      19          24 :   ulong txn_chain_cnt = fd_funk_txn_map_chain_cnt_est( txn_max );
      20          24 :   l = FD_LAYOUT_APPEND( l, fd_funk_txn_map_align(), fd_funk_txn_map_footprint( txn_chain_cnt ) );
      21          24 :   l = FD_LAYOUT_APPEND( l, fd_funk_txn_pool_align(), fd_funk_txn_pool_footprint() );
      22          24 :   l = FD_LAYOUT_APPEND( l, alignof(fd_funk_txn_t), sizeof(fd_funk_txn_t) * txn_max );
      23             : 
      24          24 :   ulong rec_chain_cnt = fd_funk_rec_map_chain_cnt_est( rec_max );
      25          24 :   l = FD_LAYOUT_APPEND( l, fd_funk_rec_map_align(), fd_funk_rec_map_footprint( rec_chain_cnt ) );
      26          24 :   l = FD_LAYOUT_APPEND( l, fd_funk_rec_pool_align(), fd_funk_rec_pool_footprint() );
      27          24 :   l = FD_LAYOUT_APPEND( l, alignof(fd_funk_rec_t), sizeof(fd_funk_rec_t) * rec_max );
      28             : 
      29          24 :   l = FD_LAYOUT_APPEND( l, fd_alloc_align(), fd_alloc_footprint() );
      30             : 
      31          24 :   return l;
      32          24 : }
      33             : 
      34             : ulong
      35             : fd_funk_locks_footprint( ulong txn_max,
      36          12 :                          ulong rec_max ) {
      37          12 :   ulong l = FD_LAYOUT_INIT;
      38          12 :   l = FD_LAYOUT_APPEND( l, alignof(fd_rwlock_t), sizeof(fd_rwlock_t) * txn_max );
      39          12 :   l = FD_LAYOUT_APPEND( l, alignof(ulong),       sizeof(ulong)       * rec_max );
      40          12 :   return FD_LAYOUT_FINI( l, fd_funk_align() );
      41          12 : }
      42             : 
      43             : /* TODO: Consider letter user just passing a join of alloc to use,
      44             :    inferring the backing wksp and cgroup_hint from that and then
      45             :    allocating exclusively from that? */
      46             : 
      47             : void *
      48             : fd_funk_shmem_new( void * shmem,
      49             :                    ulong  wksp_tag,
      50             :                    ulong  seed,
      51             :                    ulong  txn_max,
      52          12 :                    ulong  rec_max ) {
      53          12 :   fd_funk_shmem_t * funk = shmem;
      54          12 :   fd_wksp_t *       wksp = fd_wksp_containing( funk );
      55             : 
      56          12 :   if( FD_UNLIKELY( !funk ) ) {
      57           0 :     FD_LOG_WARNING(( "NULL funk" ));
      58           0 :     return NULL;
      59           0 :   }
      60             : 
      61          12 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)funk, fd_funk_align() ) ) ) {
      62           0 :     FD_LOG_WARNING(( "misaligned funk" ));
      63           0 :     return NULL;
      64           0 :   }
      65             : 
      66          12 :   if( FD_UNLIKELY( !wksp_tag ) ) {
      67           0 :     FD_LOG_WARNING(( "bad wksp_tag" ));
      68           0 :     return NULL;
      69           0 :   }
      70             : 
      71          12 :   if( FD_UNLIKELY( !wksp ) ) {
      72           0 :     FD_LOG_WARNING(( "shmem must be part of a workspace" ));
      73           0 :     return NULL;
      74           0 :   }
      75             : 
      76          12 :   if( FD_UNLIKELY( !txn_max || txn_max>FD_FUNK_TXN_IDX_NULL ) ) { /* See note in fd_funk.h about this limit */
      77           0 :     FD_LOG_WARNING(( "txn_max too large for index compression" ));
      78           0 :     return NULL;
      79           0 :   }
      80             : 
      81          12 :   if( FD_UNLIKELY( !rec_max || rec_max>UINT_MAX ) ) {
      82           0 :     FD_LOG_WARNING(( "invalid rec_max" ));
      83           0 :     return NULL;
      84           0 :   }
      85             : 
      86          12 :   FD_SCRATCH_ALLOC_INIT( l, funk+1 );
      87             : 
      88          12 :   ulong txn_chain_cnt = fd_funk_txn_map_chain_cnt_est( txn_max );
      89          12 :   void * txn_map = FD_SCRATCH_ALLOC_APPEND( l, fd_funk_txn_map_align(), fd_funk_txn_map_footprint( txn_chain_cnt ) );
      90          12 :   void * txn_pool = FD_SCRATCH_ALLOC_APPEND( l, fd_funk_txn_pool_align(), fd_funk_txn_pool_footprint() );
      91          12 :   fd_funk_txn_t * txn_ele = (fd_funk_txn_t *)FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_funk_txn_t), sizeof(fd_funk_txn_t) * txn_max );
      92             : 
      93           0 :   ulong rec_chain_cnt = fd_funk_rec_map_chain_cnt_est( rec_max );
      94          12 :   void * rec_map = FD_SCRATCH_ALLOC_APPEND( l, fd_funk_rec_map_align(), fd_funk_rec_map_footprint( rec_chain_cnt ) );
      95          12 :   void * rec_pool = FD_SCRATCH_ALLOC_APPEND( l, fd_funk_rec_pool_align(), fd_funk_rec_pool_footprint() );
      96          12 :   fd_funk_rec_t * rec_ele = (fd_funk_rec_t *)FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_funk_rec_t), sizeof(fd_funk_rec_t) * rec_max );
      97             : 
      98          12 :   void * alloc = FD_SCRATCH_ALLOC_APPEND( l, fd_alloc_align(), fd_alloc_footprint() );
      99             : 
     100          12 :   FD_TEST( _l == (ulong)funk + fd_funk_shmem_footprint( txn_max, rec_max ) );
     101             : 
     102          12 :   fd_memset( funk, 0, sizeof(fd_funk_shmem_t) );
     103             : 
     104          12 :   funk->funk_gaddr = fd_wksp_gaddr_fast( wksp, funk );
     105          12 :   funk->wksp_tag   = wksp_tag;
     106          12 :   funk->seed       = seed;
     107          12 :   funk->cycle_tag  = 3UL; /* various verify functions use tags 0-2 */
     108             : 
     109          12 :   funk->txn_map_gaddr = fd_wksp_gaddr_fast( wksp, fd_funk_txn_map_new( txn_map, txn_chain_cnt, seed ) );
     110          12 :   void * txn_pool2 = fd_funk_txn_pool_new( txn_pool );
     111          12 :   funk->txn_pool_gaddr = fd_wksp_gaddr_fast( wksp, txn_pool2 );
     112          12 :   fd_funk_txn_pool_t txn_join[1];
     113          12 :   fd_funk_txn_pool_join( txn_join, txn_pool2, txn_ele, txn_max );
     114          12 :   fd_funk_txn_pool_reset( txn_join, 0UL );
     115          12 :   funk->txn_ele_gaddr = fd_wksp_gaddr_fast( wksp, txn_ele );
     116          12 :   funk->txn_max = txn_max;
     117          12 :   funk->child_head_cidx = fd_funk_txn_cidx( FD_FUNK_TXN_IDX_NULL );
     118          12 :   funk->child_tail_cidx = fd_funk_txn_cidx( FD_FUNK_TXN_IDX_NULL );
     119             : 
     120         204 :   for( ulong i=0UL; i<txn_max; i++ ) {
     121         192 :     txn_join->ele[ i ].state = FD_FUNK_TXN_STATE_FREE;
     122         192 :   }
     123             : 
     124          12 :   fd_funk_txn_xid_set_root( funk->root         );
     125          12 :   fd_funk_txn_xid_set_root( funk->last_publish );
     126             : 
     127          12 :   funk->rec_map_gaddr = fd_wksp_gaddr_fast( wksp, fd_funk_rec_map_new( rec_map, rec_chain_cnt, seed ) );
     128          12 :   void * rec_pool2 = fd_funk_rec_pool_new( rec_pool );
     129          12 :   funk->rec_pool_gaddr = fd_wksp_gaddr_fast( wksp, rec_pool2 );
     130          12 :   fd_funk_rec_pool_t rec_join[1];
     131          12 :   fd_funk_rec_pool_join( rec_join, rec_pool2, rec_ele, rec_max );
     132          12 :   fd_funk_rec_pool_reset( rec_join, 0UL );
     133          12 :   funk->rec_ele_gaddr = fd_wksp_gaddr_fast( wksp, rec_ele );
     134          12 :   funk->rec_max = (uint)rec_max;
     135             : 
     136          12 :   funk->alloc_gaddr = fd_wksp_gaddr_fast( wksp, fd_alloc_join( fd_alloc_new( alloc, wksp_tag ), 0UL ) );
     137             : 
     138          12 :   FD_COMPILER_MFENCE();
     139          12 :   FD_VOLATILE( funk->magic ) = FD_FUNK_MAGIC;
     140          12 :   FD_COMPILER_MFENCE();
     141             : 
     142          12 :   return (void *)funk;
     143          12 : }
     144             : 
     145             : fd_funk_t *
     146             : fd_funk_join( fd_funk_t * ljoin,
     147             :               void *      shfunk,
     148          24 :               void *      shlocks ) {
     149          24 :   if( FD_UNLIKELY( !shfunk ) ) {
     150           0 :     FD_LOG_WARNING(( "NULL shfunk" ));
     151           0 :     return NULL;
     152           0 :   }
     153          24 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shfunk, fd_funk_align() ) ) ) {
     154           0 :     FD_LOG_WARNING(( "misaligned shfunk" ));
     155           0 :     return NULL;
     156           0 :   }
     157          24 :   fd_wksp_t * wksp = fd_wksp_containing( shfunk );
     158          24 :   if( FD_UNLIKELY( !wksp ) ) {
     159           0 :     FD_LOG_WARNING(( "shfunk must be part of a workspace" ));
     160           0 :     return NULL;
     161           0 :   }
     162             : 
     163          24 :   if( FD_UNLIKELY( !shlocks ) ) {
     164           0 :     FD_LOG_WARNING(( "NULL shlocks" ));
     165           0 :     return NULL;
     166           0 :   }
     167          24 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shlocks, fd_funk_align() ) ) ) {
     168           0 :     FD_LOG_WARNING(( "misaligned shlocks" ));
     169           0 :     return NULL;
     170           0 :   }
     171             : 
     172          24 :   fd_funk_shmem_t * shmem = shfunk;
     173          24 :   if( FD_UNLIKELY( shmem->magic!=FD_FUNK_MAGIC ) ) {
     174           0 :     if (shmem->magic == FD_FUNK_MAGIC+1) {
     175           0 :       FD_LOG_WARNING(( "attempted to join a funk that crashed in a critical section" ));
     176           0 :     } else {
     177           0 :       FD_LOG_WARNING(( "bad magic" ));
     178           0 :     }
     179           0 :     return NULL;
     180           0 :   }
     181             : 
     182          24 :   if( FD_UNLIKELY( !ljoin ) ) {
     183           0 :     FD_LOG_WARNING(( "NULL ljoin" ));
     184           0 :     return NULL;
     185           0 :   }
     186             : 
     187             : #ifdef FD_FUNK_WKSP_PROTECT
     188             :   fd_wksp_mprotect( wksp, 1 );
     189             : #endif
     190             : 
     191          24 :   fd_funk_t * funk = ljoin;
     192          24 :   memset( funk, 0, sizeof(fd_funk_t) );
     193             : 
     194          24 :   funk->shmem = shfunk;
     195          24 :   funk->wksp  = wksp;
     196             : 
     197          24 :   if( FD_UNLIKELY( !fd_funk_txn_pool_join( funk->txn_pool, fd_wksp_laddr( wksp, shmem->txn_pool_gaddr ), fd_wksp_laddr( wksp, shmem->txn_ele_gaddr ), shmem->txn_max ) ) ) {
     198           0 :     FD_LOG_WARNING(( "failed to join txn_pool" ));
     199           0 :     return NULL;
     200           0 :   }
     201          24 :   if( FD_UNLIKELY( !fd_funk_txn_map_join( funk->txn_map, fd_wksp_laddr( wksp, shmem->txn_map_gaddr ), fd_wksp_laddr_fast( wksp, shmem->txn_ele_gaddr ), shmem->txn_max ) ) ) {
     202           0 :     FD_LOG_WARNING(( "failed to join txn_map" ));
     203           0 :     return NULL;
     204           0 :   }
     205          24 :   if( FD_UNLIKELY( !fd_funk_rec_map_join( funk->rec_map, fd_wksp_laddr( wksp, shmem->rec_map_gaddr ), fd_wksp_laddr( wksp, shmem->rec_ele_gaddr ), shmem->rec_max ) ) ) {
     206           0 :     FD_LOG_WARNING(( "failed to join rec_map" ));
     207           0 :     return NULL;
     208           0 :   }
     209          24 :   if( FD_UNLIKELY( !fd_funk_rec_pool_join( funk->rec_pool, fd_wksp_laddr( wksp, shmem->rec_pool_gaddr ), fd_wksp_laddr_fast( wksp, shmem->rec_ele_gaddr ), shmem->rec_max ) ) ) {
     210           0 :     FD_LOG_WARNING(( "failed to join rec_pool" ));
     211           0 :     return NULL;
     212           0 :   }
     213          24 :   FD_SCRATCH_ALLOC_INIT( l2, shlocks );
     214          24 :   funk->txn_lock = FD_SCRATCH_ALLOC_APPEND( l2, alignof(fd_rwlock_t), sizeof(fd_rwlock_t) * shmem->txn_max );
     215          24 :   funk->rec_lock = FD_SCRATCH_ALLOC_APPEND( l2, alignof(ulong),       sizeof(ulong)       * shmem->rec_max );
     216           0 :   funk->alloc = fd_wksp_laddr( wksp, shmem->alloc_gaddr );
     217          24 :   if( FD_UNLIKELY( !fd_alloc_join( funk->alloc, fd_tile_idx() ) ) ) {
     218           0 :     FD_LOG_WARNING(( "failed to join funk alloc" ));
     219           0 :     return NULL;
     220           0 :   }
     221             : 
     222          24 :   return funk;
     223          24 : }
     224             : 
     225             : void *
     226             : fd_funk_locks_new( void * shlocks,
     227             :                    ulong  txn_max,
     228          12 :                    ulong  rec_max ) {
     229          12 :   if( FD_UNLIKELY( !shlocks ) ) {
     230           0 :     FD_LOG_WARNING(( "NULL shlocks" ));
     231           0 :     return NULL;
     232           0 :   }
     233          12 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shlocks, fd_funk_align() ) ) ) {
     234           0 :     FD_LOG_WARNING(( "misaligned shlocks" ));
     235           0 :     return NULL;
     236           0 :   }
     237          12 :   FD_SCRATCH_ALLOC_INIT( l, shlocks );
     238          12 :   fd_rwlock_t * txn_lock = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_rwlock_t), sizeof(fd_rwlock_t) * txn_max );
     239          12 :   void *        rec_lock = FD_SCRATCH_ALLOC_APPEND( l, alignof(ulong),       sizeof(ulong)       * rec_max );
     240           0 :   memset( txn_lock, 0, sizeof(fd_rwlock_t) * txn_max );
     241          12 :   memset( rec_lock, 0, sizeof(ulong) *       rec_max );
     242          12 :   return shlocks;
     243          12 : }
     244             : 
     245             : void *
     246             : fd_funk_leave( fd_funk_t * funk,
     247             :                void **     opt_shfunk,
     248          24 :                void **     opt_shlocks ) {
     249             : 
     250          24 :   if( FD_UNLIKELY( !funk ) ) {
     251           0 :     FD_LOG_WARNING(( "NULL funk" ));
     252           0 :     if( opt_shfunk  ) *opt_shfunk  = NULL;
     253           0 :     if( opt_shlocks ) *opt_shlocks = NULL;
     254           0 :     return NULL;
     255           0 :   }
     256          24 :   void * shfunk  = funk->shmem;
     257          24 :   void * shlocks = (void *)funk->txn_lock;
     258             : 
     259          24 :   memset( funk, 0, sizeof(fd_funk_t) );
     260             : 
     261          24 :   if( opt_shfunk )  *opt_shfunk  = shfunk;
     262          24 :   if( opt_shlocks ) *opt_shlocks = shlocks;
     263          24 :   return (void *)funk;
     264          24 : }
     265             : 
     266             : void *
     267          12 : fd_funk_delete( void * shfunk ) {
     268             : 
     269          12 :   if( FD_UNLIKELY( !shfunk ) ) {
     270           0 :     FD_LOG_WARNING(( "NULL shfunk" ));
     271           0 :     return NULL;
     272           0 :   }
     273             : 
     274          12 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shfunk, fd_funk_align() ) ) ) {
     275           0 :     FD_LOG_WARNING(( "misaligned shfunk" ));
     276           0 :     return NULL;
     277           0 :   }
     278             : 
     279          12 :   fd_wksp_t * wksp = fd_wksp_containing( shfunk );
     280          12 :   if( FD_UNLIKELY( !wksp ) ) {
     281           0 :     FD_LOG_WARNING(( "shfunk must be part of a workspace" ));
     282           0 :     return NULL;
     283           0 :   }
     284             : 
     285          12 :   fd_funk_shmem_t * shmem = shfunk;
     286          12 :   if( FD_UNLIKELY( shmem->magic!=FD_FUNK_MAGIC ) ) {
     287           0 :     FD_LOG_WARNING(( "bad magic" ));
     288           0 :     return NULL;
     289           0 :   }
     290             : 
     291             :   /* Free all fd_alloc allocations made, individually
     292             :      (FIXME consider walking the element pool instead of the map?) */
     293             : 
     294          12 :   fd_alloc_t * alloc = fd_alloc_join( fd_wksp_laddr_fast( wksp, shmem->alloc_gaddr ), fd_tile_idx() );
     295             : 
     296          12 :   void * shmap = fd_wksp_laddr_fast( wksp, shmem->rec_map_gaddr );
     297          12 :   void * shele = fd_wksp_laddr_fast( wksp, shmem->rec_ele_gaddr );
     298          12 :   fd_funk_rec_map_t rec_map[1];
     299          12 :   if( FD_UNLIKELY( !fd_funk_rec_map_join( rec_map, shmap, shele, 0UL ) ) ) {
     300           0 :     FD_LOG_ERR(( "failed to join rec_map (corrupt funk?)" ));
     301           0 :     return NULL;
     302           0 :   }
     303          12 :   ulong chain_cnt = fd_funk_rec_map_chain_cnt( rec_map );
     304        6156 :   for( ulong chain_idx=0UL; chain_idx<chain_cnt; chain_idx++ ) {
     305        6144 :     for(
     306        6144 :         fd_funk_rec_map_iter_t iter = fd_funk_rec_map_iter( rec_map, chain_idx );
     307        6144 :         !fd_funk_rec_map_iter_done( iter );
     308        6144 :         iter = fd_funk_rec_map_iter_next( iter )
     309        6144 :     ) {
     310           0 :       fd_funk_val_flush( fd_funk_rec_map_iter_ele( iter ), alloc, wksp );
     311           0 :     }
     312        6144 :   }
     313             : 
     314          12 :   fd_funk_rec_map_leave( rec_map );
     315             : 
     316          12 :   FD_COMPILER_MFENCE();
     317          12 :   FD_VOLATILE( shmem->magic ) = 0UL;
     318          12 :   FD_COMPILER_MFENCE();
     319             : 
     320             :   /* Free the fd_alloc instance */
     321             : 
     322          12 :   fd_wksp_free_laddr( fd_alloc_delete( fd_alloc_leave( alloc ) ) );
     323             : 
     324          12 :   return shmem;
     325          12 : }
     326             : 
     327             : void
     328           0 : fd_funk_delete_fast( void * shfunk ) {
     329             : 
     330           0 :   if( FD_UNLIKELY( !shfunk ) ) {
     331           0 :     FD_LOG_WARNING(( "NULL shfunk" ));
     332           0 :   }
     333             : 
     334           0 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shfunk, fd_funk_align() ) ) ) {
     335           0 :     FD_LOG_WARNING(( "misaligned shfunk" ));
     336           0 :   }
     337             : 
     338           0 :   fd_funk_shmem_t * shmem = shfunk;
     339           0 :   if( FD_UNLIKELY( shmem->magic!=FD_FUNK_MAGIC ) ) {
     340           0 :     FD_LOG_WARNING(( "bad magic" ));
     341           0 :   }
     342             : 
     343           0 :   fd_wksp_t * wksp = fd_wksp_containing( shmem );
     344           0 :   if( FD_UNLIKELY( !wksp ) ) {
     345           0 :     FD_LOG_WARNING(( "shfunk must be part of a workspace" ));
     346           0 :   }
     347             : 
     348           0 :   ulong const tags[1] = { shmem->wksp_tag };
     349           0 :   fd_wksp_tag_free( wksp, tags, 1UL );
     350             : 
     351           0 : }
     352             : 
     353             : int
     354           0 : fd_funk_verify( fd_funk_t * join ) {
     355           0 :   fd_funk_shmem_t * funk = join->shmem;
     356             : 
     357           0 : # define TEST(c) do {                                                                           \
     358           0 :     if( FD_UNLIKELY( !(c) ) ) { FD_LOG_WARNING(( "FAIL: %s", #c )); return FD_FUNK_ERR_INVAL; } \
     359           0 :   } while(0)
     360             : 
     361           0 :   TEST( funk );
     362             : 
     363             :   /* Test metadata */
     364             : 
     365           0 :   TEST( funk->magic==FD_FUNK_MAGIC );
     366             : 
     367           0 :   ulong funk_gaddr = funk->funk_gaddr;
     368           0 :   TEST( funk_gaddr );
     369           0 :   fd_wksp_t * wksp = fd_funk_wksp( join );
     370           0 :   TEST( wksp );
     371           0 :   TEST( fd_wksp_laddr_fast( wksp, funk_gaddr )==(void *)funk );
     372           0 :   TEST( fd_wksp_gaddr_fast( wksp, funk       )==funk_gaddr   );
     373             : 
     374           0 :   ulong wksp_tag = fd_funk_wksp_tag( join );
     375           0 :   TEST( !!wksp_tag );
     376             : 
     377           0 :   ulong seed = funk->seed; /* seed can be anything */
     378             : 
     379           0 :   TEST( funk->cycle_tag>2UL );
     380             : 
     381             :   /* Test transaction map */
     382             : 
     383           0 :   ulong txn_max = fd_funk_txn_pool_ele_max( join->txn_pool );
     384           0 :   TEST( txn_max<=FD_FUNK_TXN_IDX_NULL );
     385             : 
     386           0 :   ulong txn_map_gaddr = funk->txn_map_gaddr;
     387           0 :   TEST( txn_map_gaddr );
     388           0 :   fd_funk_txn_map_t * txn_map = fd_funk_txn_map( join );
     389           0 :   ulong txn_chain_cnt = fd_funk_txn_map_chain_cnt_est( txn_max );
     390           0 :   TEST( txn_chain_cnt==fd_funk_txn_map_chain_cnt( txn_map ) );
     391           0 :   TEST( seed==fd_funk_txn_map_seed( txn_map ) );
     392             : 
     393           0 :   ulong child_head_idx = fd_funk_txn_idx( funk->child_head_cidx );
     394           0 :   ulong child_tail_idx = fd_funk_txn_idx( funk->child_tail_cidx );
     395             : 
     396           0 :   int null_child_head = fd_funk_txn_idx_is_null( child_head_idx );
     397           0 :   int null_child_tail = fd_funk_txn_idx_is_null( child_tail_idx );
     398             : 
     399           0 :   if( !txn_max ) TEST( null_child_head & null_child_tail );
     400           0 :   else {
     401           0 :     if( null_child_head ) TEST( null_child_tail );
     402           0 :     else                  TEST( child_head_idx<txn_max );
     403             : 
     404           0 :     if( null_child_tail ) TEST( null_child_head );
     405           0 :     else                  TEST( child_tail_idx<txn_max );
     406           0 :   }
     407             : 
     408           0 :   if( !txn_max ) TEST( fd_funk_txn_idx_is_null( child_tail_idx ) );
     409             : 
     410           0 :   fd_funk_txn_xid_t const * root = fd_funk_root( join );
     411           0 :   TEST( root ); /* Practically guaranteed */
     412           0 :   TEST( fd_funk_txn_xid_eq_root( root ) );
     413             : 
     414           0 :   fd_funk_txn_xid_t * last_publish = funk->last_publish;
     415           0 :   TEST( last_publish ); /* Practically guaranteed */
     416             :   /* (*last_publish) only be root at creation and anything but root post
     417             :      creation.  But we don't know which situation applies here so this
     418             :      could be anything. */
     419             : 
     420           0 :   TEST( !fd_funk_txn_verify( join ) );
     421             : 
     422             :   /* Test record map */
     423             : 
     424           0 :   ulong rec_max = fd_funk_rec_pool_ele_max( join->rec_pool );
     425           0 :   TEST( rec_max<=FD_FUNK_TXN_IDX_NULL );
     426             : 
     427           0 :   ulong rec_map_gaddr = funk->rec_map_gaddr;
     428           0 :   TEST( rec_map_gaddr );
     429           0 :   fd_funk_rec_map_t * rec_map = fd_funk_rec_map( join );
     430           0 :   ulong rec_chain_cnt = fd_funk_rec_map_chain_cnt_est( rec_max );
     431           0 :   TEST( rec_chain_cnt==fd_funk_rec_map_chain_cnt( rec_map ) );
     432           0 :   TEST( seed==fd_funk_rec_map_seed( rec_map ) );
     433             : 
     434           0 :   TEST( !fd_funk_rec_verify( join ) );
     435             : 
     436             :   /* Test values */
     437             : 
     438           0 :   ulong alloc_gaddr = funk->alloc_gaddr;
     439           0 :   TEST( alloc_gaddr );
     440           0 :   fd_alloc_t * alloc = fd_funk_alloc( join );
     441           0 :   TEST( alloc );
     442             : 
     443           0 :   TEST( !fd_funk_val_verify( join ) );
     444             : 
     445           0 : # undef TEST
     446             : 
     447           0 :   return FD_FUNK_SUCCESS;
     448           0 : }

Generated by: LCOV version 1.14