Skip to content

Commit 8bb37a4

Browse files
committed
chore(forest): polish APIs and renaming
1 parent ad953f5 commit 8bb37a4

File tree

9 files changed

+240
-247
lines changed

9 files changed

+240
-247
lines changed

src/choreo/tower/fd_tower.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ fd_tower_to_vote_txn( fd_tower_t const * tower,
502502
tower_sync.root = root;
503503
tower_sync.lockouts_len = (ushort)fd_tower_votes_cnt( tower );
504504
tower_sync.lockouts = lockouts_scratch;
505-
tower_sync.timestamp = (long)(fd_log_wallclock() / 1e9L); /* seconds */
505+
tower_sync.timestamp = fd_log_wallclock() / (long)1e9; /* seconds */
506506
tower_sync.has_timestamp = 1;
507507

508508
ulong prev = tower_sync.root;

src/disco/store/fd_store.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ FD_FN_PURE static inline fd_store_fec_t const * fd_store_child_const ( fd_store
335335
FD_FN_PURE static inline fd_store_fec_t * fd_store_sibling ( fd_store_t * store, fd_store_fec_t const * fec ) { fd_store_pool_t pool = fd_store_pool ( store ); return fd_store_pool_ele ( &pool, fec->sibling ); }
336336
FD_FN_PURE static inline fd_store_fec_t const * fd_store_sibling_const( fd_store_t const * store, fd_store_fec_t const * fec ) { fd_store_pool_t pool = fd_store_pool_const( store ); return fd_store_pool_ele_const( &pool, fec->sibling ); }
337337

338-
/* fd_store_{shacq, shrel, exacq, exrel} acquires or releases the shared
339-
or exclusive lock. */
338+
/* fd_store_{shacq, shrel, exacq, exrel} acquires / releases the
339+
shared / exclusive lock. */
340340

341341
FD_FN_PURE static inline void fd_store_shacq( fd_store_t * store ) { fd_rwlock_read ( &store->lock ); }
342342
FD_FN_PURE static inline void fd_store_shrel( fd_store_t * store ) { fd_rwlock_unread ( &store->lock ); }

src/discof/forest/fd_forest.c

Lines changed: 91 additions & 95 deletions
Large diffs are not rendered by default.

src/discof/forest/fd_forest.h

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,19 @@
3030

3131
#define FD_FOREST_MAGIC (0xf17eda2ce7b1c0UL) /* firedancer forest version 0 */
3232

33-
#define SET_NAME fd_forest_ele_idxs
33+
#define SET_NAME fd_forest_blk_idxs
3434
#define SET_MAX FD_SHRED_BLK_MAX
3535
#include "../../util/tmpl/fd_set.c"
3636

37-
38-
/* fd_forest_ele_t implements a left-child, right-sibling n-ary
37+
/* fd_forest_blk_t implements a left-child, right-sibling n-ary
3938
tree. Each ele maintains the `pool` index of its left-most child
4039
(`child_idx`), its immediate-right sibling (`sibling_idx`), and its
4140
parent (`parent_idx`).
4241
4342
This tree structure is gaddr-safe and supports accesses and
4443
operations from processes with separate local forest joins. */
4544

46-
struct __attribute__((aligned(128UL))) fd_forest_ele {
45+
struct __attribute__((aligned(128UL))) fd_forest_blk {
4746
ulong slot; /* map key */
4847
ulong parent_slot; /* map key of the parent. invariant: if parent is populated, parent_slot is populated. the converse is not necessarily true. */
4948
ulong next; /* internal use by fd_pool, fd_map_chain */
@@ -55,32 +54,32 @@ struct __attribute__((aligned(128UL))) fd_forest_ele {
5554
uint buffered_idx; /* highest contiguous buffered shred idx */
5655
uint complete_idx; /* shred_idx with SLOT_COMPLETE_FLAG ie. last shred idx in the slot */
5756

58-
fd_forest_ele_idxs_t fecs[fd_forest_ele_idxs_word_cnt]; /* last shred idx of every FEC set */
59-
fd_forest_ele_idxs_t idxs[fd_forest_ele_idxs_word_cnt]; /* data shred idxs */
57+
fd_forest_blk_idxs_t fecs[fd_forest_blk_idxs_word_cnt]; /* last shred idx of every FEC set */
58+
fd_forest_blk_idxs_t idxs[fd_forest_blk_idxs_word_cnt]; /* data shred idxs */
6059
};
61-
typedef struct fd_forest_ele fd_forest_ele_t;
60+
typedef struct fd_forest_blk fd_forest_blk_t;
6261

6362
#define POOL_NAME fd_forest_pool
64-
#define POOL_T fd_forest_ele_t
63+
#define POOL_T fd_forest_blk_t
6564
#include "../../util/tmpl/fd_pool.c"
6665

6766
#define MAP_NAME fd_forest_ancestry
68-
#define MAP_ELE_T fd_forest_ele_t
67+
#define MAP_ELE_T fd_forest_blk_t
6968
#define MAP_KEY slot
7069
#include "../../util/tmpl/fd_map_chain.c"
7170

7271
#define MAP_NAME fd_forest_frontier
73-
#define MAP_ELE_T fd_forest_ele_t
72+
#define MAP_ELE_T fd_forest_blk_t
7473
#define MAP_KEY slot
7574
#include "../../util/tmpl/fd_map_chain.c"
7675

7776
#define MAP_NAME fd_forest_orphaned
78-
#define MAP_ELE_T fd_forest_ele_t
77+
#define MAP_ELE_T fd_forest_blk_t
7978
#define MAP_KEY slot
8079
#include "../../util/tmpl/fd_map_chain.c"
8180

8281
#define MAP_NAME fd_forest_subtrees
83-
#define MAP_ELE_T fd_forest_ele_t
82+
#define MAP_ELE_T fd_forest_blk_t
8483
#define MAP_KEY slot
8584
#include "../../util/tmpl/fd_map_chain.c"
8685

@@ -139,7 +138,7 @@ struct __attribute__((aligned(128UL))) fd_forest {
139138
ulong ver_gaddr; /* wksp gaddr of version fseq, incremented on write ops */
140139
ulong pool_gaddr; /* wksp gaddr of fd_pool */
141140
ulong ancestry_gaddr; /* wksp_gaddr of fd_forest_ancestry */
142-
ulong frontier_gaddr; /* leaves that needs repair) */
141+
ulong frontier_gaddr; /* leaves that needs repair */
143142
ulong subtrees_gaddr; /* head of orphaned trees */
144143
ulong orphaned_gaddr; /* map of parent_slot to singly-linked list of ele orphaned by that parent slot */
145144

@@ -273,12 +272,12 @@ fd_forest_ver_const( fd_forest_t const * forest ) {
273272
/* fd_forest_{pool, pool_const} returns a pointer in the caller's address
274273
space to forest's element pool. */
275274

276-
FD_FN_PURE static inline fd_forest_ele_t *
275+
FD_FN_PURE static inline fd_forest_blk_t *
277276
fd_forest_pool( fd_forest_t * forest ) {
278277
return fd_wksp_laddr_fast( fd_forest_wksp( forest ), forest->pool_gaddr );
279278
}
280279

281-
FD_FN_PURE static inline fd_forest_ele_t const *
280+
FD_FN_PURE static inline fd_forest_blk_t const *
282281
fd_forest_pool_const( fd_forest_t const * forest ) {
283282
return fd_wksp_laddr_fast( fd_forest_wksp( forest ), forest->pool_gaddr );
284283
}
@@ -370,35 +369,34 @@ fd_forest_root_slot( fd_forest_t const * forest ) {
370369
return fd_forest_pool_ele_const( fd_forest_pool_const( forest ), forest->root )->slot;
371370
}
372371

373-
fd_forest_ele_t *
372+
fd_forest_blk_t *
374373
fd_forest_query( fd_forest_t * forest, ulong slot );
375374

376375
/* Operations */
377376

378-
/* fd_forest_block_insert inserts a new block into the forest.
379-
Assumes slot >= forest->smr, and the ele pool has a free
380-
element (if handholding is enabled, explicitly checks and errors).
381-
This block insert is idempotent, and can be called multiple times
382-
with the same slot.
383-
Returns the inserted forest ele. */
377+
/* fd_forest_blk_insert inserts a new block into the forest. Assumes
378+
slot >= forest->smr, and the blk pool has a free element (if
379+
handholding is enabled, explicitly checks and errors). This blk
380+
insert is idempotent, and can be called multiple times with the same
381+
slot. Returns the inserted forest ele. */
384382

385-
fd_forest_ele_t *
386-
fd_forest_block_insert( fd_forest_t * forest, ulong slot, ulong parent_slot );
383+
fd_forest_blk_t *
384+
fd_forest_blk_insert( fd_forest_t * forest, ulong slot, ulong parent_slot );
387385

388386
/* fd_forest_shred_insert inserts a new shred into the forest.
389387
Assumes slot is already in forest, and should typically be called
390388
directly after fd_forest_block_insert. Returns the forest ele
391389
corresponding to the shred slot. */
392390

393-
fd_forest_ele_t *
391+
fd_forest_blk_t *
394392
fd_forest_data_shred_insert( fd_forest_t * forest, ulong slot, ulong parent_slot, uint shred_idx, uint fec_set_idx, int slot_complete );
395393

396394
/* fd_forest_publish publishes slot as the new forest root, setting
397395
the subtree beginning from slot as the new forest tree (ie. slot
398396
and all its descendants). Prunes all eles not in slot's forest.
399397
Assumes slot is present in forest. Returns the new root. */
400398

401-
fd_forest_ele_t const *
399+
fd_forest_blk_t const *
402400
fd_forest_publish( fd_forest_t * forest, ulong slot );
403401

404402
struct fd_forest_iter {
@@ -466,7 +464,7 @@ fd_forest_frontier_print( fd_forest_t const * forest );
466464
starting from the grandparent of the most recently executed slot:
467465
468466
```
469-
fd_forest_ele_t const * ele = fd_forest_query( slot );
467+
fd_forest_blk_t const * ele = fd_forest_query( slot );
470468
fd_forest_print( forest, fd_forest_parent( fd_forest_parent( ele ) ) )
471469
```
472470

0 commit comments

Comments
 (0)