Skip to content

Commit bac010f

Browse files
committed
fix(tower): stem burst and pr comments
1 parent bad3c2f commit bac010f

File tree

7 files changed

+26
-21
lines changed

7 files changed

+26
-21
lines changed

book/api/metrics-generated.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@
11251125

11261126
| Metric | Type | Description |
11271127
|--------|------|-------------|
1128+
| <span class="metrics-name">tower_&#8203;deser_&#8203;fail</span> | counter | Number of times we failed to deserialize |
11281129
| <span class="metrics-name">tower_&#8203;ancestor_&#8203;rollback</span> | counter | Rollback to an ancestor of our prev vote (can't vote) |
11291130
| <span class="metrics-name">tower_&#8203;sibling_&#8203;confirmed</span> | counter | Duplicate sibling got confirmed (can't vote) |
11301131
| <span class="metrics-name">tower_&#8203;same_&#8203;fork</span> | counter | Same fork as prev vote (can vote) |

src/choreo/tower/fd_tower_serde.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
#define SHORTVEC 0
55

66
#define DE( T, name ) do { \
7-
if( FD_UNLIKELY( off+sizeof(T)>buf_sz ) ) { \
8-
FD_LOG_WARNING(( "de %s: overflow (off %lu > buf_sz: %lu)", #name, off, buf_sz )); \
9-
return -1; \
10-
} \
7+
if( FD_UNLIKELY( off+sizeof(T)>buf_sz ) ) return -1; \
118
serde->name = *(T const *)fd_type_pun_const( buf+off ); \
129
off += sizeof(T); \
1310
} while(0)
@@ -45,11 +42,8 @@ fd_compact_tower_sync_deserialize( fd_compact_tower_sync_serde_t * serde,
4542
ulong off = 0;
4643
DE( ulong, root );
4744
off += de_short_u16( &serde->lockouts_cnt, buf+off );
48-
if( FD_UNLIKELY( serde->lockouts_cnt > FD_TOWER_VOTE_MAX ) ) {
49-
FD_LOG_WARNING(( "lockouts_cnt > 31: %u", serde->lockouts_cnt ));
50-
return -1;
51-
}
52-
for( ulong i = 0; i < fd_ulong_min( serde->lockouts_cnt, 31 ); i++ ) {
45+
if( FD_UNLIKELY( serde->lockouts_cnt > FD_TOWER_VOTE_MAX ) ) return -1;
46+
for( ulong i = 0; i < serde->lockouts_cnt; i++ ) {
5347
off += de_var_int( &serde->lockouts[i].offset, buf+off );
5448
DE( uchar, lockouts[i].confirmation_count );
5549
}

src/choreo/voter/fd_voter.c

Whitespace-only changes.

src/disco/metrics/generated/fd_metrics_tower.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "fd_metrics_tower.h"
33

44
const fd_metrics_meta_t FD_METRICS_TOWER[FD_METRICS_TOWER_TOTAL] = {
5+
DECLARE_METRIC( TOWER_DESER_FAIL, COUNTER ),
56
DECLARE_METRIC( TOWER_ANCESTOR_ROLLBACK, COUNTER ),
67
DECLARE_METRIC( TOWER_SIBLING_CONFIRMED, COUNTER ),
78
DECLARE_METRIC( TOWER_SAME_FORK, COUNTER ),

src/disco/metrics/generated/fd_metrics_tower.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,61 @@
66
#include "../fd_metrics_base.h"
77
#include "fd_metrics_enums.h"
88

9-
#define FD_METRICS_COUNTER_TOWER_ANCESTOR_ROLLBACK_OFF (16UL)
9+
#define FD_METRICS_COUNTER_TOWER_DESER_FAIL_OFF (16UL)
10+
#define FD_METRICS_COUNTER_TOWER_DESER_FAIL_NAME "tower_deser_fail"
11+
#define FD_METRICS_COUNTER_TOWER_DESER_FAIL_TYPE (FD_METRICS_TYPE_COUNTER)
12+
#define FD_METRICS_COUNTER_TOWER_DESER_FAIL_DESC "Number of times we failed to deserialize"
13+
#define FD_METRICS_COUNTER_TOWER_DESER_FAIL_CVT (FD_METRICS_CONVERTER_NONE)
14+
15+
#define FD_METRICS_COUNTER_TOWER_ANCESTOR_ROLLBACK_OFF (17UL)
1016
#define FD_METRICS_COUNTER_TOWER_ANCESTOR_ROLLBACK_NAME "tower_ancestor_rollback"
1117
#define FD_METRICS_COUNTER_TOWER_ANCESTOR_ROLLBACK_TYPE (FD_METRICS_TYPE_COUNTER)
1218
#define FD_METRICS_COUNTER_TOWER_ANCESTOR_ROLLBACK_DESC "Rollback to an ancestor of our prev vote (can't vote)"
1319
#define FD_METRICS_COUNTER_TOWER_ANCESTOR_ROLLBACK_CVT (FD_METRICS_CONVERTER_NONE)
1420

15-
#define FD_METRICS_COUNTER_TOWER_SIBLING_CONFIRMED_OFF (17UL)
21+
#define FD_METRICS_COUNTER_TOWER_SIBLING_CONFIRMED_OFF (18UL)
1622
#define FD_METRICS_COUNTER_TOWER_SIBLING_CONFIRMED_NAME "tower_sibling_confirmed"
1723
#define FD_METRICS_COUNTER_TOWER_SIBLING_CONFIRMED_TYPE (FD_METRICS_TYPE_COUNTER)
1824
#define FD_METRICS_COUNTER_TOWER_SIBLING_CONFIRMED_DESC "Duplicate sibling got confirmed (can't vote)"
1925
#define FD_METRICS_COUNTER_TOWER_SIBLING_CONFIRMED_CVT (FD_METRICS_CONVERTER_NONE)
2026

21-
#define FD_METRICS_COUNTER_TOWER_SAME_FORK_OFF (18UL)
27+
#define FD_METRICS_COUNTER_TOWER_SAME_FORK_OFF (19UL)
2228
#define FD_METRICS_COUNTER_TOWER_SAME_FORK_NAME "tower_same_fork"
2329
#define FD_METRICS_COUNTER_TOWER_SAME_FORK_TYPE (FD_METRICS_TYPE_COUNTER)
2430
#define FD_METRICS_COUNTER_TOWER_SAME_FORK_DESC "Same fork as prev vote (can vote)"
2531
#define FD_METRICS_COUNTER_TOWER_SAME_FORK_CVT (FD_METRICS_CONVERTER_NONE)
2632

27-
#define FD_METRICS_COUNTER_TOWER_SWITCH_PASS_OFF (19UL)
33+
#define FD_METRICS_COUNTER_TOWER_SWITCH_PASS_OFF (20UL)
2834
#define FD_METRICS_COUNTER_TOWER_SWITCH_PASS_NAME "tower_switch_pass"
2935
#define FD_METRICS_COUNTER_TOWER_SWITCH_PASS_TYPE (FD_METRICS_TYPE_COUNTER)
3036
#define FD_METRICS_COUNTER_TOWER_SWITCH_PASS_DESC "Prev vote was on a different fork, but we are allowed to switch (can vote)"
3137
#define FD_METRICS_COUNTER_TOWER_SWITCH_PASS_CVT (FD_METRICS_CONVERTER_NONE)
3238

33-
#define FD_METRICS_COUNTER_TOWER_SWITCH_FAIL_OFF (20UL)
39+
#define FD_METRICS_COUNTER_TOWER_SWITCH_FAIL_OFF (21UL)
3440
#define FD_METRICS_COUNTER_TOWER_SWITCH_FAIL_NAME "tower_switch_fail"
3541
#define FD_METRICS_COUNTER_TOWER_SWITCH_FAIL_TYPE (FD_METRICS_TYPE_COUNTER)
3642
#define FD_METRICS_COUNTER_TOWER_SWITCH_FAIL_DESC "Prev vote was on a different fork, and we are not allowed to switch (can't vote)"
3743
#define FD_METRICS_COUNTER_TOWER_SWITCH_FAIL_CVT (FD_METRICS_CONVERTER_NONE)
3844

39-
#define FD_METRICS_COUNTER_TOWER_LOCKOUT_FAIL_OFF (21UL)
45+
#define FD_METRICS_COUNTER_TOWER_LOCKOUT_FAIL_OFF (22UL)
4046
#define FD_METRICS_COUNTER_TOWER_LOCKOUT_FAIL_NAME "tower_lockout_fail"
4147
#define FD_METRICS_COUNTER_TOWER_LOCKOUT_FAIL_TYPE (FD_METRICS_TYPE_COUNTER)
4248
#define FD_METRICS_COUNTER_TOWER_LOCKOUT_FAIL_DESC "Locked out (can't vote)"
4349
#define FD_METRICS_COUNTER_TOWER_LOCKOUT_FAIL_CVT (FD_METRICS_CONVERTER_NONE)
4450

45-
#define FD_METRICS_COUNTER_TOWER_THRESHOLD_FAIL_OFF (22UL)
51+
#define FD_METRICS_COUNTER_TOWER_THRESHOLD_FAIL_OFF (23UL)
4652
#define FD_METRICS_COUNTER_TOWER_THRESHOLD_FAIL_NAME "tower_threshold_fail"
4753
#define FD_METRICS_COUNTER_TOWER_THRESHOLD_FAIL_TYPE (FD_METRICS_TYPE_COUNTER)
4854
#define FD_METRICS_COUNTER_TOWER_THRESHOLD_FAIL_DESC "Did not pass threshold check (can't vote)"
4955
#define FD_METRICS_COUNTER_TOWER_THRESHOLD_FAIL_CVT (FD_METRICS_CONVERTER_NONE)
5056

51-
#define FD_METRICS_COUNTER_TOWER_PROPAGATED_FAIL_OFF (23UL)
57+
#define FD_METRICS_COUNTER_TOWER_PROPAGATED_FAIL_OFF (24UL)
5258
#define FD_METRICS_COUNTER_TOWER_PROPAGATED_FAIL_NAME "tower_propagated_fail"
5359
#define FD_METRICS_COUNTER_TOWER_PROPAGATED_FAIL_TYPE (FD_METRICS_TYPE_COUNTER)
5460
#define FD_METRICS_COUNTER_TOWER_PROPAGATED_FAIL_DESC "Prev leader block did not propagate (can't vote)"
5561
#define FD_METRICS_COUNTER_TOWER_PROPAGATED_FAIL_CVT (FD_METRICS_CONVERTER_NONE)
5662

57-
#define FD_METRICS_TOWER_TOTAL (8UL)
63+
#define FD_METRICS_TOWER_TOTAL (9UL)
5864
extern const fd_metrics_meta_t FD_METRICS_TOWER[FD_METRICS_TOWER_TOTAL];
5965

6066
#endif /* HEADER_fd_src_disco_metrics_generated_fd_metrics_tower_h */

src/disco/metrics/metrics.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ metric introduced.
10931093
</tile>
10941094

10951095
<tile name="tower">
1096+
<counter name="DeserFail" summary="Number of times we failed to deserialize" />
10961097
<counter name="AncestorRollback" summary="Rollback to an ancestor of our prev vote (can't vote)" />
10971098
<counter name="SiblingConfirmed" summary="Duplicate sibling got confirmed (can't vote)" />
10981099
<counter name="SameFork" summary="Same fork as prev vote (can vote)" />

src/discof/tower/fd_tower_tile.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ typedef struct {
111111
/* metrics */
112112

113113
struct {
114+
ulong deser_fail;
114115
ulong ancestor_rollback;
115116
ulong sibling_confirmed;
116117
ulong same_fork;
@@ -145,6 +146,7 @@ scratch_footprint( FD_PARAM_UNUSED fd_topo_tile_t const * tile ) {
145146

146147
static inline void
147148
metrics_write( ctx_t * ctx ) {
149+
FD_MCNT_SET( TOWER, DESER_FAIL, ctx->metrics.deser_fail );
148150
FD_MCNT_SET( TOWER, ANCESTOR_ROLLBACK, ctx->metrics.ancestor_rollback );
149151
FD_MCNT_SET( TOWER, SIBLING_CONFIRMED, ctx->metrics.sibling_confirmed );
150152
FD_MCNT_SET( TOWER, SAME_FORK, ctx->metrics.same_fork );
@@ -238,7 +240,7 @@ gossip_vote( ctx_t * ctx,
238240
uchar const * payload = vote->txn;
239241
ulong payload_sz = vote->txn_sz;
240242
ulong sz = fd_txn_parse_core( vote->txn, vote->txn_sz, ctx->gossip_vote_txn, NULL, NULL );
241-
if( FD_UNLIKELY( sz==0 ) ) return;
243+
FD_TEST( sz!=0 );
242244
fd_txn_t * txn = (fd_txn_t *)ctx->gossip_vote_txn;
243245
if( FD_UNLIKELY( !fd_txn_is_simple_vote_transaction( txn, vote->txn ) ) ) return; /* TODO Agave doesn't have the same validation of <=2 signatures */
244246

@@ -262,7 +264,7 @@ gossip_vote( ctx_t * ctx,
262264
/* Deserialize the CompactTowerSync. */
263265

264266
err = fd_compact_tower_sync_deserialize( &ctx->compact_tower_sync_serde, instr_data + sizeof(uint), instr->data_sz - sizeof(uint) ); /* FIXME validate */
265-
if( FD_UNLIKELY( err == -1 ) ) return;
267+
if( FD_UNLIKELY( err == -1 ) ) { ctx->metrics.deser_fail++; return; }
266268
ulong slot = ctx->compact_tower_sync_serde.root;
267269
fd_tower_remove_all( ctx->tower_spare );
268270
for( ulong i = 0; i < ctx->compact_tower_sync_serde.lockouts_cnt; i++ ) {
@@ -737,7 +739,7 @@ populate_allowed_fds( fd_topo_t const * topo,
737739
return out_cnt;
738740
}
739741

740-
#define STEM_BURST (1UL) /* FIXME needs to be configured at runtime with max_unrooted_slots */
742+
#define STEM_BURST (4096UL) /* FIXME needs to be configured at runtime with max_unrooted_slots */
741743

742744
#define STEM_CALLBACK_CONTEXT_TYPE ctx_t
743745
#define STEM_CALLBACK_CONTEXT_ALIGN alignof(ctx_t)

0 commit comments

Comments
 (0)