replay: buffer forward confirmations#10068
Open
emwang-jump wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds buffering for forward duplicate confirmations coming from Tower so that confirmations that arrive before the connecting FEC (i.e., while the slot’s block ID is still orphaned/disconnected in reasm) can be applied once the corresponding subtree becomes connected.
Changes:
- Add a new
fd_fwd_confirmedbuffer (pool + map + dlist) and integrate it into the replay tile to store duplicate-confirmed block IDs until they can be confirmed inreasm. - Add
fd_reasm_query_connected()andfd_reasm_subtree_iter()to support “connected-only” lookups and DFS traversal of newly-connected adopted subtrees. - Add unit tests for the new subtree iterator behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/discof/replay/fd_replay_tile.c |
Buffers duplicate confirmations when the confirmed block ID isn’t connected yet; drains buffered confirmations when inserts connect orphan subtrees. |
src/discof/replay/fd_replay_tile_private.h |
Adds fd_fwd_confirmed_t * to replay tile context and includes the new header. |
src/discof/replay/fd_fwd_confirmed.h |
New public API for buffering forward-confirmed block IDs. |
src/discof/replay/fd_fwd_confirmed.c |
New implementation of the forward-confirmation buffer. |
src/discof/reasm/test_reasm.c |
Adds tests validating fd_reasm_subtree_iter() traversal order and adoption behavior. |
src/discof/reasm/fd_reasm.h |
Declares fd_reasm_query_connected() and fd_reasm_subtree_iter(). |
src/discof/reasm/fd_reasm.c |
Implements connected-only query and DFS subtree iterator. |
Comment on lines
+45
to
+51
| fd_fwd_confirmed_footprint( ulong max ) { | ||
| ulong l = FD_LAYOUT_INIT; | ||
| l = FD_LAYOUT_APPEND( l, fd_fwd_confirmed_align(), sizeof(fd_fwd_confirmed_t) ); | ||
| l = FD_LAYOUT_APPEND( l, confirmed_map_align(), confirmed_map_footprint( max ) ); | ||
| l = FD_LAYOUT_APPEND( l, confirmed_dlist_align(), confirmed_dlist_footprint() ); | ||
| l = FD_LAYOUT_APPEND( l, confirmed_pool_align(), confirmed_pool_footprint( max ) ); | ||
| return FD_LAYOUT_FINI( l, fd_fwd_confirmed_align() ); |
Comment on lines
+64
to
+73
| FD_SCRATCH_ALLOC_INIT( l, shmem ); | ||
| fd_fwd_confirmed_t * buf = FD_SCRATCH_ALLOC_APPEND( l, fd_fwd_confirmed_align(), sizeof(fd_fwd_confirmed_t) ); | ||
| void * map_mem = FD_SCRATCH_ALLOC_APPEND( l, confirmed_map_align(), confirmed_map_footprint( max ) ); | ||
| void * dlist_mem = FD_SCRATCH_ALLOC_APPEND( l, confirmed_dlist_align(), confirmed_dlist_footprint() ); | ||
| void * pool_mem = FD_SCRATCH_ALLOC_APPEND( l, confirmed_pool_align(), confirmed_pool_footprint( max ) ); | ||
| FD_TEST( FD_SCRATCH_ALLOC_FINI( l, fd_fwd_confirmed_align() ) == (ulong)shmem + footprint ); | ||
|
|
||
| buf->map = confirmed_map_new ( map_mem, max, 0UL ); | ||
| buf->dlist = confirmed_dlist_new( dlist_mem ); | ||
| buf->pool = confirmed_pool_new ( pool_mem, max ); |
Comment on lines
+87
to
+101
| void | ||
| fd_fwd_confirmed_insert( fd_fwd_confirmed_t * buf, | ||
| fd_hash_t const * block_id ) { | ||
| if( FD_UNLIKELY( !confirmed_pool_free( buf->pool ) ) ) { | ||
| confirmed_t * oldest = confirmed_dlist_ele_peek_head( buf->dlist, buf->pool ); | ||
| confirmed_map_ele_remove ( buf->map, &oldest->block_id, NULL, buf->pool ); | ||
| confirmed_dlist_ele_remove( buf->dlist, oldest, buf->pool ); | ||
| confirmed_pool_ele_release( buf->pool, oldest ); | ||
| } | ||
|
|
||
| confirmed_t * ele = confirmed_pool_ele_acquire( buf->pool ); | ||
| ele->block_id = *block_id; | ||
| confirmed_map_ele_insert ( buf->map, ele, buf->pool ); | ||
| confirmed_dlist_ele_push_tail( buf->dlist, ele, buf->pool ); | ||
| } |
Comment on lines
+1
to
+2
| #include "fd_fwd_confirmed.h" | ||
| #include "../../flamenco/fd_flamenco_base.h" |
| FD_TEST( ctx->block_id_map ); | ||
| for( ulong i=0UL; i<tile->replay.max_live_slots; i++ ) ctx->block_id_arr[ i ].block_id_seen = 0; | ||
|
|
||
| ctx->fwd_confirmed = fd_fwd_confirmed_join( fd_fwd_confirmed_new( fwd_confirmed_mem, tile->replay.max_live_slots ) ); |
| fd_tower_slot_confirmed_t const * msg = fd_chunk_to_laddr( ctx->in[ in_idx ].mem, chunk ); | ||
| if( msg->level==FD_TOWER_SLOT_CONFIRMED_OPTIMISTIC && !msg->fwd ) process_tower_optimistic_confirmed( ctx, stem, msg ); | ||
| if( msg->level==FD_TOWER_SLOT_CONFIRMED_DUPLICATE ) fd_reasm_confirm( ctx->reasm, &msg->block_id ); | ||
| if( msg->level==FD_TOWER_SLOT_CONFIRMED_DUPLICATE ) process_tower_duplicate_confirmed ( ctx, msg ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.