Skip to content

Commit 8c70efe

Browse files
mmcgee-jumplidatong
authored andcommitted
tower: add hard fork detector
1 parent 33adbdb commit 8c70efe

File tree

21 files changed

+737
-571
lines changed

21 files changed

+737
-571
lines changed

src/app/firedancer-dev/commands/backtest.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,6 @@ backtest_topo( config_t * config ) {
313313
FOR(exec_tile_cnt) fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], banks_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
314314
FD_TEST( fd_pod_insertf_ulong( topo->props, banks_obj->id, "banks" ) );
315315

316-
/* bank_hash_cmp_obj shared by replay and exec tiles */
317-
fd_topob_wksp( topo, "bh_cmp" );
318-
fd_topo_obj_t * bank_hash_cmp_obj = setup_topo_bank_hash_cmp( topo, "bh_cmp" );
319-
fd_topob_tile_uses( topo, replay_tile, bank_hash_cmp_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
320-
FOR(exec_tile_cnt) fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], bank_hash_cmp_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
321-
FD_TEST( fd_pod_insertf_ulong( topo->props, bank_hash_cmp_obj->id, "bh_cmp" ) );
322-
323316
/* txncache_obj, busy_obj and poh_slot_obj only by replay tile */
324317
fd_topob_wksp( topo, "txncache" );
325318
fd_topob_wksp( topo, "bank_busy" );
@@ -358,7 +351,6 @@ backtest_topo( config_t * config ) {
358351
fd_topo_configure_tile( tile, config );
359352

360353
if( !strcmp( tile->name, "replay" ) ) {
361-
tile->replay.enable_bank_hash_cmp = 0;
362354
tile->replay.enable_features_cnt = config->tiles.replay.enable_features_cnt;
363355
for( ulong i = 0; i < tile->replay.enable_features_cnt; i++ ) {
364356
strncpy( tile->replay.enable_features[i], config->tiles.replay.enable_features[i], sizeof(tile->replay.enable_features[i]) );

src/app/firedancer-dev/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ extern fd_topo_obj_callbacks_t fd_obj_cb_fec_sets;
2424
extern fd_topo_obj_callbacks_t fd_obj_cb_txncache;
2525
extern fd_topo_obj_callbacks_t fd_obj_cb_banks;
2626
extern fd_topo_obj_callbacks_t fd_obj_cb_funk;
27-
extern fd_topo_obj_callbacks_t fd_obj_cb_bank_hash_cmp;
2827

2928
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta;
3029
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta_ele;
@@ -47,7 +46,6 @@ fd_topo_obj_callbacks_t * CALLBACKS[] = {
4746
&fd_obj_cb_txncache,
4847
&fd_obj_cb_banks,
4948
&fd_obj_cb_funk,
50-
&fd_obj_cb_bank_hash_cmp,
5149
&fd_obj_cb_vinyl_meta,
5250
&fd_obj_cb_vinyl_meta_ele,
5351
&fd_obj_cb_vinyl_data,

src/app/firedancer/callbacks.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,6 @@ fd_topo_obj_callbacks_t fd_obj_cb_banks = {
3838
.new = banks_new,
3939
};
4040

41-
static ulong
42-
bh_cmp_footprint( fd_topo_t const * topo,
43-
fd_topo_obj_t const * obj ) {
44-
(void)topo; (void)obj;
45-
return fd_bank_hash_cmp_footprint();
46-
}
47-
48-
static ulong
49-
bh_cmp_align( fd_topo_t const * topo,
50-
fd_topo_obj_t const * obj ) {
51-
(void)topo; (void)obj;
52-
return fd_bank_hash_cmp_align();
53-
}
54-
55-
static void
56-
bh_cmp_new( fd_topo_t const * topo,
57-
fd_topo_obj_t const * obj ) {
58-
(void)topo; (void)obj;
59-
FD_TEST( fd_bank_hash_cmp_new( fd_topo_obj_laddr( topo, obj->id ) ) );
60-
}
61-
62-
fd_topo_obj_callbacks_t fd_obj_cb_bank_hash_cmp = {
63-
.name = "bh_cmp",
64-
.footprint = bh_cmp_footprint,
65-
.align = bh_cmp_align,
66-
.new = bh_cmp_new,
67-
};
68-
6941
static ulong
7042
funk_align( fd_topo_t const * topo,
7143
fd_topo_obj_t const * obj ) {

src/app/firedancer/config/default.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,19 @@ user = ""
15451545
# enabled during routine running of the validator.
15461546
core_dump = true
15471547

1548+
# A hard fork occurs when our validator has some implementation
1549+
# difference in consensus rules and gets a different blockhash for
1550+
# a given slot than the rest of the cluster.
1551+
#
1552+
# Typically, we should assume that our validator is correct and keep
1553+
# running, but during development it can be useful to detect if we
1554+
# are on the minority hard fork and immediately exit or abort.
1555+
#
1556+
# If this option is true, the validator will immediately exit with
1557+
# an error if it detects a hard fork. If false, the validator will
1558+
# log the hard fork event and continue running.
1559+
hard_fork_fatal = true
1560+
15481561
# It can be convenient during development to use a network namespace
15491562
# for running Firedancer. This allows us to send packets at a local
15501563
# Firedancer instance and have them go through more of the kernel

src/app/firedancer/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ extern fd_topo_obj_callbacks_t fd_obj_cb_fec_sets;
2121
extern fd_topo_obj_callbacks_t fd_obj_cb_txncache;
2222
extern fd_topo_obj_callbacks_t fd_obj_cb_banks;
2323
extern fd_topo_obj_callbacks_t fd_obj_cb_funk;
24-
extern fd_topo_obj_callbacks_t fd_obj_cb_bank_hash_cmp;
2524

2625
fd_topo_obj_callbacks_t * CALLBACKS[] = {
2726
&fd_obj_cb_mcache,
@@ -39,7 +38,6 @@ fd_topo_obj_callbacks_t * CALLBACKS[] = {
3938
&fd_obj_cb_txncache,
4039
&fd_obj_cb_banks,
4140
&fd_obj_cb_funk,
42-
&fd_obj_cb_bank_hash_cmp,
4341
NULL,
4442
};
4543

src/app/firedancer/topology.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ parse_ip_port( const char * name, const char * ip_port, fd_topo_ip_port_t *parse
5252
FD_LOG_ERR(( "could not parse port %s in [%s]", ip_end+1, name ));
5353
}
5454

55-
fd_topo_obj_t *
56-
setup_topo_bank_hash_cmp( fd_topo_t * topo, char const * wksp_name ) {
57-
fd_topo_obj_t * obj = fd_topob_obj( topo, "bh_cmp", wksp_name );
58-
return obj;
59-
}
60-
6155
fd_topo_obj_t *
6256
setup_topo_banks( fd_topo_t * topo,
6357
char const * wksp_name,
@@ -940,12 +934,6 @@ fd_topo_initialize( config_t * config ) {
940934
}
941935
}
942936

943-
/* TODO: This should not exist in production */
944-
fd_topo_obj_t * bank_hash_cmp_obj = setup_topo_bank_hash_cmp( topo, "bh_cmp" );
945-
/**/ fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "replay", 0UL ) ], bank_hash_cmp_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
946-
FOR(exec_tile_cnt) fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], bank_hash_cmp_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
947-
FD_TEST( fd_pod_insertf_ulong( topo->props, bank_hash_cmp_obj->id, "bh_cmp" ) );
948-
949937
ulong fec_set_cnt = shred_depth + config->tiles.shred.max_pending_shred_sets + 4UL;
950938
ulong fec_sets_sz = fec_set_cnt*sizeof(fd_shred34_t)*4; /* mirrors # of dcache entires in frankendancer */
951939
fd_topo_obj_t * fec_sets_obj = setup_topo_fec_sets( topo, "fec_sets", shred_tile_cnt*fec_sets_sz );
@@ -1185,7 +1173,6 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
11851173
strncpy( tile->replay.identity_key_path, config->paths.identity_key, sizeof(tile->replay.identity_key_path) );
11861174
tile->replay.ip_addr = config->net.ip_addr;
11871175
strncpy( tile->replay.vote_account_path, config->paths.vote_account, sizeof(tile->replay.vote_account_path) );
1188-
tile->replay.enable_bank_hash_cmp = 1;
11891176

11901177
tile->replay.capture_start_slot = config->capture.capture_start_slot;
11911178
strncpy( tile->replay.solcap_capture, config->capture.solcap_capture, sizeof(tile->replay.solcap_capture) );
@@ -1212,6 +1199,7 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
12121199

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

1202+
tile->tower.fork_fatal = config->firedancer.development.hard_fork_fatal;
12151203
tile->tower.max_live_slots = config->firedancer.runtime.max_live_slots;
12161204
tile->tower.max_lookahead_conf = config->tiles.tower.max_lookahead_conf;
12171205
strncpy( tile->tower.identity_key, config->paths.identity_key, sizeof(tile->tower.identity_key) );

src/app/firedancer/topology.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ FD_PROTOTYPES_BEGIN
1313
void
1414
fd_topo_initialize( fd_config_t * config );
1515

16-
fd_topo_obj_t *
17-
setup_topo_bank_hash_cmp( fd_topo_t * topo, char const * wksp_name );
18-
1916
fd_topo_obj_t *
2017
setup_topo_banks( fd_topo_t * topo,
2118
char const * wksp_name,

src/app/shared/fd_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ struct fd_configf {
161161
uint full_effective_age_cancel_threshold;
162162
} snapshots;
163163

164+
struct {
165+
int hard_fork_fatal;
166+
} development;
167+
164168
struct {
165169
ulong max_completed_shred_sets;
166170
} store;

src/app/shared/fd_config_parse.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ fd_config_extract_podf( uchar * pod,
118118
CFG_POP ( uint, snapshots.max_incremental_snapshots_to_keep );
119119
CFG_POP ( uint, snapshots.full_effective_age_cancel_threshold );
120120

121+
CFG_POP ( bool, development.hard_fork_fatal );
122+
121123
return config;
122124
}
123125

src/app/shared/fd_tile_unit_test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ extern fd_topo_obj_callbacks_t fd_obj_cb_fec_sets;
2121
extern fd_topo_obj_callbacks_t fd_obj_cb_txncache;
2222
extern fd_topo_obj_callbacks_t fd_obj_cb_banks;
2323
extern fd_topo_obj_callbacks_t fd_obj_cb_funk;
24-
extern fd_topo_obj_callbacks_t fd_obj_cb_bank_hash_cmp;
2524

2625
fd_topo_obj_callbacks_t * CALLBACKS[] = {
2726
&fd_obj_cb_mcache,
@@ -39,7 +38,6 @@ fd_topo_obj_callbacks_t * CALLBACKS[] = {
3938
&fd_obj_cb_txncache,
4039
&fd_obj_cb_banks,
4140
&fd_obj_cb_funk,
42-
&fd_obj_cb_bank_hash_cmp,
4341
NULL,
4442
};
4543

0 commit comments

Comments
 (0)