Skip to content

Commit f4e4593

Browse files
committed
feat(hfork): rewrite hard fork detector based on #7087
1 parent 2dbb1b0 commit f4e4593

32 files changed

+945
-900
lines changed

book/api/metrics-generated.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,5 +1195,9 @@
11951195
| <span class="metrics-name">tower_&#8203;lockout_&#8203;fail</span> | counter | Locked out (can't vote) |
11961196
| <span class="metrics-name">tower_&#8203;threshold_&#8203;fail</span> | counter | Did not pass threshold check (can't vote) |
11971197
| <span class="metrics-name">tower_&#8203;propagated_&#8203;fail</span> | counter | Prev leader block did not propagate (can't vote) |
1198+
| <span class="metrics-name">tower_&#8203;hard_&#8203;forks_&#8203;seen</span> | counter | Number of hard forks we've seen (block ids with multiple candidate bank hashes) |
1199+
| <span class="metrics-name">tower_&#8203;hard_&#8203;forks_&#8203;pruned</span> | counter | Number of hard forks (candidate bank hashes) we've pruned |
1200+
| <span class="metrics-name">tower_&#8203;hard_&#8203;forks_&#8203;active</span> | gauge | Currently active hard forks |
1201+
| <span class="metrics-name">tower_&#8203;hard_&#8203;forks_&#8203;max_&#8203;width</span> | gauge | The max width of hard forks (block id with most candidate bank hashes) we've ever seen |
11981202

11991203
</div>

src/app/firedancer/config/default.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,15 +1371,15 @@ user = ""
13711371
[tiles.tower]
13721372
# Solana reaches consensus via replay, but can "cluster confirm"
13731373
# slots ahead of the replay tip by listening to vote txns from
1374-
# gossip or TPU. The larger max_lookahead_conf, the further
1374+
# gossip or TPU. The larger max_vote_lookahead, the further
13751375
# ahead slots can be cluster confirmed before they are replayed.
13761376
#
13771377
# Specifically, tower will ignore gossip or TPU votes that are
1378-
# more than max_lookahead_conf slots ahead of the root.
1378+
# more than max_vote_lookahead slots ahead of the root.
13791379
#
1380-
# Note max_lookahead_conf must be >= max_live_slots and
1380+
# Note max_vote_lookahead must be >= max_live_slots and
13811381
# Firedancer will ignore a value where this is not the case.
1382-
max_lookahead_conf = 4096
1382+
max_vote_lookahead = 4096
13831383

13841384
[tiles.send]
13851385
# The port the send tile uses for QUIC, to send votes and other

src/app/firedancer/topology.c

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

346346
fd_topob_wksp( topo, "funk" );
347347
fd_topob_wksp( topo, "progcache" );
348-
fd_topob_wksp( topo, "bh_cmp" );
349348
fd_topob_wksp( topo, "fec_sets" );
350349
fd_topob_wksp( topo, "txncache" );
351350
fd_topob_wksp( topo, "banks" );
@@ -1199,9 +1198,9 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
11991198

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

1202-
tile->tower.fork_fatal = config->firedancer.development.hard_fork_fatal;
1201+
tile->tower.hard_fork_fatal = config->firedancer.development.hard_fork_fatal;
12031202
tile->tower.max_live_slots = config->firedancer.runtime.max_live_slots;
1204-
tile->tower.max_lookahead_conf = config->tiles.tower.max_lookahead_conf;
1203+
tile->tower.max_vote_lookahead = config->tiles.tower.max_vote_lookahead;
12051204
strncpy( tile->tower.identity_key, config->paths.identity_key, sizeof(tile->tower.identity_key) );
12061205
strncpy( tile->tower.vote_account, config->paths.vote_account, sizeof(tile->tower.vote_account) );
12071206
strncpy( tile->tower.base_path, config->paths.base, sizeof(tile->tower.base_path) );

src/app/shared/fd_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ struct fd_config {
490490
} shredcap;
491491

492492
struct {
493-
ulong max_lookahead_conf;
493+
ulong max_vote_lookahead;
494494
} tower;
495495

496496
} tiles;

src/app/shared/fd_config_parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ fd_config_extract_pod( uchar * pod,
259259

260260
CFG_POP ( ushort, tiles.send.send_src_port );
261261

262-
CFG_POP ( ulong, tiles.tower.max_lookahead_conf );
262+
CFG_POP ( ulong, tiles.tower.max_vote_lookahead );
263263

264264
CFG_POP ( bool, tiles.archiver.enabled );
265265
CFG_POP ( ulong, tiles.archiver.end_slot );

src/choreo/fd_choreo_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ typedef uchar fd_block_id_t[ 32UL ];
3636
typedef fd_slot_hash_t fd_slot_pubkey_t;
3737

3838
static const fd_pubkey_t pubkey_null = {{ 0 }};
39+
static const fd_hash_t hash_null = {{ 0 }};
3940

4041
#endif /* HEADER_fd_src_choreo_fd_choreo_base_h */

src/choreo/ghost/fd_ghost.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,18 @@ fd_ghost_insert( fd_ghost_t * ghost,
271271
void
272272
fd_ghost_count_vote( fd_ghost_t * ghost,
273273
fd_ghost_blk_t * blk,
274-
fd_pubkey_t const * vtr_addr,
274+
fd_pubkey_t const * vote_acc,
275275
ulong stake,
276276
ulong slot ) {
277277

278278
fd_ghost_blk_t const * root = fd_ghost_root( ghost );
279279
fd_ghost_blk_t * pool = ghost->pool;
280-
fd_ghost_vtr_t * vtr = vtr_map_query( ghost->vtr_map, *vtr_addr, NULL );
280+
fd_ghost_vtr_t * vtr = vtr_map_query( ghost->vtr_map, *vote_acc, NULL );
281281

282282
if( FD_UNLIKELY( slot == ULONG_MAX ) ) return; /* hasn't voted */
283283
if( FD_UNLIKELY( slot < root->slot ) ) return; /* vote older than root */
284284

285-
if( FD_UNLIKELY( !vtr ) ) vtr = vtr_map_insert( ghost->vtr_map, *vtr_addr );
285+
if( FD_UNLIKELY( !vtr ) ) vtr = vtr_map_insert( ghost->vtr_map, *vote_acc );
286286
else {
287287

288288
/* Only process the vote if it is not the same as the previous vote

src/choreo/hfork/Local.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$(call add-hdrs,fd_hfork.h)
2+
$(call add-objs,fd_hfork,fd_choreo)
3+
ifdef FD_HAS_HOSTED
4+
ifdef FD_HAS_SECP256K1
5+
$(call make-unit-test,test_hfork,test_hfork,fd_choreo fd_flamenco fd_tango fd_ballet fd_util)
6+
$(call run-unit-test,test_hfork)
7+
endif
8+
endif

0 commit comments

Comments
 (0)