Skip to content

replay: buffer forward confirmations#10068

Open
emwang-jump wants to merge 4 commits into
mainfrom
emwang/reasm-buffer-conf
Open

replay: buffer forward confirmations#10068
emwang-jump wants to merge 4 commits into
mainfrom
emwang/reasm-buffer-conf

Conversation

@emwang-jump

Copy link
Copy Markdown
Contributor

No description provided.

@emwang-jump emwang-jump marked this pull request as ready for review June 4, 2026 23:46
Copilot AI review requested due to automatic review settings June 4, 2026 23:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_confirmed buffer (pool + map + dlist) and integrate it into the replay tile to store duplicate-confirmed block IDs until they can be confirmed in reasm.
  • Add fd_reasm_query_connected() and fd_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 );
Copilot AI review requested due to automatic review settings June 5, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants