Skip to content

refactor(reasm): key reasm FECs by merkle root and rework tile root init #5903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/src/choreo @lidatong @emwang-jump
/src/disco/pack @ptaffet-jump @mmcgee-jump
/src/disco/shred @ptaffet-jump @mmcgee-jump
/src/disco/reasm @lidatong @emwang-jump
/src/disco/store @lidatong @emwang-jump
/src/discof/repair @lidatong @emwang-jump
/src/waltz/quic @nbridge-jump @ripatel-fd @akhinvasara-jumptrading
/src/waltz/tls @ripatel-fd @mmcgee-jump
Expand Down
12 changes: 6 additions & 6 deletions src/app/firedancer-dev/commands/backtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "../../../disco/metrics/fd_metrics.h"
#include "../../../util/pod/fd_pod_format.h"
#include "../../../discof/replay/fd_replay_notif.h"
#include "../../../discof/repair/fd_fec_chainer.h"
#include "../../../discof/repair/fd_reasm.h"
#include "../../../flamenco/runtime/fd_runtime_public.h" /* FD_RUNTIME_PUBLIC_ACCOUNT_UPDATE_MSG_MTU */
#include "../main.h"

Expand Down Expand Up @@ -109,7 +109,7 @@ backtest_topo( config_t * config ) {
batches from the CLI-specified source (eg. RocksDB). */

fd_topob_wksp( topo, "repair_repla" );
fd_topob_link( topo, "repair_repla", "repair_repla", 65536UL, sizeof(fd_fec_out_t), 1UL );
fd_topob_link( topo, "repair_repla", "repair_repla", 65536UL, sizeof(fd_reasm_fec_t), 1UL );
fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "repair_repla", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
fd_topob_tile_out( topo, "back", 0UL, "repair_repla", 0UL );

Expand Down Expand Up @@ -155,10 +155,10 @@ backtest_topo( config_t * config ) {
This allows the replay tile to advance its watermark, and publish
various data structures. This is an oversimplified barebones mock
of the tower tile. */
fd_topob_wksp( topo, "tower_replay" );
fd_topob_link( topo, "tower_replay", "tower_replay", 128UL, 0UL, 1UL );
fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "tower_replay", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
fd_topob_tile_out( topo, "back", 0UL, "tower_replay", 0UL );
fd_topob_wksp( topo, "root_out" );
fd_topob_link( topo, "root_out", "root_out", 128UL, 0UL, 1UL );
fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "root_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
fd_topob_tile_out( topo, "back", 0UL, "root_out", 0UL );

/**********************************************************************/
/* Setup replay->stake/send/poh links in topo w/o consumers */
Expand Down
14 changes: 10 additions & 4 deletions src/app/firedancer-dev/commands/repair.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ repair_topo( config_t * config ) {
fd_topob_wksp( topo, "gossip" );
fd_topob_wksp( topo, "metric" );
fd_topob_wksp( topo, "fec_sets" );
fd_topob_wksp( topo, "snap_out" );

fd_topob_wksp( topo, "slot_fseqs" ); /* fseqs for marked slots eg. turbine slot */

Expand Down Expand Up @@ -132,14 +133,17 @@ repair_topo( config_t * config ) {

/**/ fd_topob_link( topo, "repair_net", "net_repair", config->net.ingress_buffer_size, FD_NET_MTU, 1UL );
/**/ fd_topob_link( topo, "repair_sign", "repair_sign", 128UL, 2048UL, 1UL );
FOR(shred_tile_cnt) fd_topob_link( topo, "shred_repair", "shred_repair", pending_fec_shreds_depth, FD_SHRED_REPAIR_MTU, 2UL /* at most 2 msgs per after_frag */ );
FOR(shred_tile_cnt) fd_topob_link( topo, "shred_repair", "shred_repair", pending_fec_shreds_depth, FD_SHRED_REPAIR_MTU, 2UL );

FOR(shred_tile_cnt) fd_topob_link( topo, "repair_shred", "shred_repair", pending_fec_shreds_depth, sizeof(fd_ed25519_sig_t), 1UL );
/**/ fd_topob_link( topo, "sign_repair", "sign_repair", 128UL, 64UL, 1UL );
/**/ fd_topob_link( topo, "repair_repla", "repair_repla", 65536UL, sizeof(fd_fec_out_t), 1UL );
/**/ fd_topob_link( topo, "repair_repla", "repair_repla", 65536UL, sizeof(fd_reasm_fec_t), 1UL );
/**/ fd_topob_link( topo, "poh_shred", "poh_shred", 16384UL, USHORT_MAX, 1UL );

/**/ fd_topob_link( topo, "send_txns", "send_txns", 128UL, FD_TXN_MTU, 1UL );
/**/ fd_topob_link( topo, "send_txns", "send_txns", 128UL, FD_TXN_MTU, 1UL );

FD_TEST( sizeof(fd_snapshot_manifest_t)<=(5UL*(1UL<<30UL)) );
/**/ fd_topob_link( topo, "snap_out", "snap_out", 2UL, 5UL*(1UL<<30UL), 1UL );

ushort parsed_tile_to_cpu[ FD_TILE_MAX ];
/* Unassigned tiles will be floating, unless auto topology is enabled. */
Expand Down Expand Up @@ -296,6 +300,7 @@ repair_topo( config_t * config ) {
FOR(net_tile_cnt) fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "net_repair", i, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "gossip_repai", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "snap_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
FOR(shred_tile_cnt) fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "shred_repair", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );

/**/ fd_topob_tile_in( topo, "sign", 0UL, "metric_in", "repair_sign", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
Expand Down Expand Up @@ -330,7 +335,8 @@ repair_topo( config_t * config ) {
fd_topob_tile_in( topo, "scap", 0UL, "metric_in", "replay_scap", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );

fd_topob_tile_uses( topo, scap_tile, root_slot_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
fd_topob_tile_out( topo, "scap", 0UL, "stake_out", 0UL );
fd_topob_tile_out( topo, "scap", 0UL, "stake_out", 0UL );
fd_topob_tile_out( topo, "scap", 0UL, "snap_out", 0UL );
}

FD_TEST( link_permit_no_producers( topo, "quic_net" ) == quic_tile_cnt );
Expand Down
33 changes: 17 additions & 16 deletions src/app/firedancer/topology.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "topology.h"

#include "../../discof/repair/fd_fec_chainer.h"
#include "../../choreo/fd_choreo_base.h"
#include "../../discof/repair/fd_reasm.h"
#include "../../discof/replay/fd_replay_notif.h"
#include "../../disco/net/fd_net_tile.h"
#include "../../disco/quic/fd_tpu.h"
Expand Down Expand Up @@ -244,7 +245,8 @@ fd_topo_initialize( config_t * config ) {
fd_topob_wksp( topo, "gossip_repai" );
fd_topob_wksp( topo, "gossip_verif" );
fd_topob_wksp( topo, "gossip_tower" );
fd_topob_wksp( topo, "replay_tower" );
fd_topob_wksp( topo, "replay_out" );
fd_topob_wksp( topo, "root_out" );

fd_topob_wksp( topo, "repair_sign" );
fd_topob_wksp( topo, "sign_repair" );
Expand Down Expand Up @@ -337,8 +339,8 @@ fd_topo_initialize( config_t * config ) {

/**/ fd_topob_link( topo, "gossip_verif", "gossip_verif", config->tiles.verify.receive_buffer_size, FD_TPU_RAW_MTU, 1UL );
/**/ fd_topob_link( topo, "gossip_tower", "gossip_tower", 128UL, FD_TPU_MTU, 1UL );
/**/ fd_topob_link( topo, "replay_tower", "replay_tower", 128UL, 65536UL, 1UL );
/**/ fd_topob_link( topo, "tower_replay", "replay_tower", 128UL, 0, 1UL );
/**/ fd_topob_link( topo, "replay_out", "replay_out", 128UL, sizeof(fd_replay_out_t), 1UL );
/**/ fd_topob_link( topo, "root_out", "root_out", 128UL, sizeof(fd_block_id_t), 1UL );

/**/ fd_topob_link( topo, "crds_shred", "crds_shred", 128UL, 8UL + 40200UL * 38UL, 1UL );
/**/ fd_topob_link( topo, "gossip_repai", "gossip_repai", 128UL, 40200UL * 38UL, 1UL );
Expand All @@ -353,7 +355,7 @@ fd_topo_initialize( config_t * config ) {

FOR(shred_tile_cnt) fd_topob_link( topo, "repair_shred", "shred_repair", pending_fec_shreds_depth, sizeof(fd_ed25519_sig_t), 1UL );
/**/ fd_topob_link( topo, "sign_repair", "sign_repair", 128UL, 64UL, 1UL );
/**/ fd_topob_link( topo, "repair_repla", "repair_repla", 65536UL, sizeof(fd_fec_out_t), 1UL );
/**/ fd_topob_link( topo, "repair_repla", "repair_repla", 65536UL, sizeof(fd_reasm_fec_t), 1UL );
/**/ fd_topob_link( topo, "poh_shred", "poh_shred", 16384UL, USHORT_MAX, 1UL );
/**/ fd_topob_link( topo, "poh_pack", "replay_poh", 128UL, sizeof(fd_became_leader_t) , 1UL );
FOR(bank_tile_cnt) fd_topob_link( topo, "replay_poh", "replay_poh", 128UL, (4096UL*sizeof(fd_txn_p_t))+sizeof(fd_microblock_trailer_t), 1UL );
Expand Down Expand Up @@ -525,7 +527,6 @@ fd_topo_initialize( config_t * config ) {

for( ulong i=0UL; i<exec_tile_cnt; i++ ) {
fd_topo_obj_t * exec_fseq_obj = fd_topob_obj( topo, "fseq", "exec_fseq" );
fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], exec_fseq_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
fd_topob_tile_uses( topo, replay_tile, exec_fseq_obj, FD_SHMEM_JOIN_MODE_READ_ONLY );
FD_TEST( fd_pod_insertf_ulong( topo->props, exec_fseq_obj->id, "exec_fseq.%lu", i ) );
}
Expand All @@ -552,7 +553,6 @@ fd_topo_initialize( config_t * config ) {

fd_topo_obj_t * root_slot_obj = fd_topob_obj( topo, "fseq", "slot_fseqs" );
fd_topob_tile_uses( topo, replay_tile, root_slot_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
fd_topob_tile_uses( topo, repair_tile, root_slot_obj, FD_SHMEM_JOIN_MODE_READ_ONLY );
FD_TEST( fd_pod_insertf_ulong( topo->props, root_slot_obj->id, "root_slot" ) );

/* turbine_slot0 is an fseq marking the slot number of the first shred
Expand Down Expand Up @@ -637,10 +637,10 @@ fd_topo_initialize( config_t * config ) {

/**/ fd_topob_tile_out( topo, "repair", 0UL, "repair_net", 0UL );

/**/ fd_topob_tile_in( topo, "tower", 0UL, "metric_in", "gossip_tower", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
/**/ fd_topob_tile_in( topo, "tower", 0UL, "metric_in", "replay_tower", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );

/**/ fd_topob_tile_out( topo, "tower", 0UL, "tower_replay", 0UL );
/**/ fd_topob_tile_in ( topo, "tower", 0UL, "metric_in", "gossip_tower", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
/**/ fd_topob_tile_in ( topo, "tower", 0UL, "metric_in", "replay_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_in ( topo, "tower", 0UL, "metric_in", "snap_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_out( topo, "tower", 0UL, "root_out", 0UL );
/**/ fd_topob_tile_out( topo, "tower", 0UL, "tower_send", 0UL );

/* Sign links don't need to be reliable because they are synchronous,
Expand Down Expand Up @@ -669,12 +669,13 @@ fd_topo_initialize( config_t * config ) {
FOR(net_tile_cnt) fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "net_repair", i, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "gossip_repai", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "snap_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
FOR(shred_tile_cnt) fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "shred_repair", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );

/**/ fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "repair_repla", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_in ( topo, "replay", 0UL, "metric_in", "repair_repla", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_out( topo, "replay", 0UL, "stake_out", 0UL );
/**/ fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "tower_replay", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_out( topo, "replay", 0UL, "replay_tower", 0UL );
/**/ fd_topob_tile_in ( topo, "replay", 0UL, "metric_in", "root_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_out( topo, "replay", 0UL, "replay_out", 0UL );
FOR(bank_tile_cnt) fd_topob_tile_out( topo, "replay", 0UL, "replay_poh", i );
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "replay", 0UL, "replay_exec", i ); /* TODO check order in fd_replay.c macros*/

Expand Down Expand Up @@ -704,9 +705,9 @@ fd_topo_initialize( config_t * config ) {

fd_topob_tile_out( topo, "poh", 0UL, "poh_pack", 0UL );

/**/ fd_topob_tile_in( topo, "sign", 0UL, "metric_in", "repair_sign", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_in ( topo, "sign", 0UL, "metric_in", "repair_sign", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
/**/ fd_topob_tile_out( topo, "repair", 0UL, "repair_sign", 0UL );
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "sign_repair", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_UNPOLLED );
/**/ fd_topob_tile_in ( topo, "repair", 0UL, "metric_in", "sign_repair", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_UNPOLLED );
/**/ fd_topob_tile_out( topo, "repair", 0UL, "repair_repla", 0UL );
FOR(shred_tile_cnt) fd_topob_tile_out( topo, "repair", 0UL, "repair_shred", i );
/**/ fd_topob_tile_out( topo, "sign", 0UL, "sign_repair", 0UL );
Expand Down
11 changes: 11 additions & 0 deletions src/choreo/fd_choreo_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
#define FD_SLOT_PUBKEY_HASH(key,seed) FD_SLOT_HASH_HASH(key,seed)
/* clang-format on */

/* The block_id is the merkle root of the last FEC set for a slot. This
is guaranteed to be unique (practically speaking, the probability of
collision before sun burns out is negligibly miniscule).

This is used as the identifier for a block (hence "block_id") because
unlike the slot number, if a leader equivocates (ie. produces
multiple blocks for the same slot), the block_id will remain unique
unlike the slot. */

typedef uchar fd_block_id_t[ 32UL ];

typedef fd_slot_hash_t fd_slot_pubkey_t;

#endif /* HEADER_fd_src_choreo_fd_choreo_base_h */
Loading
Loading