Skip to content

Commit 47450df

Browse files
committed
fix(tower): stem burst and pr comments
1 parent 5f02e63 commit 47450df

File tree

19 files changed

+150
-145
lines changed

19 files changed

+150
-145
lines changed

book/api/metrics-generated.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,9 @@
11591159

11601160
| Metric | Type | Description |
11611161
|--------|------|-------------|
1162+
| <span class="metrics-name">tower_&#8203;vote_&#8203;txn_&#8203;invalid</span> | counter | Number of times we dropped a vote txn because it was invalid (malformed, bad signature, etc.) |
1163+
| <span class="metrics-name">tower_&#8203;vote_&#8203;txn_&#8203;ignored</span> | counter | Number of times we ignored all or part of a vote txn because we didn't recognize a slot (eg. our replay was behind) |
1164+
| <span class="metrics-name">tower_&#8203;vote_&#8203;txn_&#8203;mismatch</span> | counter | Number of times a vote txn mismatched our own block id |
11621165
| <span class="metrics-name">tower_&#8203;ancestor_&#8203;rollback</span> | counter | Rollback to an ancestor of our prev vote (can't vote) |
11631166
| <span class="metrics-name">tower_&#8203;sibling_&#8203;confirmed</span> | counter | Duplicate sibling got confirmed (can't vote) |
11641167
| <span class="metrics-name">tower_&#8203;same_&#8203;fork</span> | counter | Same fork as prev vote (can vote) |

src/app/firedancer/config/default.toml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,6 @@ user = ""
472472
# abort with an error.
473473
expected_genesis_hash = ""
474474

475-
# Firedancer can process at most this many slots without rooting in
476-
# the consensus rules before it must begin evicting.
477-
#
478-
# This is an estimate and should be set as generously as possible to
479-
# allow for brief anomalies such as the validator disconnecting from
480-
# part of the cluster due to data center issues. Roughly, at 400 ms
481-
# per slot, the default allows for 30 minutes without rooting.
482-
max_unrooted_slots = 4096
483-
484475
# This section configures the "funk" account database. Currently, funk
485476
# stores all Solana accounts. In future versions of Firedancer, most
486477
# accounts will be offloaded to the "groove" database.
@@ -1378,6 +1369,27 @@ user = ""
13781369
# TODO: What is this ... needs to be deleted
13791370
cluster_version = "1.18.0"
13801371

1372+
# The tower tile runs the fork choice and tower rules to determine
1373+
# both what block to vote on and what block to build our own leader
1374+
# blocks on top of.
1375+
[tiles.tower]
1376+
# Firedancer can process at most this many slots without rooting
1377+
# in the consensus rules before it must begin evicting.
1378+
#
1379+
# This is an estimate and should be set as generously as
1380+
# possible to allow for temporary outages such as network
1381+
# partitions. For example, the validator might get disconnected
1382+
# from part of the cluster due to data center issues. Roughly,
1383+
# the default of 4096 allows for 30 minutes without rooting.
1384+
#
1385+
# Specifically, tower will ignore gossip votes that exceed max
1386+
# unrooted slots ahead of the current root. Additionally, both
1387+
# fork choice and tower structures will OOM and cause Firedancer
1388+
# to exit if it needs to maintain more than max unrooted slots
1389+
# tower forks (TODO in the future Firedancer will instead
1390+
# gracefully degrade by evicting forks).
1391+
max_unrooted_slots = 4096
1392+
13811393
[tiles.send]
13821394
# The port the send tile uses for QUIC, to send votes and other
13831395
# transactions. It also uses this as the UDP src port.

src/app/firedancer/topology.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ fd_topo_initialize( config_t * config ) {
409409

410410
/* TODO: Explain this .... USHORT_MAX is not dcache max */
411411
ulong pending_fec_shreds_depth = fd_ulong_min( fd_ulong_pow2_up( config->tiles.shred.max_pending_shred_sets * FD_REEDSOL_DATA_SHREDS_MAX ), USHORT_MAX + 1 /* dcache max */ );
412-
ulong max_unrooted_slots = config->firedancer.consensus.max_unrooted_slots;
412+
ulong max_unrooted_slots = config->tiles.tower.max_unrooted_slots;
413413

414414
/* topo, link_name, wksp_name, depth, mtu, burst */
415415
/**/ fd_topob_link( topo, "gossip_net", "net_gossip", 32768UL, FD_NET_MTU, 1UL );
@@ -1210,7 +1210,7 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
12101210

12111211
} else if( FD_UNLIKELY( !strcmp( tile->name, "tower" ) ) ) {
12121212

1213-
tile->tower.slot_max = config->firedancer.consensus.max_unrooted_slots;
1213+
tile->tower.slot_max = config->tiles.tower.max_unrooted_slots;
12141214
strncpy( tile->tower.identity_key, config->paths.identity_key, sizeof(tile->tower.identity_key) );
12151215
strncpy( tile->tower.vote_account, config->paths.vote_account, sizeof(tile->tower.vote_account) );
12161216
strncpy( tile->tower.base_path, config->paths.base, sizeof(tile->tower.base_path) );

src/app/shared/fd_config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ struct fd_configf {
133133
char host[ 256 ];
134134
} gossip;
135135

136-
struct {
137-
ulong max_unrooted_slots;
138-
} consensus;
139-
140136
struct {
141137
struct {
142138
uint max_local_full_effective_age;
@@ -486,6 +482,10 @@ struct fd_config {
486482
ulong write_buffer_size;
487483
} shredcap;
488484

485+
struct {
486+
ulong max_unrooted_slots;
487+
} tower;
488+
489489
} tiles;
490490
struct {
491491
ulong capture_start_slot;

src/app/shared/fd_config_parse.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ fd_config_extract_podf( uchar * pod,
8080
fd_configf_t * config ) {
8181
CFG_POP ( cstr, gossip.host );
8282

83-
CFG_POP ( ulong, consensus.max_unrooted_slots );
84-
8583
CFG_POP ( uint, layout.exec_tile_count );
8684
CFG_POP ( uint, layout.sign_tile_count );
8785
CFG_POP ( uint, layout.gossvf_tile_count );
@@ -256,13 +254,10 @@ fd_config_extract_pod( uchar * pod,
256254
CFG_POP ( cstr, tiles.replay.cluster_version );
257255
CFG_POP_ARRAY( cstr, tiles.replay.enable_features );
258256

259-
CFG_POP ( cstr, tiles.store_int.slots_pending );
260-
CFG_POP ( cstr, tiles.store_int.shred_cap_archive );
261-
CFG_POP ( cstr, tiles.store_int.shred_cap_replay );
262-
CFG_POP ( ulong, tiles.store_int.shred_cap_end_slot );
263-
264257
CFG_POP ( ushort, tiles.send.send_src_port );
265258

259+
CFG_POP ( ulong, tiles.tower.max_unrooted_slots );
260+
266261
CFG_POP ( bool, tiles.archiver.enabled );
267262
CFG_POP ( ulong, tiles.archiver.end_slot );
268263
CFG_POP ( cstr, tiles.archiver.rocksdb_path );

src/choreo/epoch/Local.mk

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/choreo/notar/fd_notar.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ fd_notar_count_vote( fd_notar_t * notar,
101101
ulong vote_slot,
102102
fd_hash_t const * vote_block_id ) {
103103

104-
if( FD_UNLIKELY( !notar ) ) { FD_LOG_WARNING(( "NULL notar" )); return NULL; }
105-
106104
/* Ignore if this vote slot isn't in range. */
107105

108106
if( FD_UNLIKELY( vote_slot < notar->lo_wmark || vote_slot > notar->hi_wmark ) ) return NULL;
@@ -138,10 +136,14 @@ fd_notar_count_vote( fd_notar_t * notar,
138136

139137
fd_notar_blk_t * notar_blk = fd_notar_blk_query( notar->blk_map, *vote_block_id, NULL );
140138
if( FD_UNLIKELY( !notar_blk ) ) {
141-
notar_blk = fd_notar_blk_insert( notar->blk_map, *vote_block_id );
142-
notar_blk->slot = vote_slot;
143-
notar_blk->stake = 0;
144139
FD_TEST( notar_slot->block_ids_cnt < FD_VOTER_MAX ); /* at most one unique block id per voter in a slot */
140+
notar_blk = fd_notar_blk_insert( notar->blk_map, *vote_block_id );
141+
notar_blk->slot = vote_slot;
142+
notar_blk->stake = 0;
143+
notar_blk->dup_conf = 0;
144+
notar_blk->opt_conf = 0;
145+
notar_blk->dup_notif = 0;
146+
notar_blk->opt_notif = 0;
145147
notar_slot->block_ids[notar_slot->block_ids_cnt++] = *vote_block_id;
146148
}
147149
notar_blk->stake += vtr->stake;
@@ -185,7 +187,7 @@ fd_notar_advance_wmark( fd_notar_t * notar,
185187
for( ulong i=0; i<notar_slot->block_ids_cnt; i++ ) {
186188
fd_hash_t const * block_id = &notar_slot->block_ids[i];
187189
fd_notar_blk_t * notar_blk = fd_notar_blk_query( notar->blk_map, *block_id, NULL );
188-
if( FD_UNLIKELY( !notar_blk ) ) FD_LOG_CRIT(( "missing %lu %s %lu %lu", slot, FD_BASE58_ENC_32_ALLOCA( block_id ), i, notar_slot->block_ids_cnt ));
190+
if( FD_UNLIKELY( !notar_blk ) ) { FD_BASE58_ENCODE_32_BYTES( block_id->uc, crit ); FD_LOG_CRIT(( "missing %lu %s %lu %lu", slot, crit, i, notar_slot->block_ids_cnt )); };
189191
fd_notar_blk_remove( notar->blk_map, notar_blk );
190192
}
191193
fd_notar_slot_remove( notar->slot_map, notar_slot );

src/choreo/notar/fd_notar.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ struct fd_notar_slot {
110110
typedef struct fd_notar_slot fd_notar_slot_t;
111111

112112
struct fd_notar_blk {
113-
fd_hash_t block_id; /* map key */
114-
uint hash; /* reserved for fd_map_dynamic */
115-
ulong slot; /* slot associated with this block */
116-
ulong stake; /* sum of stake that has voted for this block_id */
117-
int dup_conf; /* whether this block has reached 52% of stake */
118-
int opt_conf; /* whether this block has reached 2/3 of stake */
113+
fd_hash_t block_id; /* map key */
114+
uint hash; /* reserved for fd_map_dynamic */
115+
ulong slot; /* slot associated with this block */
116+
ulong stake; /* sum of stake that has voted for this block_id */
117+
int dup_conf; /* whether this block has reached 52% of stake */
118+
int opt_conf; /* whether this block has reached 2/3 of stake */
119+
int dup_notif; /* set by caller, whether we've notified consumers this is duplicate confirmed */
120+
int opt_notif; /* set by caller, whether we've notified consumers this is optimistically confirmed */
119121
};
120122
typedef struct fd_notar_blk fd_notar_blk_t;
121123

src/choreo/tower/Local.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ $(call add-objs,fd_tower_forks,fd_choreo)
55
$(call add-objs,fd_tower_serde,fd_choreo)
66
ifdef FD_HAS_HOSTED
77
$(call make-unit-test,test_tower,test_tower,fd_choreo fd_flamenco fd_tango fd_ballet fd_util,$(SECP256K1_LIBS))
8-
$(call make-unit-test,test_tower_serde,test_tower_serde,fd_choreo fd_flamenco fd_tango fd_ballet fd_util,$(SECP256K1_LIBS))
98
$(call run-unit-test,test_tower)
10-
$(call run-unit-test,test_tower_serde)
119
endif
1210
endif

src/choreo/tower/fd_tower_forks.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,8 @@ fd_tower_forks_lowest_common_ancestor( fd_tower_forks_t * forks,
4242
}
4343

4444
fd_hash_t const *
45-
fd_tower_forks_canonical_block_id( fd_tower_forks_t * forks,
46-
ulong slot ) {
47-
fd_tower_forks_t * fork = fd_tower_forks_query( forks, slot, NULL );
48-
if( FD_UNLIKELY( !fork ) ) return NULL;
45+
fd_tower_forks_canonical_block_id( fd_tower_forks_t * fork ) {
4946
if ( FD_LIKELY( fork->confirmed ) ) return &fork->confirmed_block_id;
5047
else if( FD_LIKELY( fork->voted ) ) return &fork->voted_block_id;
51-
else if( FD_LIKELY( fork->replayed ) ) return &fork->replayed_block_id;
52-
else return NULL;
48+
else return &fork->replayed_block_id;
5349
}

0 commit comments

Comments
 (0)